This commit introduces the use of VirtualEnv to manage test
dependencies. Specifically:
1. `PythonVirtualenvPreparer` is invoked before running tests
to set up the isolated Python environment.
2. The test is declared as a `MoblyBinaryHostTest` to enable
VirtualEnv compatibility, as `PythonBinaryHostTest` lacks
this support.
3. The Mobly test runner is invoked manually to accommodate
multiple test classes, which is not supported by
`mobly.test_runner.main()`.
4. Test classes are refactored to inherit from
`mobly.BaseTestClass` for compatibility with the Mobly
test runner.
This change is a prerequisite for subsequent commits that will
install libraries via `pip install`, facilitating isolated
dependency management for improved test reliability and
maintainability.
Also, this commit uses parameterized annotation from absl
to rewrite several tests as paremeterized tests.
Test: atest NetworkStaticLibHostPythonTests
Bug: 335368434
Change-Id: Iffa2f8fa81c3913f3e08cca01b2c009ca959db73
89 lines
2.3 KiB
Text
89 lines
2.3 KiB
Text
//########################################################################
|
|
// Build NetworkStaticLibTests package
|
|
//########################################################################
|
|
|
|
package {
|
|
default_team: "trendy_team_fwk_core_networking",
|
|
default_applicable_licenses: ["Android-Apache-2.0"],
|
|
}
|
|
|
|
android_library {
|
|
name: "NetworkStaticLibTestsLib",
|
|
srcs: [
|
|
"src/**/*.java",
|
|
"src/**/*.kt",
|
|
],
|
|
min_sdk_version: "30",
|
|
defaults: ["framework-connectivity-test-defaults"],
|
|
static_libs: [
|
|
"androidx.test.rules",
|
|
"mockito-target-extended-minus-junit4",
|
|
"netd-client",
|
|
"net-tests-utils",
|
|
"net-utils-framework-common",
|
|
"net-utils-device-common",
|
|
"net-utils-device-common-async",
|
|
"net-utils-device-common-bpf",
|
|
"net-utils-device-common-ip",
|
|
"net-utils-device-common-struct-base",
|
|
"net-utils-device-common-wear",
|
|
],
|
|
libs: [
|
|
"android.test.runner",
|
|
"android.test.base",
|
|
],
|
|
visibility: [
|
|
"//frameworks/base/packages/Tethering/tests/integration",
|
|
"//packages/modules/Connectivity/tests:__subpackages__",
|
|
"//packages/modules/Connectivity/Tethering/tests:__subpackages__",
|
|
"//packages/modules/NetworkStack/tests/integration",
|
|
],
|
|
lint: {
|
|
strict_updatability_linting: true,
|
|
test: true,
|
|
},
|
|
}
|
|
|
|
android_test {
|
|
name: "NetworkStaticLibTests",
|
|
certificate: "platform",
|
|
static_libs: [
|
|
"NetworkStaticLibTestsLib",
|
|
],
|
|
jni_libs: [
|
|
// For mockito extended
|
|
"libdexmakerjvmtiagent",
|
|
"libstaticjvmtiagent",
|
|
],
|
|
jarjar_rules: "jarjar-rules.txt",
|
|
test_suites: ["device-tests"],
|
|
lint: {
|
|
strict_updatability_linting: true,
|
|
},
|
|
}
|
|
|
|
python_test_host {
|
|
name: "NetworkStaticLibHostPythonTests",
|
|
srcs: [
|
|
"host/python/*.py",
|
|
],
|
|
main: "host/python/run_tests.py",
|
|
libs: [
|
|
"mobly",
|
|
"net-tests-utils-host-python-common",
|
|
],
|
|
test_config: "host/python/test_config.xml",
|
|
test_suites: [
|
|
"general-tests",
|
|
],
|
|
// MoblyBinaryHostTest doesn't support unit_test.
|
|
test_options: {
|
|
unit_test: false,
|
|
},
|
|
// Needed for applying VirtualEnv.
|
|
version: {
|
|
py3: {
|
|
embedded_launcher: false,
|
|
},
|
|
},
|
|
}
|