]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
s390x: Regtest integration of none/tests/s390x/disasm-test
authorFlorian Krohm <flo2030@eich-krohm.de>
Sun, 13 Apr 2025 12:06:33 +0000 (12:06 +0000)
committerFlorian Krohm <flo2030@eich-krohm.de>
Sun, 13 Apr 2025 12:06:33 +0000 (12:06 +0000)
The checker requires objdump --version >= 2.44
Add command line flag --check-prereq to disasm-test and use it in
disasm-test.vgtest.
New file none/tests/s390x/disasm-test/disasm-test.post.exp as the
checker is run in the "post" hook.

none/tests/s390x/disasm-test/Makefile.am
none/tests/s390x/disasm-test/disasm-test.post.exp [new file with mode: 0644]
none/tests/s390x/disasm-test/disasm-test.stderr.exp
none/tests/s390x/disasm-test/disasm-test.vgtest
none/tests/s390x/disasm-test/main.c

index ce662cb860033f7e1f047e2283b1013b1b86a947..61d4f3196333e9ca5bac1a58ff2c4fbd4e85451d 100644 (file)
@@ -1,7 +1,7 @@
 include $(top_srcdir)/Makefile.all.am
 
-EXTRA_DIST = disasm-test.vgtest disasm-test.stderr.exp disasm-test.stdout.exp
-
+EXTRA_DIST = disasm-test.vgtest disasm-test.stderr.exp disasm-test.stdout.exp \
+             disasm-test.post.exp
 dist_noinst_SCRIPTS = filter_stderr
 
 #----------------------------------------------------------------------------
diff --git a/none/tests/s390x/disasm-test/disasm-test.post.exp b/none/tests/s390x/disasm-test/disasm-test.post.exp
new file mode 100644 (file)
index 0000000..3472222
--- /dev/null
@@ -0,0 +1,4 @@
+Total: 148751 tests generated
+Total: 148659 insns verified
+Total:      0 disassembly mismatches
+Total:     92 specification exceptions
index e6a4c48218514483efe7c45bf611e4ab7342bc11..139597f9cb07c5d48bed18984ec4747f4b4f3438 100644 (file)
@@ -1,3 +1,2 @@
 
-One of --verify, --generate, --run, --all, or --unit-test is required
 
index d7a1a409c137d9909e3391f86e5cf62db4ffa38a..9f7f9997b03219d16556f9afa395a97e85bd44c3 100644 (file)
@@ -1,6 +1,7 @@
-prog: disasm-test
-# args: --all        # enable this eventually
 #
-# NOTE: there are extra newlines in the output which are *not*
-# present when disasm-test is invoked by hand.
-# Not sure where they are coming from. 
+# We do not want disasm-test to be run under the auspices of valgrind.
+# Therefore the real test here is run in the "post" command.
+#
+prereq: ./disasm-test --check-prereq
+prog: /bin/true
+post: ./disasm-test --all --summary
index c61ab8c681061559d6aa054147fbebbfbeac8e84..aa362b511eec653092c2715258bcbea2cddb8da1 100644 (file)
@@ -25,6 +25,7 @@
 #include <stddef.h>           // NULL
 #include <stdlib.h>           // exit, malloc
 #include <stdio.h>            // vfprintf
+#include <ctype.h>            // isdigit
 #include <stdarg.h>           // va_list
 #include <string.h>           // strchr
 #include <assert.h>           // assert
@@ -38,6 +39,8 @@ const char *gcc = "gcc";          // path to GCC
 const char *objdump = "objdump";  // path to objdump
 const char *gcc_flags = "-march=arch14";
 
+#define MIN_OBJDUMP_VERSION 2044000  /* 2.44 */
+
 #define CHECK_CLO(x, s) (strncmp(x, s, sizeof s - 1) == 0)
 
 static const char usage[] =
@@ -63,10 +66,12 @@ static const char usage[] =
    "    --unit-test - Run unit tests\n"
    "    --show-spec-exc - Show insns causing specification exceptions\n"
    "    --no-show-miscompares - Do not show disassembly miscompares\n"
+   "    --check-prereq - Check prerequisites (e.g. objdump version)\n"
    ;
 
 static void remove_temp_files(const char *);
 static int  opcode_has_errors(const opcode *);
+static int  check_objdump(void);
 
 static int keep_temp = 0;
 static int summary = 0;
@@ -81,7 +86,7 @@ main(int argc, char *argv[])
 {
    int all = 0, verify = 0, generate = 0, unit_test = 0;
    int num_clargs = 0;
-   int run = 0;
+   int run = 0, check_prereq = 0;
    const char *clargs[argc];
 
    assert(sizeof(long long) == 8);
@@ -118,6 +123,8 @@ main(int argc, char *argv[])
          keep_temp = 1;
       } else if (CHECK_CLO(clo, "--run")) {
          run = 1;
+      } else if (CHECK_CLO(clo, "--check-prereq")) {
+         check_prereq = 1;
       } else if (CHECK_CLO(clo, "--help")) {
          printf("%s\n", usage);
          return 0;
@@ -134,6 +141,9 @@ main(int argc, char *argv[])
       }
    }
 
+   if (check_prereq)
+      return check_objdump();
+
    /* Check consistency of command line options */
    if (verify + generate + run + all + unit_test == 0)
       fatal("One of --verify, --generate, --run, --all, or --unit-test "
@@ -333,3 +343,53 @@ opcode_has_errors(const opcode *opc)
    }
    return 0;
 }
+
+
+/* Objdump version 2.44 or later is required, Return 0, if that's
+   the case. */
+static int
+check_objdump(void)
+{
+   unsigned need = strlen(objdump) + 3 + 1;
+   char *cmd = mallock(need);
+
+   sprintf(cmd, "%s -V", objdump);
+   FILE *fp = popen(cmd, "r");
+
+   /* The version number is expected on the first line and its
+      format ought to be one of X or X.Y or X.Y.Z where X,Y,Z are
+      positive integers. */
+   int c, rc = 1;
+   while ((c = fgetc(fp)) != EOF) {
+      if (c == '\n') break;
+      if (! isdigit(c)) continue;
+
+      /* Version number is expected to be X or X.Y or X.Y.Z */
+      char buf[32];  // assumed large enough
+      int ix = 0;
+      do {
+         buf[ix++] = c;
+         c = fgetc(fp);
+      } while (isdigit(c) || c == '.');
+      buf[ix] = '\0';
+
+      unsigned version = 0, v1, v2, v3;
+      if (sscanf(buf, "%u.%u.%u", &v1,&v2,&v3) == 3) {
+         version = v1*1000000 + v2*1000 + v3;
+      } else if (sscanf(buf, "%u.%u", &v1,&v2) == 2) {
+         version = v1*1000000 + v2*1000;
+      } else if (sscanf(buf, "%u", &v1) == 1) {
+         version = v1*1000000;
+      } else {
+         error("Could not determine objdump version\n");
+         break;
+      }
+      if (version >= MIN_OBJDUMP_VERSION)
+         rc = 0;
+      break;
+   }
+   pclose(fp);
+   free(cmd);
+
+   return rc;
+}