From: Chenbo Feng Date: Fri, 5 Apr 2019 21:14:55 +0000 (-0700) Subject: Add smoke test for jni library X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=5f8a630da7d5b308c0824a25f6fc1dd4c7552c9f;p=android-x86%2Fframeworks-base.git Add smoke test for jni library Since the Framework net test require jni library libnetworkstatsfactorytestjni, but the test fails to load that library unless *all* the dependencies of that library are explicitly listed in jni_libs, whenever any of the dependencies changes the framework net test will start failing and it might not be catched since the change might not related to frameworks/base. And this smoke test is aimed to spot those native library changes and it should be stable enough to put in global presubmit. Bug: 124764595 Test: FrameworksNetSmokeTests Change-Id: Id24e7f0558b5643e4ad7393e85f1f0a2bd875615 --- diff --git a/tests/net/Android.bp b/tests/net/Android.bp index c8ef82ec9acc..9098f90fd777 100644 --- a/tests/net/Android.bp +++ b/tests/net/Android.bp @@ -49,7 +49,6 @@ java_defaults { "libselinux", "libui", "libutils", - "libvintf", "libvndksupport", "libtinyxml2", "libunwindstack", diff --git a/tests/net/smoketest/Android.bp b/tests/net/smoketest/Android.bp new file mode 100644 index 000000000000..ef1ad2cba804 --- /dev/null +++ b/tests/net/smoketest/Android.bp @@ -0,0 +1,17 @@ +// This test exists only because the jni_libs list for these tests is difficult to +// maintain: the test itself only depends on libnetworkstatsfactorytestjni, but the test +// fails to load that library unless *all* the dependencies of that library are explicitly +// listed in jni_libs. This means that whenever any of the dependencies changes the test +// starts failing and breaking presubmits in frameworks/base. We cannot easily put +// FrameworksNetTests into global presubmit because they are at times flaky, but this +// test is effectively empty beyond validating that the libraries load correctly, and +// thus should be stable enough to put in global presubmit. +// +// TODO: remove this hack when there is a better solution for jni_libs that includes +// dependent libraries. +android_test { + name: "FrameworksNetSmokeTests", + defaults: ["FrameworksNetTests-jni-defaults"], + srcs: ["java/SmokeTest.java"], + test_suites: ["device-tests"], +} diff --git a/tests/net/smoketest/AndroidManifest.xml b/tests/net/smoketest/AndroidManifest.xml new file mode 100644 index 000000000000..f1b9febb9f57 --- /dev/null +++ b/tests/net/smoketest/AndroidManifest.xml @@ -0,0 +1,27 @@ + + + + + + + + + + diff --git a/tests/net/smoketest/AndroidTest.xml b/tests/net/smoketest/AndroidTest.xml new file mode 100644 index 000000000000..ac366e4ac544 --- /dev/null +++ b/tests/net/smoketest/AndroidTest.xml @@ -0,0 +1,28 @@ + + + + + + + diff --git a/tests/net/smoketest/java/SmokeTest.java b/tests/net/smoketest/java/SmokeTest.java new file mode 100644 index 000000000000..7d6655fde15e --- /dev/null +++ b/tests/net/smoketest/java/SmokeTest.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2019 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. + */ + +package com.android.server.net; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public final class SmokeTest { + + @Test + public void testLoadJni() { + System.loadLibrary("networkstatsfactorytestjni"); + assertEquals(0, 0x00); + } +}