]> granicus.if.org Git - strace/commitdiff
tests: add sysinfo.test
authorElvira Khabirova <lineprinter0@gmail.com>
Mon, 3 Aug 2015 03:30:49 +0000 (06:30 +0300)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 28 Aug 2015 08:46:23 +0000 (08:46 +0000)
* tests/sysinfo.c: New file.
* tests/sysinfo.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add sysinfo.
(TESTS): Add sysinfo.test.
* tests/.gitignore: Add sysinfo.

tests/.gitignore
tests/Makefile.am
tests/sysinfo.c [new file with mode: 0644]
tests/sysinfo.test [new file with mode: 0755]

index 819b0a904e3525a6b76968c4abc0a84b618038e5..8500ca747ac7ae44177b69e140973b51c8a3ac18 100644 (file)
@@ -45,6 +45,7 @@ stack-fcall
 stat
 stat32
 statfs
+sysinfo
 time
 uid
 uid16
index bfebb39e76ca5fbcc2da09120e3b6157bce2ee07..0ba7ca7255131fe4613335116511af311dde4358 100644 (file)
@@ -58,6 +58,7 @@ check_PROGRAMS = \
        stat \
        stat32 \
        statfs \
+       sysinfo \
        time \
        uid \
        uid16 \
@@ -123,6 +124,7 @@ TESTS = \
        stat32-v.test \
        stat64-v.test \
        statfs.test \
+       sysinfo.test \
        memfd_create.test \
        mmap.test \
        mmap64.test \
diff --git a/tests/sysinfo.c b/tests/sysinfo.c
new file mode 100644 (file)
index 0000000..4ca0ec7
--- /dev/null
@@ -0,0 +1,40 @@
+#include <stdio.h>
+#include <sys/sysinfo.h>
+
+int
+main (void)
+{
+       struct sysinfo si;
+       if (sysinfo(&si) == -1)
+               return 77;
+       printf("sysinfo({uptime=%llu"
+               ", loads=[%llu, %llu, %llu]"
+               ", totalram=%llu"
+               ", freeram=%llu"
+               ", sharedram=%llu"
+               ", bufferram=%llu"
+               ", totalswap=%llu"
+               ", freeswap=%llu"
+               ", procs=%u"
+               ", totalhigh=%llu"
+               ", freehigh=%llu"
+               ", mem_unit=%u"
+               "}) = 0\n",
+               (unsigned long long) si.uptime
+               , (unsigned long long) si.loads[0]
+               , (unsigned long long) si.loads[1]
+               , (unsigned long long) si.loads[2]
+               , (unsigned long long) si.totalram
+               , (unsigned long long) si.freeram
+               , (unsigned long long) si.sharedram
+               , (unsigned long long) si.bufferram
+               , (unsigned long long) si.totalswap
+               , (unsigned long long) si.freeswap
+               , (unsigned) si.procs
+               , (unsigned long long) si.totalhigh
+               , (unsigned long long) si.freehigh
+               , si.mem_unit
+               );
+       puts("+++ exited with 0 +++");
+       return 0;
+}
diff --git a/tests/sysinfo.test b/tests/sysinfo.test
new file mode 100755 (executable)
index 0000000..8e7e5c9
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Check decoding of sysinfo syscall
+
+. "${srcdir=.}/init.sh"
+
+run_prog > /dev/null
+OUT="$LOG.out"
+run_strace -esysinfo $args > "$OUT"
+match_diff "$OUT" "$LOG"
+rm -f "$OUT"
+
+exit 0