]> granicus.if.org Git - strace/commitdiff
tests: convert getrandom.test from match_awk to match_diff
authorDmitry V. Levin <ldv@altlinux.org>
Fri, 28 Aug 2015 07:11:17 +0000 (07:11 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 28 Aug 2015 08:16:43 +0000 (08:16 +0000)
* tests/getrandom.c (main): Print expected output.
* tests/getrandom.test: Use match_diff instead of match_awk.
* tests/getrandom.awk: Remove.
* tests/Makefile.am (EXTRA_DIST): Remove getrandom.awk.

tests/Makefile.am
tests/getrandom.awk [deleted file]
tests/getrandom.c
tests/getrandom.test

index 36bb5100699629462458084172caf3be6ff30e1d..f81f109e0538ef7d508e0c66b3beda7886112358 100644 (file)
@@ -162,7 +162,6 @@ EXTRA_DIST = init.sh run.sh match.awk \
             filter-unavailable.expected \
             getdents.awk \
             getdents.out \
-            getrandom.awk \
             ioctl.expected \
             ip_mreq.expected \
             ipc.sh \
diff --git a/tests/getrandom.awk b/tests/getrandom.awk
deleted file mode 100644 (file)
index 09d2a0f..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-BEGIN {
-       r[1] = "^getrandom\\(\"(\\\\x[0-9a-f][0-9a-f]){3}\", 3, 0\\) += 3$"
-       r[2] = "^getrandom\\(\"(\\\\x[0-9a-f][0-9a-f]){3}\"\\.\\.\\., 4, GRND_NONBLOCK\\) += 4$"
-       r[3] = "^getrandom\\(0x[[0-9a-f]+, 4, GRND_NONBLOCK\\|GRND_RANDOM\\|0x3000\\) += -1 "
-       s[4] = "+++ exited with 0 +++"
-
-       lines = 4
-       fail = 0
-}
-
-@include "match.awk"
index 4620f9f501d2d76381bea921471a5d218d6818d8..f15ef74ce3c729d6582ead52e074a1c662764210 100644 (file)
@@ -1,3 +1,35 @@
+/*
+ * Copyright (c) 2015 Dmitry V. Levin <ldv@altlinux.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <stdio.h>
 #include <unistd.h>
 #include <sys/syscall.h>
 
@@ -5,15 +37,24 @@ int
 main(void)
 {
 #ifdef __NR_getrandom
-       char buf[4];
+       unsigned char buf[4];
 
        if (syscall(__NR_getrandom, buf, sizeof(buf) - 1, 0) != sizeof(buf) - 1)
                return 77;
+       printf("getrandom(\"\\x%02x\\x%02x\\x%02x\", 3, 0) = 3\n",
+              (int) buf[0], (int) buf[1], (int) buf[2]);
+
        if (syscall(__NR_getrandom, buf, sizeof(buf), 1) != sizeof(buf))
                return 77;
+       printf("getrandom(\"\\x%02x\\x%02x\\x%02x\"..., 4, GRND_NONBLOCK) = 4\n",
+              (int) buf[0], (int) buf[1], (int) buf[2]);
+
        if (syscall(__NR_getrandom, buf, sizeof(buf), 0x3003) != -1)
                return 77;
+       printf("getrandom(%p, 4, GRND_NONBLOCK|GRND_RANDOM|0x3000) = "
+              "-1 EINVAL (Invalid argument)\n", buf);
 
+       puts("+++ exited with 0 +++");
        return 0;
 #else
        return 77;
index 3dd76f29a3d4e7fc4b554b232697fdd4d5b90d68..d429cdebe4da42babe39ed09ec20fba3aba43a9a 100755 (executable)
@@ -4,8 +4,10 @@
 
 . "${srcdir=.}/init.sh"
 
-run_prog
-run_strace -e getrandom -xx -s3 $args
-match_awk
+run_prog > /dev/null
+OUT="$LOG.out"
+run_strace -e getrandom -xx -s3 -a32 $args > "$OUT"
+match_diff "$OUT" "$LOG"
+rm -f "$OUT"
 
 exit 0