issue/863: add 8 testcases
This commit is contained in:
@ -17,7 +17,7 @@ void
|
||||
sig(int s)
|
||||
{
|
||||
fprintf(stderr, "kill SIGTERM (ignored)\n");
|
||||
kill(pid, SIGURG);
|
||||
kill(pid, SIGTERM);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@ -1,31 +1,31 @@
|
||||
スクリプトは Fri Mar 23 13:25:09 2018
|
||||
スクリプトは Fri Mar 23 14:44:56 2018
|
||||
に開始しました[?1034hbash-4.2$ make test
|
||||
./CT300x.sh
|
||||
13:25:13.087171 test start, kill after 3 seconds
|
||||
13:25:16.087626 signal hanlder is called
|
||||
14:44:59.479215 test start, kill after 3 seconds
|
||||
14:45:02.479661 signal hanlder is called
|
||||
CT3001 OK
|
||||
2048+0 レコード入力
|
||||
2048+0 レコード出力
|
||||
2147483648 バイト (2.1 GB) コピーされました、 19.5143 秒、 110 MB/秒
|
||||
2147483648 バイト (2.1 GB) コピーされました、 19.5222 秒、 110 MB/秒
|
||||
vm.drop_caches = 3
|
||||
signal hanlder is called
|
||||
CT3002 OK
|
||||
13:26:00.218056 test start, kill after 3 seconds
|
||||
13:26:03.230253 child process terminated
|
||||
14:45:46.852481 test start, kill after 3 seconds
|
||||
14:45:49.866473 child process terminated
|
||||
CT3003 OK
|
||||
2048+0 レコード入力
|
||||
2048+0 レコード出力
|
||||
2147483648 バイト (2.1 GB) コピーされました、 19.5203 秒、 110 MB/秒
|
||||
2147483648 バイト (2.1 GB) コピーされました、 19.513 秒、 110 MB/秒
|
||||
vm.drop_caches = 3
|
||||
13:26:23.478328 test start, kill after 1 seconds
|
||||
13:26:24.836362 child process terminated
|
||||
14:46:09.750053 test start, kill after 1 seconds
|
||||
14:46:11.100485 child process terminated
|
||||
CT3004 OK
|
||||
kill SIGURG
|
||||
kill SIGINT
|
||||
CT3005 OK
|
||||
2048+0 レコード入力
|
||||
2048+0 レコード出力
|
||||
2147483648 バイト (2.1 GB) コピーされました、 19.4966 秒、 110 MB/秒
|
||||
2147483648 バイト (2.1 GB) コピーされました、 19.5075 秒、 110 MB/秒
|
||||
vm.drop_caches = 3
|
||||
kill SIGURG
|
||||
CT3006 OK
|
||||
@ -34,12 +34,12 @@ kill SIGINT
|
||||
CT3007 OK
|
||||
2048+0 レコード入力
|
||||
2048+0 レコード出力
|
||||
2147483648 バイト (2.1 GB) コピーされました、 19.4999 秒、 110 MB/秒
|
||||
2147483648 バイト (2.1 GB) コピーされました、 19.5217 秒、 110 MB/秒
|
||||
vm.drop_caches = 3
|
||||
kill SIGTERM (ignored)
|
||||
CT3008 OK
|
||||
bash-4.2$ exit
|
||||
exit
|
||||
|
||||
スクリプトは Fri Mar 23 13:28:04 2018
|
||||
スクリプトは Fri Mar 23 14:48:02 2018
|
||||
に終了しました
|
||||
97
test/mng_mod/issues/863/CT4000.c
Normal file
97
test/mng_mod/issues/863/CT4000.c
Normal file
@ -0,0 +1,97 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
|
||||
int
|
||||
readline(int fd, char *buf)
|
||||
{
|
||||
int r;
|
||||
int rc = 0;
|
||||
|
||||
while ((r = read(fd, buf, 1)) == 1) {
|
||||
rc++;
|
||||
if (*buf == '\n')
|
||||
break;
|
||||
buf++;
|
||||
}
|
||||
if (r == -1) {
|
||||
perror("read");
|
||||
exit(1);
|
||||
}
|
||||
if (!rc) {
|
||||
fprintf(stderr, "CT400x read: BAD EOF\n");
|
||||
exit(1);
|
||||
}
|
||||
*buf = '\0';
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int fds[2];
|
||||
pid_t mcexec;
|
||||
struct stat sb;
|
||||
char line[80];
|
||||
char *m;
|
||||
int rc;
|
||||
int t;
|
||||
int p;
|
||||
int s;
|
||||
int st;
|
||||
|
||||
if (syscall(732) != -1) {
|
||||
fprintf(stderr, "run under Linux!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (stat(argv[1], &sb) == -1) {
|
||||
fprintf(stderr, "no %s found\n", argv[1]);
|
||||
exit(1);
|
||||
}
|
||||
if (pipe(fds) == -1) {
|
||||
perror("pipe");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ((mcexec = fork()) == 0) {
|
||||
char param[10];
|
||||
char *args[4];
|
||||
|
||||
close(fds[0]);
|
||||
args[0] = "mcexec";
|
||||
args[1] = argv[1];
|
||||
sprintf(param, "%d", fds[1]);
|
||||
args[2] = param;
|
||||
args[3] = NULL;
|
||||
if (stat("mcexec", &sb) == -1) {
|
||||
execvp("mcexec", args);
|
||||
}
|
||||
else {
|
||||
execv("./mcexec", args);
|
||||
}
|
||||
perror("execvp");
|
||||
exit(1);
|
||||
}
|
||||
if (mcexec == -1) {
|
||||
perror("fork");
|
||||
exit(1);
|
||||
}
|
||||
close(fds[1]);
|
||||
|
||||
readline(fds[0], line);
|
||||
sscanf(line, "%d %d %d", &t, &p, &s);
|
||||
|
||||
sleep(t);
|
||||
kill(p, s);
|
||||
|
||||
while(waitpid(mcexec, &st, 0) == -1 && errno == EINTR);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
77
test/mng_mod/issues/863/CT4001.c
Normal file
77
test/mng_mod/issues/863/CT4001.c
Normal file
@ -0,0 +1,77 @@
|
||||
#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>
|
||||
|
||||
char *
|
||||
gettime(char *buf, struct timeval *tv)
|
||||
{
|
||||
struct tm *tm;
|
||||
|
||||
gettimeofday(tv, NULL);
|
||||
tm = localtime(&tv->tv_sec);
|
||||
sprintf(buf, "%02d:%02d:%02d.%06d", tm->tm_hour, tm->tm_min, tm->tm_sec, tv->tv_usec);
|
||||
return buf;
|
||||
}
|
||||
|
||||
void
|
||||
tv_sub(struct timeval *tv1, const struct timeval *tv2)
|
||||
{
|
||||
tv1->tv_sec -= tv2->tv_sec;
|
||||
tv1->tv_usec -= tv2->tv_usec;
|
||||
if (tv1->tv_usec < 0) {
|
||||
tv1->tv_sec--;
|
||||
tv1->tv_usec += 1000000;
|
||||
}
|
||||
}
|
||||
|
||||
struct timeval tv1;
|
||||
struct timeval tv2;
|
||||
int fd;
|
||||
|
||||
void
|
||||
sig(int s)
|
||||
{
|
||||
char buf[16];
|
||||
|
||||
fprintf(stderr, "%s signal hanlder is called\n", gettime(buf, &tv2));
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
struct sigaction act;
|
||||
int fds[2];
|
||||
char c;
|
||||
int rc;
|
||||
char buf[16];
|
||||
char line[80];
|
||||
|
||||
fd = atoi(argv[1]);
|
||||
memset(&act, '\0', sizeof act);
|
||||
act.sa_handler = sig;
|
||||
sigaction(SIGALRM, &act, NULL);
|
||||
fprintf(stderr, "%s test start, kill after 3 seconds\n", gettime(buf, &tv1));
|
||||
sprintf(line, "%d %d %d\n", 3, getpid(), SIGALRM);
|
||||
write(fd, line, strlen(line));
|
||||
pipe(fds);
|
||||
rc = read(fds[0], &c, 1);
|
||||
if (rc != -1) {
|
||||
fprintf(stderr, "CT4001 NG BAD read rc=%d\n", rc);
|
||||
exit(1);
|
||||
}
|
||||
if (errno != EINTR) {
|
||||
fprintf(stderr, "CT4001 NG BAD error errno=%d\n", errno);
|
||||
exit(1);
|
||||
}
|
||||
tv_sub(&tv2, &tv1);
|
||||
if (tv2.tv_sec != 3)
|
||||
fprintf(stderr, "CT4001 NG signal delayed (%d.%06d)\n", tv2.tv_sec, tv2.tv_usec);
|
||||
else
|
||||
fprintf(stderr, "CT4001 OK\n");
|
||||
exit(0);
|
||||
}
|
||||
3
test/mng_mod/issues/863/CT4001.sh
Executable file
3
test/mng_mod/issues/863/CT4001.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
MCEXEC=mcexec
|
||||
./CT4000 ./CT4001
|
||||
58
test/mng_mod/issues/863/CT4002.c
Normal file
58
test/mng_mod/issues/863/CT4002.c
Normal file
@ -0,0 +1,58 @@
|
||||
#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;
|
||||
int ofd;
|
||||
char line[80];
|
||||
|
||||
fd = atoi(argv[1]);
|
||||
buf = malloc(FILESIZE);
|
||||
ofd = open("testfile", O_RDONLY);
|
||||
if (ofd == -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);
|
||||
sprintf(line, "%d %d %d\n", 1, getpid(), SIGALRM);
|
||||
write(fd, line, strlen(line));
|
||||
rc = read(ofd, buf, FILESIZE);
|
||||
if (rc == -1) {
|
||||
fprintf(stderr, "CT4002 NG BAD read rc=%ld errno=%d\n", rc, errno);
|
||||
exit(1);
|
||||
}
|
||||
if (sigcalled == 0) {
|
||||
fprintf(stderr, "CT4002 NG signal handler was not called\n");
|
||||
exit(1);
|
||||
}
|
||||
fprintf(stderr, "CT4002 OK\n");
|
||||
exit(0);
|
||||
}
|
||||
7
test/mng_mod/issues/863/CT4002.sh
Executable file
7
test/mng_mod/issues/863/CT4002.sh
Executable 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
|
||||
./CT4000 ./CT4002
|
||||
rm -f testfile
|
||||
87
test/mng_mod/issues/863/CT4003.c
Normal file
87
test/mng_mod/issues/863/CT4003.c
Normal file
@ -0,0 +1,87 @@
|
||||
#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>
|
||||
|
||||
char *
|
||||
gettime(char *buf, struct timeval *tv)
|
||||
{
|
||||
struct tm *tm;
|
||||
|
||||
gettimeofday(tv, NULL);
|
||||
tm = localtime(&tv->tv_sec);
|
||||
sprintf(buf, "%02d:%02d:%02d.%06d", tm->tm_hour, tm->tm_min, tm->tm_sec, tv->tv_usec);
|
||||
return buf;
|
||||
}
|
||||
|
||||
void
|
||||
tv_sub(struct timeval *tv1, const struct timeval *tv2)
|
||||
{
|
||||
tv1->tv_sec -= tv2->tv_sec;
|
||||
tv1->tv_usec -= tv2->tv_usec;
|
||||
if (tv1->tv_usec < 0) {
|
||||
tv1->tv_sec--;
|
||||
tv1->tv_usec += 1000000;
|
||||
}
|
||||
}
|
||||
|
||||
struct timeval tv1;
|
||||
struct timeval tv2;
|
||||
int fd;
|
||||
|
||||
void
|
||||
child()
|
||||
{
|
||||
struct sigaction act;
|
||||
int fds[2];
|
||||
char c;
|
||||
int rc;
|
||||
char line[80];
|
||||
|
||||
sprintf(line, "%d %d %d\n", 3, getpid(), SIGALRM);
|
||||
write(fd, line, strlen(line));
|
||||
pipe(fds);
|
||||
rc = read(fds[0], &c, 1);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
pid_t pid;
|
||||
int st;
|
||||
int rc;
|
||||
char buf[16];
|
||||
|
||||
fd = atoi(argv[1]);
|
||||
fprintf(stderr, "%s test start, kill after 3 seconds\n", gettime(buf, &tv1));
|
||||
pid = fork();
|
||||
if (pid == 0) {
|
||||
child();
|
||||
exit(1);
|
||||
}
|
||||
while ((rc = waitpid(pid, &st, 0)) == -1 && errno == EINTR);
|
||||
fprintf(stderr, "%s child process terminated\n", gettime(buf, &tv2));
|
||||
if (rc != pid) {
|
||||
fprintf(stderr, "CT4003 NG BAD wait rc=%d errno=%d\n", rc, errno);
|
||||
exit(1);
|
||||
}
|
||||
if (!WIFSIGNALED(st)) {
|
||||
fprintf(stderr, "CT4003 NG no signaled st=%08x\n", st);
|
||||
exit(1);
|
||||
}
|
||||
if (WTERMSIG(st) != SIGALRM) {
|
||||
fprintf(stderr, "CT4003 NG BAD signal sig=%d\n", WTERMSIG(st));
|
||||
exit(1);
|
||||
}
|
||||
tv_sub(&tv2, &tv1);
|
||||
if (tv2.tv_sec != 3)
|
||||
fprintf(stderr, "CT4003 NG signal delayed (%d.%06d)\n", tv2.tv_sec, tv2.tv_usec);
|
||||
else
|
||||
fprintf(stderr, "CT4003 OK\n");
|
||||
exit(0);
|
||||
}
|
||||
3
test/mng_mod/issues/863/CT4003.sh
Executable file
3
test/mng_mod/issues/863/CT4003.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
MCEXEC=mcexec
|
||||
./CT4000 ./CT4003
|
||||
98
test/mng_mod/issues/863/CT4004.c
Normal file
98
test/mng_mod/issues/863/CT4004.c
Normal file
@ -0,0 +1,98 @@
|
||||
#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)
|
||||
|
||||
char *
|
||||
gettime(char *buf, struct timeval *tv)
|
||||
{
|
||||
struct tm *tm;
|
||||
|
||||
gettimeofday(tv, NULL);
|
||||
tm = localtime(&tv->tv_sec);
|
||||
sprintf(buf, "%02d:%02d:%02d.%06d", tm->tm_hour, tm->tm_min, tm->tm_sec, tv->tv_usec);
|
||||
return buf;
|
||||
}
|
||||
|
||||
void
|
||||
tv_sub(struct timeval *tv1, const struct timeval *tv2)
|
||||
{
|
||||
tv1->tv_sec -= tv2->tv_sec;
|
||||
tv1->tv_usec -= tv2->tv_usec;
|
||||
if (tv1->tv_usec < 0) {
|
||||
tv1->tv_sec--;
|
||||
tv1->tv_usec += 1000000;
|
||||
}
|
||||
}
|
||||
|
||||
struct timeval tv1;
|
||||
struct timeval tv2;
|
||||
int fd;
|
||||
|
||||
void
|
||||
child()
|
||||
{
|
||||
char *buf;
|
||||
long rc;
|
||||
long l;
|
||||
long r;
|
||||
int ofd;
|
||||
char line[80];
|
||||
|
||||
buf = malloc(FILESIZE);
|
||||
ofd = open("testfile", O_RDONLY);
|
||||
if (ofd == -1) {
|
||||
fprintf(stderr, "Could not open file\n");
|
||||
unlink("testfile");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
sprintf(line, "%d %d %d\n", 1, getpid(), SIGALRM);
|
||||
write(fd, line, strlen(line));
|
||||
rc = read(ofd, buf, FILESIZE);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
pid_t pid;
|
||||
int st;
|
||||
int rc;
|
||||
char buf[16];
|
||||
|
||||
fd = atoi(argv[1]);
|
||||
fprintf(stderr, "%s test start, kill after 1 seconds\n", gettime(buf, &tv1));
|
||||
pid = fork();
|
||||
if (pid == 0) {
|
||||
child();
|
||||
exit(1);
|
||||
}
|
||||
while ((rc = waitpid(pid, &st, 0)) == -1 && errno == EINTR);
|
||||
fprintf(stderr, "%s child process terminated\n", gettime(buf, &tv2));
|
||||
if (rc != pid) {
|
||||
fprintf(stderr, "CT4004 NG BAD wait rc=%d errno=%d\n", rc, errno);
|
||||
exit(1);
|
||||
}
|
||||
if (!WIFSIGNALED(st)) {
|
||||
fprintf(stderr, "CT4004 NG no signaled st=%08x\n", st);
|
||||
exit(1);
|
||||
}
|
||||
if (WTERMSIG(st) != SIGALRM) {
|
||||
fprintf(stderr, "CT4004 NG BAD signal sig=%d\n", WTERMSIG(st));
|
||||
exit(1);
|
||||
}
|
||||
tv_sub(&tv2, &tv1);
|
||||
if (tv2.tv_sec != 1)
|
||||
fprintf(stderr, "CT4004 OK (%d.%06d)\n", tv2.tv_sec, tv2.tv_usec);
|
||||
else
|
||||
fprintf(stderr, "CT4004 OK\n");
|
||||
exit(0);
|
||||
}
|
||||
7
test/mng_mod/issues/863/CT4004.sh
Executable file
7
test/mng_mod/issues/863/CT4004.sh
Executable 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
|
||||
./CT4000 ./CT4004
|
||||
rm -f testfile
|
||||
74
test/mng_mod/issues/863/CT4005.c
Normal file
74
test/mng_mod/issues/863/CT4005.c
Normal file
@ -0,0 +1,74 @@
|
||||
#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;
|
||||
int fd;
|
||||
|
||||
void
|
||||
sig(int s)
|
||||
{
|
||||
static int cnt = 0;
|
||||
char line[80];
|
||||
|
||||
cnt++;
|
||||
if (cnt == 1) {
|
||||
fprintf(stderr, "kill SIGURG\n");
|
||||
sprintf(line, "%d %d %d\n", 0, pid, SIGURG);
|
||||
write(fd, line, strlen(line));
|
||||
}
|
||||
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;
|
||||
|
||||
fd = atoi(argv[1]);
|
||||
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, "CT4005 NG BAD wait rc=%d errno=%d\n", rc, errno);
|
||||
exit(1);
|
||||
}
|
||||
if (!WIFSIGNALED(st)) {
|
||||
fprintf(stderr, "CT4005 NG no signaled st=%08x\n", st);
|
||||
exit(1);
|
||||
}
|
||||
if (WTERMSIG(st) != SIGINT) {
|
||||
fprintf(stderr, "CT4005 NG BAD signal sig=%d\n", WTERMSIG(st));
|
||||
exit(1);
|
||||
}
|
||||
fprintf(stderr, "CT4005 OK\n");
|
||||
exit(0);
|
||||
}
|
||||
3
test/mng_mod/issues/863/CT4005.sh
Executable file
3
test/mng_mod/issues/863/CT4005.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
MCEXEC=mcexec
|
||||
./CT4000 ./CT4005
|
||||
80
test/mng_mod/issues/863/CT4006.c
Normal file
80
test/mng_mod/issues/863/CT4006.c
Normal file
@ -0,0 +1,80 @@
|
||||
#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;
|
||||
int fd;
|
||||
|
||||
void
|
||||
sig(int s)
|
||||
{
|
||||
char line[80];
|
||||
|
||||
fprintf(stderr, "kill SIGURG\n");
|
||||
sprintf(line, "%d %d %d\n", 0, pid, SIGURG);
|
||||
write(fd, line, strlen(line));
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
fd = atoi(argv[1]);
|
||||
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, "CT4006 NG BAD wait rc=%d errno=%d\n", rc, errno);
|
||||
exit(1);
|
||||
}
|
||||
if (WIFSIGNALED(st)) {
|
||||
fprintf(stderr, "CT4006 NG BAD signal st=%08x\n", st);
|
||||
exit(1);
|
||||
}
|
||||
if (!WIFEXITED(st)) {
|
||||
fprintf(stderr, "CT4006 NG BAD terminated st=%08x\n", st);
|
||||
exit(1);
|
||||
}
|
||||
if (WEXITSTATUS(st) != 99) {
|
||||
fprintf(stderr, "CT4006 NG BAD exit status st=%08x\n", st);
|
||||
exit(1);
|
||||
}
|
||||
fprintf(stderr, "CT4006 OK\n");
|
||||
exit(0);
|
||||
}
|
||||
7
test/mng_mod/issues/863/CT4006.sh
Executable file
7
test/mng_mod/issues/863/CT4006.sh
Executable 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
|
||||
./CT4000 ./CT4006
|
||||
rm -f testfile
|
||||
76
test/mng_mod/issues/863/CT4007.c
Normal file
76
test/mng_mod/issues/863/CT4007.c
Normal file
@ -0,0 +1,76 @@
|
||||
#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;
|
||||
int fd;
|
||||
|
||||
void
|
||||
sig(int s)
|
||||
{
|
||||
static int cnt = 0;
|
||||
|
||||
cnt++;
|
||||
if (cnt == 1) {
|
||||
char line[80];
|
||||
|
||||
fprintf(stderr, "kill SIGTERM (ignored)\n");
|
||||
sprintf(line, "%d %d %d\n", 0, pid, SIGTERM);
|
||||
write(fd, line, strlen(line));
|
||||
}
|
||||
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;
|
||||
|
||||
fd = atoi(argv[1]);
|
||||
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, "CT4007 NG BAD wait rc=%d errno=%d\n", rc, errno);
|
||||
exit(1);
|
||||
}
|
||||
if (!WIFSIGNALED(st)) {
|
||||
fprintf(stderr, "CT4007 NG no signaled st=%08x\n", st);
|
||||
exit(1);
|
||||
}
|
||||
if (WTERMSIG(st) != SIGINT) {
|
||||
fprintf(stderr, "CT4007 NG BAD signal sig=%d\n", WTERMSIG(st));
|
||||
exit(1);
|
||||
}
|
||||
fprintf(stderr, "CT4007 OK\n");
|
||||
exit(0);
|
||||
}
|
||||
3
test/mng_mod/issues/863/CT4007.sh
Executable file
3
test/mng_mod/issues/863/CT4007.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
MCEXEC=mcexec
|
||||
./CT4000 ./CT4007
|
||||
80
test/mng_mod/issues/863/CT4008.c
Normal file
80
test/mng_mod/issues/863/CT4008.c
Normal file
@ -0,0 +1,80 @@
|
||||
#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;
|
||||
int fd;
|
||||
|
||||
void
|
||||
sig(int s)
|
||||
{
|
||||
char line[80];
|
||||
fprintf(stderr, "kill SIGTERM (ignored)\n");
|
||||
sprintf(line, "%d %d %d\n", 0, pid, SIGTERM);
|
||||
write(fd, line, strlen(line));
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
fd = atoi(argv[1]);
|
||||
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, "CT4008 NG BAD wait rc=%d errno=%d\n", rc, errno);
|
||||
exit(1);
|
||||
}
|
||||
if (WIFSIGNALED(st)) {
|
||||
fprintf(stderr, "CT4008 NG BAD signal st=%08x\n", st);
|
||||
exit(1);
|
||||
}
|
||||
if (!WIFEXITED(st)) {
|
||||
fprintf(stderr, "CT4008 NG BAD terminated st=%08x\n", st);
|
||||
exit(1);
|
||||
}
|
||||
if (WEXITSTATUS(st) != 99) {
|
||||
fprintf(stderr, "CT4008 NG BAD exit status st=%08x\n", st);
|
||||
exit(1);
|
||||
}
|
||||
fprintf(stderr, "CT4008 OK\n");
|
||||
exit(0);
|
||||
}
|
||||
7
test/mng_mod/issues/863/CT4008.sh
Executable file
7
test/mng_mod/issues/863/CT4008.sh
Executable 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
|
||||
./CT4000 ./CT4008
|
||||
rm -f testfile
|
||||
12
test/mng_mod/issues/863/CT400x.sh
Executable file
12
test/mng_mod/issues/863/CT400x.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
MCKERNEL_DIR=/home/shirasawa/wallaby11-smp-x86/development/mic
|
||||
export PATH=$MCKERNEL_DIR/bin:$PATH
|
||||
|
||||
./CT4001.sh
|
||||
./CT4002.sh
|
||||
./CT4003.sh
|
||||
./CT4004.sh
|
||||
./CT4005.sh
|
||||
./CT4006.sh
|
||||
./CT4007.sh
|
||||
./CT4008.sh
|
||||
45
test/mng_mod/issues/863/CT400x.txt
Normal file
45
test/mng_mod/issues/863/CT400x.txt
Normal file
@ -0,0 +1,45 @@
|
||||
スクリプトは Fri Mar 23 14:34:24 2018
|
||||
に開始しました[?1034hbash-4.2$ make test2
|
||||
./CT400x.sh
|
||||
14:34:27.063487 test start, kill after 3 seconds
|
||||
14:34:30.063982 signal hanlder is called
|
||||
CT4001 OK
|
||||
2048+0 レコード入力
|
||||
2048+0 レコード出力
|
||||
2147483648 バイト (2.1 GB) コピーされました、 19.4964 秒、 110 MB/秒
|
||||
vm.drop_caches = 3
|
||||
signal hanlder is called
|
||||
CT4002 OK
|
||||
14:35:14.331110 test start, kill after 3 seconds
|
||||
14:35:17.343787 child process terminated
|
||||
CT4003 OK
|
||||
2048+0 レコード入力
|
||||
2048+0 レコード出力
|
||||
2147483648 バイト (2.1 GB) コピーされました、 19.527 秒、 110 MB/秒
|
||||
vm.drop_caches = 3
|
||||
14:35:37.609699 test start, kill after 1 seconds
|
||||
14:35:38.967493 child process terminated
|
||||
CT4004 OK
|
||||
kill SIGURG
|
||||
kill SIGINT
|
||||
CT4005 OK
|
||||
2048+0 レコード入力
|
||||
2048+0 レコード出力
|
||||
2147483648 バイト (2.1 GB) コピーされました、 19.5092 秒、 110 MB/秒
|
||||
vm.drop_caches = 3
|
||||
kill SIGURG
|
||||
CT4006 OK
|
||||
kill SIGTERM (ignored)
|
||||
kill SIGINT
|
||||
CT4007 OK
|
||||
2048+0 レコード入力
|
||||
2048+0 レコード出力
|
||||
2147483648 バイト (2.1 GB) コピーされました、 19.508 秒、 110 MB/秒
|
||||
vm.drop_caches = 3
|
||||
kill SIGTERM (ignored)
|
||||
CT4008 OK
|
||||
bash-4.2$ exit
|
||||
exit
|
||||
|
||||
スクリプトは Fri Mar 23 14:37:18 2018
|
||||
に終了しました
|
||||
@ -1,5 +1,6 @@
|
||||
CC=gcc
|
||||
TARGET=CT3001 CT3002 CT3003 CT3004 CT3005 CT3006 CT3007 CT3008
|
||||
TARGET=CT3001 CT3002 CT3003 CT3004 CT3005 CT3006 CT3007 CT3008 \
|
||||
CT4001 CT4002 CT4003 CT4004 CT4005 CT4006 CT4007 CT4008 CT4000
|
||||
all:: $(TARGET)
|
||||
|
||||
CT3001: CT3001.c
|
||||
@ -26,8 +27,38 @@ CT3007: CT3007.c
|
||||
CT3008: CT3008.c
|
||||
$(CC) -o CT3008 $<
|
||||
|
||||
CT4000: CT4000.c
|
||||
$(CC) -o CT4000 $<
|
||||
|
||||
CT4001: CT4001.c
|
||||
$(CC) -o CT4001 $<
|
||||
|
||||
CT4002: CT4002.c
|
||||
$(CC) -o CT4002 $<
|
||||
|
||||
CT4003: CT4003.c
|
||||
$(CC) -o CT4003 $<
|
||||
|
||||
CT4004: CT4004.c
|
||||
$(CC) -o CT4004 $<
|
||||
|
||||
CT4005: CT4005.c
|
||||
$(CC) -o CT4005 $<
|
||||
|
||||
CT4006: CT4006.c
|
||||
$(CC) -o CT4006 $<
|
||||
|
||||
CT4007: CT4007.c
|
||||
$(CC) -o CT4007 $<
|
||||
|
||||
CT4008: CT4008.c
|
||||
$(CC) -o CT4008 $<
|
||||
|
||||
test:: $(TARGET)
|
||||
./CT300x.sh
|
||||
|
||||
test2:: $(TARGET)
|
||||
./CT400x.sh
|
||||
|
||||
clean::
|
||||
rm -f $(TARGET)
|
||||
|
||||
@ -13,7 +13,8 @@
|
||||
CT1001.txt Issue#863の指摘で使用されたテストプログラムの実行結果(OK 1件、NG 0件)
|
||||
CT2001.txt Issue#870の指摘で使用されたテストプログラムの実行結果(OK 1件、NG 0件)
|
||||
|
||||
2. Issue#863の変更が既存シグナル機能に影響しないことを確認した。
|
||||
2. Issue#863の変更が、McKernelプロセス間のシグナルに対する既存処理に
|
||||
影響しないことを確認した。
|
||||
確認内容は以下の通り。
|
||||
|
||||
CT3001 遅いI/Oシステムコール実行中にシグナルを受け、即座にシグナル
|
||||
@ -37,3 +38,29 @@ CT3008 遅くないI/Oシステムコール実行中に無視(SIG_IGN)するシ
|
||||
|
||||
CT300x の実行は、make test で行う。
|
||||
エビデンスは CT300x.txt に示す。(OK 8件、NG 0件)
|
||||
|
||||
3. Issue#863の変更が、Linuxからmcexec経由でMcKernelプロセスに届くシグナルの
|
||||
既存処理に影響しないことを確認した (Issue#870対応の確認)。
|
||||
確認内容は以下の通り。
|
||||
|
||||
CT4001 遅いI/Oシステムコール実行中にシグナルを受け、即座にシグナル
|
||||
ハンドラが呼び出され、システムコールがEINTRを返却することを
|
||||
確認する。
|
||||
CT4002 遅くないI/Oシステムコール実行中にシグナルを受け、システム
|
||||
コール完了後にシグナルハンドラが呼び出され、システムコール
|
||||
が正常に終了することを確認する。
|
||||
CT4003 遅いI/Oシステムコール実行中にプログラムを終了するシグナルを
|
||||
受けとると、即座にプログラムが終了することを確認する。
|
||||
CT4004 遅くないI/Oシステムコール実行中にプログラムを終了するシグナル
|
||||
を受けとると、即座にプログラムを終了することを確認する。
|
||||
CT4005 遅いI/Oシステムコール実行中にプログラムを終了しないシグナル(SIGURG)
|
||||
を受けとっても、プログラムの実行に影響しないことを確認する。
|
||||
CT4006 遅くないI/Oシステムコール実行中にプログラムを終了しないシグナル
|
||||
(SIGURG)を受けとっても、プログラムの実行に影響しないことを確認する。
|
||||
CT4007 遅いI/Oシステムコール実行中に無視(SIG_IGN)するシグナルを
|
||||
受けとっても、プログラムの実行に影響しないことを確認する。
|
||||
CT4008 遅くないI/Oシステムコール実行中に無視(SIG_IGN)するシグナルを
|
||||
受けとっても、プログラムの実行に影響しないことを確認する。
|
||||
|
||||
CT400x の実行は、make test2 で行う。
|
||||
エビデンスは CT400x.txt に示す。(OK 8件、NG 0件)
|
||||
|
||||
Reference in New Issue
Block a user