diff --git a/tools/testing/android/bin/kselftest.sh b/tools/testing/android/bin/kselftest.sh index c6574d35ba46..44c8ea990c20 100755 --- a/tools/testing/android/bin/kselftest.sh +++ b/tools/testing/android/bin/kselftest.sh @@ -12,14 +12,18 @@ 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 "This script runs Selftests on an Android device." + echo "Please run the script with full path common/tools/testing/android/bin/." + echo "Building kernel and launching virtual device are enabled by default;" + echo "use options to skip the workflow." + echo "" 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 " If serial is specified, virtual 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 " --gcov Collect coverage data from the test result" diff --git a/tools/testing/android/bin/kunit.sh b/tools/testing/android/bin/kunit.sh index 3f20c8b11482..c6c87a9eed29 100755 --- a/tools/testing/android/bin/kunit.sh +++ b/tools/testing/android/bin/kunit.sh @@ -12,16 +12,20 @@ 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 "This script runs KUnit tests on an Android device." + echo "Please run the script with full path common/tools/testing/android/bin/." + echo "Building kernel and launching virtual device are enabled by default;" + echo "use options to skip the workflow." + echo "" 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 " If serial is specified, virtual 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 " If test is not specified, all tests will be run" echo " -h, --help Display this help message and exit" echo "" echo "Examples:" @@ -154,12 +158,14 @@ 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 ..." +echo "Building KUnit tests according to device $SERIAL_NUMBER ro.product.cpu.abi $ABI ..." case $ABI in arm64*) + TESTSDIR+="_arm64" $BAZEL run //common:kunit_tests_arm64 -- -v --destdir $TESTSDIR ;; x86_64*) + TESTSDIR+="_x86_64" $BAZEL run //common:kunit_tests_x86_64 -- -v --destdir $TESTSDIR ;; *) diff --git a/tools/testing/kunit/android/README b/tools/testing/kunit/android/README index 369048d81697..12b3e51d5145 100644 --- a/tools/testing/kunit/android/README +++ b/tools/testing/kunit/android/README @@ -2,16 +2,33 @@ HOW TO RUN KUNIT TESTS IN ANDROID ================================= Prerequisites - * Pass kunit.enable=1 as a kernel command line argument - * This should be done in either userdebug or eng build configs. See - the following examples: - * https://android-review.git.corp.google.com/c/device/google/cuttlefish/+/2085612 - * https://android-review.git.corp.google.com/c/kernel/google-modules/raviole-device/+/2095369 - * For a local device you can run the following: - $ fastboot oem cmdline add "kunit.enable=1" - * Run a "no trim" kernel (e.g. add `--notrim` to bazel build command) + * If you want to run a vendor module KUnit tests, please run the tests with a + "no trim" kernel (e.g. add `--notrim` to bazel build command). + +Run test with a single shell script command: + $ common/tools/testing/android/bin/kunit.sh + + By default, the script will build the kernel and launch an Android virtual + device and then run the tests. Additional options may be passed to change + the default behavior. The following are some examples on how to use it: + + * Build kernel, launch a virtual device, run KUnit tests: + $ common/tools/testing/android/bin/kunit.sh + + * Run KUnit tests on a connected device directly: + $ common/tools/testing/android/bin/kunit.sh -s 127.0.0.1:37693 + + * Check other available options: + $ common/tools/testing/android/bin/kunit.sh -h + +Load and run a test module on Android device manually + * Push the KUnit test framework module kunit.ko over to the device. For example: + $ adb push kunit.ko /data + + * Load test module on device: + $ cd /data + $ insmod kunit.ko enable=1 -Run a test module * Push the KUnit test module over to the device. For example using adb: $ adb push kunit-test-example.ko /data @@ -48,7 +65,7 @@ View test results .... -Run ACK KUnit tests via tradefed +Run KUnit tests on Android Device via test automation infrastructure tradefed * Build ACK KUnit tests and install (e.g. /tmp/kunit_tests): $ tools/bazel run -- //common:kunit_tests_x86_64_install -v --destdir /tmp/kunit_tests @@ -68,7 +85,6 @@ Run ACK KUnit tests via tradefed ============================================ .... - TROUBLESHOOTING =============== diff --git a/tools/testing/selftests/android/README b/tools/testing/selftests/android/README new file mode 100644 index 000000000000..eb3360bcc3a7 --- /dev/null +++ b/tools/testing/selftests/android/README @@ -0,0 +1,18 @@ +HOW TO RUN SELFTESTS IN ANDROID +================================= + +Run test with a single shell script command: + $ common/tools/testing/android/bin/kselftest.sh + + By default, the script will build the kernel and launch an Android virtual + device and then run the tests. Additional options may be passed to change + the default behavior. The following are some examples on how to use it: + + * Build kernel, launch a virtual device, run KUnit tests: + $ common/tools/testing/android/bin/kselftest.sh + + * Run Selftests on a connected device directly: + $ common/tools/testing/android/bin/kselftest.sh -s 127.0.0.1:37693 + + * Check other available options: + $ common/tools/testing/android/bin/kselftest.sh -h