mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-05 08:55:19 +02:00
ANDROID: Build GKI with CONFIG_KUNIT=m
Update KUnit build rules and configs to build and load kunit.ko before
testing.
Bug: 345309292
Change-Id: Ifde4e51a97214159bcbc1c6ee81b96765d57f21c
Signed-off-by: Betty Zhou <bettyzhou@google.com>
(cherry picked from commit 22f9005179
)
This commit is contained in:
parent
6e69248f50
commit
b935ae8fd4
171
BUILD.bazel
171
BUILD.bazel
|
@ -3,8 +3,10 @@
|
|||
|
||||
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
|
||||
load("@bazel_skylib//rules:write_file.bzl", "write_file")
|
||||
load("@rules_pkg//pkg:install.bzl", "pkg_install")
|
||||
load(
|
||||
"@rules_pkg//pkg:mappings.bzl",
|
||||
"pkg_filegroup",
|
||||
"pkg_files",
|
||||
"strip_prefix",
|
||||
)
|
||||
|
@ -25,7 +27,7 @@ load(
|
|||
"merged_kernel_uapi_headers",
|
||||
)
|
||||
load(":abi.bzl", "cc_binary_with_abi")
|
||||
load(":modules.bzl", "get_gki_modules_list")
|
||||
load(":modules.bzl", "get_gki_modules_list", "get_kunit_modules_list")
|
||||
|
||||
package(
|
||||
default_visibility = [
|
||||
|
@ -74,6 +76,7 @@ alias(
|
|||
write_file(
|
||||
name = "gki_system_dlkm_modules_arm64",
|
||||
out = "android/gki_system_dlkm_modules_arm64",
|
||||
# Do not built kunit modules into system_dlkm
|
||||
content = get_gki_modules_list("arm64") + [
|
||||
# Ensure new line at the end.
|
||||
"",
|
||||
|
@ -83,6 +86,7 @@ write_file(
|
|||
write_file(
|
||||
name = "gki_system_dlkm_modules_x86_64",
|
||||
out = "android/gki_system_dlkm_modules_x86_64",
|
||||
# Do not built kunit modules into system_dlkm
|
||||
content = get_gki_modules_list("x86_64") + [
|
||||
# Ensure new line at the end.
|
||||
"",
|
||||
|
@ -128,7 +132,7 @@ define_common_kernels(target_configs = {
|
|||
"trim_nonlisted_kmi": True,
|
||||
"protected_exports_list": "android/abi_gki_protected_exports_aarch64",
|
||||
"protected_modules_list": "android/gki_aarch64_protected_modules",
|
||||
"module_implicit_outs": get_gki_modules_list("arm64"),
|
||||
"module_implicit_outs": get_gki_modules_list("arm64") + get_kunit_modules_list("arm64"),
|
||||
"make_goals": _GKI_AARCH64_MAKE_GOALS,
|
||||
"ddk_headers_archive": ":kernel_aarch64_ddk_headers_archive",
|
||||
"extra_dist": [
|
||||
|
@ -138,13 +142,13 @@ define_common_kernels(target_configs = {
|
|||
},
|
||||
"kernel_aarch64_16k": {
|
||||
"kmi_symbol_list_strict_mode": False,
|
||||
"module_implicit_outs": get_gki_modules_list("arm64"),
|
||||
"module_implicit_outs": get_gki_modules_list("arm64") + get_kunit_modules_list("arm64"),
|
||||
"make_goals": _GKI_AARCH64_MAKE_GOALS,
|
||||
"extra_dist": [":test_mappings_zip"],
|
||||
},
|
||||
"kernel_x86_64": {
|
||||
"kmi_symbol_list_strict_mode": False,
|
||||
"module_implicit_outs": get_gki_modules_list("x86_64"),
|
||||
"module_implicit_outs": get_gki_modules_list("x86_64") + get_kunit_modules_list("x86_64"),
|
||||
"make_goals": _GKI_X86_64_MAKE_GOALS,
|
||||
"extra_dist": [
|
||||
":test_mappings_zip",
|
||||
|
@ -608,7 +612,7 @@ kernel_build(
|
|||
"modules",
|
||||
"rk3399-rock-pi-4b.dtb",
|
||||
],
|
||||
module_outs = get_gki_modules_list("arm64") + _ROCKPI4_MODULE_OUTS + _ROCKPI4_WATCHDOG_MODULE_OUTS,
|
||||
module_outs = get_gki_modules_list("arm64") + get_kunit_modules_list("arm64") + _ROCKPI4_MODULE_OUTS + _ROCKPI4_WATCHDOG_MODULE_OUTS,
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
|
@ -632,7 +636,7 @@ kernel_build(
|
|||
"modules",
|
||||
"rk3399-rock-pi-4b.dtb",
|
||||
],
|
||||
module_outs = get_gki_modules_list("arm64") + _ROCKPI4_MODULE_OUTS,
|
||||
module_outs = get_gki_modules_list("arm64") + get_kunit_modules_list("arm64") + _ROCKPI4_MODULE_OUTS,
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
|
@ -746,77 +750,84 @@ kernel_build(
|
|||
)
|
||||
|
||||
# KUnit test targets
|
||||
_KUNIT_DIR = "testcases/kunit"
|
||||
|
||||
# Modules defined by tools/testing/kunit/configs/android/kunit_defconfig
|
||||
_KUNIT_COMMON_MODULES = [
|
||||
# keep sorted
|
||||
"drivers/base/regmap/regmap-kunit.ko",
|
||||
"drivers/base/regmap/regmap-ram.ko",
|
||||
"drivers/base/regmap/regmap-raw-ram.ko",
|
||||
"drivers/hid/hid-uclogic-test.ko",
|
||||
"drivers/iio/test/iio-test-format.ko",
|
||||
"drivers/input/tests/input_test.ko",
|
||||
"drivers/rtc/lib_test.ko",
|
||||
"fs/ext4/ext4-inode-test.ko",
|
||||
"fs/fat/fat_test.ko",
|
||||
"kernel/time/time_test.ko",
|
||||
"lib/kunit/kunit-example-test.ko",
|
||||
"lib/kunit/kunit-test.ko",
|
||||
"mm/kfence/kfence_test.ko",
|
||||
"net/core/dev_addr_lists_test.ko",
|
||||
"sound/soc/soc-topology-test.ko",
|
||||
"sound/soc/soc-utils-test.ko",
|
||||
]
|
||||
|
||||
_KUNIT_CLK_MODULES = [
|
||||
"drivers/clk/clk-gate_test.ko",
|
||||
"drivers/clk/clk_test.ko",
|
||||
]
|
||||
|
||||
kernel_build(
|
||||
name = "kunit_aarch64",
|
||||
srcs = [":kernel_aarch64_sources"],
|
||||
outs = [],
|
||||
arch = "arm64",
|
||||
base_kernel = ":kernel_aarch64",
|
||||
build_config = "build.config.kunit.aarch64",
|
||||
defconfig_fragments = [
|
||||
"tools/testing/kunit/configs/android/kunit_defconfig",
|
||||
"tools/testing/kunit/configs/android/kunit_clk_defconfig",
|
||||
pkg_files(
|
||||
name = "kunit_tests_config_arm64",
|
||||
srcs = [
|
||||
"tools/testing/kunit/android/tradefed_configs/config_arm64.xml",
|
||||
],
|
||||
make_goals = ["modules"],
|
||||
module_outs = _KUNIT_COMMON_MODULES + _KUNIT_CLK_MODULES,
|
||||
renames = {
|
||||
"tools/testing/kunit/android/tradefed_configs/config_arm64.xml": _KUNIT_DIR + "/kunit.config",
|
||||
},
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
copy_to_dist_dir(
|
||||
name = "kunit_aarch64_dist",
|
||||
data = [":kunit_aarch64"],
|
||||
dist_dir = "out/kunit_aarch64/dist",
|
||||
flat = True,
|
||||
log = "info",
|
||||
)
|
||||
|
||||
kernel_build(
|
||||
name = "kunit_x86_64",
|
||||
srcs = [":kernel_x86_64_sources"],
|
||||
outs = [],
|
||||
arch = "x86_64",
|
||||
base_kernel = ":kernel_x86_64",
|
||||
build_config = "build.config.kunit.x86_64",
|
||||
defconfig_fragments = [
|
||||
"tools/testing/kunit/configs/android/kunit_defconfig",
|
||||
# x86_64 does not set CONFIG_COMMON_CLK
|
||||
pkg_files(
|
||||
name = "kunit_tests_config_x86_64",
|
||||
srcs = [
|
||||
"tools/testing/kunit/android/tradefed_configs/config_x86_64.xml",
|
||||
],
|
||||
make_goals = ["modules"],
|
||||
module_outs = _KUNIT_COMMON_MODULES,
|
||||
renames = {
|
||||
"tools/testing/kunit/android/tradefed_configs/config_x86_64.xml": _KUNIT_DIR + "/kunit.config",
|
||||
},
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
copy_to_dist_dir(
|
||||
name = "kunit_x86_64_dist",
|
||||
data = [":kunit_x86_64"],
|
||||
dist_dir = "out/kunit_x86_64/dist",
|
||||
flat = True,
|
||||
log = "info",
|
||||
pkg_files(
|
||||
name = "kunit_modules_arm64",
|
||||
srcs = [
|
||||
":kernel_aarch64/" + e
|
||||
for e in get_kunit_modules_list("arm64")
|
||||
],
|
||||
prefix = _KUNIT_DIR + "/arm64",
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
pkg_files(
|
||||
name = "kunit_modules_x86_64",
|
||||
srcs = [
|
||||
":kernel_x86_64/" + e
|
||||
for e in get_kunit_modules_list("x86_64")
|
||||
],
|
||||
prefix = _KUNIT_DIR + "/x86_64/",
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
pkg_filegroup(
|
||||
name = "kunit_tests_arm64_pgk_files",
|
||||
srcs = [
|
||||
":kunit_modules_arm64",
|
||||
":kunit_tests_config_arm64",
|
||||
],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
pkg_filegroup(
|
||||
name = "kunit_tests_x86_64_pkg_files",
|
||||
srcs = [
|
||||
":kunit_modules_x86_64",
|
||||
":kunit_tests_config_x86_64",
|
||||
],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
# KUnit build rules for local execution workflow
|
||||
# Run by bazel run //common:kunit_tests_arm64 -- -v --destdir /tmp/kernel_tests/
|
||||
pkg_install(
|
||||
name = "kunit_tests_arm64",
|
||||
srcs = [
|
||||
":kunit_tests_arm64_pkg_files",
|
||||
],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
pkg_install(
|
||||
name = "kunit_tests_x86_64",
|
||||
srcs = [
|
||||
":kunit_tests_x86_64_pkg_files",
|
||||
],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
# DDK Headers
|
||||
|
@ -1360,6 +1371,7 @@ cc_binary_with_abi(
|
|||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
":kselftest_headers_lib",
|
||||
":kselftest_mm_vm_util",
|
||||
"@libcap",
|
||||
],
|
||||
)
|
||||
|
@ -1449,8 +1461,15 @@ cc_binary_with_abi(
|
|||
cc_library(
|
||||
name = "kselftest_mm_vm_util",
|
||||
srcs = ["tools/testing/selftests/mm/vm_util.c"],
|
||||
hdrs = ["tools/testing/selftests/mm/vm_util.h"],
|
||||
hdrs = [
|
||||
"include/uapi/linux/fs.h",
|
||||
"tools/testing/selftests/mm/vm_util.h",
|
||||
],
|
||||
copts = _KSELFTEST_COPTS,
|
||||
includes = [
|
||||
"include/uapi/",
|
||||
"tools/testing/selftests",
|
||||
],
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
":kselftest_headers_lib",
|
||||
|
@ -2282,14 +2301,20 @@ 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",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
pkg_zip(
|
||||
name = "tests_zip_arm64",
|
||||
srcs = [":kselftest_tests_arm64_pkg_files"],
|
||||
srcs = [
|
||||
":kselftest_tests_arm64_pkg_files",
|
||||
":kunit_tests_arm64_pgk_files",
|
||||
],
|
||||
out = "arm64/tests.zip",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
CONFIG_UAPI_HEADER_TEST=y
|
||||
CONFIG_LOCALVERSION="-4k"
|
||||
CONFIG_AUDIT=y
|
||||
CONFIG_TIME_KUNIT_TEST=m
|
||||
CONFIG_NO_HZ=y
|
||||
CONFIG_HIGH_RES_TIMERS=y
|
||||
CONFIG_BPF_SYSCALL=y
|
||||
|
@ -291,6 +292,7 @@ CONFIG_BT_HCIUART_QCA=y
|
|||
CONFIG_RFKILL=m
|
||||
CONFIG_NET_9P=m
|
||||
CONFIG_NFC=m
|
||||
CONFIG_NETDEV_ADDR_LIST_TEST=m
|
||||
CONFIG_PCI=y
|
||||
CONFIG_PCIEPORTBUS=y
|
||||
CONFIG_PCIEAER=y
|
||||
|
@ -303,6 +305,7 @@ CONFIG_PCIE_QCOM=y
|
|||
CONFIG_PCI_ENDPOINT=y
|
||||
CONFIG_FW_LOADER_USER_HELPER=y
|
||||
# CONFIG_FW_CACHE is not set
|
||||
CONFIG_REGMAP_KUNIT=m
|
||||
# CONFIG_SUN50I_DE2_BUS is not set
|
||||
# CONFIG_SUNXI_RSB is not set
|
||||
CONFIG_ARM_SCMI_PROTOCOL=y
|
||||
|
@ -381,6 +384,7 @@ CONFIG_USB_NET_AQC111=m
|
|||
CONFIG_WWAN=m
|
||||
# CONFIG_WWAN_DEBUGFS is not set
|
||||
CONFIG_INPUT_EVDEV=y
|
||||
CONFIG_INPUT_KUNIT_TEST=m
|
||||
CONFIG_KEYBOARD_GPIO=y
|
||||
# CONFIG_MOUSE_PS2 is not set
|
||||
CONFIG_INPUT_JOYSTICK=y
|
||||
|
@ -480,6 +484,8 @@ CONFIG_SND_HRTIMER=y
|
|||
# CONFIG_SND_DRIVERS is not set
|
||||
CONFIG_SND_USB_AUDIO=y
|
||||
CONFIG_SND_SOC=y
|
||||
CONFIG_SND_SOC_TOPOLOGY_KUNIT_TEST=m
|
||||
CONFIG_SND_SOC_UTILS_KUNIT_TEST=m
|
||||
CONFIG_HID_BATTERY_STRENGTH=y
|
||||
CONFIG_HIDRAW=y
|
||||
CONFIG_UHID=y
|
||||
|
@ -503,6 +509,7 @@ CONFIG_SONY_FF=y
|
|||
CONFIG_HID_STEAM=y
|
||||
CONFIG_HID_WACOM=y
|
||||
CONFIG_HID_WIIMOTE=y
|
||||
CONFIG_HID_KUNIT_TEST=m
|
||||
CONFIG_USB_HIDDEV=y
|
||||
CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
|
||||
CONFIG_USB_OTG=y
|
||||
|
@ -557,6 +564,7 @@ CONFIG_LEDS_TRIGGER_TIMER=y
|
|||
CONFIG_LEDS_TRIGGER_TRANSIENT=y
|
||||
CONFIG_EDAC=y
|
||||
CONFIG_RTC_CLASS=y
|
||||
CONFIG_RTC_LIB_KUNIT_TEST=m
|
||||
CONFIG_RTC_DRV_PL030=y
|
||||
CONFIG_RTC_DRV_PL031=y
|
||||
CONFIG_DMABUF_HEAPS=y
|
||||
|
@ -578,6 +586,8 @@ CONFIG_STAGING=y
|
|||
CONFIG_ASHMEM=y
|
||||
CONFIG_COMMON_CLK_SCPI=y
|
||||
# CONFIG_SUNXI_CCU is not set
|
||||
CONFIG_CLK_KUNIT_TEST=m
|
||||
CONFIG_CLK_GATE_KUNIT_TEST=m
|
||||
CONFIG_HWSPINLOCK=y
|
||||
# CONFIG_SUN50I_ERRATUM_UNKNOWN1 is not set
|
||||
CONFIG_IOMMU_IO_PGTABLE_ARMV7S=y
|
||||
|
@ -595,6 +605,7 @@ CONFIG_MEMORY=y
|
|||
CONFIG_IIO=y
|
||||
CONFIG_IIO_BUFFER=y
|
||||
CONFIG_IIO_TRIGGER=y
|
||||
CONFIG_IIO_FORMAT_KUNIT_TEST=m
|
||||
CONFIG_PWM=y
|
||||
CONFIG_POWERCAP=y
|
||||
CONFIG_IDLE_INJECT=y
|
||||
|
@ -610,6 +621,7 @@ CONFIG_LIBNVDIMM=y
|
|||
CONFIG_EXT4_FS=y
|
||||
CONFIG_EXT4_FS_POSIX_ACL=y
|
||||
CONFIG_EXT4_FS_SECURITY=y
|
||||
CONFIG_EXT4_KUNIT_TESTS=m
|
||||
CONFIG_F2FS_FS=y
|
||||
CONFIG_F2FS_FS_SECURITY=y
|
||||
CONFIG_F2FS_FS_COMPRESSION=y
|
||||
|
@ -627,6 +639,7 @@ CONFIG_OVERLAY_FS=y
|
|||
CONFIG_INCREMENTAL_FS=y
|
||||
CONFIG_MSDOS_FS=y
|
||||
CONFIG_VFAT_FS=y
|
||||
CONFIG_FAT_KUNIT_TEST=m
|
||||
CONFIG_EXFAT_FS=y
|
||||
CONFIG_TMPFS=y
|
||||
# CONFIG_EFIVAR_FS is not set
|
||||
|
@ -754,7 +767,9 @@ CONFIG_WQ_WATCHDOG=y
|
|||
CONFIG_SCHEDSTATS=y
|
||||
CONFIG_HIST_TRIGGERS=y
|
||||
CONFIG_PID_IN_CONTEXTIDR=y
|
||||
CONFIG_KUNIT=y
|
||||
CONFIG_KUNIT=m
|
||||
CONFIG_KUNIT_DEBUGFS=y
|
||||
CONFIG_KUNIT_TEST=m
|
||||
CONFIG_KUNIT_EXAMPLE_TEST=m
|
||||
# CONFIG_KUNIT_DEFAULT_ENABLED is not set
|
||||
# CONFIG_RUNTIME_TESTING_MENU is not set
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
CONFIG_UAPI_HEADER_TEST=y
|
||||
CONFIG_KERNEL_LZ4=y
|
||||
CONFIG_AUDIT=y
|
||||
CONFIG_TIME_KUNIT_TEST=m
|
||||
CONFIG_NO_HZ=y
|
||||
CONFIG_HIGH_RES_TIMERS=y
|
||||
CONFIG_BPF_SYSCALL=y
|
||||
|
@ -282,6 +283,7 @@ CONFIG_BT_HCIUART_QCA=y
|
|||
CONFIG_RFKILL=m
|
||||
CONFIG_NET_9P=m
|
||||
CONFIG_NFC=m
|
||||
CONFIG_NETDEV_ADDR_LIST_TEST=m
|
||||
CONFIG_PCI=y
|
||||
CONFIG_PCIEPORTBUS=y
|
||||
CONFIG_PCIEAER=y
|
||||
|
@ -291,6 +293,7 @@ CONFIG_PCIE_DW_PLAT_EP=y
|
|||
CONFIG_PCI_ENDPOINT=y
|
||||
CONFIG_FW_LOADER_USER_HELPER=y
|
||||
# CONFIG_FW_CACHE is not set
|
||||
CONFIG_REGMAP_KUNIT=m
|
||||
CONFIG_GNSS=y
|
||||
CONFIG_OF=y
|
||||
CONFIG_ZRAM=m
|
||||
|
@ -361,6 +364,7 @@ CONFIG_USB_NET_AQC111=m
|
|||
CONFIG_WWAN=m
|
||||
# CONFIG_WWAN_DEBUGFS is not set
|
||||
CONFIG_INPUT_EVDEV=y
|
||||
CONFIG_INPUT_KUNIT_TEST=m
|
||||
CONFIG_KEYBOARD_GPIO=y
|
||||
# CONFIG_MOUSE_PS2 is not set
|
||||
CONFIG_INPUT_JOYSTICK=y
|
||||
|
@ -438,6 +442,8 @@ CONFIG_SND_HRTIMER=y
|
|||
# CONFIG_SND_DRIVERS is not set
|
||||
CONFIG_SND_USB_AUDIO=y
|
||||
CONFIG_SND_SOC=y
|
||||
CONFIG_SND_SOC_TOPOLOGY_KUNIT_TEST=m
|
||||
CONFIG_SND_SOC_UTILS_KUNIT_TEST=m
|
||||
CONFIG_HID_BATTERY_STRENGTH=y
|
||||
CONFIG_HIDRAW=y
|
||||
CONFIG_UHID=y
|
||||
|
@ -461,6 +467,7 @@ CONFIG_SONY_FF=y
|
|||
CONFIG_HID_STEAM=y
|
||||
CONFIG_HID_WACOM=y
|
||||
CONFIG_HID_WIIMOTE=y
|
||||
CONFIG_HID_KUNIT_TEST=m
|
||||
CONFIG_USB_HIDDEV=y
|
||||
CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
|
||||
CONFIG_USB_MON=m
|
||||
|
@ -514,6 +521,7 @@ CONFIG_LEDS_TRIGGER_TRANSIENT=y
|
|||
CONFIG_EDAC=y
|
||||
CONFIG_RTC_CLASS=y
|
||||
# CONFIG_RTC_HCTOSYS is not set
|
||||
CONFIG_RTC_LIB_KUNIT_TEST=m
|
||||
CONFIG_DMABUF_HEAPS=y
|
||||
CONFIG_DMABUF_SYSFS_STATS=y
|
||||
CONFIG_DMABUF_HEAPS_DEFERRED_FREE=y
|
||||
|
@ -532,6 +540,7 @@ CONFIG_PM_DEVFREQ_EVENT=y
|
|||
CONFIG_IIO=y
|
||||
CONFIG_IIO_BUFFER=y
|
||||
CONFIG_IIO_TRIGGER=y
|
||||
CONFIG_IIO_FORMAT_KUNIT_TEST=m
|
||||
CONFIG_GENERIC_PHY=y
|
||||
CONFIG_POWERCAP=y
|
||||
CONFIG_IDLE_INJECT=y
|
||||
|
@ -546,6 +555,7 @@ CONFIG_INTERCONNECT=y
|
|||
CONFIG_EXT4_FS=y
|
||||
CONFIG_EXT4_FS_POSIX_ACL=y
|
||||
CONFIG_EXT4_FS_SECURITY=y
|
||||
CONFIG_EXT4_KUNIT_TESTS=m
|
||||
CONFIG_F2FS_FS=y
|
||||
CONFIG_F2FS_FS_SECURITY=y
|
||||
CONFIG_F2FS_FS_COMPRESSION=y
|
||||
|
@ -563,6 +573,7 @@ CONFIG_OVERLAY_FS=y
|
|||
CONFIG_INCREMENTAL_FS=y
|
||||
CONFIG_MSDOS_FS=y
|
||||
CONFIG_VFAT_FS=y
|
||||
CONFIG_FAT_KUNIT_TEST=m
|
||||
CONFIG_EXFAT_FS=y
|
||||
CONFIG_TMPFS=y
|
||||
CONFIG_TMPFS_POSIX_ACL=y
|
||||
|
@ -686,6 +697,8 @@ CONFIG_WQ_WATCHDOG=y
|
|||
CONFIG_SCHEDSTATS=y
|
||||
CONFIG_HIST_TRIGGERS=y
|
||||
CONFIG_UNWINDER_FRAME_POINTER=y
|
||||
CONFIG_KUNIT=y
|
||||
CONFIG_KUNIT=m
|
||||
CONFIG_KUNIT_DEBUGFS=y
|
||||
CONFIG_KUNIT_TEST=m
|
||||
CONFIG_KUNIT_EXAMPLE_TEST=m
|
||||
# CONFIG_KUNIT_DEFAULT_ENABLED is not set
|
||||
|
|
58
modules.bzl
58
modules.bzl
|
@ -134,3 +134,61 @@ def get_gki_modules_list(arch = None):
|
|||
))
|
||||
|
||||
return gki_modules_list
|
||||
|
||||
_KUNIT_FRAMEWORK_MODULES = [
|
||||
"lib/kunit/kunit.ko",
|
||||
]
|
||||
|
||||
# Common Kunit test modules
|
||||
_KUNIT_COMMON_MODULES_LIST = [
|
||||
# keep sorted
|
||||
"drivers/base/regmap/regmap-kunit.ko",
|
||||
"drivers/base/regmap/regmap-ram.ko",
|
||||
"drivers/base/regmap/regmap-raw-ram.ko",
|
||||
"drivers/hid/hid-uclogic-test.ko",
|
||||
"drivers/iio/test/iio-test-format.ko",
|
||||
"drivers/input/tests/input_test.ko",
|
||||
"drivers/rtc/lib_test.ko",
|
||||
"fs/ext4/ext4-inode-test.ko",
|
||||
"fs/fat/fat_test.ko",
|
||||
"kernel/time/time_test.ko",
|
||||
"lib/kunit/kunit-example-test.ko",
|
||||
"lib/kunit/kunit-test.ko",
|
||||
# "mm/kfence/kfence_test.ko",
|
||||
"net/core/dev_addr_lists_test.ko",
|
||||
"sound/soc/soc-topology-test.ko",
|
||||
"sound/soc/soc-utils-test.ko",
|
||||
]
|
||||
|
||||
# KUnit test module for arm64 only
|
||||
_KUNIT_CLK_MODULES_LIST = [
|
||||
"drivers/clk/clk-gate_test.ko",
|
||||
"drivers/clk/clk_test.ko",
|
||||
]
|
||||
|
||||
# buildifier: disable=unnamed-macro
|
||||
def get_kunit_modules_list(arch = None):
|
||||
""" Provides the list of GKI modules.
|
||||
|
||||
Args:
|
||||
arch: One of [arm, arm64, i386, x86_64].
|
||||
|
||||
Returns:
|
||||
The list of KUnit modules for the given |arch|.
|
||||
"""
|
||||
kunit_modules_list = _KUNIT_FRAMEWORK_MODULES + _KUNIT_COMMON_MODULES_LIST
|
||||
if arch == "arm":
|
||||
kunit_modules_list += _KUNIT_CLK_MODULES_LIST
|
||||
elif arch == "arm64":
|
||||
kunit_modules_list += _KUNIT_CLK_MODULES_LIST
|
||||
elif arch == "i386":
|
||||
kunit_modules_list += []
|
||||
elif arch == "x86_64":
|
||||
kunit_modules_list += []
|
||||
else:
|
||||
fail("{}: arch {} not supported. Use one of [arm, arm64, i386, x86_64]".format(
|
||||
str(native.package_relative_label(":x")).removesuffix(":x"),
|
||||
arch,
|
||||
))
|
||||
|
||||
return kunit_modules_list
|
||||
|
|
|
@ -6,6 +6,8 @@ BIN_DIR=common/tools/testing/android/bin
|
|||
ACLOUD=$BIN_DIR/acloudb.sh
|
||||
TRADEFED=prebuilts/tradefed/filegroups/tradefed/tradefed.sh
|
||||
TESTSDIR=bazel-bin/common/
|
||||
LOG_DIR=$PWD/out/test_logs/$(date +%Y%m%d_%H%M%S)
|
||||
JDK_PATH=prebuilts/jdk/jdk11/linux-x86
|
||||
|
||||
print_help() {
|
||||
echo "Usage: $0 [OPTIONS]"
|
||||
|
@ -116,7 +118,15 @@ done
|
|||
if $BUILD_KERNEL; then
|
||||
echo "Building kernel..."
|
||||
# TODO: add support to build kernel for physical device
|
||||
$BAZEL run //common-modules/virtual-device:virtual_device_x86_64_dist -- --dist_dir=$DIST_DIR
|
||||
$BAZEL run $BUILD_FLAGS //common-modules/virtual-device:virtual_device_x86_64_dist -- \
|
||||
--dist_dir=$DIST_DIR
|
||||
exit_code=$?
|
||||
if [ $exit_code -eq 0 ]; then
|
||||
echo "Build kernel succeeded"
|
||||
else
|
||||
echo "Build kernel failed with exit code $exit_code"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if $LAUNCH_CVD; then
|
||||
|
@ -140,17 +150,24 @@ echo "Get abi from device $SERIAL_NUMBER"
|
|||
ABI=$(adb -s $SERIAL_NUMBER shell getprop ro.product.cpu.abi)
|
||||
echo "Building kselftests according to device $SERIAL_NUMBER ro.product.cpu.abi $ABI ..."
|
||||
case $ABI in
|
||||
arm64*)
|
||||
$BAZEL build //common:kselftest_tests_arm64
|
||||
;;
|
||||
x86_64*)
|
||||
$BAZEL build //common:kselftest_tests_x86_64
|
||||
;;
|
||||
*)
|
||||
echo "$ABI not supported"
|
||||
exit 1
|
||||
;;
|
||||
arm64*)
|
||||
$BAZEL build //common:kselftest_tests_arm64
|
||||
;;
|
||||
x86_64*)
|
||||
$BAZEL build //common:kselftest_tests_x86_64
|
||||
;;
|
||||
*)
|
||||
echo "$ABI not supported"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
exit_code=$?
|
||||
if [ $exit_code -eq 0 ]; then
|
||||
echo "Build kselftest succeeded"
|
||||
else
|
||||
echo "Build kselftest failed with exit code $exit_code"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$SELECTED_TESTS" ]; then
|
||||
echo "Running all kselftests with device $SERIAL_NUMBER..."
|
||||
|
@ -159,9 +176,10 @@ else
|
|||
echo "Running $SELECTED_TESTS with device $SERIAL_NUMBER ..."
|
||||
fi
|
||||
|
||||
tf_cli="$TRADEFED run commandAndExit template/local_min \
|
||||
--template:map test=suite/test_mapping_suite \
|
||||
$TEST_FILTERS --tests-dir=$TESTSDIR --primary-abi-only -s $SERIAL_NUMBER"
|
||||
tf_cli="JAVA_HOME=$JDK_PATH PATH=$JDK_PATH/bin:$PATH $TRADEFED run commandAndExit \
|
||||
template/local_min --template:map test=suite/test_mapping_suite \
|
||||
$TEST_FILTERS --tests-dir=$TESTSDIR --log-file-path=$LOG_DIR \
|
||||
--primary-abi-only -s $SERIAL_NUMBER"
|
||||
|
||||
echo "Runing tradefed command: $tf_cli"
|
||||
|
||||
|
|
198
tools/testing/android/bin/kunit.sh
Executable file
198
tools/testing/android/bin/kunit.sh
Executable file
|
@ -0,0 +1,198 @@
|
|||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
BAZEL=tools/bazel
|
||||
BIN_DIR=common/tools/testing/android/bin
|
||||
ACLOUD=$BIN_DIR/acloudb.sh
|
||||
TRADEFED=prebuilts/tradefed/filegroups/tradefed/tradefed.sh
|
||||
TESTSDIR=$PWD/out/tests
|
||||
LOG_DIR=$PWD/out/test_logs/$(date +%Y%m%d_%H%M%S)
|
||||
JDK_PATH=prebuilts/jdk/jdk11/linux-x86
|
||||
|
||||
print_help() {
|
||||
echo "Usage: $0 [OPTIONS]"
|
||||
echo ""
|
||||
echo "This script builds kernel, launches cvd and runs selftests on it."
|
||||
echo "Available options:"
|
||||
echo " --skip-kernel-build Skip the kernel building step"
|
||||
echo " --skip-cvd-launch Skip the CVD launch step"
|
||||
echo " --skip-cvd-kill Do not kill CVD launched by running this script"
|
||||
echo " -d, --dist-dir=DIR The kernel dist dir (default is /tmp/kernel_dist)"
|
||||
echo " -s, --serial=SERIAL The device serial number."
|
||||
echo " If serial is specified, cuttlefish device launch will be skipped"
|
||||
echo " -t, --test=TEST_NAME The test target name. Can be repeated"
|
||||
echo " If test is not specified, all kselftests will be run"
|
||||
echo " -h, --help Display this help message and exit"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo "$0"
|
||||
echo "$0 -t regmap-kunit.ko -t lib_test.ko"
|
||||
echo "$0 -s 127.0.0.1:45549"
|
||||
echo ""
|
||||
exit 0
|
||||
}
|
||||
|
||||
BUILD_KERNEL=true
|
||||
LAUNCH_CVD=true
|
||||
KILL_CVD=true
|
||||
DIST_DIR=/tmp/kernel_dist
|
||||
SERIAL_NUMBER=
|
||||
MODULE_NAME="kunit"
|
||||
TEST_FILTERS=
|
||||
SELECTED_TESTS=
|
||||
|
||||
while test $# -gt 0; do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
print_help
|
||||
;;
|
||||
--skip-kernel-build)
|
||||
BUILD_KERNEL=false
|
||||
shift
|
||||
;;
|
||||
--skip-cvd-launch)
|
||||
LAUNCH_CVD=false
|
||||
shift
|
||||
;;
|
||||
--skip-cvd-kill)
|
||||
KILL_CVD=false
|
||||
shift
|
||||
;;
|
||||
-d)
|
||||
shift
|
||||
if test $# -gt 0; then
|
||||
DIST_DIR=$1
|
||||
else
|
||||
echo "kernel distribution directory is not specified"
|
||||
exit 1
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
--dist-dir*)
|
||||
DIST_DIR=$(echo $1 | sed -e "s/^[^=]*=//g")
|
||||
shift
|
||||
;;
|
||||
-s)
|
||||
shift
|
||||
if test $# -gt 0; then
|
||||
SERIAL_NUMBER=$1
|
||||
BUILD_KERNEL=false
|
||||
LAUNCH_CVD=false
|
||||
KILL_CVD=false
|
||||
else
|
||||
echo "device serial is not specified"
|
||||
exit 1
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
--serial*)
|
||||
BUILD_KERNEL=false
|
||||
LAUNCH_CVD=false
|
||||
KILL_CVD=false
|
||||
SERIAL_NUMBER=$(echo $1 | sed -e "s/^[^=]*=//g")
|
||||
shift
|
||||
;;
|
||||
-t)
|
||||
shift
|
||||
if test $# -gt 0; then
|
||||
TEST_NAME=$1
|
||||
SELECTED_TESTS+="$TEST_NAME "
|
||||
TEST_FILTERS+="--include-filter '$MODULE_NAME $TEST_NAME' "
|
||||
else
|
||||
echo "test name is not specified"
|
||||
exit 1
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
--test*)
|
||||
TEST_NAME=$(echo $1 | sed -e "s/^[^=]*=//g")
|
||||
SELECTED_TESTS+="$TEST_NAME "
|
||||
TEST_FILTERS+="--include-filter '$MODULE_NAME $TEST_NAME'"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if $BUILD_KERNEL; then
|
||||
echo "Building kernel..."
|
||||
# TODO: add support to build kernel for physical device
|
||||
$BAZEL run //common-modules/virtual-device:virtual_device_x86_64_dist -- --dist_dir=$DIST_DIR
|
||||
exit_code=$?
|
||||
if [ $exit_code -eq 0 ]; then
|
||||
echo "Command succeeded"
|
||||
else
|
||||
echo "Command failed with exit code $exit_code"
|
||||
exit 1
|
||||
fi
|
||||
exit_code=$?
|
||||
if [ $exit_code -eq 0 ]; then
|
||||
echo "Build kernel succeeded"
|
||||
else
|
||||
echo "Build kernel failed with exit code $exit_code"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if $LAUNCH_CVD; then
|
||||
echo "Launching cvd..."
|
||||
CVD_OUT=$($ACLOUD create --local-kernel-image $DIST_DIR)
|
||||
echo $CVD_OUT
|
||||
INSTANCE_NAME=$(echo "$CVD_OUT" | grep -o "ins-[^\[]*")
|
||||
SERIAL_STRING=$(echo "$CVD_OUT" | grep -oE 'device serial: ([0-9]+\.){3}[0-9]+:[0-9]+')
|
||||
SERIAL_NUMBER=$(echo "$SERIAL_STRING" | sed 's/device serial: //')
|
||||
echo "acloud launched device $SERIAL_NUMBER with instance $INSTANCE_NAME"
|
||||
fi
|
||||
|
||||
if [ -z "$SERIAL_NUMBER" ]; then
|
||||
echo "Device serial is not provided by acloud or by command line flag -s|--serial flag"
|
||||
exit 1
|
||||
else
|
||||
echo "Test with device: $SERIAL_NUMBER"
|
||||
fi
|
||||
|
||||
echo "Get abi from device $SERIAL_NUMBER"
|
||||
ABI=$(adb -s $SERIAL_NUMBER shell getprop ro.product.cpu.abi)
|
||||
echo "Building kunit tests according to device $SERIAL_NUMBER ro.product.cpu.abi $ABI ..."
|
||||
# $ tools/bazel run -- //common:kunit_tests_x86_64_install -v --destdir /tmp/kunit_tests
|
||||
case $ABI in
|
||||
arm64*)
|
||||
$BAZEL run //common:kunit_tests_arm64 -- -v --destdir $TESTSDIR
|
||||
;;
|
||||
x86_64*)
|
||||
$BAZEL run //common:kunit_tests_x86_64 -- -v --destdir $TESTSDIR
|
||||
;;
|
||||
*)
|
||||
echo "$ABI not supported"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
exit_code=$?
|
||||
if [ $exit_code -eq 0 ]; then
|
||||
echo "Build kunit succeeded"
|
||||
else
|
||||
echo "Build kunit failed with exit code $exit_code"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$SELECTED_TESTS" ]; then
|
||||
echo "Running all KUnit tests with device $SERIAL_NUMBER..."
|
||||
TEST_FILTERS="--include-filter $MODULE_NAME"
|
||||
else
|
||||
echo "Running $SELECTED_TESTS with device $SERIAL_NUMBER ..."
|
||||
fi
|
||||
|
||||
tf_cli="JAVA_HOME=$JDK_PATH PATH=$JDK_PATH/bin:$PATH $TRADEFED run commandAndExit \
|
||||
template/local_min --template:map test=suite/test_mapping_suite \
|
||||
$TEST_FILTERS --tests-dir=$TESTSDIR --log-file-path=$LOG_DIR \
|
||||
--primary-abi-only -s $SERIAL_NUMBER"
|
||||
|
||||
echo "Runing tradefed command: $tf_cli"
|
||||
|
||||
eval $tf_cli
|
||||
|
||||
if $LAUNCH_CVD && $KILL_CVD; then
|
||||
echo "Test finished. Deleting cvd instance $INSTANCE_NAME ..."
|
||||
$ACLOUD delete --instance-names $INSTANCE_NAME
|
||||
fi
|
|
@ -0,0 +1,37 @@
|
|||
<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>
|
||||
|
||||
<target_preparer class="com.android.tradefed.targetprep.InstallKernelModulePreparer">
|
||||
<option name="module-path" value="/data/kunit/arm64/kunit.ko" />
|
||||
<option name="install-arg" value="enable=1" />
|
||||
</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/regmap-kunit.ko' /> -->
|
||||
<!-- <option name='binary' key='drivers/base/regmap/regmap-ram' value='/data/kunit/arm64/regmap-ram.ko' /> -->
|
||||
<!-- <option name='binary' key='drivers/base/regmap/regmap-raw-ram' value='/data/kunit/arm64/egmap-raw-ram.ko' /> -->
|
||||
<option name='binary' key='drivers/hid/hid-uclogic-test' value='/data/kunit/arm64/hid-uclogic-test.ko' />
|
||||
<!-- <option name='binary' key='drivers/iio/test/iio-test-format' value='/data/kunit/arm64/iio-test-format.ko' /> -->
|
||||
<option name='binary' key='drivers/input/tests/input_test' value='/data/kunit/arm64/input_test.ko' />
|
||||
<option name='binary' key='drivers/rtc/lib_test' value='/data/kunit/arm64/lib_test.ko' />
|
||||
<option name='binary' key='fs/ext4/ext4-inode-test' value='/data/kunit/arm64/ext4-inode-test.ko' />
|
||||
<option name='binary' key='fs/fat/fat_test' value='/data/kunit/arm64/fat_test.ko' />
|
||||
<option name='binary' key='kernel/time/time_test' value='/data/kunit/arm64/time_test.ko' />
|
||||
<option name='binary' key='lib/kunit/kunit-example-test' value='/data/kunit/arm64/kunit-example-test.ko' />
|
||||
<!-- <option name='binary' key='lib/kunit/kunit-test' value='/data/kunit/arm64/kunit-test.ko' /> -->
|
||||
<!-- <option name='binary' key='mm/kfence/kfence_test' value='/data/kunit/arm64/kfence_test.ko' /> -->
|
||||
<option name='binary' key='net/core/dev_addr_lists_test' value='/data/kunit/arm64/dev_addr_lists_test.ko' />
|
||||
<!-- <option name='binary' key='sound/soc/soc-topology-test' value='/data/kunit/arm64/soc-topology-test.ko' /> -->
|
||||
<option name='binary' key='sound/soc/soc-utils-test' value='/data/kunit/arm64/soc-utils-test.ko' />
|
||||
|
||||
<!-- <option name='binary' key='drivers/clk/clk-gate_test' value='/data/kunit/arm64/clk-gate_test.ko' /> -->
|
||||
<!-- <option name='binary' key='drivers/clk/clk_test' value='/data/kunit/arm64/clk_test.ko' /> -->
|
||||
</test>
|
||||
</configuration>
|
|
@ -0,0 +1,34 @@
|
|||
<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>
|
||||
|
||||
<target_preparer class="com.android.tradefed.targetprep.InstallKernelModulePreparer">
|
||||
<option name="module-path" value="/data/kunit/x86_64/kunit.ko" />
|
||||
<option name="install-arg" value="enable=1" />
|
||||
</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/regmap-kunit.ko' /> -->
|
||||
<!-- <option name='binary' key='drivers/base/regmap/regmap-ram' value='/data/kunit/x86_64/regmap-ram.ko' /> -->
|
||||
<!-- <option name='binary' key='drivers/base/regmap/regmap-raw-ram' value='/data/kunit/x86_64/regmap-raw-ram.ko' /> -->
|
||||
<option name='binary' key='drivers/hid/hid-uclogic-test' value='/data/kunit/x86_64/hid-uclogic-test.ko' />
|
||||
<!-- <option name='binary' key='drivers/iio/test/iio-test-format' value='/data/kunit/x86_64/iio-test-format.ko' /> -->
|
||||
<option name='binary' key='drivers/input/tests/input_test' value='/data/kunit/x86_64/input_test.ko' />
|
||||
<option name='binary' key='drivers/rtc/lib_test' value='/data/kunit/x86_64/lib_test.ko' />
|
||||
<option name='binary' key='fs/ext4/ext4-inode-test' value='/data/kunit/x86_64/ext4-inode-test.ko' />
|
||||
<option name='binary' key='fs/fat/fat_test' value='/data/kunit/x86_64/fat_test.ko' />
|
||||
<option name='binary' key='kernel/time/time_test' value='/data/kunit/x86_64/time_test.ko' />
|
||||
<option name='binary' key='lib/kunit/kunit-example-test' value='/data/kunit/x86_64/kunit-example-test.ko' />
|
||||
<!-- <option name='binary' key='lib/kunit/kunit-test' value='/data/kunit/x86_64/kunit-test.ko' /> -->
|
||||
<!-- <option name='binary' key='mm/kfence/kfence_test' value='/data/kunit/x86_64/kfence_test.ko' /> -->
|
||||
<option name='binary' key='net/core/dev_addr_lists_test' value='/data/kunit/x86_64/dev_addr_lists_test.ko' />
|
||||
<!-- <option name='binary' key='sound/soc/soc-topology-test' value='/data/kunit/x86_64/soc-topology-test.ko' /> -->
|
||||
<option name='binary' key='sound/soc/soc-utils-test' value='/data/kunit/x86_64/soc-utils-test.ko' />
|
||||
</test>
|
||||
</configuration>
|
|
@ -20,7 +20,7 @@ CONFIG_RTC_LIB_KUNIT_TEST=m
|
|||
CONFIG_IIO_FORMAT_KUNIT_TEST=m
|
||||
CONFIG_EXT4_KUNIT_TESTS=m
|
||||
CONFIG_FAT_KUNIT_TEST=m
|
||||
CONFIG_KFENCE_KUNIT_TEST=m
|
||||
# CONFIG_KFENCE_KUNIT_TEST=m
|
||||
CONFIG_KUNIT_TEST=m
|
||||
CONFIG_KUNIT_EXAMPLE_TEST=m
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user