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:
parent
3ae8690d8e
commit
a067b8d3b0
1
tests/.gitignore
vendored
1
tests/.gitignore
vendored
@ -118,6 +118,7 @@ select
|
||||
sendfile
|
||||
sendfile64
|
||||
set_ptracer_any
|
||||
sethostname
|
||||
sigaction
|
||||
sigaltstack
|
||||
signalfd
|
||||
|
@ -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
37
tests/sethostname.c
Normal 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
6
tests/sethostname.test
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Check sethostname syscall decoding.
|
||||
|
||||
. "${srcdir=.}/init.sh"
|
||||
run_strace_match_diff -a22
|
Loading…
Reference in New Issue
Block a user