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

Change-Id: I5c8ab90ffd5c5da30162d606f4d86dca9d387b5a
Refs: #863
This commit is contained in:
Shiratori, Takehiro
2018-11-29 20:00:09 +09:00
committed by Masamichi Takagi
parent 3f11c1aee5
commit 556a64ac5e
41 changed files with 830 additions and 0 deletions

View File

@ -0,0 +1,5 @@
#!/bin/sh
## CT2001.sh COPYRIGHT FUJITSU LIMITED 2018 ##
MCEXEC=mcexec
$MCEXEC ./CT2001

View File

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

View File

@ -0,0 +1,5 @@
#!/bin/sh
## CT2003.sh COPYRIGHT FUJITSU LIMITED 2018 ##
MCEXEC=mcexec
$MCEXEC ./CT2003

View File

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

View File

@ -0,0 +1,5 @@
#!/bin/sh
## CT2005.sh COPYRIGHT FUJITSU LIMITED 2018 ##
MCEXEC=mcexec
$MCEXEC ./CT2005

View File

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

View File

@ -0,0 +1,5 @@
#!/bin/sh
## CT2007.sh COPYRIGHT FUJITSU LIMITED 2018 ##
MCEXEC=mcexec
$MCEXEC ./CT2007

View File

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

View File

@ -0,0 +1,33 @@
#!/bin/sh
## CT200x.sh COPYRIGHT FUJITSU LIMITED 2018 ##
USELTP=0
USEOSTEST=0
. ../../../../common.sh
STRESSBIN=
${MCEXEC} ${STRESSBIN}/signalonread
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,71 @@
/* README COPYRIGHT FUJITSU LIMITED 2018 */
McKernel プロセス/スレッドへ直接送信されたシグナルによるシステムコールオフロード中断機能
テストセットREADME
(1) テストの実行方法
以下の手順でテストを実行する
1. $HOME/.mck_test_configを用意する
当該ファイルは、McKernelをビルドした際に生成されるmck_test_config.sample ファイルを
$HOMEにコピーし、適宜編集する
2. CT200x.sh内のSTRESSBINにストレステストセットのパスを設定する
3. make test を実行する
(2) テスト項目詳細
1. Issue#863で指摘されたテストプログラムを用いて現象が解消されていることを確認する。
CT1001: プログラムがSIGTERMで終了すること。
→ The TEST process is terminated by the signal 15 の表示があればOK
CT1002: プログラムがLinuxから送付されたシグナルに即座に応答すること。
→ TEST FAILED: Signal response time is more than or equal to 1 second
の表示が無ければOK
2. Issue#863の変更が、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,48 @@
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
./CT200x.sh
mcstop+release.sh ... done
mcreboot.sh -c 4-7 -m 3G ... done
DANGERTEST SIGNALONREAD
NUMTHREADS: 1
NOSIGNAL: 0
TIMETOWAIT: 500 msec
BUFFSIZE: 2147483648
[17612] I am the examiner for 17619.
The TEST process is terminated by the signal 15
TEST SUCCESSED
CT1001-2: OK
2048+0 レコード入力
2048+0 レコード出力
2147483648 バイト (2.1 GB) コピーされました、 34.1908 秒、 62.8 MB/秒
19:28:52.323974 test start, kill after 3 seconds
19:28:55.362275 signal hanlder is called
CT2001 OK
vm.drop_caches = 3
signal hanlder is called
CT2002 OK
19:29:19.215304 test start, kill after 3 seconds
19:29:22.419269 child process terminated
CT2003 OK
vm.drop_caches = 3
19:29:24.295527 test start, kill after 1 seconds
19:29:27.258408 child process terminated
CT2004 OK (2.962881)
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,73 @@
#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;
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];
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));
alarm(3);
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,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, "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,83 @@
#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;
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;
char buf[16];
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,94 @@
#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;
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;
char buf[16];
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,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, "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,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, "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,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, "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,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, SIGTERM);
}
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, "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,34 @@
CC=gcc
TARGET=CT2001 CT2002 CT2003 CT2004 CT2005 CT2006 CT2007 CT2008
all:: $(TARGET)
chmod u+x CT200?.sh
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)