From a5c1d077fbb5b53a755a2fd068026a1e0ed50210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mamy=20Andr=C3=A9-Ratsimbazafy?= Date: Sun, 3 Jan 2021 21:50:22 +0100 Subject: [PATCH] deal with DLL mess for OpenSSL test --- tests/t_hash_sha256_vs_openssl.nim | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/t_hash_sha256_vs_openssl.nim b/tests/t_hash_sha256_vs_openssl.nim index 2c48bc4..339b683 100644 --- a/tests/t_hash_sha256_vs_openssl.nim +++ b/tests/t_hash_sha256_vs_openssl.nim @@ -6,16 +6,42 @@ import # Third-party stew/byteutils +# Deal with platform mess +# -------------------------------------------------------------------- +when defined(windows): + when sizeof(int) == 8: + const DLLSSLName* = "(libssl-1_1-x64|ssleay64|libssl64).dll" + else: + const DLLSSLName* = "(libssl-1_1|ssleay32|libssl32).dll" +else: + when defined(macosx): + const versions = "(.1.1|.38|.39|.41|.43|.44|.45|.46|.47|.48|.10|.1.0.2|.1.0.1|.1.0.0|.0.9.9|.0.9.8|)" + else: + const versions = "(.1.1|.1.0.2|.1.0.1|.1.0.0|.0.9.9|.0.9.8|.48|.47|.46|.45|.44|.43|.41|.39|.38|.10|)" + + when defined(macosx): + const DLLSSLName* = "libssl" & versions & ".dylib" + elif defined(genode): + const DLLSSLName* = "libssl.lib.so" + else: + const DLLSSLName* = "libssl.so" & versions + +# OpenSSL wrapper +# -------------------------------------------------------------------- + proc SHA256[T: byte|char]( msg: openarray[T], digest: ptr array[32, byte] = nil - ): ptr array[32, byte] {.cdecl, dynlib: "libssl.so", importc.} + ): ptr array[32, byte] {.cdecl, dynlib: DLLSSLName, importc.} proc SHA256_OpenSSL[T: byte|char]( digest: var array[32, byte], s: openarray[T]) = discard SHA256(s, digest.addr) +# Test +# -------------------------------------------------------------------- + echo "\n------------------------------------------------------\n" const SmallSizeIters = 128 const LargeSizeIters = 10