Fix device transfer test dependent on native library.

This commit is contained in:
Cody Henthorne
2021-06-29 15:02:44 -04:00
committed by Alex Hart
parent c54c6018b2
commit 90a27d2227
7 changed files with 23 additions and 9 deletions

View File

@@ -11,8 +11,8 @@ import java.util.Arrays;
import java.util.Collection;
import static org.junit.Assert.assertEquals;
import static org.thoughtcrime.securesms.testutil.LibSignalLibraryUtil.assumeLibSignalSupportedOnOS;
import static org.thoughtcrime.securesms.testutil.ZkGroupLibraryUtil.assumeZkGroupSupportedOnOS;
import static org.whispersystems.signalservice.test.LibSignalLibraryUtil.assumeLibSignalSupportedOnOS;
@RunWith(Parameterized.class)
public final class GroupId_v1_v2_migration_derivation_Test {

View File

@@ -12,8 +12,7 @@ import org.whispersystems.signalservice.internal.push.SignalServiceProtos;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.thoughtcrime.securesms.testutil.LibSignalLibraryUtil.assumeLibSignalSupportedOnOS;
import static org.whispersystems.signalservice.test.LibSignalLibraryUtil.assumeLibSignalSupportedOnOS;
public final class MobileCoinPublicAddressProfileUtilTest {

View File

@@ -1,42 +0,0 @@
package org.thoughtcrime.securesms.testutil;
import org.signal.client.internal.Native;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeNoException;
public final class LibSignalLibraryUtil {
/**
* Attempts to initialize the LibSignal Native class, which will load the native binaries.
* <p>
* If that fails to link, then on Unix, it will fail as we rely on that for CI.
* <p>
* If that fails to link, and it's not Unix, it will skip the test via assumption violation.
* <p>
* If using inside a PowerMocked test, the assumption violation can be fatal, use:
* {@code @PowerMockRunnerDelegate(JUnit4.class)}
*/
public static void assumeLibSignalSupportedOnOS() {
try {
Class.forName(Native.class.getName());
} catch (ClassNotFoundException e) {
fail();
} catch (NoClassDefFoundError | UnsatisfiedLinkError e) {
String osName = System.getProperty("os.name");
if (isUnix(osName)) {
fail("Not able to link native LibSignal on a key OS: " + osName);
} else {
assumeNoException("Not able to link native LibSignal on this operating system: " + osName, e);
}
}
}
private static boolean isUnix(String osName) {
assertNotNull(osName);
osName = osName.toLowerCase();
return osName.contains("nix") || osName.contains("nux") || osName.contains("aix");
}
}