Initialize the register dumping machinery while testing assembler code.
[catacomb] / symm / chacha.c
index 90a4c67..8cc16b8 100644 (file)
@@ -849,9 +849,14 @@ CHACHA_VARS(DEFXGRAND)
 #include <stdio.h>
 #include <string.h>
 
+#include <mLib/macros.h>
 #include <mLib/quis.h>
 #include <mLib/testrig.h>
 
+#ifdef ENABLE_ASM_DEBUG
+#  include "regdump.h"
+#endif
+
 #define DEFVCORE(r)                                                    \
   static int v_core_##r(dstr *v)                                       \
   {                                                                    \
@@ -870,7 +875,7 @@ CHACHA_VARS(DEFXGRAND)
     }                                                                  \
     for (i = 0; i < CHACHA_OUTSZ/4; i++) STORE32_L(d.buf + 4*i, a[i]); \
                                                                        \
-    if (d.len != v[2].len || memcmp(d.buf, v[2].buf, v[2].len) != 0) { \
+    if (d.len != v[2].len || MEMCMP(d.buf, !=, v[2].buf, v[2].len)) {  \
       ok = 0;                                                          \
       printf("\nfail core:"                                            \
             "\n\titerations = %d"                                      \
@@ -940,7 +945,7 @@ CHACHA_VARS(DEFVCORE)
       }                                                                        \
       if (sz) BASE##_ENCRYPT(r, &ctx, p, q, sz);                       \
                                                                        \
-      if (d.len != v[5].len || memcmp(d.buf, v[5].buf, v[5].len) != 0) { \
+      if (d.len != v[5].len || MEMCMP(d.buf, !=, v[5].buf, v[5].len)) {        \
        ok = 0;                                                         \
        printf("\nfail encrypt:"                                        \
               "\n\tstep           = %lu"                               \
@@ -986,6 +991,9 @@ CHACHA_VARS(DEFXTAB)
 
 int main(int argc, char *argv[])
 {
+#ifdef ENABLE_ASM_DEBUG
+  regdump_init();
+#endif
   test_run(argc, argv, defs, SRCDIR"/t/chacha");
   return (0);
 }