Skip to content

Commit

Permalink
ANDROID: Build kselftests for 32bit x86
Browse files Browse the repository at this point in the history
Add build rules and test config for kselftests on x86 32

Bug: 291147200
Change-Id: I6a9957bcf13a27c4b91d45a044b8985f1938b8ee
Signed-off-by: Edward Liaw <[email protected]>
  • Loading branch information
edliaw committed Jan 17, 2024
1 parent b9f7882 commit 71f973e
Show file tree
Hide file tree
Showing 3 changed files with 196 additions and 9 deletions.
115 changes: 107 additions & 8 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,12 @@ config_setting(
visibility = ["//visibility:private"],
)

config_setting(
name = "i386",
values = {"platforms": "//build/kernel/kleaf/impl:android_i386"},
visibility = ["//visibility:private"],
)

config_setting(
name = "arm64",
values = {"platforms": "//build/kernel/kleaf/impl:android_arm64"},
Expand Down Expand Up @@ -992,7 +998,7 @@ cc_binary_with_abi(
name = "kselftest_breakpoints_breakpoint_test",
srcs = select({
":x86_64": ["tools/testing/selftests/breakpoints/breakpoint_test.c"],
":x86": ["tools/testing/selftests/breakpoints/breakpoint_test.c"],
":i386": ["tools/testing/selftests/breakpoints/breakpoint_test.c"],
":arm64": ["tools/testing/selftests/breakpoints/breakpoint_test_arm64.c"],
"//conditions:default": [],
}),
Expand Down Expand Up @@ -1879,7 +1885,10 @@ cc_binary_with_abi(
"tools/testing/selftests/x86/helpers.h",
"tools/testing/selftests/x86/single_step_syscall.c",
],
abis = ["x86_64"],
abis = [
"x86_64",
"x86",
],
copts = [
"-std=gnu99",
"-O2",
Expand All @@ -1901,7 +1910,10 @@ cc_binary_with_abi(
"tools/testing/selftests/x86/helpers.h",
"tools/testing/selftests/x86/syscall_nt.c",
],
abis = ["x86_64"],
abis = [
"x86_64",
"x86",
],
copts = [
"-std=gnu99",
"-O2",
Expand All @@ -1923,7 +1935,10 @@ cc_binary_with_abi(
"tools/testing/selftests/x86/helpers.h",
"tools/testing/selftests/x86/ptrace_syscall.c",
],
abis = ["x86_64"],
abis = [
"x86_64",
"x86",
],
copts = [
"-std=gnu99",
"-O2",
Expand All @@ -1945,7 +1960,10 @@ cc_binary_with_abi(
"tools/testing/selftests/x86/helpers.h",
"tools/testing/selftests/x86/test_mremap_vdso.c",
],
abis = ["x86_64"],
abis = [
"x86_64",
"x86",
],
copts = [
"-std=gnu99",
"-O2",
Expand All @@ -1967,7 +1985,10 @@ cc_binary_with_abi(
"tools/testing/selftests/x86/check_initial_reg_state.c",
"tools/testing/selftests/x86/helpers.h",
],
abis = ["x86_64"],
abis = [
"x86_64",
"x86",
],
copts = [
"-std=gnu99",
"-O2",
Expand All @@ -1993,7 +2014,10 @@ cc_binary_with_abi(
"tools/testing/selftests/x86/helpers.h",
"tools/testing/selftests/x86/ldt_gdt.c",
],
abis = ["x86_64"],
abis = [
"x86_64",
"x86",
],
copts = [
"-std=gnu99",
"-O2",
Expand All @@ -2013,6 +2037,7 @@ copy_file(
name = "kselftest_gen_config",
src = select({
":x86_64": "tools/testing/selftests/android/config_x86_64.xml",
":i386": "tools/testing/selftests/android/config_x86.xml",
":arm64": "tools/testing/selftests/android/config_arm64.xml",
":arm": "tools/testing/selftests/android/config_arm.xml",
}),
Expand Down Expand Up @@ -2091,6 +2116,77 @@ android_filegroup(
visibility = ["//visibility:private"],
)

android_filegroup(
name = "kselftest_tests_x86",
srcs = [
":kselftest_binderfs_binderfs_test_x86",
":kselftest_breakpoints_breakpoint_test_x86",
":kselftest_capabilities_test_execve_x86",
":kselftest_capabilities_validate_cap_x86",
":kselftest_futex_futex_requeue_pi_mismatched_ops_x86",
":kselftest_futex_futex_requeue_pi_signal_restart_x86",
":kselftest_futex_futex_requeue_pi_x86",
":kselftest_futex_futex_requeue_x86",
":kselftest_futex_futex_wait_private_mapped_file_x86",
":kselftest_futex_futex_wait_timeout_x86",
":kselftest_futex_futex_wait_uninitialized_heap_x86",
":kselftest_futex_futex_wait_wouldblock_x86",
":kselftest_futex_futex_wait_x86",
":kselftest_gen_config",
":kselftest_kcmp_kcmp_test_x86",
":kselftest_mm_compaction_test_x86",
":kselftest_mm_hugepage_mmap_x86",
":kselftest_mm_hugepage_shm_x86",
":kselftest_mm_map_hugetlb_x86",
":kselftest_mm_mlock2_tests_x86",
":kselftest_mm_mlock_random_test_x86",
":kselftest_mm_mremap_dontunmap_x86",
":kselftest_mm_mremap_test_x86",
":kselftest_mm_on_fault_limit_x86",
":kselftest_mm_thuge_gen_x86",
":kselftest_mm_transhuge_stress_x86",
":kselftest_mm_uffd_unit_tests_x86",
":kselftest_net_psock_tpacket_x86",
":kselftest_net_reuseaddr_conflict_x86",
":kselftest_net_socket_x86",
":kselftest_ptrace_peeksiginfo_x86",
":kselftest_rtc_rtctest_x86",
":kselftest_seccomp_seccomp_bpf_x86",
":kselftest_size_test_get_size_x86",
":kselftest_timers_adjtick_x86",
":kselftest_timers_alarmtimer_suspend_x86",
":kselftest_timers_change_skew_x86",
":kselftest_timers_clocksource_switch_x86",
":kselftest_timers_freq_step_x86",
":kselftest_timers_inconsistency_check_x86",
":kselftest_timers_leap_a_day_x86",
":kselftest_timers_leapcrash_x86",
":kselftest_timers_nanosleep_x86",
":kselftest_timers_nsleep_lat_x86",
":kselftest_timers_posix_timers_x86",
":kselftest_timers_set_2038_x86",
":kselftest_timers_set_tai_x86",
":kselftest_timers_set_timer_lat_x86",
":kselftest_timers_set_tz_x86",
":kselftest_timers_skew_consistency_x86",
":kselftest_timers_tests_raw_skew_x86",
":kselftest_timers_threadtest_x86",
":kselftest_timers_valid_adjtimex_x86",
":kselftest_vdso_vdso_test_abi_x86",
":kselftest_vdso_vdso_test_clock_getres_x86",
":kselftest_vdso_vdso_test_getcpu_x86",
":kselftest_vdso_vdso_test_gettimeofday_x86",
":kselftest_x86_check_initial_reg_state_x86",
":kselftest_x86_ldt_gdt_x86",
":kselftest_x86_ptrace_syscall_x86",
":kselftest_x86_single_step_syscall_x86",
":kselftest_x86_syscall_nt_x86",
":kselftest_x86_test_mremap_vdso_x86",
],
cpu = "i386",
visibility = ["//visibility:private"],
)

android_filegroup(
name = "kselftest_tests_arm",
srcs = [
Expand Down Expand Up @@ -2222,7 +2318,10 @@ android_filegroup(

zip_archive(
name = "tests_zip_x86_64",
srcs = [":kselftest_tests_x86_64"],
srcs = [
":kselftest_tests_x86",
":kselftest_tests_x86_64",
],
out = "tests.zip",
)

Expand Down
2 changes: 1 addition & 1 deletion abi.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ load("@bazel_skylib//rules:native_binary.bzl", "native_binary")

visibility("private")

_ALL_ABIS = ["arm", "arm64", "x86_64"]
_ALL_ABIS = ["arm", "arm64", "x86", "x86_64"]

def _copy_with_abi(
name,
Expand Down
88 changes: 88 additions & 0 deletions tools/testing/selftests/android/config_x86.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2023 The Android Open Source Project
SPDX-License-Identifier: GPL-2.0 OR Apache-2.0
-->
<!DOCTYPE configuration [
<!ENTITY ktest_dir "/data/selftests/x86">
]>
<configuration description="kselftest">
<option name="test-suite-tag" value="kernel-test" />
<target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer" />
<target_preparer class="com.android.tradefed.targetprep.StopServicesSetup" />

<object type="module_controller" class="com.android.tradefed.testtype.suite.module.KernelTestModuleController" >
<option name="arch" value="x86"/>
</object>

<target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
<option name="cleanup" value="true" />
<option name="push-file" key="selftests" value="/data/selftests" />
<option name="skip-abi-filtering" value="true" />
<option name="post-push" value='chmod -R 755 /data/selftests; find /data/selftests -type f | xargs grep -l -e "bin/sh" -e "bin/bash" | xargs sed -i -e "s?/bin/echo?echo?" -i -e "s?#!/bin/sh?#!/system/bin/sh?" -i -e "s?#!/bin/bash?#!/system/bin/sh?" || echo "There were no files to process"' />
</target_preparer>

<test class="com.android.tradefed.testtype.binary.KernelTargetTest" >
<option name="exit-code-skip" value="4" />
<option name="skip-binary-check" value="true" />
<option name="test-command-line" key="kselftest_binderfs_binderfs_test" value="cd &ktest_dir;; ./kselftest_binderfs_binderfs_test" />
<option name="test-command-line" key="kselftest_breakpoints_breakpoint_test" value="cd &ktest_dir;; ./kselftest_breakpoints_breakpoint_test" />
<option name="test-command-line" key="kselftest_capabilities_test_execve" value="cd &ktest_dir;; ./kselftest_capabilities_test_execve" />
<option name="test-command-line" key="kselftest_futex_requeue" value="cd &ktest_dir;; ./futex_requeue" />
<option name="test-command-line" key="kselftest_futex_requeue_pi" value="cd &ktest_dir;; ./futex_requeue_pi" />
<option name="test-command-line" key="kselftest_futex_requeue_pi_b" value="cd &ktest_dir;; ./futex_requeue_pi -b" />
<option name="test-command-line" key="kselftest_futex_requeue_pi_bl" value="cd &ktest_dir;; ./futex_requeue_pi -b -l" />
<option name="test-command-line" key="kselftest_futex_requeue_pi_bo" value="cd &ktest_dir;; ./futex_requeue_pi -b -o" />
<option name="test-command-line" key="kselftest_futex_requeue_pi_l" value="cd &ktest_dir;; ./futex_requeue_pi -l" />
<option name="test-command-line" key="kselftest_futex_requeue_pi_o" value="cd &ktest_dir;; ./futex_requeue_pi -o" />
<option name="test-command-line" key="kselftest_futex_requeue_pi_5k" value="cd &ktest_dir;; ./futex_requeue_pi -t 5000" />
<option name="test-command-line" key="kselftest_futex_requeue_pi_b_5k" value="cd &ktest_dir;; ./futex_requeue_pi -b -t 5000" />
<option name="test-command-line" key="kselftest_futex_requeue_pi_bl_5k" value="cd &ktest_dir;; ./futex_requeue_pi -b -l -t 5000" />
<option name="test-command-line" key="kselftest_futex_requeue_pi_bo_5k" value="cd &ktest_dir;; ./futex_requeue_pi -b -o -t 5000" />
<option name="test-command-line" key="kselftest_futex_requeue_pi_l_5k" value="cd &ktest_dir;; ./futex_requeue_pi -l -t 5000" />
<option name="test-command-line" key="kselftest_futex_requeue_pi_o_5k" value="cd &ktest_dir;; ./futex_requeue_pi -o -t 5000" />
<option name="test-command-line" key="kselftest_futex_requeue_pi_500k" value="cd &ktest_dir;; ./futex_requeue_pi -t 500000" />
<option name="test-command-line" key="kselftest_futex_requeue_pi_b_500k" value="cd &ktest_dir;; ./futex_requeue_pi -b -t 500000" />
<option name="test-command-line" key="kselftest_futex_requeue_pi_bl_500k" value="cd &ktest_dir;; ./futex_requeue_pi -b -l -t 500000" />
<option name="test-command-line" key="kselftest_futex_requeue_pi_bo_500k" value="cd &ktest_dir;; ./futex_requeue_pi -b -o -t 500000" />
<option name="test-command-line" key="kselftest_futex_requeue_pi_l_500k" value="cd &ktest_dir;; ./futex_requeue_pi -l -t 500000" />
<option name="test-command-line" key="kselftest_futex_requeue_pi_o_500k" value="cd &ktest_dir;; ./futex_requeue_pi -o -t 500000" />
<option name="test-command-line" key="kselftest_futex_requeue_pi_bl_2G" value="cd &ktest_dir;; ./futex_requeue_pi -b -l -t 2000000000" />
<option name="test-command-line" key="kselftest_futex_requeue_pi_l_2G" value="cd &ktest_dir;; ./futex_requeue_pi -l -t 2000000000" />
<option name="test-command-line" key="kselftest_futex_requeue_pi_mismatched_ops" value="cd &ktest_dir;; ./futex_requeue_pi_mismatched_ops" />
<option name="test-command-line" key="kselftest_futex_requeue_pi_signal_restart" value="cd &ktest_dir;; ./futex_requeue_pi_signal_restart" />
<option name="test-command-line" key="kselftest_futex_wait" value="cd &ktest_dir;; ./futex_wait" />
<option name="test-command-line" key="kselftest_futex_wait_private_mapped_file" value="cd &ktest_dir;; ./futex_wait_private_mapped_file" />
<option name="test-command-line" key="kselftest_futex_wait_timeout" value="cd &ktest_dir;; ./futex_wait_timeout" />
<option name="test-command-line" key="kselftest_futex_wait_uninitialized_heap" value="cd &ktest_dir;; ./futex_wait_uninitialized_heap" />
<option name="test-command-line" key="kselftest_futex_wait_wouldblock" value="cd &ktest_dir;; ./futex_wait_wouldblock" />
<option name="test-command-line" key="kselftest_kcmp_kcmp_test" value="cd &ktest_dir;; ./kselftest_kcmp_kcmp_test" />
<option name="test-command-line" key="kselftest_mm_mremap_dontunmap" value="cd &ktest_dir;; ./kselftest_mm_mremap_dontunmap" />
<option name="test-command-line" key="kselftest_mm_mremap_test" value="cd &ktest_dir;; ./kselftest_mm_mremap_test" />
<option name="test-command-line" key="kselftest_mm_uffd_unit_tests" value="cd &ktest_dir;; ./kselftest_mm_uffd_unit_tests" />
<option name="test-command-line" key="kselftest_net_socket" value="cd &ktest_dir;; ./kselftest_net_socket" />
<option name="test-command-line" key="kselftest_net_psock_tpacket" value="cd &ktest_dir;; ./kselftest_net_psock_tpacket" />
<option name="test-command-line" key="kselftest_net_reuseaddr_conflict" value="cd &ktest_dir;; ./kselftest_net_reuseaddr_conflict" />
<option name="test-command-line" key="kselftest_ptrace_peeksiginfo" value="cd &ktest_dir;; ./kselftest_ptrace_peeksiginfo" />
<option name="test-command-line" key="kselftest_rtc_rtctest" value="cd &ktest_dir;; ./kselftest_rtc_rtctest" />
<option name="test-command-line" key="kselftest_seccomp_seccomp_bpf" value="cd &ktest_dir;; ./kselftest_seccomp_seccomp_bpf" />
<option name="test-command-line" key="kselftest_size_test_get_size" value="cd &ktest_dir;; ./kselftest_size_test_get_size" />
<option name="test-command-line" key="kselftest_timers_inconsistency_check" value="cd &ktest_dir;; ./inconsistency-check" />
<option name="test-command-line" key="kselftest_timers_nanosleep" value="cd &ktest_dir;; ./nanosleep" />
<option name="test-command-line" key="kselftest_timers_nsleep_lat" value="cd &ktest_dir;; ./nsleep-lat" />
<option name="test-command-line" key="kselftest_timers_posix_timers" value="cd &ktest_dir;; ./kselftest_timers_posix_timers" />
<option name="test-command-line" key="kselftest_timers_set_timer_lat" value="cd &ktest_dir;; ./kselftest_timers_set_timer_lat" />
<option name="test-command-line" key="kselftest_timers_tests_raw_skew" value="cd &ktest_dir;; ./raw_skew" />
<option name="test-command-line" key="kselftest_timers_threadtest" value="cd &ktest_dir;; ./kselftest_timers_threadtest" />
<option name="test-command-line" key="kselftest_timers_valid_adjtimex" value="cd &ktest_dir;; ./kselftest_timers_valid_adjtimex" />
<option name="test-command-line" key="kselftest_vdso_vdso_test_abi" value="cd &ktest_dir;; ./kselftest_vdso_vdso_test_abi" />
<option name="test-command-line" key="kselftest_vdso_vdso_test_clock_getres" value="cd &ktest_dir;; ./kselftest_vdso_vdso_test_clock_getres" />
<option name="test-command-line" key="kselftest_vdso_vdso_test_getcpu" value="cd &ktest_dir;; ./kselftest_vdso_vdso_test_getcpu" />
<option name="test-command-line" key="kselftest_vdso_vdso_test_gettimeofday" value="cd &ktest_dir;; ./kselftest_vdso_vdso_test_gettimeofday" />
<option name="test-command-line" key="kselftest_x86_check_initial_reg_state" value="cd &ktest_dir;; ./kselftest_x86_check_initial_reg_state" />
<option name="test-command-line" key="kselftest_x86_ldt_gdt" value="cd &ktest_dir;; ./kselftest_x86_ldt_gdt" />
<option name="test-command-line" key="kselftest_x86_ptrace_syscall" value="cd &ktest_dir;; ./kselftest_x86_ptrace_syscall" />
<option name="test-command-line" key="kselftest_x86_single_step_syscall" value="cd &ktest_dir;; ./kselftest_x86_single_step_syscall" />
<option name="test-command-line" key="kselftest_x86_syscall_nt" value="cd &ktest_dir;; ./kselftest_x86_syscall_nt" />
<option name="test-command-line" key="kselftest_x86_test_mremap_vdso" value="cd &ktest_dir;; ./kselftest_x86_test_mremap_vdso" />
</test>
</configuration>

0 comments on commit 71f973e

Please sign in to comment.