odsign_e2e_tests: Add required artifacts to test.
Make sure we verify some critical parts of the boot class path actually
exist as part of the test.
Bug: 187494247
Test: atest od2sign_e2e_tests
Change-Id: Ic94bc6dc87d5d3dcd20caeca0f815e71bc629873
diff --git a/test/odsign/src/com/android/tests/odsign/ArtifactsSignedTest.java b/test/odsign/src/com/android/tests/odsign/ArtifactsSignedTest.java
index 46bd474..25a46e3 100644
--- a/test/odsign/src/com/android/tests/odsign/ArtifactsSignedTest.java
+++ b/test/odsign/src/com/android/tests/odsign/ArtifactsSignedTest.java
@@ -30,6 +30,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@@ -38,6 +39,20 @@
private static final String ARTIFACTS_DIR = "/data/misc/apexdata/com.android.art/dalvik-cache";
private static final String FS_VERITY_PROC_PATH = "/proc/sys/fs/verity";
+ // Note that some of these files may exist multiple times - for different architectures
+ // Verifying that they are generated for the correct architectures is currently out of
+ // scope for this test.
+ private static final String[] REQUIRED_ARTIFACT_NAMES = {
+ "boot-framework.art",
+ "boot-framework.oat",
+ "boot-framework.vdex",
+ "system@framework@services.jar@classes.vdex",
+ "system@framework@services.jar@classes.odex",
+ "system@framework@services.jar@classes.art",
+ };
+
+ private static final ArrayList<String> mFoundArtifactNames = new ArrayList<>();
+
static {
System.loadLibrary("OdsignTestAppJni");
}
@@ -60,7 +75,27 @@
assertTrue(file.getPath() + " is not in fs-verity",
hasFsverityNative(file.getPath()));
Log.i(TAG, file.getPath() + " is in fs-verity");
+ mFoundArtifactNames.add(file.getName());
}
}
+ for (String artifact : REQUIRED_ARTIFACT_NAMES) {
+ assertTrue("Missing artifact " + artifact, mFoundArtifactNames.contains(artifact));
+ }
+ }
+
+ @Test
+ public void testGeneratesRequiredArtArtifacts() throws Exception {
+ List<File> files = Files.walk(Paths.get(ARTIFACTS_DIR), Integer.MAX_VALUE).
+ map(Path::toFile)
+ .collect(Collectors.toList());
+
+ for (File file : files) {
+ if (file.isFile()) {
+ mFoundArtifactNames.add(file.getName());
+ }
+ }
+ for (String artifact : REQUIRED_ARTIFACT_NAMES) {
+ assertTrue("Missing artifact " + artifact, mFoundArtifactNames.contains(artifact));
+ }
}
}
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 4144e00..b2d5624 100644
--- a/test/odsign/test-src/com/android/tests/odsign/OnDeviceSigningHostTest.java
+++ b/test/odsign/test-src/com/android/tests/odsign/OnDeviceSigningHostTest.java
@@ -49,9 +49,11 @@
@Before
public void setUp() throws Exception {
assumeTrue("Updating APEX is not supported", mInstallUtils.isApexUpdateSupported());
+ installPackage(TEST_APP_APK);
+ mInstallUtils.installApexes(APEX_FILENAME);
+ reboot();
}
- @Before // Generally not needed, but local test devices are sometimes in a "bad" start state.
@After
public void cleanup() throws Exception {
ApexInfo apex = mInstallUtils.getApexInfo(mInstallUtils.getTestFile(APEX_FILENAME));
@@ -61,15 +63,20 @@
@Test
public void verifyArtUpgradeSignsFiles() throws Exception {
- installPackage(TEST_APP_APK);
- mInstallUtils.installApexes(APEX_FILENAME);
- reboot();
DeviceTestRunOptions options = new DeviceTestRunOptions(TEST_APP_PACKAGE_NAME);
options.setTestClassName(TEST_APP_PACKAGE_NAME + ".ArtifactsSignedTest");
options.setTestMethodName("testArtArtifactsHaveFsverity");
runDeviceTests(options);
}
+ @Test
+ public void verifyArtUpgradeGeneratesRequiredArtifacts() throws Exception {
+ DeviceTestRunOptions options = new DeviceTestRunOptions(TEST_APP_PACKAGE_NAME);
+ options.setTestClassName(TEST_APP_PACKAGE_NAME + ".ArtifactsSignedTest");
+ options.setTestMethodName("testGeneratesRequiredArtArtifacts");
+ runDeviceTests(options);
+ }
+
private void reboot() throws Exception {
getDevice().reboot();
boolean success = getDevice().waitForBootComplete(BOOT_COMPLETE_TIMEOUT.toMillis());