Build the 6 per-opcode bitops tests as a single executable,
test_mips64r6_bitops.c, to reduce the number of test binaries.
Each opcode reports one TAP line.

Prefix the per-case output of test_utils_64.h with '# ' so TAP
parsers treat it as a comment.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
---
 tests/tcg/mips/include/test_utils_64.h  | 24 +++++-----
 tests/tcg/mips64/test_mips64r6_bitops.c | 60 +++++++++++++++++++++++++
 tests/tcg/mips64/meson.build            |  7 +--
 3 files changed, 73 insertions(+), 18 deletions(-)
 create mode 100644 tests/tcg/mips64/test_mips64r6_bitops.c

diff --git a/tests/tcg/mips/include/test_utils_64.h 
b/tests/tcg/mips/include/test_utils_64.h
index b785c26d0934..7767ee1a32a2 100644
--- a/tests/tcg/mips/include/test_utils_64.h
+++ b/tests/tcg/mips/include/test_utils_64.h
@@ -28,6 +28,8 @@
 #include <inttypes.h>
 #include <string.h>
 
+#include "../../include/tap.h"
+
 #define PRINT_RESULTS 0
 
 
@@ -41,25 +43,21 @@ static inline int32_t check_results_64(const char 
*isa_ase_name,
 {
 #if PRINT_RESULTS
     uint32_t ii;
-    printf("\n");
     for (ii = 0; ii < test_count; ii++) {
         uint64_t a;
         memcpy(&a, (b64_result + ii), 8);
         if (ii % 8 != 0) {
-            printf("        0x%016llxULL,\n", a);
+            TAP_INFO("        0x%016llxULL,", a);
         } else {
-            printf("        0x%016llxULL,                    /* %3d  */\n",
-                   a, ii);
+            TAP_INFO("        0x%016llxULL,                    /* %3d  */",
+                     a, ii);
         }
     }
-    printf("\n");
 #endif
     uint32_t i;
     uint32_t pass_count = 0;
     uint32_t fail_count = 0;
 
-    printf("| %-10s \t| %-20s\t| %-16s \t|",
-           isa_ase_name, group_name, instruction_name);
     for (i = 0; i < test_count; i++) {
         if (b64_result[i] == b64_expect[i]) {
             pass_count++;
@@ -68,8 +66,10 @@ static inline int32_t check_results_64(const char 
*isa_ase_name,
         }
     }
 
-    printf(" PASS: %3d \t| FAIL: %3d \t| elapsed time: %5.2f ms \t|\n",
-           pass_count, fail_count, elapsed_time);
+    TAP_INFO("%-10s \t| %-20s\t| %-16s \t| PASS: %3d \t| FAIL: %3d \t| "
+             "elapsed time: %5.2f ms \t|",
+             isa_ase_name, group_name, instruction_name,
+             pass_count, fail_count, elapsed_time);
 
     if (fail_count > 0) {
         return -1;
@@ -92,10 +92,10 @@ static inline bool 
check_binary_op_64_with_input(binary_op_64 op, const char *op
             uint64_t expected = expect[i * cols + j];
             uint64_t res = 0;
             op(&input1, &input2, &res);
-            printf("assert(0x%"PRIx64" == %s(0x%"PRIx64", 0x%"PRIx64"));\n",
-                   res, op_str, input1, input2);
+            TAP_INFO("assert(0x%"PRIx64" == %s(0x%"PRIx64", 0x%"PRIx64"));",
+                     res, op_str, input1, input2);
             if (expected != res) {
-                printf("// error: expected 0x%"PRIx64"\n", expected);
+                TAP_INFO("error: expected 0x%"PRIx64, expected);
                 ret = false;
             }
         }
diff --git a/tests/tcg/mips64/test_mips64r6_bitops.c 
b/tests/tcg/mips64/test_mips64r6_bitops.c
new file mode 100644
index 000000000000..7b174afd6901
--- /dev/null
+++ b/tests/tcg/mips64/test_mips64r6_bitops.c
@@ -0,0 +1,60 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/* MIPS64R6 tests: bit count and bit swap */
+
+#include "../include/tap.h"
+
+#define main test_mips64r6_bitswap
+#include "test_mips64r6_bitswap.c"
+#undef main
+#undef TEST_COUNT_TOTAL
+
+#define main test_mips64r6_dbitswap
+#include "test_mips64r6_dbitswap.c"
+#undef main
+#undef TEST_COUNT_TOTAL
+
+#define main test_mips64r6_clo
+#include "test_mips64r6_clo.c"
+#undef main
+#undef TEST_COUNT_TOTAL
+
+#define main test_mips64r6_clz
+#include "test_mips64r6_clz.c"
+#undef main
+#undef TEST_COUNT_TOTAL
+
+#define main test_mips64r6_dclo
+#include "test_mips64r6_dclo.c"
+#undef main
+#undef TEST_COUNT_TOTAL
+
+#define main test_mips64r6_dclz
+#include "test_mips64r6_dclz.c"
+#undef main
+#undef TEST_COUNT_TOTAL
+
+static const struct {
+    const char *name;
+    int32_t (*fn)(void);
+} r6_tests[] = {
+    { "bitswap", test_mips64r6_bitswap },
+    { "dbitswap", test_mips64r6_dbitswap },
+    { "clo", test_mips64r6_clo },
+    { "clz", test_mips64r6_clz },
+    { "dclo", test_mips64r6_dclo },
+    { "dclz", test_mips64r6_dclz },
+};
+
+int main(void)
+{
+    unsigned count = sizeof(r6_tests) / sizeof(r6_tests[0]);
+    unsigned i;
+
+    TAP_START();
+    for (i = 0; i < count; i++) {
+        tap_report(!r6_tests[i].fn(), "MIPS64R6 bit count and bit swap %s",
+                   r6_tests[i].name);
+    }
+
+    return tap_done();
+}
diff --git a/tests/tcg/mips64/meson.build b/tests/tcg/mips64/meson.build
index 3b895a169758..cb9e09ed3c29 100644
--- a/tests/tcg/mips64/meson.build
+++ b/tests/tcg/mips64/meson.build
@@ -28,10 +28,8 @@ endif
 tests = []
 
 tests_mips64r6 = [
+  '../mips64/test_mips64r6_bitops.c',
   '../mips64/test_mips64r6_and.c',
-  '../mips64/test_mips64r6_bitswap.c',
-  '../mips64/test_mips64r6_clo.c',
-  '../mips64/test_mips64r6_clz.c',
   '../mips64/test_mips64r6_crc32b.c',
   '../mips64/test_mips64r6_crc32cb.c',
   '../mips64/test_mips64r6_crc32cd.c',
@@ -40,9 +38,6 @@ tests_mips64r6 = [
   '../mips64/test_mips64r6_crc32d.c',
   '../mips64/test_mips64r6_crc32h.c',
   '../mips64/test_mips64r6_crc32w.c',
-  '../mips64/test_mips64r6_dbitswap.c',
-  '../mips64/test_mips64r6_dclo.c',
-  '../mips64/test_mips64r6_dclz.c',
   '../mips64/test_mips64r6_dmuh.c',
   '../mips64/test_mips64r6_dmuhu.c',
   '../mips64/test_mips64r6_dmul.c',
-- 
2.55.0


Reply via email to