From 5d9f8ed872e0ccccfe39b5a3b41b277ca66c1b63 Mon Sep 17 00:00:00 2001 From: Lorenzo Colitti Date: Tue, 21 Jan 2020 15:31:06 +0900 Subject: [PATCH] Run NetworkStaticLibTests on the actual source files. Currently, NetworkStaticLibTests tests the class files that are on the bootclasspath of the device. This makes running these tests slow and/or confusing, because the framework must be rebuilt and the device flashed before running the tests, and if this is not done, the old code will be tested instead. Instead, jarjar the tests so the test can be run without updating the device. Bug: 142892223 Test: atest NetworkStaticLibTests passes on device that does not have the library Change-Id: I6a0dbebddbd0b64e2722078345ffe6b0c0a1801e --- staticlibs/Android.bp | 2 ++ staticlibs/tests/unit/Android.bp | 3 +++ staticlibs/tests/unit/jarjar-rules.txt | 4 ++++ 3 files changed, 9 insertions(+) create mode 100644 staticlibs/tests/unit/jarjar-rules.txt diff --git a/staticlibs/Android.bp b/staticlibs/Android.bp index 713a0d61d7..3f867fcd7c 100644 --- a/staticlibs/Android.bp +++ b/staticlibs/Android.bp @@ -40,6 +40,7 @@ java_library { "//frameworks/opt/telephony", "//packages/modules/NetworkStack", "//packages/modules/CaptivePortalLogin", + "//frameworks/libs/net/common/tests:__subpackages__", ] } @@ -53,6 +54,7 @@ java_library { "//frameworks/opt/net/ike", "//packages/modules/NetworkStack", "//packages/modules/CaptivePortalLogin", + "//frameworks/libs/net/common/tests:__subpackages__", ], } diff --git a/staticlibs/tests/unit/Android.bp b/staticlibs/tests/unit/Android.bp index 4a51a8c2d3..fe363f5a28 100644 --- a/staticlibs/tests/unit/Android.bp +++ b/staticlibs/tests/unit/Android.bp @@ -6,9 +6,12 @@ android_test { name: "NetworkStaticLibTests", certificate: "platform", srcs: ["src/**/*.java","src/**/*.kt"], + jarjar_rules: "jarjar-rules.txt", test_suites: ["device-tests"], static_libs: [ "androidx.test.rules", + "net-utils-framework-common", + "net-utils-services-common", ], libs: [ "android.test.runner", diff --git a/staticlibs/tests/unit/jarjar-rules.txt b/staticlibs/tests/unit/jarjar-rules.txt new file mode 100644 index 0000000000..dbb3974f7a --- /dev/null +++ b/staticlibs/tests/unit/jarjar-rules.txt @@ -0,0 +1,4 @@ +# Ensure that the tests can directly use the version of classes from the library. Otherwise, they +# will use whatever version is currently in the bootclasspath on the device running the test. +# These rules must match the jarjar rules used to build the library. +rule android.net.util.** com.android.net.module.util.@1