summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chris Wailes <chriswailes@google.com> 2021-01-13 16:13:41 -0800
committer Christian Wailes <chriswailes@google.com> 2021-02-04 17:03:10 +0000
commitbfd622abc23c77ffc8799f376df7241f15d6550a (patch)
treef783c1bc6a577df480929c84476711a3bc41ff9f
parentbefdad488b42600826b4a3bd7c92f19a0104d7fa (diff)
Initial commit of the test code for ART Service
This CL adds the scaffolding for testing the ART Tools and ART Service libraries. The command `atest ArtServiceTest` will fail with Tradefed errors, but these same errors are generated by existing tests such as `atest android-icu4j-tests`. Test: m test-art-host-gtest && atest ArtServiceTest Bug: 177273468 Merged-In: I053f2446144a1fc020b040b952a370ab7779dd47 Change-Id: I053f2446144a1fc020b040b952a370ab7779dd47
-rw-r--r--TEST_MAPPING3
-rw-r--r--build/Android.gtest.mk2
-rw-r--r--build/apex/Android.bp2
-rwxr-xr-xbuild/apex/art_apex_test.py2
-rw-r--r--libartservice/Android.bp14
-rw-r--r--libartservice/service/native/service_test.cc28
-rw-r--r--libartservice/tests/Android.bp36
-rw-r--r--libartservice/tests/src/com/android/server/art/ArtServiceTests.java39
-rw-r--r--libarttools/Android.bp14
-rw-r--r--libarttools/tools/tools_test.cc28
-rwxr-xr-xtest/utils/regen-test-files3
11 files changed, 171 insertions, 0 deletions
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 6d11523b7c..740a8aa70e 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -12,6 +12,9 @@
{
"name": "BootImageProfileTest"
},
+ {
+ "name": "ArtServiceTests"
+ },
// ART gtests.
{
"name": "ArtGtestsTarget"
diff --git a/build/Android.gtest.mk b/build/Android.gtest.mk
index 3ff4cc4c55..7ae6596701 100644
--- a/build/Android.gtest.mk
+++ b/build/Android.gtest.mk
@@ -128,6 +128,8 @@ ART_TEST_MODULES := \
art_imgdiag_tests \
art_libartbase_tests \
art_libartpalette_tests \
+ art_libartservice_tests \
+ art_libarttools_tests \
art_libdexfile_external_tests \
art_libdexfile_support_static_tests \
art_libdexfile_support_tests \
diff --git a/build/apex/Android.bp b/build/apex/Android.bp
index f0a58f0cfe..0c37c1f262 100644
--- a/build/apex/Android.bp
+++ b/build/apex/Android.bp
@@ -325,6 +325,8 @@ art_gtests = [
"art_imgdiag_tests",
"art_libartbase_tests",
"art_libartpalette_tests",
+ "art_libartservice_tests",
+ "art_libarttools_tests",
"art_libdexfile_tests",
"art_libdexfile_support_tests",
"art_libprofile_tests",
diff --git a/build/apex/art_apex_test.py b/build/apex/art_apex_test.py
index fbe62232e7..95e193dbf0 100755
--- a/build/apex/art_apex_test.py
+++ b/build/apex/art_apex_test.py
@@ -747,6 +747,8 @@ class TestingTargetChecker:
self._checker.check_art_test_executable('art_imgdiag_tests')
self._checker.check_art_test_executable('art_libartbase_tests')
self._checker.check_art_test_executable('art_libartpalette_tests')
+ self._checker.check_art_test_executable('art_libartservice_tests')
+ self._checker.check_art_test_executable('art_libarttools_tests')
self._checker.check_art_test_executable('art_libdexfile_support_tests')
self._checker.check_art_test_executable('art_libdexfile_tests')
self._checker.check_art_test_executable('art_libprofile_tests')
diff --git a/libartservice/Android.bp b/libartservice/Android.bp
index c629cfb58a..297a1f2b7a 100644
--- a/libartservice/Android.bp
+++ b/libartservice/Android.bp
@@ -60,3 +60,17 @@ java_library {
plugins: ["java_api_finder"],
}
+
+art_cc_test {
+ name: "art_libartservice_tests",
+ defaults: [
+ "art_gtest_defaults",
+ ],
+ srcs: [
+ "service/native/service_test.cc",
+ ],
+ shared_libs: [
+ "libbase",
+ "libartservice",
+ ],
+}
diff --git a/libartservice/service/native/service_test.cc b/libartservice/service/native/service_test.cc
new file mode 100644
index 0000000000..eb84b732c7
--- /dev/null
+++ b/libartservice/service/native/service_test.cc
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+#include "service.h"
+#include "gtest/gtest.h"
+
+namespace art {
+
+class ArtServiceTest : public testing::Test {};
+
+TEST_F(ArtServiceTest, Hello) {
+ EXPECT_EQ("hello world!", art::service::getMsg());
+}
+
+} // namespace art
diff --git a/libartservice/tests/Android.bp b/libartservice/tests/Android.bp
new file mode 100644
index 0000000000..dbe091d964
--- /dev/null
+++ b/libartservice/tests/Android.bp
@@ -0,0 +1,36 @@
+//
+// Copyright (C) 2021 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.
+//
+
+//########################################################################
+// Build ArtServiceTests package
+//########################################################################
+
+java_test {
+ name: "ArtServiceTests",
+
+ // Include all test java files.
+ srcs: [
+ "src/**/*.java",
+ ],
+
+ static_libs: [
+ "junit",
+ "artservice",
+ ],
+
+ platform_apis: true,
+ test_suites: ["general-tests"],
+}
diff --git a/libartservice/tests/src/com/android/server/art/ArtServiceTests.java b/libartservice/tests/src/com/android/server/art/ArtServiceTests.java
new file mode 100644
index 0000000000..243204f63d
--- /dev/null
+++ b/libartservice/tests/src/com/android/server/art/ArtServiceTests.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2021 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.art;
+
+import static org.junit.Assert.assertEquals;
+
+import com.android.server.art.ArtService;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class ArtServiceTests {
+ private static ArtService mArtService;
+
+ @Before
+ public void setup() {
+ mArtService = new ArtService();
+ }
+
+ @Test
+ public void testNotifyPrimaryUse() {
+ assertEquals(mArtService.getMsg(), "Hello world!");
+ }
+} \ No newline at end of file
diff --git a/libarttools/Android.bp b/libarttools/Android.bp
index b602f4f4b5..bfb18fe5c7 100644
--- a/libarttools/Android.bp
+++ b/libarttools/Android.bp
@@ -35,3 +35,17 @@ cc_library {
],
export_shared_lib_headers: ["libbase"],
}
+
+art_cc_test {
+ name: "art_libarttools_tests",
+ defaults: [
+ "art_gtest_defaults",
+ ],
+ srcs: [
+ "tools/tools_test.cc",
+ ],
+ shared_libs: [
+ "libbase",
+ "libarttools",
+ ],
+}
diff --git a/libarttools/tools/tools_test.cc b/libarttools/tools/tools_test.cc
new file mode 100644
index 0000000000..6eaa8f60bb
--- /dev/null
+++ b/libarttools/tools/tools_test.cc
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+#include "tools.h"
+#include "gtest/gtest.h"
+
+namespace art {
+
+class ArtToolsTest : public testing::Test {};
+
+TEST_F(ArtToolsTest, Hello) {
+ EXPECT_EQ("hello world!", art::tools::getMsg());
+}
+
+} // namespace art
diff --git a/test/utils/regen-test-files b/test/utils/regen-test-files
index d5bff4acb5..0984c0f08b 100755
--- a/test/utils/regen-test-files
+++ b/test/utils/regen-test-files
@@ -434,6 +434,9 @@ cat >>TEST_MAPPING <<EOF
{
"name": "BootImageProfileTest"
},
+ {
+ "name": "ArtServiceTests"
+ },
// ART gtests.
{
"name": "ArtGtestsTarget"