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

Add test_dsp_runner.h: assert() only counts failures, and
RUN_TEST() resets DSPControl and reports each test in TAP.
Drop the unused hello-world test.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
---
 tests/tcg/mipsel/test_dsp_runner.h        |  39 ++++++++
 tests/tcg/mipsel/test_dsp_acc.c           | 112 ++++++++++++++++++++++
 tests/tcg/mipsel/test_dsp_r1_extp.c       |   1 -
 tests/tcg/mipsel/test_dsp_r1_extpdp.c     |   1 -
 tests/tcg/mipsel/test_dsp_r1_extpdpv.c    |   1 -
 tests/tcg/mipsel/test_dsp_r1_extpv.c      |   1 -
 tests/tcg/mipsel/test_dsp_r1_extr_r_w.c   |   1 -
 tests/tcg/mipsel/test_dsp_r1_extr_rs_w.c  |   1 -
 tests/tcg/mipsel/test_dsp_r1_extr_s_h.c   |   1 -
 tests/tcg/mipsel/test_dsp_r1_extr_w.c     |   1 -
 tests/tcg/mipsel/test_dsp_r1_extrv_r_w.c  |   1 -
 tests/tcg/mipsel/test_dsp_r1_extrv_rs_w.c |   1 -
 tests/tcg/mipsel/test_dsp_r1_extrv_s_h.c  |   1 -
 tests/tcg/mipsel/test_dsp_r1_extrv_w.c    |   1 -
 tests/tcg/mipsel/test_dsp_r1_main.c       |   6 --
 tests/tcg/mipsel/test_dsp_r1_mfhi.c       |   1 -
 tests/tcg/mipsel/test_dsp_r1_mflo.c       |   1 -
 tests/tcg/mipsel/test_dsp_r1_mthi.c       |   1 -
 tests/tcg/mipsel/test_dsp_r1_mthlip.c     |   1 -
 tests/tcg/mipsel/test_dsp_r1_mtlo.c       |   1 -
 tests/tcg/mipsel/test_dsp_r1_shilo.c      |   1 -
 tests/tcg/mipsel/test_dsp_r1_shilov.c     |   1 -
 tests/tcg/mipsel/meson.build              |  21 +---
 23 files changed, 152 insertions(+), 45 deletions(-)
 create mode 100644 tests/tcg/mipsel/test_dsp_runner.h
 create mode 100644 tests/tcg/mipsel/test_dsp_acc.c
 delete mode 100644 tests/tcg/mipsel/test_dsp_r1_main.c

