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

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

index f81f109e0538ef7d508e0c66b3beda7886112358..e4439171bc0dbdaf718f5508727708cbec48a76e 100644 (file)
@@ -175,8 +175,6 @@ EXTRA_DIST = init.sh run.sh match.awk \
             pipe.expected \
             ppoll.expected \
             ppoll-v.expected \
-            readlink.awk \
-            readlinkat.awk \
             restart_syscall.expected \
             restart_syscall_unknown.expected \
             sigaction.awk \
diff --git a/tests/readlink.awk b/tests/readlink.awk
deleted file mode 100644 (file)
index 7b74250..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-BEGIN {
-       pathname = "\\\\x72\\\\x65\\\\x61\\\\x64\\\\x6c\\\\x69\\\\x6e\\\\x6b\\\\x2e\\\\x6c\\\\x69\\\\x6e\\\\x6b"
-       buf = "\\\\x72\\\\x65\\\\x61"
-       r[1] = "^readlink\\(\"" pathname "\", \"" buf "\"\\.\\.\\., 31\\) += 10"
-       r[2] = "^\\+\\+\\+ exited with 0 \\+\\+\\+$"
-       lines = 2
-       fail = 0
-}
-
-@include "match.awk"
index b31c8913e026ed1281a1e6e89f9ba5ccd774e1eb..0d9c15f72c5fad2e162f7b8556632ed0a27a4259 100644 (file)
@@ -1,3 +1,8 @@
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <stdio.h>
 #include <unistd.h>
 #include <sys/syscall.h>
 
@@ -5,11 +10,24 @@ int
 main(void)
 {
 #ifdef __NR_readlink
-       char buf[31];
+       static const char fname[] = "readlink.link";
+       unsigned char buf[31];
+       long rc;
+       unsigned int i;
 
-       if (syscall(__NR_readlink, "readlink.link", buf, sizeof(buf)) != 10)
+       rc = syscall(__NR_readlink, fname, buf, sizeof(buf));
+       if (rc < 0)
                return 77;
 
+       printf("readlink(\"");
+       for (i = 0; fname[i]; ++i)
+               printf("\\x%02x", (int) (unsigned char) fname[i]);
+       printf("\", \"");
+       for (i = 0; i < 3; ++i)
+               printf("\\x%02x", (int) buf[i]);
+       printf("\"..., %zu) = %ld\n", sizeof(buf), rc);
+
+       puts("+++ exited with 0 +++");
        return 0;
 #else
        return 77;
index 1578859919a05aa288ba12b3f5d45507b79e8dbe..ff563361382f5e7b7d5eb31cde299bb8c06acae2 100755 (executable)
@@ -4,13 +4,18 @@
 
 . "${srcdir=.}/init.sh"
 
-ln -sf readlink.c readlink.link ||
+syscall=readlink
+target=$syscall.c
+link=$syscall.link
+OUT="$LOG.out"
+
+ln -snf $target $link ||
        framework_skip_ 'failed to create a symlink'
 
-run_prog
-run_strace -e readlink -xx -s3 $args
-match_awk
+run_prog > /dev/null
+run_strace -e $syscall -xx -s3 $args > "$OUT"
+match_diff "$OUT" "$LOG"
 
-rm -f readlink.link
+rm -f -- "$OUT" $link
 
 exit 0
diff --git a/tests/readlinkat.awk b/tests/readlinkat.awk
deleted file mode 100644 (file)
index 5611b43..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-BEGIN {
-       pathname = "\\\\x72\\\\x65\\\\x61\\\\x64\\\\x6c\\\\x69\\\\x6e\\\\x6b\\\\x61\\\\x74\\\\x2e\\\\x6c\\\\x69\\\\x6e\\\\x6b"
-       buf = "\\\\x72\\\\x65\\\\x61"
-       r[1] = "^readlinkat\\(AT_FDCWD, \"" pathname "\", \"" buf "\"\\.\\.\\., 31\\) += 12"
-       r[2] = "^\\+\\+\\+ exited with 0 \\+\\+\\+$"
-       lines = 2
-       fail = 0
-}
-
-@include "match.awk"
index d22c49e4c53f97dad08a622f8b1863c3e5b16d28..758dd0f32adafa26c63226197cef09bce53e813a 100644 (file)
@@ -1,3 +1,8 @@
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <stdio.h>
 #include <unistd.h>
 #include <sys/syscall.h>
 
@@ -5,11 +10,24 @@ int
 main(void)
 {
 #ifdef __NR_readlinkat
-       char buf[31];
+       static const char fname[] = "readlinkat.link";
+       unsigned char buf[31];
+       long rc;
+       unsigned int i;
 
-       if (syscall(__NR_readlinkat, -100, "readlinkat.link", buf, sizeof(buf)) != 12)
+       rc = syscall(__NR_readlinkat, -100, fname, buf, sizeof(buf));
+       if (rc < 0)
                return 77;
 
+       printf("readlinkat(AT_FDCWD, \"");
+       for (i = 0; fname[i]; ++i)
+               printf("\\x%02x", (int) (unsigned char) fname[i]);
+       printf("\", \"");
+       for (i = 0; i < 3; ++i)
+               printf("\\x%02x", (int) buf[i]);
+       printf("\"..., %zu) = %ld\n", sizeof(buf), rc);
+
+       puts("+++ exited with 0 +++");
        return 0;
 #else
        return 77;
index 9ae46a98e48fb7fa79f2733fc9adafdb303ac707..289704cf8e323da1fb18232f76e035de722b5a27 100755 (executable)
@@ -4,13 +4,18 @@
 
 . "${srcdir=.}/init.sh"
 
-ln -sf readlinkat.c readlinkat.link ||
+syscall=readlinkat
+target=$syscall.c
+link=$syscall.link
+OUT="$LOG.out"
+
+ln -snf $target $link ||
        framework_skip_ 'failed to create a symlink'
 
-run_prog
-run_strace -e readlinkat -xx -s3 $args
-match_awk
+run_prog > /dev/null
+run_strace -e $syscall -xx -s3 $args > "$OUT"
+match_diff "$OUT" "$LOG"
 
-rm -f readlinkat.link
+rm -f -- "$OUT" $link
 
 exit 0