odrefresh: fix instruction set selection.

Refactoring led to the instruction-set argument being dropped in
odrefresh. This manifested itself as failures in the odsign_e2e_tests
as the secondary zygote was running in jit-zygote mode.

Re-enables the verifyGeneratedArtifactsLoaded test and enforces a
deterministic order for the odsign_e2e_tests.

(cherry picked from commit 71b2cb54099218952385c8c295dbff8be81263ce)

Fix: 191113888
Test: atest odsign_e2e_tests
Merged-In: I5308a6cf9ddf16e2991bfaf9c6f27bd7e8ff0aff
Change-Id: Ida2a1e2e11e039fc1324c054889b158664f67bbc
diff --git a/odrefresh/odrefresh.cc b/odrefresh/odrefresh.cc
index 637b927..cccf2b3 100644
--- a/odrefresh/odrefresh.cc
+++ b/odrefresh/odrefresh.cc
@@ -637,17 +637,17 @@
     return ExitCode::kOkay;
   }
 
-  static void AddDex2OatCommonOptions(/*inout*/ std::vector<std::string>& args) {
-    args.emplace_back("--android-root=out/empty");
-    args.emplace_back("--abort-on-hard-verifier-error");
-    args.emplace_back("--no-abort-on-soft-verifier-error");
-    args.emplace_back("--compilation-reason=boot");
-    args.emplace_back("--image-format=lz4");
-    args.emplace_back("--force-determinism");
-    args.emplace_back("--resolve-startup-const-strings=true");
+  static void AddDex2OatCommonOptions(/*inout*/ std::vector<std::string>* args) {
+    args->emplace_back("--android-root=out/empty");
+    args->emplace_back("--abort-on-hard-verifier-error");
+    args->emplace_back("--no-abort-on-soft-verifier-error");
+    args->emplace_back("--compilation-reason=boot");
+    args->emplace_back("--image-format=lz4");
+    args->emplace_back("--force-determinism");
+    args->emplace_back("--resolve-startup-const-strings=true");
   }
 
-  static void AddDex2OatConcurrencyArguments(/*inout*/ std::vector<std::string>& args) {
+  static void AddDex2OatConcurrencyArguments(/*inout*/ std::vector<std::string>* args) {
     static constexpr std::pair<const char*, const char*> kPropertyArgPairs[] = {
         std::make_pair("dalvik.vm.boot-dex2oat-cpu-set", "--cpu-set="),
         std::make_pair("dalvik.vm.boot-dex2oat-threads", "-j"),
@@ -656,29 +656,30 @@
       auto [property, arg] = property_arg_pair;
       std::string value = android::base::GetProperty(property, {});
       if (!value.empty()) {
-        args.push_back(arg + value);
+        args->push_back(arg + value);
       }
     }
   }
 
-  static void AddDex2OatDebugInfo(/*inout*/ std::vector<std::string>& args) {
-    args.emplace_back("--generate-mini-debug-info");
-    args.emplace_back("--strip");
+  static void AddDex2OatDebugInfo(/*inout*/ std::vector<std::string>* args) {
+    args->emplace_back("--generate-mini-debug-info");
+    args->emplace_back("--strip");
   }
 
-  static void AddDex2OatInstructionSet(/*inout*/ std::vector<std::string> args,
+  static void AddDex2OatInstructionSet(/*inout*/ std::vector<std::string>* args,
                                        InstructionSet isa) {
     const char* isa_str = GetInstructionSetString(isa);
-    args.emplace_back(Concatenate({"--instruction-set=", isa_str}));
+    args->emplace_back(Concatenate({"--instruction-set=", isa_str}));
   }
 
-  static void AddDex2OatProfileAndCompilerFilter(/*inout*/ std::vector<std::string>& args,
+
+  static void AddDex2OatProfileAndCompilerFilter(/*inout*/ std::vector<std::string>* args,
                                                  const std::string& profile_file) {
     if (OS::FileExists(profile_file.c_str(), /*check_file_type=*/true)) {
-      args.emplace_back(Concatenate({"--profile-file=", profile_file}));
-      args.emplace_back("--compiler-filter=speed-profile");
+      args->emplace_back(Concatenate({"--profile-file=", profile_file}));
+      args->emplace_back("--compiler-filter=speed-profile");
     } else {
-      args.emplace_back("--compiler-filter=speed");
+      args->emplace_back("--compiler-filter=speed");
     }
   }
 
@@ -999,12 +1000,12 @@
     std::vector<std::string> args;
     args.push_back(config_.GetDex2Oat());
 
-    AddDex2OatCommonOptions(args);
-    AddDex2OatConcurrencyArguments(args);
-    AddDex2OatDebugInfo(args);
-    AddDex2OatInstructionSet(args, isa);
+    AddDex2OatCommonOptions(&args);
+    AddDex2OatConcurrencyArguments(&args);
+    AddDex2OatDebugInfo(&args);
+    AddDex2OatInstructionSet(&args, isa);
     const std::string boot_profile_file(GetAndroidRoot() + "/etc/boot-image.prof");
-    AddDex2OatProfileAndCompilerFilter(args, boot_profile_file);
+    AddDex2OatProfileAndCompilerFilter(&args, boot_profile_file);
 
     // Compile as a single image for fewer files and slightly less memory overhead.
     args.emplace_back("--single-image");
@@ -1114,13 +1115,13 @@
       args.emplace_back(dex2oat);
       args.emplace_back("--dex-file=" + jar);
 
-      AddDex2OatCommonOptions(args);
-      AddDex2OatConcurrencyArguments(args);
-      AddDex2OatDebugInfo(args);
-      AddDex2OatInstructionSet(args, isa);
+      AddDex2OatCommonOptions(&args);
+      AddDex2OatConcurrencyArguments(&args);
+      AddDex2OatDebugInfo(&args);
+      AddDex2OatInstructionSet(&args, isa);
       const std::string jar_name(android::base::Basename(jar));
       const std::string profile = Concatenate({GetAndroidRoot(), "/framework/", jar_name, ".prof"});
-      AddDex2OatProfileAndCompilerFilter(args, profile);
+      AddDex2OatProfileAndCompilerFilter(&args, profile);
 
       const std::string image_location = GetSystemServerImagePath(/*on_system=*/false, jar);
       const std::string install_location = android::base::Dirname(image_location);
diff --git a/test/odsign/test-src/com/android/tests/odsign/OnDeviceSigningHostTest.java b/test/odsign/test-src/com/android/tests/odsign/OnDeviceSigningHostTest.java
index 49c4fe0..e44bc80 100644
--- a/test/odsign/test-src/com/android/tests/odsign/OnDeviceSigningHostTest.java
+++ b/test/odsign/test-src/com/android/tests/odsign/OnDeviceSigningHostTest.java
@@ -31,16 +31,19 @@
 
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Ignore;
+import org.junit.FixMethodOrder;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.junit.runners.MethodSorters;
 
 import java.time.Duration;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 @RunWith(DeviceJUnit4ClassRunner.class)
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
 public class OnDeviceSigningHostTest extends BaseHostJUnit4Test {
 
     private static final String APEX_FILENAME = "test_com.android.art.apex";
@@ -176,16 +179,17 @@
         }
     }
 
-    private void verifyZygoteLoadedArtifacts(String zygotePid) throws Exception {
+    private void verifyZygoteLoadedArtifacts(String zygoteName, String zygotePid) throws Exception {
         final String bootExtensionName = "boot-framework";
         final Set<String> mappedArtifacts = getMappedArtifacts(zygotePid, bootExtensionName);
 
         assertTrue("Expect 3 boot-framework artifacts", mappedArtifacts.size() == 3);
 
+        String allArtifacts = mappedArtifacts.stream().collect(Collectors.joining(","));
         for (String extension : BCP_ARTIFACT_EXTENSIONS) {
             final String artifact = bootExtensionName + extension;
             final boolean found = mappedArtifacts.stream().anyMatch(a -> a.endsWith(artifact));
-            assertTrue(artifact + " not found", found);
+            assertTrue(zygoteName + " " + artifact + " not found: '" + allArtifacts + "'", found);
         }
     }
 
@@ -194,20 +198,20 @@
         // instances 32-bit and 64-bit unspecialized app_process processes.
         // (frameworks/base/cmds/app_process).
         int zygoteCount = 0;
-        for (String processName : new String[] {"zygote", "zygote64"}) {
+        for (String zygoteName : new String[] {"zygote", "zygote64"}) {
             final CommandResult pgrepResult =
-                    getDevice().executeShellV2Command("pgrep " + processName);
+                    getDevice().executeShellV2Command("pgrep " + zygoteName);
             if (pgrepResult.getExitCode() != 0) {
                 continue;
             }
             final String zygotePid = pgrepResult.getStdout();
-            verifyZygoteLoadedArtifacts(zygotePid);
+            verifyZygoteLoadedArtifacts(zygoteName, zygotePid);
             zygoteCount += 1;
         }
         assertTrue("No zygote processes found", zygoteCount > 0);
     }
 
-    @Test @Ignore("b/191113888 failing with secondary 64-bit zygote checks")
+    @Test
     public void verifyGeneratedArtifactsLoaded() throws Exception {
         // Checking zygote and system_server need the device have adb root to walk process maps.
         final boolean adbEnabled = getDevice().enableAdbRoot();