diff options
| -rw-r--r-- | test/odsign/src/com/android/tests/odsign/ArtifactsSignedTest.java | 35 | ||||
| -rw-r--r-- | test/odsign/test-src/com/android/tests/odsign/OnDeviceSigningHostTest.java | 15 |
2 files changed, 46 insertions, 4 deletions
diff --git a/test/odsign/src/com/android/tests/odsign/ArtifactsSignedTest.java b/test/odsign/src/com/android/tests/odsign/ArtifactsSignedTest.java index 46bd47414a..25a46e3600 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.io.IOException; 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 @@ public class ArtifactsSignedTest { 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 @@ public class ArtifactsSignedTest { 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 4144e000a2..b2d56245af 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 @@ public class OnDeviceSigningHostTest extends BaseHostJUnit4Test { @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 @@ public class OnDeviceSigningHostTest extends BaseHostJUnit4Test { @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()); |