Test "signal: When the process receives a termination signal, it first terminates mcexec." on arm64

Change-Id: I1be32b991a45f0892146d93a9e6d6be9199faf59
Refs: #870
This commit is contained in:
Shiratori, Takehiro
2018-11-29 20:57:55 +09:00
committed by Masamichi Takagi
parent 556a64ac5e
commit b94247c478
43 changed files with 971 additions and 0 deletions

View File

@ -0,0 +1,4 @@
#!/bin/sh
## CT2001.sh COPYRIGHT FUJITSU LIMITED 2018 ##
./CT2000 ./CT2001

View File

@ -0,0 +1,6 @@
#!/bin/sh
## CT2002.sh COPYRIGHT FUJITSU LIMITED 2018 ##
sync
sudo /sbin/sysctl vm.drop_caches=3
./CT2000 ./CT2002

View File

@ -0,0 +1,4 @@
#!/bin/sh
## CT2003.sh COPYRIGHT FUJITSU LIMITED 2018 ##
./CT2000 ./CT2003

View File

@ -0,0 +1,6 @@
#!/bin/sh
## CT2004.sh COPYRIGHT FUJITSU LIMITED 2018 ##
sync
sudo /sbin/sysctl vm.drop_caches=3
./CT2000 ./CT2004

View File

@ -0,0 +1,4 @@
#!/bin/sh
## CT2005.sh COPYRIGHT FUJITSU LIMITED 2018 ##
./CT2000 ./CT2005

View File

@ -0,0 +1,6 @@
#!/bin/sh
## CT2006.sh COPYRIGHT FUJITSU LIMITED 2018 ##
sync
sudo /sbin/sysctl vm.drop_caches=3
./CT2000 ./CT2006

View File

@ -0,0 +1,4 @@
#!/bin/sh
## CT2007.sh COPYRIGHT FUJITSU LIMITED 2018 ##
./CT2000 ./CT2007

View File

@ -0,0 +1,6 @@
#!/bin/sh
## CT2008.sh COPYRIGHT FUJITSU LIMITED 2018 ##
sync
sudo /sbin/sysctl vm.drop_caches=3
./CT2000 ./CT2008

View File

@ -0,0 +1,33 @@
#!/bin/sh
## CT200x.sh COPYRIGHT FUJITSU LIMITED 2018 ##
USELTP=0
USEOSTEST=0
. ../../../../common.sh
STRESSBIN=
${STRESSBIN}/mck-mcexec.sh ${STRESSBIN}/killit -t 4000 ${STRESSBIN}/signalonread -nt 4 -nosignal
if [ $? == 0 ]; then
echo "CT1001-2: OK"
else
echo "CT1001-2: NG"
fi
exist=`ls -l | grep testfile | grep -c $((2 * 1024 * 1024 * 1024))`
if [ ${exist} == 0 ]; then
dd if=/dev/zero of=testfile bs=$((1024 * 1024)) count=$((2 * 1024))
sync
fi
export PATH=$BIN:$PATH
./CT2001.sh
./CT2002.sh
./CT2003.sh
./CT2004.sh
./CT2005.sh
./CT2006.sh
./CT2007.sh
./CT2008.sh

View File

@ -0,0 +1,72 @@
/* README COPYRIGHT FUJITSU LIMITED 2018 */
mcexec へ送信されたシグナルによるシステムコールオフロード中断機能
テストセットREADME
(1) テストの実行方法
以下の手順でテストを実行する
1. $HOME/.mck_test_configを用意する
当該ファイルは、McKernelをビルドした際に生成されるmck_test_config.sample ファイルを
$HOMEにコピーし、適宜編集する
2. CT200x.sh内のSTRESSBINにストレステストセットのパスを設定する
3. make test を実行する
(2) テスト項目詳細
1. Issue#870で指摘されたテストプログラムを用いて現象が解消されていることを確認する。
CT1001: プログラムがLinuxから送付されたシグナルに即座に応答すること。
→ TEST FAILED: Signal response time is more than or equal to 1 second
の表示が無ければOK
CT1002: プログラム実行完了後、プロセスとスレッドの残留が無いこと。
→ 0 processes found/ 0 threads found の出力があればOK
2. Issue#863の変更が、Linuxからmcexec経由でMcKernelプロセスに届くシグナルの
既存処理に影響しないことを確認する。
確認内容は以下の通り。
CT2001: 遅いI/Oシステムコール実行中にシグナルを受け、即座にシグナルハンドラが呼び出され、
システムコールがEINTRを返却することを確認する。
CT2002: 遅くないI/Oシステムコール実行中にシグナルを受け、システムコール完了後にシグナルハンドラが
呼び出され、システムコールが正常に終了することを確認する。
CT2003: 遅いI/Oシステムコール実行中にプログラムを終了するシグナルを受けとると、
即座にプログラムが終了することを確認する。
CT2004: 遅くないI/Oシステムコール実行中にプログラムを終了するシグナルを受けとると、
即座にプログラムを終了することを確認する。
CT2005: 遅いI/Oシステムコール実行中にプログラムを終了しないシグナル(SIGURG)を受けとっても、
プログラムの実行に影響しないことを確認する。
CT2006: 遅くないI/Oシステムコール実行中にプログラムを終了しないシグナル(SIGURG)を受けとっても、
プログラムの実行に影響しないことを確認する。
CT2007: 遅いI/Oシステムコール実行中に無視(SIG_IGN)するシグナルを受けとっても、
プログラムの実行に影響しないことを確認する。
CT2008: 遅くないI/Oシステムコール実行中に無視(SIG_IGN)するシグナルを受けとっても、
プログラムの実行に影響しないことを確認する。
(3) 実行結果ログ
result.logファイル内に実行時のログを記載する。
実行に利用したIHK/McKernelは、IA版における下記の版数相当の
arm64版移植IHK/McKernelである。
IHK
commit d6fcbee8cb91f9ec4b49f97c918e696ac0335aaf
Author: Shiratori, Takehiro <fj0300es@aa.jp.fujitsu.com>
Date: Tue Oct 16 16:25:33 2018 +0900
McKernel
commit 6f9fef2b13447c74c36d15cf5ebd186f8395ccca
Author: Ken Sato <ken.sato.ty@hitachi-solutions.com>
Date: Tue Sep 25 10:05:41 2018 +0900
(4) 備考
特になし。
以上。

