[PATCH 1/3] tests: add uname.test
Fei Jie
feij.fnst at cn.fujitsu.com
Fri Feb 26 09:41:37 UTC 2016
* tests/uname.c: New file.
* tests/uname.test: New test.
* tests/.gitignore: Add uname.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(TESTS): Add uname.test.
---
tests/.gitignore | 1 +
tests/Makefile.am | 2 ++
tests/uname.c | 38 ++++++++++++++++++++++++++++++++++++++
tests/uname.test | 11 +++++++++++
4 files changed, 52 insertions(+)
create mode 100644 tests/uname.c
create mode 100755 tests/uname.test
diff --git a/tests/.gitignore b/tests/.gitignore
index bdce2db..e79d317 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -124,6 +124,7 @@ umount
umount2
umovestr
umovestr2
+uname
unix-pair-send-recv
userfaultfd
utime
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 54f3d5b..d924b9a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -172,6 +172,7 @@ check_PROGRAMS = \
umount2 \
umovestr \
umovestr2 \
+ uname \
unix-pair-send-recv \
userfaultfd \
utime \
@@ -326,6 +327,7 @@ TESTS = \
umount2.test \
umovestr.test \
umovestr2.test \
+ uname.test \
userfaultfd.test \
utime.test \
utimensat.test \
diff --git a/tests/uname.c b/tests/uname.c
new file mode 100644
index 0000000..ac1adce
--- /dev/null
+++ b/tests/uname.c
@@ -0,0 +1,38 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_uname
+
+# include <stdio.h>
+# include <sys/utsname.h>
+# include <unistd.h>
+
+int main()
+{
+ struct utsname *const uname = tail_alloc(sizeof(struct utsname));
+ int rc = syscall(__NR_uname, uname);
+ printf("uname({sysname=\"%s\", nodename=\"%s\", release=\"%s\""
+ ", version=\"%s\", machine=\"%s\""
+# ifdef _GNU_SOURCE
+ ", domainname=\"%s\""
+# endif
+ "}) = %d\n",
+ uname->sysname,
+ uname->nodename,
+ uname->release,
+ uname->version,
+ uname->machine,
+# ifdef _GNU_SOURCE
+ uname->domainname,
+# endif
+ rc);
+
+ puts("+++ exited with 0 +++");
+ return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_uname")
+
+#endif
diff --git a/tests/uname.test b/tests/uname.test
new file mode 100755
index 0000000..d11af15
--- /dev/null
+++ b/tests/uname.test
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Check uname syscall decoding.
+
+. "${srcdir=.}/init.sh"
+
+run_prog > /dev/null
+OUT="$LOG.out"
+run_strace -v -euname $args >"$OUT"
+match_diff "$LOG" "$OUT"
+rm -f "$OUT"
--
1.8.3.1
More information about the Strace-devel
mailing list