hwfeatures: add 'all' for disabling all hardware features
authorJussi Kivilinna <jussi.kivilinna@iki.fi>
Sat, 10 Dec 2016 10:29:12 +0000 (12:29 +0200)
committerJussi Kivilinna <jussi.kivilinna@iki.fi>
Sat, 10 Dec 2016 10:29:12 +0000 (12:29 +0200)
* .gitignore: Add 'tests/basic-disable-all-hwf'.
* configure.ac: Ditto.
* tests/Makefile.am: Ditto.
* src/hwfeatures.c (_gcry_disable_hw_feature): Match 'all' for
masking all HW features off.
(parse_hwf_deny_file): Use '_gcry_disable_hw_feature' for matching.
* tests/basic-disable-all-hwf.in: New.
--

Also add new test to run 'basic' with all HWF disable. With current
assembly implementations and build servers using new CPUs, generic
implementations are not being tested enough anymore and compiler
problems might end up unnoticed.

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
.gitignore
configure.ac
src/hwfeatures.c
tests/Makefile.am
tests/basic-disable-all-hwf.in [new file with mode: 0644]

index 3cd83a2..5d481aa 100644 (file)
@@ -73,6 +73,7 @@ tests/ac-data
 tests/ac-schemes
 tests/aeswrap
 tests/basic
+tests/basic-disable-all-hwf
 tests/bench-slope
 tests/benchmark
 tests/curves
index 17ff407..91562a9 100644 (file)
@@ -2555,6 +2555,7 @@ src/versioninfo.rc
 tests/Makefile
 ])
 AC_CONFIG_FILES([tests/hashtest-256g], [chmod +x tests/hashtest-256g])
+AC_CONFIG_FILES([tests/basic-disable-all-hwf], [chmod +x tests/basic-disable-all-hwf])
 AC_OUTPUT
 
 
index 07221e8..99aba34 100644 (file)
@@ -83,6 +83,12 @@ _gcry_disable_hw_feature (const char *name)
 {
   int i;
 
+  if (!strcmp(name, "all"))
+    {
+      disabled_hw_features = ~0;
+      return 0;
+    }
+
   for (i=0; i < DIM (hwflist); i++)
     if (!strcmp (hwflist[i].desc, name))
       {
@@ -159,15 +165,7 @@ parse_hwf_deny_file (void)
       if (!*p || *p == '#')
         continue;
 
-      for (i=0; i < DIM (hwflist); i++)
-        {
-          if (!strcmp (hwflist[i].desc, p))
-            {
-              disabled_hw_features |= hwflist[i].flag;
-              break;
-            }
-        }
-      if (i == DIM (hwflist))
+      if (_gcry_disable_hw_feature (p) == GPG_ERR_INV_NAME)
         {
 #ifdef HAVE_SYSLOG
           syslog (LOG_USER|LOG_WARNING,
index 374e72e..db51cbd 100644 (file)
@@ -26,7 +26,7 @@ tests_bin = \
 
 tests_bin_last = benchmark bench-slope
 
-tests_sh =
+tests_sh = basic-disable-all-hwf
 
 tests_sh_last = hashtest-256g
 
@@ -58,7 +58,8 @@ noinst_HEADERS = t-common.h
 EXTRA_DIST = README rsa-16k.key cavs_tests.sh cavs_driver.pl \
             pkcs1v2-oaep.h pkcs1v2-pss.h pkcs1v2-v15c.h pkcs1v2-v15s.h \
             t-ed25519.inp stopwatch.h hashtest-256g.in \
-            sha3-224.h sha3-256.h sha3-384.h sha3-512.h
+            sha3-224.h sha3-256.h sha3-384.h sha3-512.h \
+            basic-disable-all-hwf.in
 
 LDADD = $(standard_ldadd) $(GPG_ERROR_LIBS)
 t_lock_LDADD = $(standard_ldadd) $(GPG_ERROR_MT_LIBS)
diff --git a/tests/basic-disable-all-hwf.in b/tests/basic-disable-all-hwf.in
new file mode 100644 (file)
index 0000000..1f0a4de
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+echo "      now running 'basic' test with all hardware features disabled."
+exec ./basic@EXEEXT@ --disable-hwf all