From 07e3cca9296ca6203ccd4bd6281a76a4482aeaa6 Mon Sep 17 00:00:00 2001 From: Weijia He Date: Fri, 8 Dec 2023 12:35:04 +0800 Subject: [PATCH] ANDROID: Add capabilities and seccomp self tests Build and enable capabilities and seccomp kselftests Change-Id: Ia7dfdc6557551d2349c53093d32b3e27c8a76edd Signed-off-by: Weijia He Bug: 291147200 --- BUILD.bazel | 52 +++++++++++++++++++ .../selftests/android/config_arm64.xml | 2 + .../selftests/android/config_x86_64.xml | 2 + 3 files changed, 56 insertions(+) diff --git a/BUILD.bazel b/BUILD.bazel index d896de86b49c..d33c9ea4c892 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1805,6 +1805,52 @@ cc_binary_with_abi( deps = [":kselftest_headers_lib"], ) +cc_binary_with_abi( + name = "kselftest_capabilities_test_execve", + srcs = ["tools/testing/selftests/capabilities/test_execve.c"], + path_prefix = _KSELFTEST_DIR, + target_compatible_with = ["@platforms//os:android"], + visibility = ["//visibility:private"], + deps = [ + ":kselftest_capabilities_validate_cap", + ":kselftest_headers_lib", + "@libcap_ng//:libcap-ng", + ], +) + +cc_binary_with_abi( + name = "kselftest_capabilities_validate_cap", + srcs = ["tools/testing/selftests/capabilities/validate_cap.c"], + out = "validate_cap", + path_prefix = _KSELFTEST_DIR, + target_compatible_with = ["@platforms//os:android"], + visibility = ["//visibility:private"], + deps = [ + ":kselftest_headers_lib", + "@libcap_ng//:libcap-ng", + ], +) + +cc_binary_with_abi( + name = "kselftest_seccomp_seccomp_bpf", + srcs = [ + "tools/testing/selftests/clone3/clone3_selftests.h", + "tools/testing/selftests/seccomp/seccomp_bpf.c", + ], + copts = [ + "-Wno-unused-function", + "-D__GLIBC_PREREQ(a,b)", + ], + includes = ["tools/testing/selftests"], + path_prefix = _KSELFTEST_DIR, + target_compatible_with = ["@platforms//os:android"], + visibility = ["//visibility:private"], + deps = [ + ":kselftest_headers_lib", + "@libcap", + ], +) + copy_file( name = "kselftest_gen_config", src = select({ @@ -1820,6 +1866,8 @@ android_filegroup( srcs = [ ":kselftest_binderfs_binderfs_test_x86_64", ":kselftest_breakpoints_breakpoint_test_x86_64", + ":kselftest_capabilities_test_execve_x86_64", + ":kselftest_capabilities_validate_cap_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", @@ -1848,6 +1896,7 @@ android_filegroup( ":kselftest_net_socket_x86_64", ":kselftest_ptrace_peeksiginfo_x86_64", ":kselftest_rtc_rtctest_x86_64", + ":kselftest_seccomp_seccomp_bpf_x86_64", ":kselftest_size_test_get_size_x86_64", ":kselftest_timers_adjtick_x86_64", ":kselftest_timers_alarmtimer_suspend_x86_64", @@ -1882,6 +1931,8 @@ android_filegroup( srcs = [ ":kselftest_binderfs_binderfs_test_arm64", ":kselftest_breakpoints_breakpoint_test_arm64", + ":kselftest_capabilities_test_execve_arm64", + ":kselftest_capabilities_validate_cap_arm64", ":kselftest_futex_futex_requeue_arm64", ":kselftest_futex_futex_requeue_pi_arm64", ":kselftest_futex_futex_requeue_pi_mismatched_ops_arm64", @@ -1910,6 +1961,7 @@ android_filegroup( ":kselftest_net_socket_arm64", ":kselftest_ptrace_peeksiginfo_arm64", ":kselftest_rtc_rtctest_arm64", + ":kselftest_seccomp_seccomp_bpf_arm64", ":kselftest_size_test_get_size_arm64", ":kselftest_timers_adjtick_arm64", ":kselftest_timers_alarmtimer_suspend_arm64", diff --git a/tools/testing/selftests/android/config_arm64.xml b/tools/testing/selftests/android/config_arm64.xml index 7ee13ad9698b..734a0396ec0d 100644 --- a/tools/testing/selftests/android/config_arm64.xml +++ b/tools/testing/selftests/android/config_arm64.xml @@ -22,6 +22,7 @@ SPDX-License-Identifier: GPL-2.0 OR Apache-2.0