move test programs

This commit is contained in:
Tomoki Shirasawa
2018-06-07 10:08:48 +09:00
parent 6602cf442c
commit 139123dc12
10 changed files with 951 additions and 0 deletions

152
test/issues/840/C840.sh Normal file
View File

@ -0,0 +1,152 @@
#!/bin/sh
if ! sudo ls /sys/kernel/debug | grep kmemleak > /dev/null 2>&1; then
echo kmemleak: not found >&2
exit 1
fi
echo 'C840T01... '
ng=0
sync
sudo /sbin/sysctl vm.drop_caches=3 > /dev/null 2>&1
./ihkosctl 0 clear_kmsg
sudo dmesg -c > /dev/null
sudo sh -c 'echo clear > /sys/kernel/debug/kmemleak'
./mcexec ./C840T01
if [ `sudo cat /sys/kernel/debug/kmemleak | wc -l` != 0 ]; then
echo 'C840T01: NG (kmemleak)'
ng=1
fi
if ! dmesg | grep 'remote_page_fault:interrupted. -512' > /dev/null 2>&1; then
echo 'C840T01: WARN (remote_page_fault)'
ng=1
fi
if ! ./ihkosctl 0 kmsg | grep 'is dead, terminate()' > /dev/null 2>&1; then
echo 'C840T01: WARN (syscall offloading)'
ng=1
fi
if [ $ng = 0 ]; then
echo C840T01: OK
fi
echo 'C840T02... '
ng=0
sync
sudo /sbin/sysctl vm.drop_caches=3 > /dev/null 2>&1
./ihkosctl 0 clear_kmsg
sudo dmesg -c > /dev/null
sudo sh -c 'echo clear > /sys/kernel/debug/kmemleak'
./mcexec ./C840T02
if [ `sudo cat /sys/kernel/debug/kmemleak | wc -l` != 0 ]; then
echo 'C840T02: NG (kmemleak)'
ng=1
fi
if dmesg | grep 'remote_page_fault:interrupted. -512' > /dev/null 2>&1; then
echo 'C840T02: WARN (remote_page_fault)'
ng=1
fi
if ! ./ihkosctl 0 kmsg | grep 'is dead, terminate()' > /dev/null 2>&1; then
echo 'C840T02: WARN (syscall offloading)'
ng=1
fi
if [ $ng = 0 ]; then
echo C840T02: OK
fi
echo 'C840T03... '
ng=0
sync
sudo /sbin/sysctl vm.drop_caches=3 > /dev/null 2>&1
./ihkosctl 0 clear_kmsg
sudo dmesg -c > /dev/null
sudo sh -c 'echo clear > /sys/kernel/debug/kmemleak'
./mcexec ./C840T03
if [ `sudo cat /sys/kernel/debug/kmemleak | wc -l` != 0 ]; then
echo 'C840T03: NG (kmemleak)'
ng=1
fi
if dmesg | grep 'remote_page_fault:interrupted. -512' > /dev/null 2>&1; then
echo 'C840T03: WARN (remote_page_fault)'
ng=1
fi
if ./ihkosctl 0 kmsg | grep 'is dead, terminate()' > /dev/null 2>&1; then
echo 'C840T03: WARN (syscall offloading)'
ng=1
fi
if [ $ng = 0 ]; then
echo C840T03: OK
fi
echo 'C840T04... '
ng=0
sync
sudo /sbin/sysctl vm.drop_caches=3 > /dev/null 2>&1
./ihkosctl 0 clear_kmsg
sudo dmesg -c > /dev/null
sudo sh -c 'echo clear > /sys/kernel/debug/kmemleak'
timeout -s 9 2 ./mcexec ./C840T04
sleep 2
if [ `sudo cat /sys/kernel/debug/kmemleak | wc -l` != 0 ]; then
echo 'C840T04: NG (kmemleak)'
ng=1
fi
if ! dmesg | grep 'remote_page_fault:interrupted. -512' > /dev/null 2>&1; then
echo 'C840T04: WARN (remote_page_fault)'
ng=1
fi
if ! ./ihkosctl 0 kmsg | grep 'is dead, terminate()' > /dev/null 2>&1; then
echo 'C840T04: WARN (syscall offloading)'
ng=1
fi
if [ $ng = 0 ]; then
echo C840T04: OK
fi
echo 'C840T05... '
ng=0
sync
sudo /sbin/sysctl vm.drop_caches=3 > /dev/null 2>&1
./ihkosctl 0 clear_kmsg
sudo dmesg -c > /dev/null
sudo sh -c 'echo clear > /sys/kernel/debug/kmemleak'
timeout -s 9 2 ./mcexec ./C840T05
sleep 2
if [ `sudo cat /sys/kernel/debug/kmemleak | wc -l` != 0 ]; then
echo 'C840T05: NG (kmemleak)'
ng=1
fi
if dmesg | grep 'remote_page_fault:interrupted. -512' > /dev/null 2>&1; then
echo 'C840T05: WARN (remote_page_fault)'
ng=1
fi
if ! ./ihkosctl 0 kmsg | grep 'is dead, terminate()' > /dev/null 2>&1; then
echo 'C840T05: WARN (syscall offloading)'
ng=1
fi
if [ $ng = 0 ]; then
echo C840T05: OK
fi
echo 'C840T06... '
ng=0
sync
sudo /sbin/sysctl vm.drop_caches=3 > /dev/null 2>&1
./ihkosctl 0 clear_kmsg
sudo dmesg -c > /dev/null
sudo sh -c 'echo clear > /sys/kernel/debug/kmemleak'
timeout -s 9 2 ./mcexec ./C840T06
sleep 2
if [ `sudo cat /sys/kernel/debug/kmemleak | wc -l` != 0 ]; then
echo 'C840T06: NG (kmemleak)'
ng=1
fi
if dmesg | grep 'remote_page_fault:interrupted. -512' > /dev/null 2>&1; then
echo 'C840T06: WARN (remote_page_fault)'
ng=1
fi
if ./ihkosctl 0 kmsg | grep 'is dead, terminate()' > /dev/null 2>&1; then
echo 'C840T06: WARN (syscall offloading)'
ng=1
fi
if [ $ng = 0 ]; then
echo C840T06: OK
fi

