ANDROID: Add futex self tests
This change adds futex self tests Change-Id: I20fcc0ecc139db017e235ee679f22ca1aa0ea71c Signed-off-by: Weijia He <hwj@google.com> Bug: 291147200 Signed-off-by: Edward Liaw <edliaw@google.com>
This commit is contained in:
+248
-1
@@ -16,7 +16,7 @@ load(
|
||||
"kernel_modules_install",
|
||||
"merged_kernel_uapi_headers",
|
||||
)
|
||||
load(":abi.bzl", "cc_binary_with_abi")
|
||||
load(":abi.bzl", "cc_binary_with_abi", "sh_binary_with_abi")
|
||||
load(":modules.bzl", "get_gki_modules_list")
|
||||
|
||||
package(
|
||||
@@ -991,6 +991,231 @@ cc_binary_with_abi(
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "kselftest_futex_headers_lib",
|
||||
hdrs = glob(["tools/testing/selftests/futex/include/*.h"]),
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
cc_binary_with_abi(
|
||||
name = "kselftest_futex_futex_requeue_pi_mismatched_ops",
|
||||
srcs = ["tools/testing/selftests/futex/functional/futex_requeue_pi_mismatched_ops.c"],
|
||||
out = "futex_requeue_pi_mismatched_ops",
|
||||
copts = [
|
||||
"-D_GNU_SOURCE",
|
||||
"-pthread",
|
||||
],
|
||||
includes = [
|
||||
"tools/testing/selftests",
|
||||
"tools/testing/selftests/futex/include",
|
||||
],
|
||||
path_prefix = _KSELFTEST_DIR,
|
||||
target_compatible_with = ["@platforms//os:android"],
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
":kselftest_futex_headers_lib",
|
||||
":kselftest_headers_lib",
|
||||
],
|
||||
)
|
||||
|
||||
cc_binary_with_abi(
|
||||
name = "kselftest_futex_futex_requeue_pi_signal_restart",
|
||||
srcs = ["tools/testing/selftests/futex/functional/futex_requeue_pi_signal_restart.c"],
|
||||
out = "futex_requeue_pi_signal_restart",
|
||||
copts = [
|
||||
"-D_GNU_SOURCE",
|
||||
"-pthread",
|
||||
],
|
||||
includes = [
|
||||
"tools/testing/selftests",
|
||||
"tools/testing/selftests/futex/include",
|
||||
],
|
||||
path_prefix = _KSELFTEST_DIR,
|
||||
target_compatible_with = ["@platforms//os:android"],
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
":kselftest_futex_headers_lib",
|
||||
":kselftest_headers_lib",
|
||||
],
|
||||
)
|
||||
|
||||
cc_binary_with_abi(
|
||||
name = "kselftest_futex_futex_requeue_pi",
|
||||
srcs = ["tools/testing/selftests/futex/functional/futex_requeue_pi.c"],
|
||||
out = "futex_requeue_pi",
|
||||
copts = [
|
||||
"-D_GNU_SOURCE",
|
||||
"-pthread",
|
||||
],
|
||||
includes = [
|
||||
"tools/testing/selftests",
|
||||
"tools/testing/selftests/futex/include",
|
||||
],
|
||||
path_prefix = _KSELFTEST_DIR,
|
||||
target_compatible_with = ["@platforms//os:android"],
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
":kselftest_futex_headers_lib",
|
||||
":kselftest_headers_lib",
|
||||
],
|
||||
)
|
||||
|
||||
cc_binary_with_abi(
|
||||
name = "kselftest_futex_futex_requeue",
|
||||
srcs = ["tools/testing/selftests/futex/functional/futex_requeue.c"],
|
||||
out = "futex_requeue",
|
||||
copts = [
|
||||
"-D_GNU_SOURCE",
|
||||
"-pthread",
|
||||
],
|
||||
includes = [
|
||||
"tools/testing/selftests",
|
||||
"tools/testing/selftests/futex/include",
|
||||
],
|
||||
path_prefix = _KSELFTEST_DIR,
|
||||
target_compatible_with = ["@platforms//os:android"],
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
":kselftest_futex_headers_lib",
|
||||
":kselftest_headers_lib",
|
||||
],
|
||||
)
|
||||
|
||||
cc_binary_with_abi(
|
||||
name = "kselftest_futex_futex_wait_private_mapped_file",
|
||||
srcs = ["tools/testing/selftests/futex/functional/futex_wait_private_mapped_file.c"],
|
||||
out = "futex_wait_private_mapped_file",
|
||||
copts = [
|
||||
"-D_GNU_SOURCE",
|
||||
"-pthread",
|
||||
],
|
||||
includes = [
|
||||
"tools/testing/selftests",
|
||||
"tools/testing/selftests/futex/include",
|
||||
],
|
||||
path_prefix = _KSELFTEST_DIR,
|
||||
target_compatible_with = ["@platforms//os:android"],
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
":kselftest_futex_headers_lib",
|
||||
":kselftest_headers_lib",
|
||||
],
|
||||
)
|
||||
|
||||
cc_binary_with_abi(
|
||||
name = "kselftest_futex_futex_wait_timeout",
|
||||
srcs = ["tools/testing/selftests/futex/functional/futex_wait_timeout.c"],
|
||||
out = "futex_wait_timeout",
|
||||
copts = [
|
||||
"-D_GNU_SOURCE",
|
||||
"-pthread",
|
||||
],
|
||||
includes = [
|
||||
"tools/testing/selftests",
|
||||
"tools/testing/selftests/futex/include",
|
||||
],
|
||||
path_prefix = _KSELFTEST_DIR,
|
||||
target_compatible_with = ["@platforms//os:android"],
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
":kselftest_futex_headers_lib",
|
||||
":kselftest_headers_lib",
|
||||
],
|
||||
)
|
||||
|
||||
cc_binary_with_abi(
|
||||
name = "kselftest_futex_futex_wait_uninitialized_heap",
|
||||
srcs = ["tools/testing/selftests/futex/functional/futex_wait_uninitialized_heap.c"],
|
||||
out = "futex_wait_uninitialized_heap",
|
||||
copts = [
|
||||
"-D_GNU_SOURCE",
|
||||
"-pthread",
|
||||
],
|
||||
includes = [
|
||||
"tools/testing/selftests",
|
||||
"tools/testing/selftests/futex/include",
|
||||
],
|
||||
path_prefix = _KSELFTEST_DIR,
|
||||
target_compatible_with = ["@platforms//os:android"],
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
":kselftest_futex_headers_lib",
|
||||
":kselftest_headers_lib",
|
||||
],
|
||||
)
|
||||
|
||||
cc_binary_with_abi(
|
||||
name = "kselftest_futex_futex_wait_wouldblock",
|
||||
srcs = ["tools/testing/selftests/futex/functional/futex_wait_wouldblock.c"],
|
||||
out = "futex_wait_wouldblock",
|
||||
copts = [
|
||||
"-D_GNU_SOURCE",
|
||||
"-pthread",
|
||||
],
|
||||
includes = [
|
||||
"tools/testing/selftests",
|
||||
"tools/testing/selftests/futex/include",
|
||||
],
|
||||
path_prefix = _KSELFTEST_DIR,
|
||||
target_compatible_with = ["@platforms//os:android"],
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
":kselftest_futex_headers_lib",
|
||||
":kselftest_headers_lib",
|
||||
],
|
||||
)
|
||||
|
||||
cc_binary_with_abi(
|
||||
name = "kselftest_futex_futex_wait",
|
||||
srcs = ["tools/testing/selftests/futex/functional/futex_wait.c"],
|
||||
out = "futex_wait",
|
||||
copts = [
|
||||
"-D_GNU_SOURCE",
|
||||
"-pthread",
|
||||
],
|
||||
includes = [
|
||||
"tools/testing/selftests",
|
||||
"tools/testing/selftests/futex/include",
|
||||
],
|
||||
path_prefix = _KSELFTEST_DIR,
|
||||
target_compatible_with = ["@platforms//os:android"],
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
":kselftest_futex_headers_lib",
|
||||
":kselftest_headers_lib",
|
||||
],
|
||||
)
|
||||
|
||||
cc_binary_with_abi(
|
||||
name = "kselftest_futex_futex_waitv",
|
||||
srcs = ["tools/testing/selftests/futex/functional/futex_waitv.c"],
|
||||
out = "futex_waitv",
|
||||
copts = [
|
||||
"-D_GNU_SOURCE",
|
||||
"-pthread",
|
||||
],
|
||||
includes = [
|
||||
"tools/testing/selftests",
|
||||
"tools/testing/selftests/futex/include",
|
||||
],
|
||||
path_prefix = _KSELFTEST_DIR,
|
||||
target_compatible_with = ["@platforms//os:android"],
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
":kselftest_futex_headers_lib",
|
||||
":kselftest_headers_lib",
|
||||
],
|
||||
)
|
||||
|
||||
sh_binary_with_abi(
|
||||
name = "kselftest_futex_run",
|
||||
src = "tools/testing/selftests/futex/functional/run.sh",
|
||||
out = "kselftest_futex_run",
|
||||
path_prefix = _KSELFTEST_DIR,
|
||||
target_compatible_with = ["@platforms//os:android"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
cc_binary_with_abi(
|
||||
name = "kselftest_size_test_get_size",
|
||||
srcs = ["tools/testing/selftests/size/get_size.c"],
|
||||
@@ -1025,6 +1250,17 @@ android_filegroup(
|
||||
":kselftest_binderfs_binderfs_test_x86_64",
|
||||
":kselftest_breakpoints_breakpoint_test_x86_64",
|
||||
":kselftest_breakpoints_step_after_suspend_test_x86_64",
|
||||
":kselftest_futex_futex_requeue_pi_mismatched_ops_x86_64",
|
||||
":kselftest_futex_futex_requeue_pi_signal_restart_x86_64",
|
||||
":kselftest_futex_futex_requeue_pi_x86_64",
|
||||
":kselftest_futex_futex_requeue_x86_64",
|
||||
":kselftest_futex_futex_wait_private_mapped_file_x86_64",
|
||||
":kselftest_futex_futex_wait_timeout_x86_64",
|
||||
":kselftest_futex_futex_wait_uninitialized_heap_x86_64",
|
||||
":kselftest_futex_futex_wait_wouldblock_x86_64",
|
||||
":kselftest_futex_futex_wait_x86_64",
|
||||
":kselftest_futex_futex_waitv_x86_64",
|
||||
":kselftest_futex_run_x86_64",
|
||||
":kselftest_gen_config",
|
||||
":kselftest_kcmp_kcmp_test_x86_64",
|
||||
":kselftest_ptrace_peeksiginfo_x86_64",
|
||||
@@ -1044,6 +1280,17 @@ android_filegroup(
|
||||
":kselftest_binderfs_binderfs_test_arm64",
|
||||
":kselftest_breakpoints_breakpoint_test_arm64",
|
||||
":kselftest_breakpoints_step_after_suspend_test_arm64",
|
||||
":kselftest_futex_futex_requeue_arm64",
|
||||
":kselftest_futex_futex_requeue_pi_arm64",
|
||||
":kselftest_futex_futex_requeue_pi_mismatched_ops_arm64",
|
||||
":kselftest_futex_futex_requeue_pi_signal_restart_arm64",
|
||||
":kselftest_futex_futex_wait_arm64",
|
||||
":kselftest_futex_futex_wait_private_mapped_file_arm64",
|
||||
":kselftest_futex_futex_wait_timeout_arm64",
|
||||
":kselftest_futex_futex_wait_uninitialized_heap_arm64",
|
||||
":kselftest_futex_futex_wait_wouldblock_arm64",
|
||||
":kselftest_futex_futex_waitv_arm64",
|
||||
":kselftest_futex_run_arm64",
|
||||
":kselftest_gen_config",
|
||||
":kselftest_kcmp_kcmp_test_arm64",
|
||||
":kselftest_ptrace_peeksiginfo_arm64",
|
||||
|
||||
@@ -17,24 +17,41 @@ ABI aware build rules.
|
||||
|
||||
load("@bazel_skylib//lib:paths.bzl", "paths")
|
||||
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
|
||||
load("@bazel_skylib//rules:native_binary.bzl", "native_binary")
|
||||
|
||||
visibility("private")
|
||||
|
||||
_ALL_ABIS = ["arm64", "x86_64"]
|
||||
|
||||
def _build_with_abi(name, build_rule, path_prefix, abis, visibility, **kwargs):
|
||||
build_rule(name = name, visibility = visibility, **kwargs)
|
||||
def _copy_with_abi(
|
||||
name,
|
||||
visibility = None,
|
||||
path_prefix = None,
|
||||
abis = None,
|
||||
out = None):
|
||||
if not path_prefix:
|
||||
path_prefix = ""
|
||||
if not abis:
|
||||
abis = _ALL_ABIS
|
||||
if not out:
|
||||
out = name
|
||||
|
||||
for abi in abis:
|
||||
copy_file(
|
||||
name = "{name}_{abi}".format(name = name, abi = abi),
|
||||
src = ":{name}".format(name = name),
|
||||
out = paths.join(path_prefix, abi, name),
|
||||
out = paths.join(path_prefix, abi, out),
|
||||
allow_symlink = True,
|
||||
visibility = visibility,
|
||||
)
|
||||
|
||||
def cc_binary_with_abi(name, path_prefix = None, abis = None, visibility = None, **kwargs):
|
||||
def cc_binary_with_abi(
|
||||
name,
|
||||
path_prefix = None,
|
||||
abis = None,
|
||||
visibility = None,
|
||||
out = None,
|
||||
**kwargs):
|
||||
"""A cc_binary replacement that generates output in each subdirectory named by abi.
|
||||
|
||||
For example:
|
||||
@@ -54,21 +71,76 @@ def cc_binary_with_abi(name, path_prefix = None, abis = None, visibility = None,
|
||||
path_prefix: [Nonconfigurable](https://bazel.build/reference/be/common-definitions#configurable-attributes).
|
||||
The path prefix to attach to output.
|
||||
abis: [Nonconfigurable](https://bazel.build/reference/be/common-definitions#configurable-attributes).
|
||||
The intended abis to generate.
|
||||
The intended abis to generate. Default is arm64 & x86_64.
|
||||
visibility: [Nonconfigurable](https://bazel.build/reference/be/common-definitions#configurable-attributes).
|
||||
The visibility attribute on a target controls whether the target can be used in other packages.
|
||||
out: [Nonconfigurable](https://bazel.build/reference/be/common-definitions#configurable-attributes).
|
||||
The output filename. Default is `name`.
|
||||
**kwargs: the rest args that cc_binary uses.
|
||||
"""
|
||||
if not path_prefix:
|
||||
path_prefix = ""
|
||||
if not abis:
|
||||
abis = _ALL_ABIS
|
||||
|
||||
_build_with_abi(
|
||||
native.cc_binary(
|
||||
name = name,
|
||||
build_rule = native.cc_binary,
|
||||
path_prefix = path_prefix,
|
||||
abis = abis,
|
||||
visibility = visibility,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
_copy_with_abi(
|
||||
name = name,
|
||||
path_prefix = path_prefix,
|
||||
abis = abis,
|
||||
visibility = visibility,
|
||||
out = out,
|
||||
)
|
||||
|
||||
def sh_binary_with_abi(
|
||||
name,
|
||||
path_prefix = None,
|
||||
abis = None,
|
||||
visibility = None,
|
||||
out = None,
|
||||
**kwargs):
|
||||
"""A sh_binary replacement that generates output in each subdirectory named by abi.
|
||||
|
||||
For example:
|
||||
```
|
||||
sh_binary_with_abi(
|
||||
name = "a_binary",
|
||||
abis = ["x86_64", "arm64"],
|
||||
path_prefix = "my/path",
|
||||
)
|
||||
```
|
||||
generates 2 rules:
|
||||
* Rule a_binary_x86_64: Copies a_binary and put output in my/path/x86_64/a_binary.
|
||||
* Rule a_binary_arm64: Copies a_binary and put output in my/path/arm64/a_binary.
|
||||
|
||||
Args:
|
||||
name: the name of the build rule.
|
||||
path_prefix: [Nonconfigurable](https://bazel.build/reference/be/common-definitions#configurable-attributes).
|
||||
The path prefix to attach to output.
|
||||
abis: [Nonconfigurable](https://bazel.build/reference/be/common-definitions#configurable-attributes).
|
||||
The intended abis to generate. Default is arm64 & x86_64.
|
||||
visibility: [Nonconfigurable](https://bazel.build/reference/be/common-definitions#configurable-attributes).
|
||||
The visibility attribute on a target controls whether the target can be used in other packages.
|
||||
out: [Nonconfigurable](https://bazel.build/reference/be/common-definitions#configurable-attributes).
|
||||
The output filename. Default is `name`.
|
||||
**kwargs: the rest args that native_binary uses.
|
||||
"""
|
||||
if not out:
|
||||
out = name
|
||||
|
||||
# Uses native_binary instead of sh_binary because sh_binary is not
|
||||
# compatible with copy_file (sh_binary generates more than 1 outs).
|
||||
native_binary(
|
||||
name = name,
|
||||
visibility = visibility,
|
||||
out = out,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
_copy_with_abi(
|
||||
name = name,
|
||||
path_prefix = path_prefix,
|
||||
abis = abis,
|
||||
visibility = visibility,
|
||||
out = out,
|
||||
)
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
<option name="test-command-line" key="kselftest_binderfs_binderfs_test" value="/data/selftests/arm64/kselftest_binderfs_binderfs_test" />
|
||||
<option name="test-command-line" key="kselftest_breakpoints_breakpoint_test" value="/data/selftests/arm64/kselftest_breakpoints_breakpoint_test" />
|
||||
<option name="test-command-line" key="kselftest_breakpoints_step_after_suspend_test" value="/data/selftests/arm64/kselftest_breakpoints_step_after_suspend_test" />
|
||||
<option name="test-command-line" key="kselftest_futex_run" value="cd /data/selftests/arm64/;USE_COLOR=0 ./kselftest_futex_run" />
|
||||
<option name="test-command-line" key="kselftest_kcmp_kcmp_test" value="/data/selftests/arm64/kselftest_kcmp_kcmp_test" />
|
||||
<option name="test-command-line" key="kselftest_ptrace_peeksiginfo" value="/data/selftests/arm64/kselftest_ptrace_peeksiginfo" />
|
||||
<option name="test-command-line" key="kselftest_rtc_rtctest" value="/data/selftests/arm64/kselftest_rtc_rtctest" />
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
<option name="test-command-line" key="kselftest_binderfs_binderfs_test" value="/data/selftests/x86_64/kselftest_binderfs_binderfs_test" />
|
||||
<option name="test-command-line" key="kselftest_breakpoints_breakpoint_test" value="/data/selftests/x86_64/kselftest_breakpoints_breakpoint_test" />
|
||||
<option name="test-command-line" key="kselftest_breakpoints_step_after_suspend_test" value="/data/selftests/x86_64/kselftest_breakpoints_step_after_suspend_test" />
|
||||
<option name="test-command-line" key="kselftest_futex_run" value="cd /data/selftests/x86_64/;USE_COLOR=0 ./kselftest_futex_run" />
|
||||
<option name="test-command-line" key="kselftest_kcmp_kcmp_test" value="/data/selftests/x86_64/kselftest_kcmp_kcmp_test" />
|
||||
<option name="test-command-line" key="kselftest_ptrace_peeksiginfo" value="/data/selftests/x86_64/kselftest_ptrace_peeksiginfo" />
|
||||
<option name="test-command-line" key="kselftest_rtc_rtctest" value="/data/selftests/x86_64/kselftest_rtc_rtctest" />
|
||||
|
||||
Reference in New Issue
Block a user