tests: convert readlink.test and readlinkat.test from match_awk to match_diff
* 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.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f81f109..e443917 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -175,8 +175,6 @@
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
index 7b74250..0000000
--- a/tests/readlink.awk
+++ /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"
diff --git a/tests/readlink.c b/tests/readlink.c
index b31c891..0d9c15f 100644
--- a/tests/readlink.c
+++ b/tests/readlink.c
@@ -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 @@
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;
diff --git a/tests/readlink.test b/tests/readlink.test
index 1578859..ff56336 100755
--- a/tests/readlink.test
+++ b/tests/readlink.test
@@ -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
index 5611b43..0000000
--- a/tests/readlinkat.awk
+++ /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"
diff --git a/tests/readlinkat.c b/tests/readlinkat.c
index d22c49e..758dd0f 100644
--- a/tests/readlinkat.c
+++ b/tests/readlinkat.c
@@ -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 @@
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;
diff --git a/tests/readlinkat.test b/tests/readlinkat.test
index 9ae46a9..289704c 100755
--- a/tests/readlinkat.test
+++ b/tests/readlinkat.test
@@ -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