diff --git a/tests/tcg/mipsel/test_dsp_runner.h 
b/tests/tcg/mipsel/test_dsp_runner.h
new file mode 100644
index 000000000000..4fde59e97825
--- /dev/null
+++ b/tests/tcg/mipsel/test_dsp_runner.h
@@ -0,0 +1,39 @@
+/*
+ * Helpers to run several DSP ASE tests from the same process: assert()
+ * only counts failures, and RUN_TEST() reports one status line per test,
+ * after resetting DSPControl, in TAP format. A test calling RUN_TEST() must
+ * end with DSP_TAP_PLAN().
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef TEST_DSP_RUNNER_H
+#define TEST_DSP_RUNNER_H
+
+#include <stdio.h>
+
+static int dsp_failures;
+static int dsp_tests;
+
+#undef assert
+#define assert(cond) \
+    do { \
+        if (!(cond)) { \
+            printf("# FAIL %s:%d: %s\n", __FILE__, __LINE__, #cond); \
+            dsp_failures++; \
+        } \
+    } while (0)
+
+#define RUN_TEST(fn) \
+    do { \
+        int ret_; \
+        dsp_failures = 0; \
+        __asm__ volatile("wrdsp $zero, 0x3f\n\t"); \
+        ret_ = fn(); \
+        printf("%s %d - %s\n", (ret_ || dsp_failures) ? "not ok" : "ok", \
+               ++dsp_tests, #fn); \
+        ret |= ret_ || dsp_failures; \
+    } while (0)
+
+#define DSP_TAP_PLAN() printf("1..%d\n", dsp_tests)
+
+#endif
diff --git a/tests/tcg/mipsel/test_dsp_acc.c b/tests/tcg/mipsel/test_dsp_acc.c
new file mode 100644
index 000000000000..7eebaa4ca2e3
--- /dev/null
+++ b/tests/tcg/mipsel/test_dsp_acc.c
@@ -0,0 +1,112 @@
+/*
+ * MIPS DSP ASE tests: Accumulator access and Extract instructions
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "test_dsp_runner.h"
+
+#define main test_dsp_r1_extp
+#include "test_dsp_r1_extp.c"
+#undef main
+
+#define main test_dsp_r1_extpdp
+#include "test_dsp_r1_extpdp.c"
+#undef main
+
+#define main test_dsp_r1_extpdpv
+#include "test_dsp_r1_extpdpv.c"
+#undef main
+
+#define main test_dsp_r1_extpv
+#include "test_dsp_r1_extpv.c"
+#undef main
+
+#define main test_dsp_r1_extr_r_w
+#include "test_dsp_r1_extr_r_w.c"
+#undef main
+
+#define main test_dsp_r1_extr_rs_w
+#include "test_dsp_r1_extr_rs_w.c"
+#undef main
+
+#define main test_dsp_r1_extr_s_h
+#include "test_dsp_r1_extr_s_h.c"
+#undef main
+
+#define main test_dsp_r1_extr_w
+#include "test_dsp_r1_extr_w.c"
+#undef main
+
+#define main test_dsp_r1_extrv_r_w
+#include "test_dsp_r1_extrv_r_w.c"
+#undef main
+
+#define main test_dsp_r1_extrv_rs_w
+#include "test_dsp_r1_extrv_rs_w.c"
+#undef main
+
+#define main test_dsp_r1_extrv_s_h
+#include "test_dsp_r1_extrv_s_h.c"
+#undef main
+
+#define main test_dsp_r1_extrv_w
+#include "test_dsp_r1_extrv_w.c"
+#undef main
+
+#define main test_dsp_r1_mfhi
+#include "test_dsp_r1_mfhi.c"
+#undef main
+
+#define main test_dsp_r1_mflo
+#include "test_dsp_r1_mflo.c"
+#undef main
+
+#define main test_dsp_r1_mthi
+#include "test_dsp_r1_mthi.c"
+#undef main
+
+#define main test_dsp_r1_mthlip
+#include "test_dsp_r1_mthlip.c"
+#undef main
+
+#define main test_dsp_r1_mtlo
+#include "test_dsp_r1_mtlo.c"
+#undef main
+
+#define main test_dsp_r1_shilo
+#include "test_dsp_r1_shilo.c"
+#undef main
+
+#define main test_dsp_r1_shilov
+#include "test_dsp_r1_shilov.c"
+#undef main
+
+int main(void)
+{
+    int ret = 0;
+
+    RUN_TEST(test_dsp_r1_extp);
+    RUN_TEST(test_dsp_r1_extpdp);
+    RUN_TEST(test_dsp_r1_extpdpv);
+    RUN_TEST(test_dsp_r1_extpv);
+    RUN_TEST(test_dsp_r1_extr_r_w);
+    RUN_TEST(test_dsp_r1_extr_rs_w);
+    RUN_TEST(test_dsp_r1_extr_s_h);
+    RUN_TEST(test_dsp_r1_extr_w);
+    RUN_TEST(test_dsp_r1_extrv_r_w);
+    RUN_TEST(test_dsp_r1_extrv_rs_w);
+    RUN_TEST(test_dsp_r1_extrv_s_h);
+    RUN_TEST(test_dsp_r1_extrv_w);
+    RUN_TEST(test_dsp_r1_mfhi);
+    RUN_TEST(test_dsp_r1_mflo);
+    RUN_TEST(test_dsp_r1_mthi);
+    RUN_TEST(test_dsp_r1_mthlip);
+    RUN_TEST(test_dsp_r1_mtlo);
+    RUN_TEST(test_dsp_r1_shilo);
+    RUN_TEST(test_dsp_r1_shilov);
+
+    DSP_TAP_PLAN();
+
+    return ret;
+}
diff --git a/tests/tcg/mipsel/test_dsp_r1_extp.c 
b/tests/tcg/mipsel/test_dsp_r1_extp.c
index b18bdb34c872..5f9e81f51e97 100644
--- a/tests/tcg/mipsel/test_dsp_r1_extp.c
+++ b/tests/tcg/mipsel/test_dsp_r1_extp.c
@@ -1,5 +1,4 @@
 #include<stdio.h>
-#include<assert.h>
 
 int main()
 {
diff --git a/tests/tcg/mipsel/test_dsp_r1_extpdp.c 
b/tests/tcg/mipsel/test_dsp_r1_extpdp.c
index 79ee16e8b87c..6dec2bb31617 100644
--- a/tests/tcg/mipsel/test_dsp_r1_extpdp.c
+++ b/tests/tcg/mipsel/test_dsp_r1_extpdp.c
@@ -1,5 +1,4 @@
 #include<stdio.h>
-#include<assert.h>
 
 int main()
 {
diff --git a/tests/tcg/mipsel/test_dsp_r1_extpdpv.c 
b/tests/tcg/mipsel/test_dsp_r1_extpdpv.c
index f5774eed3cae..80c5a7fa3ee8 100644
--- a/tests/tcg/mipsel/test_dsp_r1_extpdpv.c
+++ b/tests/tcg/mipsel/test_dsp_r1_extpdpv.c
@@ -1,5 +1,4 @@
 #include<stdio.h>
-#include<assert.h>
 
 int main()
 {
diff --git a/tests/tcg/mipsel/test_dsp_r1_extpv.c 
b/tests/tcg/mipsel/test_dsp_r1_extpv.c
index 401b94afadfc..d575750b7ffd 100644
--- a/tests/tcg/mipsel/test_dsp_r1_extpv.c
+++ b/tests/tcg/mipsel/test_dsp_r1_extpv.c
@@ -1,5 +1,4 @@
 #include<stdio.h>
-#include<assert.h>
 
 int main()
 {
diff --git a/tests/tcg/mipsel/test_dsp_r1_extr_r_w.c 
b/tests/tcg/mipsel/test_dsp_r1_extr_r_w.c
index 489c1931b475..d3244b730297 100644
--- a/tests/tcg/mipsel/test_dsp_r1_extr_r_w.c
+++ b/tests/tcg/mipsel/test_dsp_r1_extr_r_w.c
@@ -1,5 +1,4 @@
 #include<stdio.h>
-#include<assert.h>
 
 int main()
 {
diff --git a/tests/tcg/mipsel/test_dsp_r1_extr_rs_w.c 
b/tests/tcg/mipsel/test_dsp_r1_extr_rs_w.c
index f9d2ed646fa3..6e899ccd4c4b 100644
--- a/tests/tcg/mipsel/test_dsp_r1_extr_rs_w.c
+++ b/tests/tcg/mipsel/test_dsp_r1_extr_rs_w.c
@@ -1,5 +1,4 @@
 #include<stdio.h>
-#include<assert.h>
 
 int main()
 {
diff --git a/tests/tcg/mipsel/test_dsp_r1_extr_s_h.c 
b/tests/tcg/mipsel/test_dsp_r1_extr_s_h.c
index 9bc2a63cc2d1..aa36b4e9f31c 100644
--- a/tests/tcg/mipsel/test_dsp_r1_extr_s_h.c
+++ b/tests/tcg/mipsel/test_dsp_r1_extr_s_h.c
@@ -1,5 +1,4 @@
 #include<stdio.h>
-#include<assert.h>
 
 int main()
 {
diff --git a/tests/tcg/mipsel/test_dsp_r1_extr_w.c 
b/tests/tcg/mipsel/test_dsp_r1_extr_w.c
index cf926146d54c..f82e38e34fb7 100644
--- a/tests/tcg/mipsel/test_dsp_r1_extr_w.c
+++ b/tests/tcg/mipsel/test_dsp_r1_extr_w.c
@@ -1,5 +1,4 @@
 #include<stdio.h>
-#include<assert.h>
 
 int main()
 {
diff --git a/tests/tcg/mipsel/test_dsp_r1_extrv_r_w.c 
b/tests/tcg/mipsel/test_dsp_r1_extrv_r_w.c
index 2403b3afe40f..6af471076904 100644
--- a/tests/tcg/mipsel/test_dsp_r1_extrv_r_w.c
+++ b/tests/tcg/mipsel/test_dsp_r1_extrv_r_w.c
@@ -1,5 +1,4 @@
 #include<stdio.h>
-#include<assert.h>
 
 int main()
 {
diff --git a/tests/tcg/mipsel/test_dsp_r1_extrv_rs_w.c 
b/tests/tcg/mipsel/test_dsp_r1_extrv_rs_w.c
index 10c182a54b23..9a4f5fac7a59 100644
--- a/tests/tcg/mipsel/test_dsp_r1_extrv_rs_w.c
+++ b/tests/tcg/mipsel/test_dsp_r1_extrv_rs_w.c
@@ -1,5 +1,4 @@
 #include<stdio.h>
-#include<assert.h>
 
 int main()
 {
diff --git a/tests/tcg/mipsel/test_dsp_r1_extrv_s_h.c 
b/tests/tcg/mipsel/test_dsp_r1_extrv_s_h.c
index feac3e2e334a..d0747331f9ed 100644
--- a/tests/tcg/mipsel/test_dsp_r1_extrv_s_h.c
+++ b/tests/tcg/mipsel/test_dsp_r1_extrv_s_h.c
@@ -1,5 +1,4 @@
 #include<stdio.h>
-#include<assert.h>
 
 int main()
 {
diff --git a/tests/tcg/mipsel/test_dsp_r1_extrv_w.c 
b/tests/tcg/mipsel/test_dsp_r1_extrv_w.c
index 9e8b238a04d4..b1caee3ff085 100644
--- a/tests/tcg/mipsel/test_dsp_r1_extrv_w.c
+++ b/tests/tcg/mipsel/test_dsp_r1_extrv_w.c
@@ -1,5 +1,4 @@
 #include<stdio.h>
-#include<assert.h>
 
 int main()
 {
diff --git a/tests/tcg/mipsel/test_dsp_r1_main.c 
b/tests/tcg/mipsel/test_dsp_r1_main.c
deleted file mode 100644
index b296b20c9254..000000000000
--- a/tests/tcg/mipsel/test_dsp_r1_main.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include<stdio.h>
-
-int main()
-{
-    printf("hello world\n");
-}
diff --git a/tests/tcg/mipsel/test_dsp_r1_mfhi.c 
b/tests/tcg/mipsel/test_dsp_r1_mfhi.c
index 43a80669d1ea..5d2233d6eea5 100644
--- a/tests/tcg/mipsel/test_dsp_r1_mfhi.c
+++ b/tests/tcg/mipsel/test_dsp_r1_mfhi.c
@@ -1,5 +1,4 @@
 #include<stdio.h>
-#include<assert.h>
 
 int main()
 {
diff --git a/tests/tcg/mipsel/test_dsp_r1_mflo.c 
b/tests/tcg/mipsel/test_dsp_r1_mflo.c
index caeafdb05ce4..3e4046c57ffe 100644
--- a/tests/tcg/mipsel/test_dsp_r1_mflo.c
+++ b/tests/tcg/mipsel/test_dsp_r1_mflo.c
@@ -1,5 +1,4 @@
 #include<stdio.h>
-#include<assert.h>
 
 int main()
 {
diff --git a/tests/tcg/mipsel/test_dsp_r1_mthi.c 
b/tests/tcg/mipsel/test_dsp_r1_mthi.c
index 43a80669d1ea..5d2233d6eea5 100644
--- a/tests/tcg/mipsel/test_dsp_r1_mthi.c
+++ b/tests/tcg/mipsel/test_dsp_r1_mthi.c
@@ -1,5 +1,4 @@
 #include<stdio.h>
-#include<assert.h>
 
 int main()
 {
diff --git a/tests/tcg/mipsel/test_dsp_r1_mthlip.c 
b/tests/tcg/mipsel/test_dsp_r1_mthlip.c
index 85f94d8450ea..9c96751c8cbe 100644
--- a/tests/tcg/mipsel/test_dsp_r1_mthlip.c
+++ b/tests/tcg/mipsel/test_dsp_r1_mthlip.c
@@ -1,5 +1,4 @@
 #include<stdio.h>
-#include<assert.h>
 
 int main()
 {
diff --git a/tests/tcg/mipsel/test_dsp_r1_mtlo.c 
b/tests/tcg/mipsel/test_dsp_r1_mtlo.c
index caeafdb05ce4..3e4046c57ffe 100644
--- a/tests/tcg/mipsel/test_dsp_r1_mtlo.c
+++ b/tests/tcg/mipsel/test_dsp_r1_mtlo.c
@@ -1,5 +1,4 @@
 #include<stdio.h>
-#include<assert.h>
 
 int main()
 {
diff --git a/tests/tcg/mipsel/test_dsp_r1_shilo.c 
b/tests/tcg/mipsel/test_dsp_r1_shilo.c
index ce8ebc69c2ac..e1b3292c3d42 100644
--- a/tests/tcg/mipsel/test_dsp_r1_shilo.c
+++ b/tests/tcg/mipsel/test_dsp_r1_shilo.c
@@ -1,5 +1,4 @@
 #include<stdio.h>
-#include<assert.h>
 
 int main()
 {
diff --git a/tests/tcg/mipsel/test_dsp_r1_shilov.c 
b/tests/tcg/mipsel/test_dsp_r1_shilov.c
index e1d6cea4b6de..18e3ee1f213e 100644
--- a/tests/tcg/mipsel/test_dsp_r1_shilov.c
+++ b/tests/tcg/mipsel/test_dsp_r1_shilov.c
@@ -1,5 +1,4 @@
 #include<stdio.h>
-#include<assert.h>
 
 int main()
 {
diff --git a/tests/tcg/mipsel/meson.build b/tests/tcg/mipsel/meson.build
index c9e869b000f4..77f210a47a70 100644
--- a/tests/tcg/mipsel/meson.build
+++ b/tests/tcg/mipsel/meson.build
@@ -4,6 +4,7 @@ tests = []
 tests += tcg_tests['multiarch-linux-user']['tests']
 
 tests_dsp = [
+  'test_dsp_acc.c',
   'test_dsp_r1_absq_s_ph.c',
   'test_dsp_r1_absq_s_w.c',
   'test_dsp_r1_addq_ph.c',
@@ -32,37 +33,19 @@ tests_dsp = [
   'test_dsp_r1_dpsq_sa_l_w.c',
   'test_dsp_r1_dpsu_h_qbl.c',
   'test_dsp_r1_dpsu_h_qbr.c',
-  'test_dsp_r1_extp.c',
-  'test_dsp_r1_extpdp.c',
-  'test_dsp_r1_extpdpv.c',
-  'test_dsp_r1_extpv.c',
-  'test_dsp_r1_extr_r_w.c',
-  'test_dsp_r1_extr_rs_w.c',
-  'test_dsp_r1_extr_s_h.c',
-  'test_dsp_r1_extr_w.c',
-  'test_dsp_r1_extrv_r_w.c',
-  'test_dsp_r1_extrv_rs_w.c',
-  'test_dsp_r1_extrv_s_h.c',
-  'test_dsp_r1_extrv_w.c',
   'test_dsp_r1_insv.c',
   'test_dsp_r1_lbux.c',
   'test_dsp_r1_lhx.c',
   'test_dsp_r1_lwx.c',
   'test_dsp_r1_madd.c',
   'test_dsp_r1_maddu.c',
-  'test_dsp_r1_main.c',
   'test_dsp_r1_maq_s_w_phl.c',
   'test_dsp_r1_maq_s_w_phr.c',
   'test_dsp_r1_maq_sa_w_phl.c',
   'test_dsp_r1_maq_sa_w_phr.c',
-  'test_dsp_r1_mfhi.c',
-  'test_dsp_r1_mflo.c',
   'test_dsp_r1_modsub.c',
   'test_dsp_r1_msub.c',
   'test_dsp_r1_msubu.c',
-  'test_dsp_r1_mthi.c',
-  'test_dsp_r1_mthlip.c',
-  'test_dsp_r1_mtlo.c',
   'test_dsp_r1_muleq_s_w_phl.c',
   'test_dsp_r1_muleq_s_w_phr.c',
   'test_dsp_r1_muleu_s_ph_qbl.c',
@@ -93,8 +76,6 @@ tests_dsp = [
   'test_dsp_r1_repl_qb.c',
   'test_dsp_r1_replv_ph.c',
   'test_dsp_r1_replv_qb.c',
-  'test_dsp_r1_shilo.c',
-  'test_dsp_r1_shilov.c',
   'test_dsp_r1_shll_ph.c',
   'test_dsp_r1_shll_qb.c',
   'test_dsp_r1_shll_s_ph.c',
-- 
2.55.0


Reply via email to