ANDROID: Add KUnit test config and packaging rules for tests.zip

Include KUnit modules and Tradefed test configuration inside
'tests.zip' alongside the kselftest tests. The zip can built via:
$ tools/bazel build //common:tests_zip_arm64

The KUnit tests can be executed on running device with matching kernel
via:
$ tradefed.sh run commandAndExit template/local_min --template:map \
    test=suite/test_mapping_suite --include-filter kunit \
    --tests-dir=<directory of zip contents>  --primary-abi-only

Example zip structure:
Archive:  bazel-bin/common/x86_64/tests.zip

testcases/kunit/kunit.config
testcases/kunit/x86_64/drivers/hid/hid-uclogic-test.ko
testcases/kunit/x86_64/drivers/iio/test/iio-test-format.ko
<truncate>
testcases/selftests/selftests.config
testcases/selftests/x86/futex_requeue
testcases/selftests/x86/futex_requeue_pi
<truncate>
testcases/selftests/x86_64/futex_requeue
testcases/selftests/x86_64/futex_requeue_pi
<truncate>

Bug: 311187098

Test build (x86_64): https://android-build.corp.google.com/builds/abtd/run/L50600030001493915
Test build (arm64): https://android-build.corp.google.com/builds/abtd/run/L76000030001501406

Change-Id: Ic53a000d9d797fc043a626d8892246d0faae2eab
Signed-off-by: Joe Fradley <joefradley@google.com>
This commit is contained in:
Joe Fradley
2023-12-06 07:40:39 -08:00
parent 339f191a41
commit af8ff008f4
3 changed files with 133 additions and 2 deletions
+72 -2
View File
@@ -1,10 +1,12 @@
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2021 The Android Open Source Project
load("@bazel_skylib//lib:paths.bzl", "paths")
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load(
"@rules_pkg//pkg:mappings.bzl",
"pkg_filegroup",
"pkg_files",
"strip_prefix",
)
@@ -778,6 +780,68 @@ copy_to_dist_dir(
log = "info",
)
_KUNIT_DIR = "testcases/kunit"
pkg_files(
name = "kunit_arm64_stripped",
srcs = [":kunit_aarch64"],
prefix = "arm64",
strip_prefix = paths.join(
strip_prefix.from_pkg(),
"kunit_aarch64",
),
visibility = ["//visibility:private"],
)
pkg_files(
name = "kunit_arm64_test_config",
srcs = [":tools/testing/kunit/android/config_arm64.xml"],
renames = {
"tools/testing/kunit/android/config_arm64.xml": "kunit.config",
},
visibility = ["//visibility:private"],
)
pkg_filegroup(
name = "kunit_tests_arm64_pkg_files",
srcs = [
":kunit_arm64_stripped",
":kunit_arm64_test_config",
],
prefix = _KUNIT_DIR,
visibility = ["//visibility:private"],
)
pkg_files(
name = "kunit_x86_64_stripped",
srcs = [":kunit_x86_64"],
prefix = "x86_64",
strip_prefix = paths.join(
strip_prefix.from_pkg(),
"kunit_x86_64",
),
visibility = ["//visibility:private"],
)
pkg_files(
name = "kunit_x86_64_test_config",
srcs = [":tools/testing/kunit/android/config_x86_64.xml"],
renames = {
"tools/testing/kunit/android/config_x86_64.xml": "kunit.config",
},
visibility = ["//visibility:private"],
)
pkg_filegroup(
name = "kunit_tests_x86_64_pkg_files",
srcs = [
":kunit_x86_64_stripped",
":kunit_x86_64_test_config",
],
prefix = _KUNIT_DIR,
visibility = ["//visibility:private"],
)
# DDK Headers
# All headers. These are the public targets for DDK modules to use.
alias(
@@ -2341,13 +2405,19 @@ pkg_files(
pkg_zip(
name = "tests_zip_x86_64",
srcs = [":kselftest_tests_x86_64_pkg_files"],
srcs = [
":kselftest_tests_x86_64_pkg_files",
":kunit_tests_x86_64_pkg_files",
],
out = "x86_64/tests.zip",
)
pkg_zip(
name = "tests_zip_arm64",
srcs = [":kselftest_tests_arm64_pkg_files"],
srcs = [
":kselftest_tests_arm64_pkg_files",
":kunit_tests_arm64_pkg_files",
],
out = "arm64/tests.zip",
)
@@ -0,0 +1,32 @@
<configuration description="kunit">
<target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"/>
<target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
<option name="cleanup" value="true" />
<option name="push-file" key="kunit" value="/data/kunit" />
</target_preparer>
<!-- Modules that leave the OS in an unstable state have been temporarily commented out. -->
<test class="com.android.tradefed.testtype.binary.KUnitModuleTest" >
<option name="skip-binary-check" value="true" />
<!-- <option name='binary' key='drivers/base/regmap/regmap-kunit' value='/data/kunit/arm64/drivers/base/regmap/regmap-kunit.ko' /> -->
<!-- <option name='binary' key='drivers/base/regmap/regmap-ram' value='/data/kunit/arm64/drivers/base/regmap/regmap-ram.ko' /> -->
<!-- <option name='binary' key='drivers/base/regmap/regmap-raw-ram' value='/data/kunit/arm64/drivers/base/regmap/regmap-raw-ram.ko' /> -->
<option name='binary' key='drivers/hid/hid-uclogic-test' value='/data/kunit/arm64/drivers/hid/hid-uclogic-test.ko' />
<!-- <option name='binary' key='drivers/iio/test/iio-test-format' value='/data/kunit/arm64/drivers/iio/test/iio-test-format.ko' /> -->
<option name='binary' key='drivers/input/tests/input_test' value='/data/kunit/arm64/drivers/input/tests/input_test.ko' />
<option name='binary' key='drivers/rtc/lib_test' value='/data/kunit/arm64/drivers/rtc/lib_test.ko' />
<option name='binary' key='fs/ext4/ext4-inode-test' value='/data/kunit/arm64/fs/ext4/ext4-inode-test.ko' />
<option name='binary' key='fs/fat/fat_test' value='/data/kunit/arm64/fs/fat/fat_test.ko' />
<option name='binary' key='kernel/time/time_test' value='/data/kunit/arm64/kernel/time/time_test.ko' />
<option name='binary' key='lib/kunit/kunit-example-test' value='/data/kunit/arm64/lib/kunit/kunit-example-test.ko' />
<!-- <option name='binary' key='lib/kunit/kunit-test' value='/data/kunit/arm64/lib/kunit/kunit-test.ko' /> -->
<!-- <option name='binary' key='mm/kfence/kfence_test' value='/data/kunit/arm64/mm/kfence/kfence_test.ko' /> -->
<option name='binary' key='net/core/dev_addr_lists_test' value='/data/kunit/arm64/net/core/dev_addr_lists_test.ko' />
<!-- <option name='binary' key='sound/soc/soc-topology-test' value='/data/kunit/arm64/sound/soc/soc-topology-test.ko' /> -->
<option name='binary' key='sound/soc/soc-utils-test' value='/data/kunit/arm64/sound/soc/soc-utils-test.ko' />
<option name='binary' key='drivers/clk/clk-gate_test' value='/data/kunit/arm64/drivers/clk/clk-gate_test.ko' />
<option name='binary' key='drivers/clk/clk_test' value='/data/kunit/arm64/drivers/clk/clk_test.ko' />
</test>
</configuration>
@@ -0,0 +1,29 @@
<configuration description="kunit">
<target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"/>
<target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
<option name="cleanup" value="true" />
<option name="push-file" key="kunit" value="/data/kunit" />
</target_preparer>
<!-- Modules that leave the OS in an unstable state have been temporarily commented out. -->
<test class="com.android.tradefed.testtype.binary.KUnitModuleTest" >
<option name="skip-binary-check" value="true" />
<!-- <option name='binary' key='drivers/base/regmap/regmap-kunit' value='/data/kunit/x86_64/drivers/base/regmap/regmap-kunit.ko' /> -->
<!-- <option name='binary' key='drivers/base/regmap/regmap-ram' value='/data/kunit/x86_64/drivers/base/regmap/regmap-ram.ko' /> -->
<!-- <option name='binary' key='drivers/base/regmap/regmap-raw-ram' value='/data/kunit/x86_64/drivers/base/regmap/regmap-raw-ram.ko' /> -->
<option name='binary' key='drivers/hid/hid-uclogic-test' value='/data/kunit/x86_64/drivers/hid/hid-uclogic-test.ko' />
<!-- <option name='binary' key='drivers/iio/test/iio-test-format' value='/data/kunit/x86_64/drivers/iio/test/iio-test-format.ko' /> -->
<option name='binary' key='drivers/input/tests/input_test' value='/data/kunit/x86_64/drivers/input/tests/input_test.ko' />
<option name='binary' key='drivers/rtc/lib_test' value='/data/kunit/x86_64/drivers/rtc/lib_test.ko' />
<option name='binary' key='fs/ext4/ext4-inode-test' value='/data/kunit/x86_64/fs/ext4/ext4-inode-test.ko' />
<option name='binary' key='fs/fat/fat_test' value='/data/kunit/x86_64/fs/fat/fat_test.ko' />
<option name='binary' key='kernel/time/time_test' value='/data/kunit/x86_64/kernel/time/time_test.ko' />
<option name='binary' key='lib/kunit/kunit-example-test' value='/data/kunit/x86_64/lib/kunit/kunit-example-test.ko' />
<!-- <option name='binary' key='lib/kunit/kunit-test' value='/data/kunit/x86_64/lib/kunit/kunit-test.ko' /> -->
<!-- <option name='binary' key='mm/kfence/kfence_test' value='/data/kunit/x86_64/mm/kfence/kfence_test.ko' /> -->
<option name='binary' key='net/core/dev_addr_lists_test' value='/data/kunit/x86_64/net/core/dev_addr_lists_test.ko' />
<!-- <option name='binary' key='sound/soc/soc-topology-test' value='/data/kunit/x86_64/sound/soc/soc-topology-test.ko' /> -->
<option name='binary' key='sound/soc/soc-utils-test' value='/data/kunit/x86_64/sound/soc/soc-utils-test.ko' />
</test>
</configuration>