tests: add getrusage.test
* tests/getrusage.c: New file. * tests/getrusage.test: New test. * tests/.gitignore: Add getrusage. * tests/Makefile.am (check_PROGRAMS): Likewise. (TESTS): Add getrusage.test.
This commit is contained in:
parent
49faae958a
commit
5204dbdbb1
1
tests/.gitignore
vendored
1
tests/.gitignore
vendored
@ -37,6 +37,7 @@ ftruncate64
|
||||
getdents
|
||||
getdents64
|
||||
getrandom
|
||||
getrusage
|
||||
getxxid
|
||||
inet-cmsg
|
||||
ioctl
|
||||
|
@ -87,6 +87,7 @@ check_PROGRAMS = \
|
||||
getdents \
|
||||
getdents64 \
|
||||
getrandom \
|
||||
getrusage \
|
||||
getxxid \
|
||||
inet-cmsg \
|
||||
ioctl \
|
||||
@ -244,6 +245,7 @@ TESTS = \
|
||||
getdents.test \
|
||||
getdents64.test \
|
||||
getrandom.test \
|
||||
getrusage.test \
|
||||
getxxid.test \
|
||||
inet-cmsg.test \
|
||||
ioctl.test \
|
||||
|
37
tests/getrusage.c
Normal file
37
tests/getrusage.c
Normal file
@ -0,0 +1,37 @@
|
||||
#include "tests.h"
|
||||
#include <sys/syscall.h>
|
||||
|
||||
#ifdef __NR_getrusage
|
||||
|
||||
# include <stdio.h>
|
||||
# include <sys/resource.h>
|
||||
# include <unistd.h>
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
struct rusage usage;
|
||||
int rc = syscall(__NR_getrusage, RUSAGE_SELF, &usage);
|
||||
printf("getrusage(RUSAGE_SELF, {ru_utime={%lu, %lu}"
|
||||
", ru_stime={%lu, %lu}, ru_maxrss=%lu, ru_ixrss=%lu"
|
||||
", ru_idrss=%lu, ru_isrss=%lu, ru_minflt=%lu"
|
||||
", ru_majflt=%lu, ru_nswap=%lu, ru_inblock=%lu"
|
||||
", ru_oublock=%lu, ru_msgsnd=%lu, ru_msgrcv=%lu"
|
||||
", ru_nsignals=%lu, ru_nvcsw=%lu, ru_nivcsw=%lu}) = %d\n",
|
||||
usage.ru_utime.tv_sec, usage.ru_utime.tv_usec,
|
||||
usage.ru_stime.tv_sec, usage.ru_stime.tv_usec,
|
||||
usage.ru_maxrss, usage.ru_ixrss, usage.ru_idrss,
|
||||
usage.ru_isrss, usage.ru_minflt, usage.ru_majflt,
|
||||
usage.ru_nswap, usage.ru_inblock, usage.ru_oublock,
|
||||
usage.ru_msgsnd, usage.ru_msgrcv, usage.ru_nsignals,
|
||||
usage.ru_nvcsw, usage.ru_nivcsw, rc);
|
||||
|
||||
puts("+++ exited with 0 +++");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
SKIP_MAIN_UNDEFINED("__NR_getrusage")
|
||||
|
||||
#endif
|
11
tests/getrusage.test
Executable file
11
tests/getrusage.test
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Check getrusage syscall decoding.
|
||||
|
||||
. "${srcdir=.}/init.sh"
|
||||
|
||||
run_prog > /dev/null
|
||||
OUT="$LOG.out"
|
||||
run_strace -v -egetrusage $args > "$OUT"
|
||||
match_diff "$LOG" "$OUT"
|
||||
rm -f "$OUT"
|
Loading…
x
Reference in New Issue
Block a user