diff options
author | Edward Liaw <edliaw@google.com> | 2024-05-01 21:38:14 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-05-01 21:38:14 +0000 |
commit | d2a0e6d91ab81c97b584e2ac3d692bfb941335c7 (patch) | |
tree | a723602bdff63fb81b6a00b1c4768c14f4df6a1e | |
parent | f48fb6c16c4efd2802848133890a32a64c59d835 (diff) | |
parent | 3fb5297ca4ecbec7619a8f24ece9a991d856cd7e (diff) | |
download | vts-android14-tests-dev.tar.gz |
Merge changes from topic "cherrypicker-L67900030002138301:N95200030034784381" into android14-tests-devandroid14-tests-dev
* changes:
Separate sysrq-trigger test from proc file api tests
VtsKernelProcFileApiTest: Increase timeout after kernel_panic to allow device to finish booting
5 files changed, 105 insertions, 18 deletions
diff --git a/tests/kernel_proc_file_api_test/Android.bp b/tests/kernel_proc_file_api_test/Android.bp index b2f1ae7a4..ac10837de 100644 --- a/tests/kernel_proc_file_api_test/Android.bp +++ b/tests/kernel_proc_file_api_test/Android.bp @@ -14,22 +14,41 @@ // limitations under the License. // - package { default_applicable_licenses: ["Android-Apache-2.0"], } python_test_host { + name: "vts_kernel_proc_sysrq_trigger_test", + main: "vts_kernel_proc_sysrq_trigger_test.py", + srcs: [ + "vts_kernel_proc_sysrq_trigger_test.py", + "proc_utils.py", + ], + libs: [ + "vts_vndk_utils", + ], + test_suites: [ + "general-tests", + "vts", + ], + test_config: "kernel_proc_sysrq_trigger_test.xml", + test_options: { + unit_test: false, + }, +} + +python_test_host { name: "vts_kernel_proc_file_api_test", main: "vts_kernel_proc_file_api_test.py", srcs: [ "**/*.py", ], libs: [ - "py-parse_type", - "py-ply", - "vndk_utils", - "vts_vndk_utils", + "py-parse_type", + "py-ply", + "vndk_utils", + "vts_vndk_utils", ], test_suites: [ "vts", diff --git a/tests/kernel_proc_file_api_test/TEST_MAPPING b/tests/kernel_proc_file_api_test/TEST_MAPPING index 614855beb..11078b5c5 100644 --- a/tests/kernel_proc_file_api_test/TEST_MAPPING +++ b/tests/kernel_proc_file_api_test/TEST_MAPPING @@ -2,6 +2,9 @@ "kernel-presubmit": [ { "name": "vts_kernel_proc_file_api_test" + }, + { + "name": "vts_kernel_proc_sysrq_trigger_test" } ] } diff --git a/tests/kernel_proc_file_api_test/kernel_proc_sysrq_trigger_test.xml b/tests/kernel_proc_file_api_test/kernel_proc_sysrq_trigger_test.xml new file mode 100644 index 000000000..2ae177664 --- /dev/null +++ b/tests/kernel_proc_file_api_test/kernel_proc_sysrq_trigger_test.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2024 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> +<configuration description="Config for kernel_proc_sysrq_trigger_test"> + <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer" /> + <test class="com.android.tradefed.testtype.python.PythonBinaryHostTest"> + <option name="par-file-name" value="vts_kernel_proc_sysrq_trigger_test" /> + <option name="test-timeout" value="10m" /> + </test> +</configuration> diff --git a/tests/kernel_proc_file_api_test/vts_kernel_proc_file_api_test.py b/tests/kernel_proc_file_api_test/vts_kernel_proc_file_api_test.py index 7e7716414..88cdc3025 100644 --- a/tests/kernel_proc_file_api_test/vts_kernel_proc_file_api_test.py +++ b/tests/kernel_proc_file_api_test/vts_kernel_proc_file_api_test.py @@ -149,19 +149,6 @@ class VtsKernelProcFileApiTest(unittest.TestCase): r_code, 0, "Failed to parse %s." % filepath) - def testProcSysrqTrigger(self): - filepath = "/proc/sysrq-trigger" - - # This command only performs a best effort attempt to remount all - # filesystems. Check that it doesn't throw an error. - self.dut.shell.Execute("echo u > %s" % filepath) - - # Reboot the device. - self.dut.shell.Execute("echo b > %s" % filepath) - self.assertTrue(self.dut.IsShutdown(10), "Device is still alive.") - self.assertTrue(self.dut.WaitForBootCompletion(300)) - self.assertTrue(self.dut.Root()) - def testProcUidProcstatSet(self): def UidIOStats(uid): diff --git a/tests/kernel_proc_file_api_test/vts_kernel_proc_sysrq_trigger_test.py b/tests/kernel_proc_file_api_test/vts_kernel_proc_sysrq_trigger_test.py new file mode 100644 index 000000000..0a95bc36b --- /dev/null +++ b/tests/kernel_proc_file_api_test/vts_kernel_proc_sysrq_trigger_test.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python +# +# Copyright (C) 2024 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import os +import unittest + +import proc_utils as utils + + +class VtsKernelProcSysrqTriggerTest(unittest.TestCase): + def setUp(self): + """Initializes tests. + + Data file path, device, remote shell instance and temporary directory + are initialized. + """ + serial_number = os.environ.get("ANDROID_SERIAL") + self.assertTrue(serial_number, "$ANDROID_SERIAL is empty.") + self.dut = utils.AndroidDevice(serial_number) + + def testProcSysrqTrigger(self): + filepath = "/proc/sysrq-trigger" + + # This command only performs a best effort attempt to remount all + # filesystems. Check that it doesn't throw an error. + self.dut.shell.Execute("echo u > %s" % filepath) + + # Reboot the device. + self.dut.shell.Execute("echo b > %s" % filepath) + self.assertTrue(self.dut.IsShutdown(10), "Device is still alive.") + self.assertTrue(self.dut.WaitForBootCompletion(600)) + self.assertTrue(self.dut.Root()) + +if __name__ == "__main__": + try: + suite = unittest.TestLoader().loadTestsFromTestCase( + VtsKernelProcSysrqTriggerTest) + results = unittest.TextTestRunner(verbosity=2).run(suite) + finally: + if results.failures: + sys.exit(1) |