issue 863: add test cases and test evidences

This commit is contained in:
Tomoki Shirasawa
2018-02-05 16:07:00 +09:00
parent 748429fc92
commit 8ee9eca74e
22 changed files with 704 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
スクリプトは Wed Jan 24 20:43:43 2018
に開始しました[?1034hbash-4.2$ ~/wallaby11-smp-x86/development/mic/mcexec ./signalonread-multi
[4261] I am the examiner for 4270.
[4270] I am a subjectThread 1, ad000700 ad000700
[4270] I am a subjectThread 3, ae400700 ae400700
[4270] I am a subjectThread 2, ada00700 ada00700
[4270] I am a subjectThread 0, ac72aec0 ac72aec0
[3] setup: 1367 ms
[2] setup: 1367 ms
[1] setup: 1367 ms
[0] setup: 1367 ms
[3] START TEST
[2] START TEST
[3] ./signalonread-multi try to read 2147483648 bytes. buffp=0x2aac40000010
[1] START TEST
[2] ./signalonread-multi try to read 2147483648 bytes. buffp=0x2aad00000010
[0] START TEST
[1] ./signalonread-multi try to read 2147483648 bytes. buffp=0x2aab80000010
[0] ./signalonread-multi try to read 2147483648 bytes. buffp=0x2aaac0000010
The TEST process is terminated by the signal 15
TEST SUCCESSED IF YOU DID NOT SEE 'OVERRUN'
TEST FINISHED
bash-4.2$ シェルから脱出するには "exit" を使用してください。
bash-4.2$ exit
スクリプトは Wed Jan 24 20:45:10 2018
に終了しました

View File

@@ -0,0 +1,21 @@
スクリプトは Wed Jan 24 20:56:37 2018
に開始しました[?1034hbash-4.2$ pwd
/home/shirasawa/dangertest/bin
bash-4.2$ ./mck-mcexec.sh ./killit -t 4000 - ./signalonread -nt 4 -nosignal
SUCCESS kmsg
SUCCESS clear_kmsg
SUCCESS mcexec
SUCCESS ./killit -t 4000 mcexec ./signalonread -nt 4 -nosignal
SUCCESS kmsg
SUCCESS kmsg 1 lines
SUCCESS ioctl 40000000 1
SUCCESS kmsg
SUCCESS 0 processes found
SUCCESS ioctl 40000000 2
SUCCESS kmsg
SUCCESS 0 threads found
bash-4.2$ シェルから脱出するには "exit" を使用してください。
bash-4.2$ exit
スクリプトは Wed Jan 24 20:57:07 2018
に終了しました

View File

@@ -0,0 +1,40 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <time.h>
#include <sys/time.h>
void
sig(int s)
{
fprintf(stderr, "signal hanlder is called\n");
}
int
main(int argc, char **argv)
{
struct sigaction act;
int fds[2];
char c;
int rc;
memset(&act, '\0', sizeof act);
act.sa_handler = sig;
sigaction(SIGALRM, &act, NULL);
alarm(3);
pipe(fds);
rc = read(fds[0], &c, 1);
if (rc != -1) {
fprintf(stderr, "CT3001 NG BAD read rc=%d\n", rc);
exit(1);
}
if (errno != EINTR) {
fprintf(stderr, "CT3001 NG BAD error errno=%d\n", errno);
exit(1);
}
fprintf(stderr, "CT3001 OK\n");
exit(0);
}

View File

@@ -0,0 +1,3 @@
#!/bin/sh
MCEXEC=mcexec
$MCEXEC ./CT3001

View File

@@ -0,0 +1,54 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <fcntl.h>
#include <time.h>
#include <sys/time.h>
#define FILESIZE (2L * 1024 * 1024 * 1024)
int sigcalled = 0;
void
sig(int s)
{
sigcalled = 1;
fprintf(stderr, "signal hanlder is called\n");
}
int
main(int argc, char **argv)
{
struct sigaction act;
char *buf;
long rc;
long l;
long r;
int fd;
buf = malloc(FILESIZE);
fd = open("testfile", O_RDONLY);
if (fd == -1) {
fprintf(stderr, "Could not open file\n");
unlink("testfile");
exit(1);
}
memset(&act, '\0', sizeof act);
act.sa_handler = sig;
sigaction(SIGALRM, &act, NULL);
alarm(1);
rc = read(fd, buf, FILESIZE);
if (rc == -1) {
fprintf(stderr, "CT3002 NG BAD read rc=%ld errno=%d\n", rc, errno);
exit(1);
}
if (sigcalled == 0) {
fprintf(stderr, "CT3002 NG signal handler was not called\n");
exit(1);
}
fprintf(stderr, "CT3002 OK\n");
exit(0);
}

View File

@@ -0,0 +1,7 @@
#!/bin/sh
MCEXEC=mcexec
dd if=/dev/zero of=testfile bs=$((1024 * 1024)) count=$((2 * 1024))
sync
sudo /sbin/sysctl vm.drop_caches=3
$MCEXEC ./CT3002
rm -f testfile

View File

@@ -0,0 +1,51 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <time.h>
#include <sys/time.h>
#include <sys/wait.h>
void
child()
{
struct sigaction act;
int fds[2];
char c;
int rc;
alarm(3);
pipe(fds);
rc = read(fds[0], &c, 1);
}
int
main(int argc, char **argv)
{
pid_t pid;
int st;
int rc;
pid = fork();
if (pid == 0) {
child();
exit(1);
}
while ((rc = waitpid(pid, &st, 0)) == -1 && errno == EINTR);
if (rc != pid) {
fprintf(stderr, "CT3003 NG BAD wait rc=%d errno=%d\n", rc, errno);
exit(1);
}
if (!WIFSIGNALED(st)) {
fprintf(stderr, "CT3003 NG no signaled st=%08x\n", st);
exit(1);
}
if (WTERMSIG(st) != SIGALRM) {
fprintf(stderr, "CT3003 NG BAD signal sig=%d\n", WTERMSIG(st));
exit(1);
}
fprintf(stderr, "CT3003 OK\n");
exit(0);
}

View File

@@ -0,0 +1,3 @@
#!/bin/sh
MCEXEC=mcexec
$MCEXEC ./CT3003

View File

@@ -0,0 +1,62 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <fcntl.h>
#include <time.h>
#include <sys/time.h>
#include <sys/wait.h>
#define FILESIZE (2L * 1024 * 1024 * 1024)
void
child()
{
char *buf;
long rc;
long l;
long r;
int fd;
buf = malloc(FILESIZE);
fd = open("testfile", O_RDONLY);
if (fd == -1) {
fprintf(stderr, "Could not open file\n");
unlink("testfile");
exit(1);
}
alarm(1);
rc = read(fd, buf, FILESIZE);
}
int
main(int argc, char **argv)
{
pid_t pid;
int st;
int rc;
pid = fork();
if (pid == 0) {
child();
exit(1);
}
while ((rc = waitpid(pid, &st, 0)) == -1 && errno == EINTR);
if (rc != pid) {
fprintf(stderr, "CT3004 NG BAD wait rc=%d errno=%d\n", rc, errno);
exit(1);
}
if (!WIFSIGNALED(st)) {
fprintf(stderr, "CT3004 NG no signaled st=%08x\n", st);
exit(1);
}
if (WTERMSIG(st) != SIGALRM) {
fprintf(stderr, "CT3004 NG BAD signal sig=%d\n", WTERMSIG(st));
exit(1);
}
fprintf(stderr, "CT3004 OK\n");
exit(0);
}

View File

@@ -0,0 +1,7 @@
#!/bin/sh
MCEXEC=mcexec
dd if=/dev/zero of=testfile bs=$((1024 * 1024)) count=$((2 * 1024))
sync
sudo /sbin/sysctl vm.drop_caches=3
$MCEXEC ./CT3004
rm -f testfile

View File

@@ -0,0 +1,70 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <time.h>
#include <sys/time.h>
#include <sys/wait.h>
pid_t pid;
void
sig(int s)
{
static int cnt = 0;
cnt++;
if (cnt == 1) {
fprintf(stderr, "kill SIGURG\n");
kill(pid, SIGURG);
}
else if (cnt == 2) {
fprintf(stderr, "kill SIGINT\n");
kill(pid, SIGINT);
}
alarm(2);
}
void
child()
{
struct sigaction act;
int fds[2];
char c;
int rc;
pipe(fds);
rc = read(fds[0], &c, 1);
}
int
main(int argc, char **argv)
{
int st;
int rc;
pid = fork();
if (pid == 0) {
child();
exit(1);
}
signal(SIGALRM, sig);
alarm(2);
while ((rc = waitpid(pid, &st, 0)) == -1 && errno == EINTR);
if (rc != pid) {
fprintf(stderr, "CT3005 NG BAD wait rc=%d errno=%d\n", rc, errno);
exit(1);
}
if (!WIFSIGNALED(st)) {
fprintf(stderr, "CT3005 NG no signaled st=%08x\n", st);
exit(1);
}
if (WTERMSIG(st) != SIGINT) {
fprintf(stderr, "CT3005 NG BAD signal sig=%d\n", WTERMSIG(st));
exit(1);
}
fprintf(stderr, "CT3005 OK\n");
exit(0);
}

View File

@@ -0,0 +1,3 @@
#!/bin/sh
MCEXEC=mcexec
$MCEXEC ./CT3005

View File

@@ -0,0 +1,75 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <fcntl.h>
#include <time.h>
#include <sys/time.h>
#include <sys/wait.h>
#define FILESIZE (2L * 1024 * 1024 * 1024)
pid_t pid;
void
sig(int s)
{
fprintf(stderr, "kill SIGURG\n");
kill(pid, SIGURG);
}
void
child()
{
char *buf;
long rc;
long l;
long r;
int fd;
buf = malloc(FILESIZE);
fd = open("testfile", O_RDONLY);
if (fd == -1) {
fprintf(stderr, "Could not open file\n");
unlink("testfile");
exit(1);
}
rc = read(fd, buf, FILESIZE);
}
int
main(int argc, char **argv)
{
int st;
int rc;
pid = fork();
if (pid == 0) {
child();
exit(99);
}
signal(SIGALRM, sig);
alarm(2);
while ((rc = waitpid(pid, &st, 0)) == -1 && errno == EINTR);
if (rc != pid) {
fprintf(stderr, "CT3006 NG BAD wait rc=%d errno=%d\n", rc, errno);
exit(1);
}
if (WIFSIGNALED(st)) {
fprintf(stderr, "CT3006 NG BAD signal st=%08x\n", st);
exit(1);
}
if (!WIFEXITED(st)) {
fprintf(stderr, "CT3006 NG BAD terminated st=%08x\n", st);
exit(1);
}
if (WEXITSTATUS(st) != 99) {
fprintf(stderr, "CT3006 NG BAD exit status st=%08x\n", st);
exit(1);
}
fprintf(stderr, "CT3006 OK\n");
exit(0);
}

View File

@@ -0,0 +1,7 @@
#!/bin/sh
MCEXEC=mcexec
dd if=/dev/zero of=testfile bs=$((1024 * 1024)) count=$((2 * 1024))
sync
sudo /sbin/sysctl vm.drop_caches=3
$MCEXEC ./CT3006
rm -f testfile

View File

@@ -0,0 +1,71 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <time.h>
#include <sys/time.h>
#include <sys/wait.h>
pid_t pid;
void
sig(int s)
{
static int cnt = 0;
cnt++;
if (cnt == 1) {
fprintf(stderr, "kill SIGTERM (ignored)\n");
kill(pid, SIGTERM);
}
else if (cnt == 2) {
fprintf(stderr, "kill SIGINT\n");
kill(pid, SIGINT);
}
alarm(2);
}
void
child()
{
struct sigaction act;
int fds[2];
char c;
int rc;
pipe(fds);
rc = read(fds[0], &c, 1);
}
int
main(int argc, char **argv)
{
int st;
int rc;
pid = fork();
if (pid == 0) {
signal(SIGTERM, SIG_IGN);
child();
exit(1);
}
signal(SIGALRM, sig);
alarm(2);
while ((rc = waitpid(pid, &st, 0)) == -1 && errno == EINTR);
if (rc != pid) {
fprintf(stderr, "CT3007 NG BAD wait rc=%d errno=%d\n", rc, errno);
exit(1);
}
if (!WIFSIGNALED(st)) {
fprintf(stderr, "CT3007 NG no signaled st=%08x\n", st);
exit(1);
}
if (WTERMSIG(st) != SIGINT) {
fprintf(stderr, "CT3007 NG BAD signal sig=%d\n", WTERMSIG(st));
exit(1);
}
fprintf(stderr, "CT3007 OK\n");
exit(0);
}

View File

@@ -0,0 +1,3 @@
#!/bin/sh
MCEXEC=mcexec
$MCEXEC ./CT3007

View File

@@ -0,0 +1,76 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <fcntl.h>
#include <time.h>
#include <sys/time.h>
#include <sys/wait.h>
#define FILESIZE (2L * 1024 * 1024 * 1024)
pid_t pid;
void
sig(int s)
{
fprintf(stderr, "kill SIGTERM (ignored)\n");
kill(pid, SIGURG);
}
void
child()
{
char *buf;
long rc;
long l;
long r;
int fd;
buf = malloc(FILESIZE);
fd = open("testfile", O_RDONLY);
if (fd == -1) {
fprintf(stderr, "Could not open file\n");
unlink("testfile");
exit(1);
}
rc = read(fd, buf, FILESIZE);
}
int
main(int argc, char **argv)
{
int st;
int rc;
pid = fork();
if (pid == 0) {
signal(SIGTERM, SIG_IGN);
child();
exit(99);
}
signal(SIGALRM, sig);
alarm(2);
while ((rc = waitpid(pid, &st, 0)) == -1 && errno == EINTR);
if (rc != pid) {
fprintf(stderr, "CT3008 NG BAD wait rc=%d errno=%d\n", rc, errno);
exit(1);
}
if (WIFSIGNALED(st)) {
fprintf(stderr, "CT3008 NG BAD signal st=%08x\n", st);
exit(1);
}
if (!WIFEXITED(st)) {
fprintf(stderr, "CT3008 NG BAD terminated st=%08x\n", st);
exit(1);
}
if (WEXITSTATUS(st) != 99) {
fprintf(stderr, "CT3008 NG BAD exit status st=%08x\n", st);
exit(1);
}
fprintf(stderr, "CT3008 OK\n");
exit(0);
}

View File

@@ -0,0 +1,7 @@
#!/bin/sh
MCEXEC=mcexec
dd if=/dev/zero of=testfile bs=$((1024 * 1024)) count=$((2 * 1024))
sync
sudo /sbin/sysctl vm.drop_caches=3
$MCEXEC ./CT3008
rm -f testfile

View File

@@ -0,0 +1,12 @@
#!/bin/sh
MCKERNEL_DIR=/home/shirasawa/wallaby11-smp-x86/development/mic
export PATH=$MCKERNEL_DIR/bin:$PATH
./CT3001.sh
./CT3002.sh
./CT3003.sh
./CT3004.sh
./CT3005.sh
./CT3006.sh
./CT3007.sh
./CT3008.sh

View File

@@ -0,0 +1,40 @@
スクリプトは Mon Feb 5 16:00:07 2018
に開始しました[?1034hbash-4.2$ make test
./CT300x.sh
signal hanlder is called
CT3001 OK
2048+0 レコード入力
2048+0 レコード出力
2147483648 バイト (2.1 GB) コピーされました、 19.5651 秒、 110 MB/秒
vm.drop_caches = 3
signal hanlder is called
CT3002 OK
CT3003 OK
2048+0 レコード入力
2048+0 レコード出力
2147483648 バイト (2.1 GB) コピーされました、 19.5383 秒、 110 MB/秒
vm.drop_caches = 3
CT3004 OK
kill SIGURG
kill SIGINT
CT3005 OK
2048+0 レコード入力
2048+0 レコード出力
2147483648 バイト (2.1 GB) コピーされました、 19.5148 秒、 110 MB/秒
vm.drop_caches = 3
kill SIGURG
CT3006 OK
kill SIGTERM (ignored)
kill SIGINT
CT3007 OK
2048+0 レコード入力
2048+0 レコード出力
2147483648 バイト (2.1 GB) コピーされました、 19.5614 秒、 110 MB/秒
vm.drop_caches = 3
kill SIGTERM (ignored)
CT3008 OK
bash-4.2$ exit
exit
スクリプトは Mon Feb 5 16:03:02 2018
に終了しました

View File

@@ -0,0 +1,33 @@
CC=gcc
TARGET=CT3001 CT3002 CT3003 CT3004 CT3005 CT3006 CT3007 CT3008
all:: $(TARGET)
CT3001: CT3001.c
$(CC) -o CT3001 $<
CT3002: CT3002.c
$(CC) -o CT3002 $<
CT3003: CT3003.c
$(CC) -o CT3003 $<
CT3004: CT3004.c
$(CC) -o CT3004 $<
CT3005: CT3005.c
$(CC) -o CT3005 $<
CT3006: CT3006.c
$(CC) -o CT3006 $<
CT3007: CT3007.c
$(CC) -o CT3007 $<
CT3008: CT3008.c
$(CC) -o CT3008 $<
test:: $(TARGET)
./CT300x.sh
clean::
rm -f $(TARGET)

View File

@@ -0,0 +1,32 @@
【Issue#863 動作確認】
1. Issue#863および、同件のIssue#870で指摘されたテストプログラムを用いて
現象が解消されていることを確認した。(2件)
実行結果(エビデンス)は以下の通り。
CT1001.txt Issue#863の指摘で使用されたテストプログラムの実行結果(OK 1件、NG 0件)
CT2001.txt Issue#870の指摘で使用されたテストプログラムの実行結果(OK 1件、NG 0件)
2. Issue#863の変更が既存シグナル機能に影響しないことを確認した。
確認内容は以下の通り。
CT3001 遅いI/Oシステムコール実行中にシグナルを受け、即座にシグナル
ハンドラが呼び出され、システムコールがEINTRを返却することを
確認する。
CT3002 遅くないI/Oシステムコール実行中にシグナルを受け、システム
コール完了後にシグナルハンドラが呼び出され、システムコール
が正常に終了することを確認する。
CT3003 遅いI/Oシステムコール実行中にプログラムを終了するシグナルを
受けとると、即座にプログラムが終了することを確認する。
CT3004 遅くないI/Oシステムコール実行中にプログラムを終了するシグナル
を受けとると、即座にプログラムを終了することを確認する。
CT3005 遅いI/Oシステムコール実行中にプログラムを終了しないシグナル(SIGURG)
を受けとっても、プログラムの実行に影響しないことを確認する。
CT3006 遅くないI/Oシステムコール実行中にプログラムを終了しないシグナル
(SIGURG)を受けとっても、プログラムの実行に影響しないことを確認する。
CT3007 遅いI/Oシステムコール実行中に無視(SIG_IGN)するシグナルを
受けとっても、プログラムの実行に影響しないことを確認する。
CT3008 遅くないI/Oシステムコール実行中に無視(SIG_IGN)するシグナルを
受けとっても、プログラムの実行に影響しないことを確認する。
CT300x の実行は、make test で行う。
エビデンスは CT300x.txt に示す。(OK 8件、NG 0件)