diff options
author | Maciej Żenczykowski <maze@google.com> | 2024-03-05 20:37:21 -0800 |
---|---|---|
committer | Maciej Żenczykowski <maze@google.com> | 2024-03-06 06:23:22 +0000 |
commit | ca9fd66f5b48abc92990c9c770f73380b428362b (patch) | |
tree | 8fa2aed96d8b97193b7cbcc704a0bdcebc853556 | |
parent | 255b35ea3c9f5e364aa71fc480e8f5462b3a1cec (diff) | |
download | tests-ca9fd66f5b48abc92990c9c770f73380b428362b.tar.gz |
net-test: add a new target for old gki branches
MinLTS passes on all GKI ACK branches at HEAD,
but fails on old release branches...
This change gives us a new test target to run on
release branches, without affecting actual V VTS requirements.
Test: TreeHugger, manually on UML, atest vts_kernel_net_tests gki_kernel_net_tests
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I852dae8377b60857f42e702959305adae1254712
-rw-r--r-- | net/test/Android.bp | 20 | ||||
-rwxr-xr-x | net/test/all_tests.py | 22 | ||||
-rwxr-xr-x | net/test/all_tests_gki.py | 27 | ||||
-rwxr-xr-x | net/test/gki.py | 18 | ||||
-rwxr-xr-x | net/test/kernel_feature_test.py | 11 |
5 files changed, 88 insertions, 10 deletions
diff --git a/net/test/Android.bp b/net/test/Android.bp index 25015d7..fe063ee 100644 --- a/net/test/Android.bp +++ b/net/test/Android.bp @@ -26,3 +26,23 @@ python_test { "general-tests", ], } + +// Main target used for GKI tests. +// equivalent to above, but has 'gki.IS_GKI == True' +python_test { + name: "gki_kernel_net_tests", + stem: "kernel_net_tests_bin", + srcs: [ + "*.py", + ], + libs: [ + "scapy", + ], + main: "all_tests_gki.py", + version: { + py3: { + embedded_launcher: true, + }, + }, + test_config: "vts_kernel_net_tests.xml", +} diff --git a/net/test/all_tests.py b/net/test/all_tests.py index 6f87167..2e2d487 100755 --- a/net/test/all_tests.py +++ b/net/test/all_tests.py @@ -15,13 +15,12 @@ # limitations under the License. import importlib -import os import sys import unittest import namespace -test_modules = [ +all_test_modules = [ 'anycast_test', 'bpf_test', 'csocket_test', @@ -48,21 +47,18 @@ test_modules = [ 'xfrm_tunnel_test', ] -if __name__ == '__main__': - namespace.EnterNewNetworkNamespace() - # If one or more tests were passed in on the command line, only run those. - if len(sys.argv) > 1: - test_modules = sys.argv[1:] +def RunTests(modules_to_test): + namespace.EnterNewNetworkNamespace() # First, run InjectTests on all modules, to ensure that any parameterized # tests in those modules are injected. - for name in test_modules: + for name in modules_to_test: importlib.import_module(name) if hasattr(sys.modules[name], 'InjectTests'): sys.modules[name].InjectTests() - test_suite = unittest.defaultTestLoader.loadTestsFromNames(test_modules) + test_suite = unittest.defaultTestLoader.loadTestsFromNames(modules_to_test) assert test_suite.countTestCases() > 0, ( 'Inconceivable: no tests found! Command line: %s' % ' '.join(sys.argv)) @@ -70,3 +66,11 @@ if __name__ == '__main__': runner = unittest.TextTestRunner(verbosity=2) result = runner.run(test_suite) sys.exit(not result.wasSuccessful()) + + +if __name__ == '__main__': + # If one or more tests were passed in on the command line, only run those. + if len(sys.argv) > 1: + RunTests(sys.argv[1:]) + else: + RunTests(all_test_modules) diff --git a/net/test/all_tests_gki.py b/net/test/all_tests_gki.py new file mode 100755 index 0000000..cd87195 --- /dev/null +++ b/net/test/all_tests_gki.py @@ -0,0 +1,27 @@ +#!/usr/bin/python3 +# +# Copyright 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 sys + +import all_tests +import gki + +if __name__ == '__main__': + gki.IS_GKI = True + if len(sys.argv) > 1: + all_tests.RunTests(sys.argv[1:]) + else: + all_tests.RunTests(all_tests.all_test_modules) diff --git a/net/test/gki.py b/net/test/gki.py new file mode 100755 index 0000000..77f1ea9 --- /dev/null +++ b/net/test/gki.py @@ -0,0 +1,18 @@ +#!/usr/bin/python3 +# +# Copyright 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. + +# all_tests_gki.py sets this to True +IS_GKI = False diff --git a/net/test/kernel_feature_test.py b/net/test/kernel_feature_test.py index 89269d1..2594a82 100755 --- a/net/test/kernel_feature_test.py +++ b/net/test/kernel_feature_test.py @@ -20,6 +20,7 @@ import os from socket import * # pylint: disable=wildcard-import,g-importing-member import unittest +import gki import net_test @@ -87,7 +88,15 @@ class KernelFeatureTest(net_test.NetworkTest): with net_test.RunAsUidGid(12345, self.AID_NET_RAW): self.assertRaisesErrno(errno.EPERM, socket, AF_PACKET, SOCK_RAW, 0) - @unittest.skipUnless(not net_test.IS_GSI, "GSI") + @unittest.skipUnless(net_test.IS_GSI, "not GSI") + def testIsGSI(self): + pass + + @unittest.skipUnless(gki.IS_GKI, "not GKI") + def testIsGKI(self): + pass + + @unittest.skipUnless(not net_test.IS_GSI and not gki.IS_GKI, "GSI or GKI") def testMinRequiredKernelVersion(self): self.assertTrue(net_test.KernelAtLeast([(4, 19, 236), (5, 4, 186), |