tests: add sethostname.test

* tests/sethostname.c: New file.
* tests/sethostname.test: New test.
* tests/.gitignore: Add sethostname.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add sethostname.test.
This commit is contained in:
Fei Jie 2016-03-31 16:06:49 +08:00 committed by Dmitry V. Levin
parent 3ae8690d8e
commit a067b8d3b0
4 changed files with 46 additions and 0 deletions

1
tests/.gitignore vendored
View File

@ -118,6 +118,7 @@ select
sendfile
sendfile64
set_ptracer_any
sethostname
sigaction
sigaltstack
signalfd

View File

@ -167,6 +167,7 @@ check_PROGRAMS = \
sendfile \
sendfile64 \
set_ptracer_any \
sethostname \
sigaction \
sigaltstack \
signalfd \
@ -343,6 +344,7 @@ DECODER_TESTS = \
select.test \
sendfile.test \
sendfile64.test \
sethostname.test \
sigaction.test \
sigaltstack.test \
signalfd.test \

37
tests/sethostname.c Normal file
View File

@ -0,0 +1,37 @@
#include "tests.h"
#include <sys/syscall.h>
#ifdef __NR_sethostname
# include <errno.h>
# include <stdio.h>
# include <unistd.h>
int
main(void)
{
const char *hostname = NULL;
int rc = syscall(__NR_sethostname, hostname, 63);
const char *errno_text;
switch (errno) {
case ENOSYS:
errno_text = "ENOSYS";
break;
case EPERM:
errno_text = "EPERM";
break;
default:
errno_text = "EFAULT";
}
printf("sethostname(NULL, %d) = %d %s (%m)\n",
63, rc, errno_text);
puts("+++ exited with 0 +++");
return 0;
}
#else
SKIP_MAIN_UNDEFINED("__NR_sethostname")
#endif

6
tests/sethostname.test Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
# Check sethostname syscall decoding.
. "${srcdir=.}/init.sh"
run_strace_match_diff -a22