View File

@ -0,0 +1,62 @@
gcc -o CT2001 CT2001.c
gcc -o CT2002 CT2002.c
gcc -o CT2003 CT2003.c
gcc -o CT2004 CT2004.c
gcc -o CT2005 CT2005.c
gcc -o CT2006 CT2006.c
gcc -o CT2007 CT2007.c
gcc -o CT2008 CT2008.c
gcc -o CT2000 CT2000.c
./CT200x.sh
mcstop+release.sh ... done
mcreboot.sh -c 4-15 -m 4G@0,4G@1,4G@2,4G@3 -O ... done
/opt/stress_test/src /opt/repo/mckernel/test/mng_mod/issues/870/arm64
SUCCESS kmsg
SUCCESS clear_kmsg
timeout -s 9 60 /opt/ppos//bin/mcexec ./killit -t 4000 ./signalonread -nt 4 -nosignal 1> /tmp/dtest.log 2>&1
SUCCESS mcexec
SUCCESS mcexec ./killit -t 4000 ./signalonread -nt 4 -nosignal
SUCCESS kmsg
mck-mcexec.sh: WARNING: kmsg isn't empty
=== kmsg begins ====
[ 0]: fileobj_free(ffff800042231040 ffff8007c3ec0580): free failed. -32
[ 0]: fileobj_free(ffff8000422d0020 ffff8007c3eca600): free failed. -32
=== kmsg ends ====
SUCCESS ioctl 40000000 1
SUCCESS kmsg
SUCCESS 0 processes found
SUCCESS ioctl 40000000 2
SUCCESS kmsg
SUCCESS 0 threads found
SUCCESS mcexec not found
CT1001-2: OK
/opt/repo/mckernel/test/mng_mod/issues/870/arm64
2048+0 レコード入力
2048+0 レコード出力
2147483648 バイト (2.1 GB) コピーされました、 35.6169 秒、 60.3 MB/秒
20:46:34.635060 test start, kill after 3 seconds
20:46:37.675917 signal hanlder is called
CT2001 OK
vm.drop_caches = 3
signal hanlder is called
CT2002 OK
20:47:01.644099 test start, kill after 3 seconds
20:47:04.971801 child process terminated
CT2003 OK
vm.drop_caches = 3
20:47:06.536037 test start, kill after 1 seconds
20:47:09.644867 child process terminated
CT2004 OK (3.108830)
kill SIGURG
kill SIGINT
CT2005 OK
vm.drop_caches = 3
kill SIGURG
CT2006 OK
kill SIGTERM (ignored)
kill SIGINT
CT2007 OK
vm.drop_caches = 3
kill SIGTERM (ignored)
CT2008 OK

View 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, "CT200x 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);
}

View 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, "CT2001 NG BAD read rc=%d\n", rc);
exit(1);
}
if (errno != EINTR) {
fprintf(stderr, "CT2001 NG BAD error errno=%d\n", errno);
exit(1);
}
tv_sub(&tv2, &tv1);
if (tv2.tv_sec != 3)
fprintf(stderr, "CT2001 NG signal delayed (%d.%06d)\n", tv2.tv_sec, tv2.tv_usec);
else
fprintf(stderr, "CT2001 OK\n");
exit(0);
}

