tests: add swap.test
* tests/swap.c: New file. * tests/swap.test: New test. * tests/.gitignore: Add swap. * tests/Makefile.am (check_PROGRAMS): Likewise. (DECODER_TESTS): Add swap.test.
This commit is contained in:
parent
41cd657930
commit
93faa4cc88
1
tests/.gitignore
vendored
1
tests/.gitignore
vendored
@ -137,6 +137,7 @@ stack-fcall
|
||||
stat
|
||||
stat64
|
||||
statfs
|
||||
swap
|
||||
sync_file_range
|
||||
sync_file_range2
|
||||
sysinfo
|
||||
|
@ -186,6 +186,7 @@ check_PROGRAMS = \
|
||||
stat \
|
||||
stat64 \
|
||||
statfs \
|
||||
swap \
|
||||
sync_file_range \
|
||||
sync_file_range2 \
|
||||
sysinfo \
|
||||
@ -374,6 +375,7 @@ DECODER_TESTS = \
|
||||
stat64.test \
|
||||
statfs.test \
|
||||
sun_path.test \
|
||||
swap.test \
|
||||
sync_file_range.test \
|
||||
sync_file_range2.test \
|
||||
sysinfo.test \
|
||||
|
42
tests/swap.c
Normal file
42
tests/swap.c
Normal file
@ -0,0 +1,42 @@
|
||||
#include "tests.h"
|
||||
#include <sys/syscall.h>
|
||||
|
||||
#if defined __NR_swapon && defined __NR_swapoff
|
||||
|
||||
# include <errno.h>
|
||||
# include <stdio.h>
|
||||
# include <sys/swap.h>
|
||||
# include <unistd.h>
|
||||
|
||||
static const char *
|
||||
error_msg(int error_num)
|
||||
{
|
||||
switch (error_num) {
|
||||
case ENOSYS: return "ENOSYS";
|
||||
case EPERM: return "EPERM";
|
||||
default: return "ENOENT";
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
static const char sample[] = "swap.sample";
|
||||
|
||||
int rc = syscall(__NR_swapon, sample, 0);
|
||||
printf("swapon(\"%s\", 0) = %d %s (%m)\n",
|
||||
sample, rc, error_msg(errno));
|
||||
|
||||
rc = syscall(__NR_swapoff, sample);
|
||||
printf("swapoff(\"%s\") = %d %s (%m)\n",
|
||||
sample, rc, error_msg(errno));
|
||||
|
||||
puts("+++ exited with 0 +++");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
SKIP_MAIN_UNDEFINED("__NR_swapon && __NR_swapoff")
|
||||
|
||||
#endif
|
6
tests/swap.test
Executable file
6
tests/swap.test
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Check swapon and swapoff syscalls decoding.
|
||||
|
||||
. "${srcdir=.}/init.sh"
|
||||
run_strace_match_diff -a23 -e trace=swapon,swapoff
|
Loading…
Reference in New Issue
Block a user