mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-26 19:56:02 +01:00
Skip native LibSignal tests on unsupported and non-unix OS.
This commit is contained in:
@@ -16,8 +16,8 @@ import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.thoughtcrime.securesms.groups.ZkGroupLibraryUtil.assumeZkGroupSupportedOnOS;
|
||||
import static org.thoughtcrime.securesms.testutil.SecureRandomTestUtil.mockRandom;
|
||||
import static org.thoughtcrime.securesms.testutil.ZkGroupLibraryUtil.assumeZkGroupSupportedOnOS;
|
||||
|
||||
public final class GroupIdTest {
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.thoughtcrime.securesms.groups;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
@@ -10,11 +11,18 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.thoughtcrime.securesms.groups.ZkGroupLibraryUtil.assumeZkGroupSupportedOnOS;
|
||||
import static org.thoughtcrime.securesms.testutil.LibSignalLibraryUtil.assumeLibSignalSupportedOnOS;
|
||||
import static org.thoughtcrime.securesms.testutil.ZkGroupLibraryUtil.assumeZkGroupSupportedOnOS;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public final class GroupId_v1_v2_migration_derivation_Test {
|
||||
|
||||
@Before
|
||||
public void ensureNativeSupported() {
|
||||
assumeLibSignalSupportedOnOS();
|
||||
assumeZkGroupSupportedOnOS();
|
||||
}
|
||||
|
||||
@Parameterized.Parameter(0)
|
||||
public String inputV1GroupId;
|
||||
|
||||
@@ -44,8 +52,6 @@ public final class GroupId_v1_v2_migration_derivation_Test {
|
||||
|
||||
@Test
|
||||
public void deriveMigrationV2GroupId() {
|
||||
assumeZkGroupSupportedOnOS();
|
||||
|
||||
GroupId.V1 groupV1Id = GroupId.v1orThrow(Hex.fromStringOrThrow(inputV1GroupId));
|
||||
GroupId.V2 migratedV2GroupId = groupV1Id.deriveV2MigrationGroupId();
|
||||
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
package org.thoughtcrime.securesms.groups;
|
||||
|
||||
import org.signal.zkgroup.internal.Native;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.Assume.assumeNoException;
|
||||
|
||||
class ZkGroupLibraryUtil {
|
||||
|
||||
/**
|
||||
* Attempts to initialize the ZkGroup 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.
|
||||
*/
|
||||
static void assumeZkGroupSupportedOnOS() {
|
||||
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 ZkGroup on a key OS: " + osName);
|
||||
} else {
|
||||
assumeNoException("Not able to link native ZkGroup 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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user