28
test/issues/840/C840.txt Normal file
View File

@ -0,0 +1,28 @@
スクリプトは Wed Jun 6 14:38:21 2018
に開始しました[?1034hbash-4.2$ sh C840.sh
C840T01...
Terminate by signal 9
C840.sh: 14 行: 22464 強制終了 ./mcexec ./C840T01
C840T01: OK
C840T02...
Terminate by signal 9
C840.sh: 38 行: 22500 強制終了 ./mcexec ./C840T02
C840T02: OK
C840T03...
Terminate by signal 9
C840.sh: 62 行: 22535 強制終了 ./mcexec ./C840T03
C840T03: OK
C840T04...
C840.sh: 86 行: 22570 強制終了 timeout -s 9 2 ./mcexec ./C840T04
C840T04: OK
C840T05...
C840.sh: 111 行: 22598 強制終了 timeout -s 9 2 ./mcexec ./C840T05
C840T05: OK
C840T06...
C840.sh: 136 行: 22626 強制終了 timeout -s 9 2 ./mcexec ./C840T06
C840T06: OK
bash-4.2$ exit
exit
スクリプトは Wed Jun 6 14:38:51 2018
に終了しました

46
test/issues/840/C840T01.c Normal file
View File

@ -0,0 +1,46 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <signal.h>
#include <errno.h>
int
main(int argc, char **argv)
{
int fd;
void *p;
long l;
pid_t pid;
pid = fork();
if (pid == 0) {
sleep(1);
kill(getppid(), SIGKILL);
exit(0);
}
fd = open("rpf.data", O_RDONLY);
if (fd == -1) {
perror("open(rpf.data)");
exit(1);
}
p = mmap(NULL, 512*1024*1024, PROT_READ, MAP_PRIVATE, fd, 0);
if (p == (void *)-1) {
perror("mmap");
exit(1);
}
close(fd);
fd = open("rpf.out", O_WRONLY|O_CREAT|O_TRUNC, 0600);
if (fd == -1) {
perror("open(fpt.out)");
exit(1);
}
l = write(fd, p, 512*1024*1024);
printf("write=%ld\n", l);
close(fd);
munmap(p, 512*1024*1024);
exit(0);
}

27
test/issues/840/C840T02.c Normal file
View File

@ -0,0 +1,27 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <signal.h>
#include <errno.h>
int
main(int argc, char **argv)
{
pid_t pid;
int pfd[2];
char c;
pid = fork();
if (pid == 0) {
sleep(1);
kill(getppid(), SIGKILL);
exit(0);
}
pipe(pfd);
read(pfd[0], &c, 1);
exit(0);
}

24
test/issues/840/C840T03.c Normal file
View File

@ -0,0 +1,24 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <signal.h>
#include <errno.h>
int
main(int argc, char **argv)
{
pid_t pid;
pid = fork();
if (pid == 0) {
sleep(1);
kill(getppid(), SIGKILL);
exit(0);
}
for(;;);
exit(0);
}

38
test/issues/840/C840T04.c Normal file
View File

@ -0,0 +1,38 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <signal.h>
#include <errno.h>
int
main(int argc, char **argv)
{
int fd;
void *p;
long l;
fd = open("rpf.data", O_RDONLY);
if (fd == -1) {
perror("open(rpf.data)");
exit(1);
}
p = mmap(NULL, 512*1024*1024, PROT_READ, MAP_PRIVATE, fd, 0);
if (p == (void *)-1) {
perror("mmap");
exit(1);
}
close(fd);
fd = open("rpf.out", O_WRONLY|O_CREAT|O_TRUNC, 0600);
if (fd == -1) {
perror("open(fpt.out)");
exit(1);
}
l = write(fd, p, 512*1024*1024);
printf("write=%ld\n", l);
close(fd);
munmap(p, 512*1024*1024);
exit(0);
}

19
test/issues/840/C840T05.c Normal file
View File

@ -0,0 +1,19 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <signal.h>
#include <errno.h>
int
main(int argc, char **argv)
{
int pfd[2];
char c;
pipe(pfd);
read(pfd[0], &c, 1);
exit(0);
}

15
test/issues/840/C840T06.c Normal file
View File

@ -0,0 +1,15 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <signal.h>
#include <errno.h>
int
main(int argc, char **argv)
{
for(;;);
exit(0);
}