diff options
| author | J08nY | 2024-03-27 15:55:17 +0100 |
|---|---|---|
| committer | J08nY | 2024-03-27 15:55:17 +0100 |
| commit | 05677a74bdb26001183d663fe6c1b57b853967bc (patch) | |
| tree | 0b1629ece758f285c98403f2cefd8f1f56f553fe /standalone | |
| parent | 09049c9cc9990b0d26765dcc36a415f1ed9f4552 (diff) | |
| download | ECTester-05677a74bdb26001183d663fe6c1b57b853967bc.tar.gz ECTester-05677a74bdb26001183d663fe6c1b57b853967bc.tar.zst ECTester-05677a74bdb26001183d663fe6c1b57b853967bc.zip | |
Fix wilfCrypt use in CI and tests.
Diffstat (limited to 'standalone')
3 files changed, 25 insertions, 7 deletions
diff --git a/standalone/build.gradle.kts b/standalone/build.gradle.kts index 1c9c485..8fe4bff 100644 --- a/standalone/build.gradle.kts +++ b/standalone/build.gradle.kts @@ -11,7 +11,12 @@ repositories { } dependencies { - implementation(files("$rootDir/ext/wolfcrypt-jni.jar")) + // Fallback to bundled wolfcrypt-jni if the submodule one is not built. + if (file("$rootDir/ext/wolfcrypt-jni/lib/wolfcrypt-jni.jar").exists()) { + implementation(files("$rootDir/ext/wolfcrypt-jni/lib/wolfcrypt-jni.jar")) + } else { + implementation(files("$rootDir/ext/wolfcrypt-jni.jar")) + } implementation(project(":common")) testImplementation(platform("org.junit:junit-bom:5.10.2")) @@ -32,10 +37,12 @@ application { tasks.named<Test>("test") { useJUnitPlatform() -} - -tasks.test { - finalizedBy(tasks.jacocoTestReport) // report is always generated after tests run + // Report is always generated after tests run + finalizedBy(tasks.jacocoTestReport) + // Add wolfcrypt JNI lib path to LD_LIBRARY_PATH (as our native library loading does not handle it) + environment( + "LD_LIBRARY_PATH", "$rootDir/ext/wolfcrypt-jni/lib/:" + System.getenv("LD_LIBRARY_PATH") + ) } tasks.jacocoTestReport { diff --git a/standalone/src/main/java/cz/crcs/ectester/standalone/libs/WolfCryptLib.java b/standalone/src/main/java/cz/crcs/ectester/standalone/libs/WolfCryptLib.java index b58eb91..ff592d1 100644 --- a/standalone/src/main/java/cz/crcs/ectester/standalone/libs/WolfCryptLib.java +++ b/standalone/src/main/java/cz/crcs/ectester/standalone/libs/WolfCryptLib.java @@ -12,6 +12,16 @@ public class WolfCryptLib extends ProviderECLibrary { } @Override + public boolean initialize() { + try { + System.loadLibrary("wolfcryptjni"); + return super.initialize(); + } catch (UnsatisfiedLinkError ule) { + return false; + } + } + + @Override public Set<String> getCurves() { return new HashSet<>(); } diff --git a/standalone/src/test/java/cz/crcs/ectester/standalone/AppTests.java b/standalone/src/test/java/cz/crcs/ectester/standalone/AppTests.java index c095ea5..6714e56 100644 --- a/standalone/src/test/java/cz/crcs/ectester/standalone/AppTests.java +++ b/standalone/src/test/java/cz/crcs/ectester/standalone/AppTests.java @@ -53,8 +53,9 @@ public class AppTests { @SuppressWarnings("JUnitMalformedDeclaration") @ParameterizedTest - // TODO: Add "wolfCrypt" to the list - @ValueSource(strings = {"Bouncy", "Sun", "libtomcrypt", "Botan", "Crypto++", "OpenSSL 3", "BoringSSL", "libgcrypt", "mbedTLS", "2021" /* IPPCP */, "Nettle", "LibreSSL"}) + // TODO: @ExpectedToFail does not work with parameterized tests: https://github.com/junit-pioneer/junit-pioneer/issues/762 + @ExpectedToFail + @ValueSource(strings = {"Bouncy", "Sun", "libtomcrypt", "Botan", "Crypto++", "OpenSSL 3", "BoringSSL", "libgcrypt", "mbedTLS", "2021" /* IPPCP */, "Nettle", "LibreSSL", "wolfCrypt"}) @StdIo() public void defaultSuite(String libName, StdOut out, StdErr err) { String[] args = new String[]{"test", "default", libName}; |
