use of com.facebook.buck.testutil.TestConsole in project buck by facebook.
the class AndroidBinaryIntegrationTest method testNativeRelinker.
@Test
public void testNativeRelinker() throws IOException, InterruptedException {
NdkCxxPlatform platform = AndroidNdkHelper.getNdkCxxPlatform(workspace, filesystem);
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
Path tmpDir = tmpFolder.newFolder("xdso");
SymbolGetter syms = new SymbolGetter(new DefaultProcessExecutor(new TestConsole()), tmpDir, platform.getObjdump(), pathResolver);
Symbols sym;
Path apkPath = workspace.buildAndReturnOutput("//apps/sample:app_xdso_dce");
sym = syms.getSymbols(apkPath, "lib/x86/libnative_xdsodce_top.so");
assertTrue(sym.global.contains("_Z10JNI_OnLoadii"));
assertTrue(sym.undefined.contains("_Z10midFromTopi"));
assertTrue(sym.undefined.contains("_Z10botFromTopi"));
assertFalse(sym.all.contains("_Z6unusedi"));
sym = syms.getSymbols(apkPath, "lib/x86/libnative_xdsodce_mid.so");
assertTrue(sym.global.contains("_Z10midFromTopi"));
assertTrue(sym.undefined.contains("_Z10botFromMidi"));
assertFalse(sym.all.contains("_Z6unusedi"));
sym = syms.getSymbols(apkPath, "lib/x86/libnative_xdsodce_bot.so");
assertTrue(sym.global.contains("_Z10botFromTopi"));
assertTrue(sym.global.contains("_Z10botFromMidi"));
assertFalse(sym.all.contains("_Z6unusedi"));
// Run some verification on the same apk with native_relinker disabled.
apkPath = workspace.buildAndReturnOutput("//apps/sample:app_no_xdso_dce");
sym = syms.getSymbols(apkPath, "lib/x86/libnative_xdsodce_top.so");
assertTrue(sym.all.contains("_Z6unusedi"));
sym = syms.getSymbols(apkPath, "lib/x86/libnative_xdsodce_mid.so");
assertTrue(sym.all.contains("_Z6unusedi"));
sym = syms.getSymbols(apkPath, "lib/x86/libnative_xdsodce_bot.so");
assertTrue(sym.all.contains("_Z6unusedi"));
}
use of com.facebook.buck.testutil.TestConsole in project buck by facebook.
the class DxStepTest method createExecutionContext.
private ExecutionContext createExecutionContext(int verbosityLevel) throws IOException {
Verbosity verbosity = VerbosityParser.getVerbosityForLevel(verbosityLevel);
TestConsole console = new TestConsole(verbosity);
return TestExecutionContext.newBuilder().setConsole(console).setAndroidPlatformTargetSupplier(Suppliers.ofInstance(androidPlatformTarget)).build();
}
use of com.facebook.buck.testutil.TestConsole in project buck by facebook.
the class CodeSignIdentityStoreTest method testCodeSignIdentitiesCommandOverride.
@Test
public void testCodeSignIdentitiesCommandOverride() throws Exception {
ProcessExecutor executor = new DefaultProcessExecutor(new TestConsole());
Path testdataDir = TestDataHelper.getTestDataDirectory(this).resolve("code_sign_identity_store");
CodeSignIdentityStore store = CodeSignIdentityStore.fromSystem(executor, ImmutableList.of(testdataDir.resolve("fake_identities.sh").toString()));
ImmutableList<CodeSignIdentity> expected = ImmutableList.of(CodeSignIdentity.builder().setFingerprint(CodeSignIdentity.toFingerprint("0000000000000000000000000000000000000000")).setSubjectCommonName("iPhone Developer: Fake").build());
assertThat(store.getIdentities(), is(equalTo(expected)));
}
use of com.facebook.buck.testutil.TestConsole in project buck by facebook.
the class XctoolRunTestsStepTest method xctoolCommandWithTestSelectorFailsIfListTestsOnlyFails.
@Test
public void xctoolCommandWithTestSelectorFailsIfListTestsOnlyFails() throws Exception {
FakeProjectFilesystem projectFilesystem = new FakeProjectFilesystem();
XctoolRunTestsStep step = new XctoolRunTestsStep(projectFilesystem, Paths.get("/path/to/xctool"), ImmutableMap.of(), Optional.empty(), "iphonesimulator", Optional.empty(), ImmutableSet.of(Paths.get("/path/to/FooTest.xctest"), Paths.get("/path/to/BarTest.xctest")), ImmutableMap.of(), Paths.get("/path/to/output.json"), Optional.empty(), Suppliers.ofInstance(Optional.of(Paths.get("/path/to/developer/dir"))), TestSelectorList.builder().addRawSelectors("#.*Magic.*").build(), false, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty());
ProcessExecutorParams xctoolListOnlyParams = ProcessExecutorParams.builder().setCommand(ImmutableList.of("/path/to/xctool", "-reporter", "json-stream", "-sdk", "iphonesimulator", "run-tests", "-logicTest", "/path/to/FooTest.xctest", "-logicTest", "/path/to/BarTest.xctest", "-listTestsOnly")).setEnvironment(ImmutableMap.of("DEVELOPER_DIR", "/path/to/developer/dir")).setDirectory(projectFilesystem.getRootPath().toAbsolutePath()).setRedirectOutput(ProcessBuilder.Redirect.PIPE).build();
FakeProcess fakeXctoolListTestsFailureProcess = new FakeProcess(42, "", "Chopper Dave, we have Uh-Oh");
FakeProcessExecutor processExecutor = new FakeProcessExecutor(ImmutableMap.of(xctoolListOnlyParams, fakeXctoolListTestsFailureProcess));
TestConsole testConsole = new TestConsole();
ExecutionContext executionContext = TestExecutionContext.newBuilder().setProcessExecutor(processExecutor).setEnvironment(ImmutableMap.of()).setConsole(testConsole).build();
assertThat(step.execute(executionContext).getExitCode(), equalTo(42));
assertThat(testConsole.getTextWrittenToStdErr(), allOf(containsString("xctool failed with exit code 42: Chopper Dave, we have Uh-Oh"), containsString("Failed to query tests with xctool")));
}
use of com.facebook.buck.testutil.TestConsole in project buck by facebook.
the class ProvisioningProfileCopyStepTest method testDoesNotFailInDryRunMode.
@Test
public void testDoesNotFailInDryRunMode() throws Exception {
assumeTrue(Platform.detect() == Platform.MACOS);
Path emptyDir = TestDataHelper.getTestDataDirectory(this).resolve("provisioning_profiles_empty");
ProvisioningProfileCopyStep step = new ProvisioningProfileCopyStep(projectFilesystem, testdataDir.resolve("Info.plist"), ApplePlatform.IPHONEOS, Optional.empty(), Optional.empty(), ProvisioningProfileStore.fromSearchPath(new DefaultProcessExecutor(new TestConsole()), ProvisioningProfileStore.DEFAULT_READ_COMMAND, emptyDir), outputFile, xcentFile, codeSignIdentityStore, Optional.of(dryRunResultFile));
Future<Optional<ProvisioningProfileMetadata>> profileFuture = step.getSelectedProvisioningProfileFuture();
step.execute(executionContext);
assertTrue(profileFuture.isDone());
assertNotNull(profileFuture.get());
assertFalse(profileFuture.get().isPresent());
Optional<String> resultContents = projectFilesystem.readFileIfItExists(dryRunResultFile);
assertTrue(resultContents.isPresent());
NSDictionary resultPlist = (NSDictionary) PropertyListParser.parse(resultContents.get().getBytes(Charsets.UTF_8));
assertEquals(new NSString("com.example.TestApp"), resultPlist.get("bundle-id"));
}
Aggregations