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
Change-Id: I053f2446144a1fc020b040b952a370ab7779dd47
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 6d11523..740a8aa 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 3ff4cc4..7ae6596 100644
--- a/build/Android.gtest.mk
+++ b/build/Android.gtest.mk
@@ -128,6 +128,8 @@
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 8b6df9d..cd72346 100644
--- a/build/apex/Android.bp
+++ b/build/apex/Android.bp
@@ -327,6 +327,8 @@
"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 fbe6223..95e193d 100755
--- a/build/apex/art_apex_test.py
+++ b/build/apex/art_apex_test.py
@@ -747,6 +747,8 @@
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 c629cfb..297a1f2 100644
--- a/libartservice/Android.bp
+++ b/libartservice/Android.bp
@@ -60,3 +60,17 @@
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 0000000..eb84b73
--- /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 0000000..dbe091d
--- /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 0000000..243204f
--- /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 b602f4f..bfb18fe 100644
--- a/libarttools/Android.bp
+++ b/libarttools/Android.bp
@@ -35,3 +35,17 @@
],
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 0000000..6eaa8f6
--- /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 d5bff4a..0984c0f 100755
--- a/test/utils/regen-test-files
+++ b/test/utils/regen-test-files
@@ -434,6 +434,9 @@
{
"name": "BootImageProfileTest"
},
+ {
+ "name": "ArtServiceTests"
+ },
// ART gtests.
{
"name": "ArtGtestsTarget"