]> wagner.pp.ru Git - openssl-gost/engine.git/commitdiff
tests: Load just built engine from the output directory 120/head
authorVitaly Chikunov <vt@altlinux.org>
Fri, 15 Feb 2019 19:18:08 +0000 (22:18 +0300)
committerVitaly Chikunov <vt@altlinux.org>
Fri, 15 Feb 2019 20:21:56 +0000 (23:21 +0300)
Define ENGINE_DIR for all binary tests. Instead of auto-loading engine
using `example.conf' load it directly from the OUTPUT_DIRECTORY for
curves tests.

CMakeLists.txt
test_curves.c
test_params.c
test_sign.c

index 198d746d32821a12eddaa3869bf1dc9392ec226d..0538af546a0a25bfc5e51341053acf02f5246600 100644 (file)
@@ -182,6 +182,18 @@ endif()
 add_executable(sign benchmark/sign.c)
 target_link_libraries(sign gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY} ${CLOCK_GETTIME_LIB})
 
+# All that may need to load just built engine will have path to it defined.
+set(BINARY_TESTS_TARGETS
+        test_curves
+        test_params
+        test_sign
+        test_context
+        test_grasshopper
+        test_keyexpimp
+        test_gost89
+        )
+set_property(TARGET ${BINARY_TESTS_TARGETS} APPEND PROPERTY COMPILE_DEFINITIONS ENGINE_DIR="${OUTPUT_DIRECTORY}")
+
 add_library(gost_core STATIC ${GOST_LIB_SOURCE_FILES})
 set_target_properties(gost_core PROPERTIES POSITION_INDEPENDENT_CODE ON)
 
index 28ccce41d2cd14367da74f3b350980cbd5000d71..973307b0fdec87727838e7c7d7b05545d0a5a9d5 100644 (file)
@@ -222,11 +222,22 @@ int main(int argc, char **argv)
 {
     int ret = 0;
 
+    setenv("OPENSSL_ENGINES", ENGINE_DIR, 0);
+    OPENSSL_add_all_algorithms_conf();
+    ERR_load_crypto_strings();
+    ENGINE *eng;
+    T(eng = ENGINE_by_id("gost"));
+    T(ENGINE_init(eng));
+    T(ENGINE_set_default(eng, ENGINE_METHOD_ALL));
+
     struct test_curve *tc;
     for (tc = test_curves; tc->nid; tc++) {
        ret |= parameter_test(tc);
     }
 
+    ENGINE_finish(eng);
+    ENGINE_free(eng);
+
     if (ret)
        printf(cDRED "= Some tests FAILED!\n" cNORM);
     else
index 3e12d5a9669bbd23e2a8da997270128f6e38e4e7..f7d4b90f8fbb3989ea9b94ce4713f9e38bfb0207 100644 (file)
@@ -1093,9 +1093,13 @@ int main(int argc, char **argv)
 {
     int ret = 0;
 
-    setenv("OPENSSL_CONF", "../example.conf", 0);
+    setenv("OPENSSL_ENGINES", ENGINE_DIR, 0);
     OPENSSL_add_all_algorithms_conf();
     ERR_load_crypto_strings();
+    ENGINE *eng;
+    T(eng = ENGINE_by_id("gost"));
+    T(ENGINE_init(eng));
+    T(ENGINE_set_default(eng, ENGINE_METHOD_ALL));
 
     struct test_param **tpp;
     for (tpp = test_params; *tpp; tpp++)
@@ -1105,5 +1109,8 @@ int main(int argc, char **argv)
     for (tc = test_certs; tc->cert; tc++)
        ret |= test_cert(tc);
 
+    ENGINE_finish(eng);
+    ENGINE_free(eng);
+
     return ret;
 }
index 4a63f420f0535c6e4d5c8b47d15d8bbacac88162..1d0058164f14bfda18fa93f0f44f0aebc7f00c45 100644 (file)
@@ -236,14 +236,21 @@ int main(int argc, char **argv)
 {
     int ret = 0;
 
-    setenv("OPENSSL_CONF", "../example.conf", 0);
+    setenv("OPENSSL_ENGINES", ENGINE_DIR, 0);
     OPENSSL_add_all_algorithms_conf();
     ERR_load_crypto_strings();
+    ENGINE *eng;
+    T(eng = ENGINE_by_id("gost"));
+    T(ENGINE_init(eng));
+    T(ENGINE_set_default(eng, ENGINE_METHOD_ALL));
 
     struct test_sign *sp;
     for (sp = test_signs; sp->name; sp++)
        ret |= test_sign(sp);
 
+    ENGINE_finish(eng);
+    ENGINE_free(eng);
+
     if (ret)
        printf(cDRED "= Some tests FAILED!\n" cNORM);
     else