installd: Unit test for RunDex2oat
Add unit tests run_dex2oat_test.
In order to make RunDex2oat testable,
- RunDex2Oat is extracted from dexopt.cpp such that the class is
visible to test
- ExecVHelper is extracted from dexopt.cpp such that it can be used by
RunDex2Oat and the others in the original file.
- Main logic of RunDex2Oat is removed from constructor (otherwise
virtual functions can't be overridden in derived class).
Bug: 161470356
Test: atest run_dex2oat_test
Test: atest frameworks/native/cmds/installd/tests
Test: cmd package compile -m speed -f com.android.egg
Change-Id: I416d57a008374a598def9160b65407ed043ab0eb
diff --git a/cmds/installd/Android.bp b/cmds/installd/Android.bp
index 75dec37..f7f8a93 100644
--- a/cmds/installd/Android.bp
+++ b/cmds/installd/Android.bp
@@ -16,7 +16,9 @@
"InstalldNativeService.cpp",
"QuotaUtils.cpp",
"dexopt.cpp",
+ "execv_helper.cpp",
"globals.cpp",
+ "run_dex2oat.cpp",
"utils.cpp",
"utils_default.cpp",
"view_compiler.cpp",
@@ -102,6 +104,30 @@
}
//
+// Unit tests
+//
+
+cc_test_host {
+ name: "run_dex2oat_test",
+ test_suites: ["general-tests"],
+ clang: true,
+ srcs: [
+ "run_dex2oat_test.cpp",
+ "run_dex2oat.cpp",
+ "execv_helper.cpp",
+ ],
+ cflags: ["-Wall", "-Werror"],
+ shared_libs: [
+ "libbase",
+ "server_configurable_flags",
+ ],
+ static_libs: [
+ //"libinstalld",
+ ],
+ test_config: "run_dex2oat_test.xml",
+}
+
+//
// Executable
//
@@ -203,9 +229,11 @@
srcs: [
"dexopt.cpp",
+ "execv_helper.cpp",
"globals.cpp",
"otapreopt.cpp",
"otapreopt_utils.cpp",
+ "run_dex2oat.cpp",
"utils.cpp",
"utils_default.cpp",
"view_compiler.cpp",