use of com.facebook.buck.testutil.integration.ZipInspector in project buck by facebook.
the class AndroidExopackageBinaryIntegrationTest method testDexExopackageHasNoSecondary.
@Test
public void testDexExopackageHasNoSecondary() throws IOException {
ZipInspector zipInspector = new ZipInspector(workspace.getPath(BuildTargets.getGenPath(filesystem, BuildTargetFactory.newInstance(DEX_EXOPACKAGE_TARGET), "%s.apk")));
zipInspector.assertFileDoesNotExist("assets/secondary-program-dex-jars/metadata.txt");
zipInspector.assertFileDoesNotExist("assets/secondary-program-dex-jars/secondary-1.dex.jar");
zipInspector.assertFileDoesNotExist("classes2.dex");
zipInspector.assertFileExists("classes.dex");
zipInspector.assertFileExists("lib/armeabi/libfakenative.so");
// It would be better if we could call getExopackageInfo on the app rule.
Path secondaryDir = workspace.resolve(BuildTargets.getScratchPath(filesystem, BuildTargetFactory.newInstance(DEX_EXOPACKAGE_TARGET).withFlavors(InternalFlavor.of("dex_merge")), "_%s_output/jarfiles/assets/secondary-program-dex-jars"));
try (DirectoryStream<Path> stream = Files.newDirectoryStream(secondaryDir)) {
List<Path> files = Lists.newArrayList(stream);
assertEquals(2, files.size());
Collections.sort(files);
Path secondaryJar = files.get(0);
ZipInspector zi = new ZipInspector(secondaryJar);
zi.assertFileExists("classes.dex");
long jarSize = Files.size(secondaryJar);
long classesDexSize = zi.getSize("classes.dex");
Path dexMeta = files.get(1);
assertEquals(String.format("jar:%s dex:%s", jarSize, classesDexSize), new String(Files.readAllBytes(dexMeta), "US-ASCII"));
}
}
use of com.facebook.buck.testutil.integration.ZipInspector in project buck by facebook.
the class AndroidInstrumentationApkIntegrationTest method testCxxLibraryDep.
@Test
public void testCxxLibraryDep() throws IOException {
AssumeAndroidPlatform.assumeSdkIsAvailable();
AssumeAndroidPlatform.assumeNdkIsAvailable();
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "android_instrumentation_apk_integration_test", tmpFolder);
workspace.setUp();
ProjectFilesystem filesystem = new ProjectFilesystem(workspace.getDestPath());
String target = "//:app_cxx_lib_dep";
workspace.runBuckCommand("build", target).assertSuccess();
ZipInspector zipInspector = new ZipInspector(workspace.getPath(BuildTargets.getGenPath(filesystem, BuildTargetFactory.newInstance(target), "%s.apk")));
zipInspector.assertFileExists("lib/armeabi/libcxx.so");
zipInspector.assertFileExists("lib/armeabi/libgnustl_shared.so");
zipInspector.assertFileExists("lib/armeabi-v7a/libcxx.so");
zipInspector.assertFileExists("lib/armeabi-v7a/libgnustl_shared.so");
zipInspector.assertFileExists("lib/x86/libcxx.so");
zipInspector.assertFileExists("lib/x86/libgnustl_shared.so");
}
use of com.facebook.buck.testutil.integration.ZipInspector in project buck by facebook.
the class AndroidBinaryIntegrationTest method testHeaderOnlyCxxLibrary.
@Test
public void testHeaderOnlyCxxLibrary() throws IOException {
String target = "//apps/sample:app_header_only_cxx_lib_dep";
workspace.runBuckCommand("build", target).assertSuccess();
ZipInspector zipInspector = new ZipInspector(workspace.getPath(BuildTargets.getGenPath(filesystem, BuildTargetFactory.newInstance(target), "%s.apk")));
zipInspector.assertFileDoesNotExist("lib/x86/libnative_cxx_headeronly.so");
}
use of com.facebook.buck.testutil.integration.ZipInspector in project buck by facebook.
the class AndroidBinaryIntegrationTest method testCompressAssetLibsModular.
@Test
public void testCompressAssetLibsModular() throws IOException {
String target = "//apps/sample:app_compress_lib_asset_modular";
workspace.runBuckCommand("build", target).assertSuccess();
ZipInspector zipInspector = new ZipInspector(workspace.getPath(BuildTargets.getGenPath(filesystem, BuildTargetFactory.newInstance(target), "%s.apk")));
zipInspector.assertFileExists("assets/lib/libs.xzs");
zipInspector.assertFileExists("assets/lib/metadata.txt");
zipInspector.assertFileExists("assets/native.cxx.libasset/libs.xzs");
zipInspector.assertFileExists("assets/native.cxx.libasset/libs.txt");
zipInspector.assertFileDoesNotExist("assets/lib/x86/libnative_cxx_libasset.so");
zipInspector.assertFileDoesNotExist("lib/x86/libnative_cxx_libasset.so");
zipInspector.assertFileExists("lib/x86/libnative_cxx_foo1.so");
zipInspector.assertFileExists("lib/x86/libnative_cxx_foo2.so");
zipInspector.assertFileDoesNotExist("assets/lib/x86/libnative_cxx_foo1.so");
zipInspector.assertFileDoesNotExist("assets/lib/x86/libnative_cxx_foo2.so");
}
use of com.facebook.buck.testutil.integration.ZipInspector in project buck by facebook.
the class AndroidBinaryIntegrationTest method testNativeLibraryCrossCellMerging.
@Test
public void testNativeLibraryCrossCellMerging() throws IOException, InterruptedException {
// Set up a cross-cell workspace
ProjectWorkspace secondary = TestDataHelper.createProjectWorkspaceForScenario(new AndroidBinaryIntegrationTest(), "android_project/secondary", secondaryFolder);
secondary.setUp();
NdkCxxPlatform platform = AndroidNdkHelper.getNdkCxxPlatform(workspace, filesystem);
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
Path tmpDir = tmpFolder.newFolder("merging_tmp");
SymbolGetter syms = new SymbolGetter(new DefaultProcessExecutor(new TestConsole()), tmpDir, platform.getObjdump(), pathResolver);
SymbolsAndDtNeeded info;
TestDataHelper.overrideBuckconfig(workspace, ImmutableMap.of("ndk", ImmutableMap.of("cpu_abis", "x86"), "repositories", ImmutableMap.of("secondary", secondary.getPath(".").normalize().toString())));
workspace.replaceFileContents(workspace.getPath("apps/sample/BUCK").normalize().toString(), "#'secondary//merge:G'", "'secondary//merge:G'");
Path apkPath = workspace.buildAndReturnOutput("//apps/sample:app_with_merged_cross_cell_libs");
ZipInspector zipInspector = new ZipInspector(apkPath);
zipInspector.assertFileDoesNotExist("lib/x86/lib1a.so");
zipInspector.assertFileDoesNotExist("lib/x86/lib1b.so");
zipInspector.assertFileDoesNotExist("lib/x86/lib1g.so");
zipInspector.assertFileDoesNotExist("lib/x86/lib1h.so");
info = syms.getSymbolsAndDtNeeded(apkPath, "lib/x86/lib1.so");
assertThat(info.symbols.global, Matchers.hasItem("A"));
assertThat(info.symbols.global, Matchers.hasItem("B"));
assertThat(info.symbols.global, Matchers.hasItem("G"));
assertThat(info.symbols.global, Matchers.hasItem("H"));
assertThat(info.symbols.global, Matchers.hasItem("glue_1"));
assertThat(info.symbols.global, not(Matchers.hasItem("glue_2")));
assertThat(info.dtNeeded, not(Matchers.hasItem("libnative_merge_B.so")));
assertThat(info.dtNeeded, not(Matchers.hasItem("libmerge_G.so")));
assertThat(info.dtNeeded, not(Matchers.hasItem("libmerge_H.so")));
}
Aggregations