From b94247c478d76c8c96ecc077a4bd5ee3ee066250 Mon Sep 17 00:00:00 2001 From: "Shiratori, Takehiro" Date: Thu, 29 Nov 2018 20:57:55 +0900 Subject: [PATCH] Test "signal: When the process receives a termination signal, it first terminates mcexec." on arm64 Change-Id: I1be32b991a45f0892146d93a9e6d6be9199faf59 Refs: #870 --- test/mng_mod/issues/870/{ => arm64}/CT2000.c | 0 test/mng_mod/issues/870/{ => arm64}/CT2001.c | 0 test/mng_mod/issues/870/arm64/CT2001.sh | 4 + test/mng_mod/issues/870/{ => arm64}/CT2002.c | 0 test/mng_mod/issues/870/arm64/CT2002.sh | 6 ++ test/mng_mod/issues/870/{ => arm64}/CT2003.c | 0 test/mng_mod/issues/870/arm64/CT2003.sh | 4 + test/mng_mod/issues/870/{ => arm64}/CT2004.c | 0 test/mng_mod/issues/870/arm64/CT2004.sh | 6 ++ test/mng_mod/issues/870/{ => arm64}/CT2005.c | 0 test/mng_mod/issues/870/arm64/CT2005.sh | 4 + test/mng_mod/issues/870/{ => arm64}/CT2006.c | 0 test/mng_mod/issues/870/arm64/CT2006.sh | 6 ++ test/mng_mod/issues/870/{ => arm64}/CT2007.c | 0 test/mng_mod/issues/870/arm64/CT2007.sh | 4 + test/mng_mod/issues/870/{ => arm64}/CT2008.c | 0 test/mng_mod/issues/870/arm64/CT2008.sh | 6 ++ test/mng_mod/issues/870/arm64/CT200x.sh | 33 +++++++ test/mng_mod/issues/870/{ => arm64}/Makefile | 0 test/mng_mod/issues/870/arm64/README | 72 ++++++++++++++ test/mng_mod/issues/870/arm64/result.log | 62 ++++++++++++ .../issues/870/{ => x86_64}/CT1001.txt | 0 test/mng_mod/issues/870/x86_64/CT2000.c | 97 ++++++++++++++++++ test/mng_mod/issues/870/x86_64/CT2001.c | 77 +++++++++++++++ .../mng_mod/issues/870/{ => x86_64}/CT2001.sh | 0 test/mng_mod/issues/870/x86_64/CT2002.c | 58 +++++++++++ .../mng_mod/issues/870/{ => x86_64}/CT2002.sh | 0 test/mng_mod/issues/870/x86_64/CT2003.c | 87 ++++++++++++++++ .../mng_mod/issues/870/{ => x86_64}/CT2003.sh | 0 test/mng_mod/issues/870/x86_64/CT2004.c | 98 +++++++++++++++++++ .../mng_mod/issues/870/{ => x86_64}/CT2004.sh | 0 test/mng_mod/issues/870/x86_64/CT2005.c | 74 ++++++++++++++ .../mng_mod/issues/870/{ => x86_64}/CT2005.sh | 0 test/mng_mod/issues/870/x86_64/CT2006.c | 80 +++++++++++++++ .../mng_mod/issues/870/{ => x86_64}/CT2006.sh | 0 test/mng_mod/issues/870/x86_64/CT2007.c | 76 ++++++++++++++ .../mng_mod/issues/870/{ => x86_64}/CT2007.sh | 0 test/mng_mod/issues/870/x86_64/CT2008.c | 80 +++++++++++++++ .../mng_mod/issues/870/{ => x86_64}/CT2008.sh | 0 .../mng_mod/issues/870/{ => x86_64}/CT200x.sh | 0 .../issues/870/{ => x86_64}/CT200x.txt | 0 test/mng_mod/issues/870/x86_64/Makefile | 37 +++++++ test/mng_mod/issues/870/{ => x86_64}/README | 0 43 files changed, 971 insertions(+) rename test/mng_mod/issues/870/{ => arm64}/CT2000.c (100%) rename test/mng_mod/issues/870/{ => arm64}/CT2001.c (100%) create mode 100755 test/mng_mod/issues/870/arm64/CT2001.sh rename test/mng_mod/issues/870/{ => arm64}/CT2002.c (100%) create mode 100755 test/mng_mod/issues/870/arm64/CT2002.sh rename test/mng_mod/issues/870/{ => arm64}/CT2003.c (100%) create mode 100755 test/mng_mod/issues/870/arm64/CT2003.sh rename test/mng_mod/issues/870/{ => arm64}/CT2004.c (100%) create mode 100755 test/mng_mod/issues/870/arm64/CT2004.sh rename test/mng_mod/issues/870/{ => arm64}/CT2005.c (100%) create mode 100755 test/mng_mod/issues/870/arm64/CT2005.sh rename test/mng_mod/issues/870/{ => arm64}/CT2006.c (100%) create mode 100755 test/mng_mod/issues/870/arm64/CT2006.sh rename test/mng_mod/issues/870/{ => arm64}/CT2007.c (100%) create mode 100755 test/mng_mod/issues/870/arm64/CT2007.sh rename test/mng_mod/issues/870/{ => arm64}/CT2008.c (100%) create mode 100755 test/mng_mod/issues/870/arm64/CT2008.sh create mode 100755 test/mng_mod/issues/870/arm64/CT200x.sh rename test/mng_mod/issues/870/{ => arm64}/Makefile (100%) create mode 100644 test/mng_mod/issues/870/arm64/README create mode 100644 test/mng_mod/issues/870/arm64/result.log rename test/mng_mod/issues/870/{ => x86_64}/CT1001.txt (100%) create mode 100644 test/mng_mod/issues/870/x86_64/CT2000.c create mode 100644 test/mng_mod/issues/870/x86_64/CT2001.c rename test/mng_mod/issues/870/{ => x86_64}/CT2001.sh (100%) create mode 100644 test/mng_mod/issues/870/x86_64/CT2002.c rename test/mng_mod/issues/870/{ => x86_64}/CT2002.sh (100%) create mode 100644 test/mng_mod/issues/870/x86_64/CT2003.c rename test/mng_mod/issues/870/{ => x86_64}/CT2003.sh (100%) create mode 100644 test/mng_mod/issues/870/x86_64/CT2004.c rename test/mng_mod/issues/870/{ => x86_64}/CT2004.sh (100%) create mode 100644 test/mng_mod/issues/870/x86_64/CT2005.c rename test/mng_mod/issues/870/{ => x86_64}/CT2005.sh (100%) create mode 100644 test/mng_mod/issues/870/x86_64/CT2006.c rename test/mng_mod/issues/870/{ => x86_64}/CT2006.sh (100%) create mode 100644 test/mng_mod/issues/870/x86_64/CT2007.c rename test/mng_mod/issues/870/{ => x86_64}/CT2007.sh (100%) create mode 100644 test/mng_mod/issues/870/x86_64/CT2008.c rename test/mng_mod/issues/870/{ => x86_64}/CT2008.sh (100%) rename test/mng_mod/issues/870/{ => x86_64}/CT200x.sh (100%) rename test/mng_mod/issues/870/{ => x86_64}/CT200x.txt (100%) create mode 100644 test/mng_mod/issues/870/x86_64/Makefile rename test/mng_mod/issues/870/{ => x86_64}/README (100%) diff --git a/test/mng_mod/issues/870/CT2000.c b/test/mng_mod/issues/870/arm64/CT2000.c similarity index 100% rename from test/mng_mod/issues/870/CT2000.c rename to test/mng_mod/issues/870/arm64/CT2000.c diff --git a/test/mng_mod/issues/870/CT2001.c b/test/mng_mod/issues/870/arm64/CT2001.c similarity index 100% rename from test/mng_mod/issues/870/CT2001.c rename to test/mng_mod/issues/870/arm64/CT2001.c diff --git a/test/mng_mod/issues/870/arm64/CT2001.sh b/test/mng_mod/issues/870/arm64/CT2001.sh new file mode 100755 index 00000000..0cea0845 --- /dev/null +++ b/test/mng_mod/issues/870/arm64/CT2001.sh @@ -0,0 +1,4 @@ +#!/bin/sh +## CT2001.sh COPYRIGHT FUJITSU LIMITED 2018 ## + +./CT2000 ./CT2001 diff --git a/test/mng_mod/issues/870/CT2002.c b/test/mng_mod/issues/870/arm64/CT2002.c similarity index 100% rename from test/mng_mod/issues/870/CT2002.c rename to test/mng_mod/issues/870/arm64/CT2002.c diff --git a/test/mng_mod/issues/870/arm64/CT2002.sh b/test/mng_mod/issues/870/arm64/CT2002.sh new file mode 100755 index 00000000..471443f6 --- /dev/null +++ b/test/mng_mod/issues/870/arm64/CT2002.sh @@ -0,0 +1,6 @@ +#!/bin/sh +## CT2002.sh COPYRIGHT FUJITSU LIMITED 2018 ## + +sync +sudo /sbin/sysctl vm.drop_caches=3 +./CT2000 ./CT2002 diff --git a/test/mng_mod/issues/870/CT2003.c b/test/mng_mod/issues/870/arm64/CT2003.c similarity index 100% rename from test/mng_mod/issues/870/CT2003.c rename to test/mng_mod/issues/870/arm64/CT2003.c diff --git a/test/mng_mod/issues/870/arm64/CT2003.sh b/test/mng_mod/issues/870/arm64/CT2003.sh new file mode 100755 index 00000000..2c57507f --- /dev/null +++ b/test/mng_mod/issues/870/arm64/CT2003.sh @@ -0,0 +1,4 @@ +#!/bin/sh +## CT2003.sh COPYRIGHT FUJITSU LIMITED 2018 ## + +./CT2000 ./CT2003 diff --git a/test/mng_mod/issues/870/CT2004.c b/test/mng_mod/issues/870/arm64/CT2004.c similarity index 100% rename from test/mng_mod/issues/870/CT2004.c rename to test/mng_mod/issues/870/arm64/CT2004.c diff --git a/test/mng_mod/issues/870/arm64/CT2004.sh b/test/mng_mod/issues/870/arm64/CT2004.sh new file mode 100755 index 00000000..19e8b631 --- /dev/null +++ b/test/mng_mod/issues/870/arm64/CT2004.sh @@ -0,0 +1,6 @@ +#!/bin/sh +## CT2004.sh COPYRIGHT FUJITSU LIMITED 2018 ## + +sync +sudo /sbin/sysctl vm.drop_caches=3 +./CT2000 ./CT2004 diff --git a/test/mng_mod/issues/870/CT2005.c b/test/mng_mod/issues/870/arm64/CT2005.c similarity index 100% rename from test/mng_mod/issues/870/CT2005.c rename to test/mng_mod/issues/870/arm64/CT2005.c diff --git a/test/mng_mod/issues/870/arm64/CT2005.sh b/test/mng_mod/issues/870/arm64/CT2005.sh new file mode 100755 index 00000000..91231062 --- /dev/null +++ b/test/mng_mod/issues/870/arm64/CT2005.sh @@ -0,0 +1,4 @@ +#!/bin/sh +## CT2005.sh COPYRIGHT FUJITSU LIMITED 2018 ## + +./CT2000 ./CT2005 diff --git a/test/mng_mod/issues/870/CT2006.c b/test/mng_mod/issues/870/arm64/CT2006.c similarity index 100% rename from test/mng_mod/issues/870/CT2006.c rename to test/mng_mod/issues/870/arm64/CT2006.c diff --git a/test/mng_mod/issues/870/arm64/CT2006.sh b/test/mng_mod/issues/870/arm64/CT2006.sh new file mode 100755 index 00000000..1f61f4c3 --- /dev/null +++ b/test/mng_mod/issues/870/arm64/CT2006.sh @@ -0,0 +1,6 @@ +#!/bin/sh +## CT2006.sh COPYRIGHT FUJITSU LIMITED 2018 ## + +sync +sudo /sbin/sysctl vm.drop_caches=3 +./CT2000 ./CT2006 diff --git a/test/mng_mod/issues/870/CT2007.c b/test/mng_mod/issues/870/arm64/CT2007.c similarity index 100% rename from test/mng_mod/issues/870/CT2007.c rename to test/mng_mod/issues/870/arm64/CT2007.c diff --git a/test/mng_mod/issues/870/arm64/CT2007.sh b/test/mng_mod/issues/870/arm64/CT2007.sh new file mode 100755 index 00000000..738dfea3 --- /dev/null +++ b/test/mng_mod/issues/870/arm64/CT2007.sh @@ -0,0 +1,4 @@ +#!/bin/sh +## CT2007.sh COPYRIGHT FUJITSU LIMITED 2018 ## + +./CT2000 ./CT2007 diff --git a/test/mng_mod/issues/870/CT2008.c b/test/mng_mod/issues/870/arm64/CT2008.c similarity index 100% rename from test/mng_mod/issues/870/CT2008.c rename to test/mng_mod/issues/870/arm64/CT2008.c diff --git a/test/mng_mod/issues/870/arm64/CT2008.sh b/test/mng_mod/issues/870/arm64/CT2008.sh new file mode 100755 index 00000000..10813fee --- /dev/null +++ b/test/mng_mod/issues/870/arm64/CT2008.sh @@ -0,0 +1,6 @@ +#!/bin/sh +## CT2008.sh COPYRIGHT FUJITSU LIMITED 2018 ## + +sync +sudo /sbin/sysctl vm.drop_caches=3 +./CT2000 ./CT2008 diff --git a/test/mng_mod/issues/870/arm64/CT200x.sh b/test/mng_mod/issues/870/arm64/CT200x.sh new file mode 100755 index 00000000..89f6351c --- /dev/null +++ b/test/mng_mod/issues/870/arm64/CT200x.sh @@ -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 diff --git a/test/mng_mod/issues/870/Makefile b/test/mng_mod/issues/870/arm64/Makefile similarity index 100% rename from test/mng_mod/issues/870/Makefile rename to test/mng_mod/issues/870/arm64/Makefile diff --git a/test/mng_mod/issues/870/arm64/README b/test/mng_mod/issues/870/arm64/README new file mode 100644 index 00000000..3a8ce621 --- /dev/null +++ b/test/mng_mod/issues/870/arm64/README @@ -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 + Date: Tue Oct 16 16:25:33 2018 +0900 + + McKernel + commit 6f9fef2b13447c74c36d15cf5ebd186f8395ccca + Author: Ken Sato + Date: Tue Sep 25 10:05:41 2018 +0900 + +(4) 備考 + 特になし。 + +以上。 diff --git a/test/mng_mod/issues/870/arm64/result.log b/test/mng_mod/issues/870/arm64/result.log new file mode 100644 index 00000000..ca61b2e0 --- /dev/null +++ b/test/mng_mod/issues/870/arm64/result.log @@ -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 diff --git a/test/mng_mod/issues/870/CT1001.txt b/test/mng_mod/issues/870/x86_64/CT1001.txt similarity index 100% rename from test/mng_mod/issues/870/CT1001.txt rename to test/mng_mod/issues/870/x86_64/CT1001.txt diff --git a/test/mng_mod/issues/870/x86_64/CT2000.c b/test/mng_mod/issues/870/x86_64/CT2000.c new file mode 100644 index 00000000..61b18cb8 --- /dev/null +++ b/test/mng_mod/issues/870/x86_64/CT2000.c @@ -0,0 +1,97 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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); +} diff --git a/test/mng_mod/issues/870/x86_64/CT2001.c b/test/mng_mod/issues/870/x86_64/CT2001.c new file mode 100644 index 00000000..0dba25b4 --- /dev/null +++ b/test/mng_mod/issues/870/x86_64/CT2001.c @@ -0,0 +1,77 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +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); +} diff --git a/test/mng_mod/issues/870/CT2001.sh b/test/mng_mod/issues/870/x86_64/CT2001.sh similarity index 100% rename from test/mng_mod/issues/870/CT2001.sh rename to test/mng_mod/issues/870/x86_64/CT2001.sh diff --git a/test/mng_mod/issues/870/x86_64/CT2002.c b/test/mng_mod/issues/870/x86_64/CT2002.c new file mode 100644 index 00000000..32019aa2 --- /dev/null +++ b/test/mng_mod/issues/870/x86_64/CT2002.c @@ -0,0 +1,58 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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); +} diff --git a/test/mng_mod/issues/870/CT2002.sh b/test/mng_mod/issues/870/x86_64/CT2002.sh similarity index 100% rename from test/mng_mod/issues/870/CT2002.sh rename to test/mng_mod/issues/870/x86_64/CT2002.sh diff --git a/test/mng_mod/issues/870/x86_64/CT2003.c b/test/mng_mod/issues/870/x86_64/CT2003.c new file mode 100644 index 00000000..ac8332ce --- /dev/null +++ b/test/mng_mod/issues/870/x86_64/CT2003.c @@ -0,0 +1,87 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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); +} diff --git a/test/mng_mod/issues/870/CT2003.sh b/test/mng_mod/issues/870/x86_64/CT2003.sh similarity index 100% rename from test/mng_mod/issues/870/CT2003.sh rename to test/mng_mod/issues/870/x86_64/CT2003.sh diff --git a/test/mng_mod/issues/870/x86_64/CT2004.c b/test/mng_mod/issues/870/x86_64/CT2004.c new file mode 100644 index 00000000..e5b9eb61 --- /dev/null +++ b/test/mng_mod/issues/870/x86_64/CT2004.c @@ -0,0 +1,98 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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); +} diff --git a/test/mng_mod/issues/870/CT2004.sh b/test/mng_mod/issues/870/x86_64/CT2004.sh similarity index 100% rename from test/mng_mod/issues/870/CT2004.sh rename to test/mng_mod/issues/870/x86_64/CT2004.sh diff --git a/test/mng_mod/issues/870/x86_64/CT2005.c b/test/mng_mod/issues/870/x86_64/CT2005.c new file mode 100644 index 00000000..412bc662 --- /dev/null +++ b/test/mng_mod/issues/870/x86_64/CT2005.c @@ -0,0 +1,74 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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); +} diff --git a/test/mng_mod/issues/870/CT2005.sh b/test/mng_mod/issues/870/x86_64/CT2005.sh similarity index 100% rename from test/mng_mod/issues/870/CT2005.sh rename to test/mng_mod/issues/870/x86_64/CT2005.sh diff --git a/test/mng_mod/issues/870/x86_64/CT2006.c b/test/mng_mod/issues/870/x86_64/CT2006.c new file mode 100644 index 00000000..51093bdf --- /dev/null +++ b/test/mng_mod/issues/870/x86_64/CT2006.c @@ -0,0 +1,80 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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); +} diff --git a/test/mng_mod/issues/870/CT2006.sh b/test/mng_mod/issues/870/x86_64/CT2006.sh similarity index 100% rename from test/mng_mod/issues/870/CT2006.sh rename to test/mng_mod/issues/870/x86_64/CT2006.sh diff --git a/test/mng_mod/issues/870/x86_64/CT2007.c b/test/mng_mod/issues/870/x86_64/CT2007.c new file mode 100644 index 00000000..d92493a3 --- /dev/null +++ b/test/mng_mod/issues/870/x86_64/CT2007.c @@ -0,0 +1,76 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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); +} diff --git a/test/mng_mod/issues/870/CT2007.sh b/test/mng_mod/issues/870/x86_64/CT2007.sh similarity index 100% rename from test/mng_mod/issues/870/CT2007.sh rename to test/mng_mod/issues/870/x86_64/CT2007.sh diff --git a/test/mng_mod/issues/870/x86_64/CT2008.c b/test/mng_mod/issues/870/x86_64/CT2008.c new file mode 100644 index 00000000..f328bfb5 --- /dev/null +++ b/test/mng_mod/issues/870/x86_64/CT2008.c @@ -0,0 +1,80 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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); +} diff --git a/test/mng_mod/issues/870/CT2008.sh b/test/mng_mod/issues/870/x86_64/CT2008.sh similarity index 100% rename from test/mng_mod/issues/870/CT2008.sh rename to test/mng_mod/issues/870/x86_64/CT2008.sh diff --git a/test/mng_mod/issues/870/CT200x.sh b/test/mng_mod/issues/870/x86_64/CT200x.sh similarity index 100% rename from test/mng_mod/issues/870/CT200x.sh rename to test/mng_mod/issues/870/x86_64/CT200x.sh diff --git a/test/mng_mod/issues/870/CT200x.txt b/test/mng_mod/issues/870/x86_64/CT200x.txt similarity index 100% rename from test/mng_mod/issues/870/CT200x.txt rename to test/mng_mod/issues/870/x86_64/CT200x.txt diff --git a/test/mng_mod/issues/870/x86_64/Makefile b/test/mng_mod/issues/870/x86_64/Makefile new file mode 100644 index 00000000..bd3bf946 --- /dev/null +++ b/test/mng_mod/issues/870/x86_64/Makefile @@ -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) diff --git a/test/mng_mod/issues/870/README b/test/mng_mod/issues/870/x86_64/README similarity index 100% rename from test/mng_mod/issues/870/README rename to test/mng_mod/issues/870/x86_64/README