View 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, "CT2002 NG BAD read rc=%ld errno=%d\n", rc, errno);
exit(1);
}
if (sigcalled == 0) {
fprintf(stderr, "CT2002 NG signal handler was not called\n");
exit(1);
}
fprintf(stderr, "CT2002 OK\n");
exit(0);
}

View 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, "CT2003 NG BAD wait rc=%d errno=%d\n", rc, errno);
exit(1);
}
if (!WIFSIGNALED(st)) {
fprintf(stderr, "CT2003 NG no signaled st=%08x\n", st);
exit(1);
}
if (WTERMSIG(st) != SIGALRM) {
fprintf(stderr, "CT2003 NG BAD signal sig=%d\n", WTERMSIG(st));
exit(1);
}
tv_sub(&tv2, &tv1);
if (tv2.tv_sec != 3)
fprintf(stderr, "CT2003 NG signal delayed (%d.%06d)\n", tv2.tv_sec, tv2.tv_usec);
else
fprintf(stderr, "CT2003 OK\n");
exit(0);
}

View 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, "CT2004 NG BAD wait rc=%d errno=%d\n", rc, errno);
exit(1);
}
if (!WIFSIGNALED(st)) {
fprintf(stderr, "CT2004 NG no signaled st=%08x\n", st);
exit(1);
}
if (WTERMSIG(st) != SIGALRM) {
fprintf(stderr, "CT2004 NG BAD signal sig=%d\n", WTERMSIG(st));
exit(1);
}
tv_sub(&tv2, &tv1);
if (tv2.tv_sec != 1)
fprintf(stderr, "CT2004 OK (%d.%06d)\n", tv2.tv_sec, tv2.tv_usec);
else
fprintf(stderr, "CT2004 OK\n");
exit(0);
}

View 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, "CT2005 NG BAD wait rc=%d errno=%d\n", rc, errno);
exit(1);
}
if (!WIFSIGNALED(st)) {
fprintf(stderr, "CT2005 NG no signaled st=%08x\n", st);
exit(1);
}
if (WTERMSIG(st) != SIGINT) {
fprintf(stderr, "CT2005 NG BAD signal sig=%d\n", WTERMSIG(st));
exit(1);
}
fprintf(stderr, "CT2005 OK\n");
exit(0);
}

View 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, "CT2006 NG BAD wait rc=%d errno=%d\n", rc, errno);
exit(1);
}
if (WIFSIGNALED(st)) {
fprintf(stderr, "CT2006 NG BAD signal st=%08x\n", st);
exit(1);
}
if (!WIFEXITED(st)) {
fprintf(stderr, "CT2006 NG BAD terminated st=%08x\n", st);
exit(1);
}
if (WEXITSTATUS(st) != 99) {
fprintf(stderr, "CT2006 NG BAD exit status st=%08x\n", st);
exit(1);
}
fprintf(stderr, "CT2006 OK\n");
exit(0);
}

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 <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, "CT2007 NG BAD wait rc=%d errno=%d\n", rc, errno);
exit(1);
}
if (!WIFSIGNALED(st)) {
fprintf(stderr, "CT2007 NG no signaled st=%08x\n", st);
exit(1);
}
if (WTERMSIG(st) != SIGINT) {
fprintf(stderr, "CT2007 NG BAD signal sig=%d\n", WTERMSIG(st));
exit(1);
}
fprintf(stderr, "CT2007 OK\n");
exit(0);
}

View 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, "CT2008 NG BAD wait rc=%d errno=%d\n", rc, errno);
exit(1);
}
if (WIFSIGNALED(st)) {
fprintf(stderr, "CT2008 NG BAD signal st=%08x\n", st);
exit(1);
}
if (!WIFEXITED(st)) {
fprintf(stderr, "CT2008 NG BAD terminated st=%08x\n", st);
exit(1);
}
if (WEXITSTATUS(st) != 99) {
fprintf(stderr, "CT2008 NG BAD exit status st=%08x\n", st);
exit(1);
}
fprintf(stderr, "CT2008 OK\n");
exit(0);
}

View File

@ -0,0 +1,37 @@
CC=gcc
TARGET= CT2001 CT2002 CT2003 CT2004 CT2005 CT2006 CT2007 CT2008 CT2000
all:: $(TARGET)
chmod u+x CT200?.sh
CT2000: CT2000.c
$(CC) -o CT2000 $<
CT2001: CT2001.c
$(CC) -o CT2001 $<
CT2002: CT2002.c
$(CC) -o CT2002 $<
CT2003: CT2003.c
$(CC) -o CT2003 $<
CT2004: CT2004.c
$(CC) -o CT2004 $<
CT2005: CT2005.c
$(CC) -o CT2005 $<
CT2006: CT2006.c
$(CC) -o CT2006 $<
CT2007: CT2007.c
$(CC) -o CT2007 $<
CT2008: CT2008.c
$(CC) -o CT2008 $<
test:: $(TARGET)
./CT200x.sh
clean::
rm -f $(TARGET)