diff --git a/test/mng_mod/issues/1031/CT_001.c b/test/mng_mod/issues/1031/arm64/CT_001.c similarity index 100% rename from test/mng_mod/issues/1031/CT_001.c rename to test/mng_mod/issues/1031/arm64/CT_001.c diff --git a/test/mng_mod/issues/1031/CT_002.c b/test/mng_mod/issues/1031/arm64/CT_002.c similarity index 100% rename from test/mng_mod/issues/1031/CT_002.c rename to test/mng_mod/issues/1031/arm64/CT_002.c diff --git a/test/mng_mod/issues/1031/CT_003.c b/test/mng_mod/issues/1031/arm64/CT_003.c similarity index 100% rename from test/mng_mod/issues/1031/CT_003.c rename to test/mng_mod/issues/1031/arm64/CT_003.c diff --git a/test/mng_mod/issues/1031/CT_004.c b/test/mng_mod/issues/1031/arm64/CT_004.c similarity index 100% rename from test/mng_mod/issues/1031/CT_004.c rename to test/mng_mod/issues/1031/arm64/CT_004.c diff --git a/test/mng_mod/issues/1031/CT_005.c b/test/mng_mod/issues/1031/arm64/CT_005.c similarity index 100% rename from test/mng_mod/issues/1031/CT_005.c rename to test/mng_mod/issues/1031/arm64/CT_005.c diff --git a/test/mng_mod/issues/1031/CT_006.c b/test/mng_mod/issues/1031/arm64/CT_006.c similarity index 100% rename from test/mng_mod/issues/1031/CT_006.c rename to test/mng_mod/issues/1031/arm64/CT_006.c diff --git a/test/mng_mod/issues/1031/CT_007.c b/test/mng_mod/issues/1031/arm64/CT_007.c similarity index 100% rename from test/mng_mod/issues/1031/CT_007.c rename to test/mng_mod/issues/1031/arm64/CT_007.c diff --git a/test/mng_mod/issues/1031/CT_008.c b/test/mng_mod/issues/1031/arm64/CT_008.c similarity index 100% rename from test/mng_mod/issues/1031/CT_008.c rename to test/mng_mod/issues/1031/arm64/CT_008.c diff --git a/test/mng_mod/issues/1031/CT_009.c b/test/mng_mod/issues/1031/arm64/CT_009.c similarity index 100% rename from test/mng_mod/issues/1031/CT_009.c rename to test/mng_mod/issues/1031/arm64/CT_009.c diff --git a/test/mng_mod/issues/1031/CT_010.c b/test/mng_mod/issues/1031/arm64/CT_010.c similarity index 100% rename from test/mng_mod/issues/1031/CT_010.c rename to test/mng_mod/issues/1031/arm64/CT_010.c diff --git a/test/mng_mod/issues/1031/arm64/Makefile b/test/mng_mod/issues/1031/arm64/Makefile new file mode 100644 index 00000000..9d715bce --- /dev/null +++ b/test/mng_mod/issues/1031/arm64/Makefile @@ -0,0 +1,45 @@ +## Makefile COPYRIGHT FUJITSU LIMITED 2018 ## +CC = gcc +TARGET=CT_001 CT_002 CT_003 CT_004 CT_005 CT_006 CT_007 CT_008 CT_009 CT_010 + +CPPFLAGS = +LDFLAGS = + +all: $(TARGET) + +CT_001: CT_001.c + $(CC) -o $@ $^ $(LDFLAGS) + +CT_002: CT_002.c + $(CC) -o $@ $^ $(LDFLAGS) + +CT_003: CT_003.c + $(CC) -o $@ $^ $(LDFLAGS) + +CT_004: CT_004.c + $(CC) -o $@ $^ $(LDFLAGS) + +CT_005: CT_005.c + $(CC) -o $@ $^ $(LDFLAGS) + +CT_006: CT_006.c + $(CC) -o $@ $^ $(LDFLAGS) + +CT_007: CT_007.c + $(CC) -o $@ $^ $(LDFLAGS) + +CT_008: CT_008.c + $(CC) -o $@ $^ $(LDFLAGS) + +CT_009: CT_009.c + $(CC) -o $@ $^ $(LDFLAGS) + +CT_010: CT_010.c + $(CC) -o $@ $^ $(LDFLAGS) + +test: all + ./run.sh + +clean: + rm -f $(TARGET) *.o + diff --git a/test/mng_mod/issues/1031/arm64/README b/test/mng_mod/issues/1031/arm64/README new file mode 100644 index 00000000..d4ddfa63 --- /dev/null +++ b/test/mng_mod/issues/1031/arm64/README @@ -0,0 +1,109 @@ +/* README COPYRIGHT FUJITSU LIMITED 2018 */ + +sigaction()のハンドラリセット機能テストセットREADME + +(1) テストの実行方法 +以下の手順でテストを実行する + 1. $HOME/.mck_test_configを用意する + 当該ファイルは、McKernelをビルドした際に生成されるmck_test_config.sample ファイルを + $HOMEにコピーし、適宜編集する + 2. make test を実行する + +(2) テスト項目詳細 +1. Issueで報告されたテストプログラムによる確認 + ISSUE01(test_mck rt_sigaction #4): SA_RESETHANDを指定しされたハンドラが1度だけ実行されること + ⇒ テストプログラムがSIGUSR1によって終了すればOK + +2.McKernelでのsigaction()の基本動作確認 + CT_001: SIG_RESETHAND 指定時の動作 + 1. SIG_RESETHANDを指定したsigaction()でSIG_USR1にハンドラを設定 + 2. 自身にSIGUSR1を送る + 3. 1.で登録したハンドラが呼び出される + 4. 自身にSIGUSR1を送る + 5. 1.で登録したハンドラが呼び出されず、プロセスが終了する + + CT_002: SIG_RESETHAND 未指定時の動作 + 1. SIG_RESETHANDを指定しないsigaction()でSIGUSR1にハンドラを設定 + 2. 自身にSIGUSR1を送る + 3. 1.で登録したハンドラが呼び出される + 4. 自身にSIGUSR1を送る + 5. 1.で登録したハンドラが呼び出される + + CT_003: SIG_RESETHANDO 指定ハンドラへの上書き登録時の動作 + 1. SIG_RESETHANDを指定したsigaction()でSIG_USR1にハンドラを設定 + 2. SIG_RESETHANDを指定しないsigaction()でSIG_USR1にハンドラを設定 + 3. 自身にSIGUSR1を送る + 4. 2.で登録したハンドラが呼び出される + 5. 自身にSIGUSR1を送る + 6. 2.で登録したハンドラが呼び出される + + CT_004: 複数のsig_numへのハンドラ登録時の動作 + 1. SIG_RESETHANDを指定したsigaction()でSIG_USR1にハンドラを設定 + 2. SIG_RESETHANDを指定したsigaction()でSIG_USR2にハンドラを設定 + 3. 自身にSIGUSR1を送る + 4. 1.で登録したハンドラが呼び出される + 5. 自身にSIGUSR2を送る + 6. 2.で登録したハンドラが呼び出される + 7. 自身にSIGUSR1を送る + 8. 1.で登録したハンドラが呼び出されず、プロセスが終了する + + CT_005: 複数回(非上書き)のSIG_RESETHAND 指定時の動作 + 1. SIG_RESETHANDを指定したsigaction()でSIG_USR1にハンドラを設定 + 2. 自身にSIGUSR1を送る + 3. 1.で登録したハンドラが呼び出される + 4. SIG_RESETHANDを指定したsigaction()でSIG_USR1にハンドラを設定 + 5. 自身にSIGUSR1を送る + 6. 4.で登録したハンドラが呼び出される + 7. 自身にSIGUSR1を送る + 8. 4.で登録したハンドラが呼び出されず、プロセスが終了する + + CT_006: 設定中のハンドラ情報の取得(上書き時) + 1. SIG_RESETHANDを指定したsigaction()でSIG_USR1にハンドラを設定 + 2. sigaction(SIGUSR1, NULL, &act) で設定情報を取得できる + 3. SIG_RESETHANDを指定しないsigaction()でSIG_USR1にデフォルトハンドラを設定 + 4. sigaction(SIGUSR1, NULL, &act) で3.で指定した設定情報を取得できる + + CT_007: 設定中のハンドラ情報の取得(デフォルトに戻った時) + 1. SIG_RESETHANDを指定したsigaction()でSIG_USR1にハンドラを設定 + 2. 自身にSIGUSR1を送る + 3. 1.で登録したハンドラが呼び出される + 4. sigaction(SIGUSR1, NULL, &act) で設定情報を取得できる + + CT_008: 不正なsig_numへのハンドラ登録 + 1. 範囲外(上限、下限)のsignumへのハンドラ登録が失敗する + 2. SIGKILL, SIGSTOPへのハンドラ登録が失敗する + + CT_009: SIGKILL, SIGSTOPのハンドラ情報の取得 + 1. sigaction(SIGKILL, NULL, &act) で設定情報を取得できる + 2. sigaction(SIGSTOP, NULL, &act) で設定情報を取得できる + + CT_010: sig_numの有効確認 + 1. sigaction(SIGUSR1, NULL, NULL) が成功する(有効) + 2. sigaction(SIGKILL, NULL, NULL) が成功する(有効) + 3. sigaction(SIGSTOP, NULL, NULL) が成功する(有効) + 4. sigaction(_NSIG, NULL, NULL) が失敗する(無効) + +(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 + + なお、test_mck rt_sigactionがSIGUSR1によって終了することで、 + make test自身はエラーとなっているが、これは期待動作である。 + +(4) 備考 + 特になし。 + + +以上。 + diff --git a/test/mng_mod/issues/1031/arm64/result.log b/test/mng_mod/issues/1031/arm64/result.log new file mode 100644 index 00000000..91f6614b --- /dev/null +++ b/test/mng_mod/issues/1031/arm64/result.log @@ -0,0 +1,76 @@ +gcc -o CT_001 CT_001.c +gcc -o CT_002 CT_002.c +gcc -o CT_003 CT_003.c +gcc -o CT_004 CT_004.c +gcc -o CT_005 CT_005.c +gcc -o CT_006 CT_006.c +gcc -o CT_007 CT_007.c +gcc -o CT_008 CT_008.c +gcc -o CT_009 CT_009.c +gcc -o CT_010 CT_010.c +./run.sh +mcstop+release.sh ... done +mcreboot.sh -c 4-7 -m 2G ... done +*** CT_001 start ******************************* + [OK] child is killed by SIGUSR1 +*** CT_001 PASSED + +*** CT_002 start ******************************* + [OK] child exited normaly +*** CT_002 PASSED + +*** CT_003 start ******************************* + [OK] child exited normaly +*** CT_003 PASSED + +*** CT_004 start ******************************* + [OK] child is killed by SIGUSR1 +*** CT_004 PASSED + +*** CT_005 start ******************************* + [OK] child is killed by SIGUSR1 +*** CT_005 PASSED + +*** CT_006 start ******************************* + [OK] sigaction with SA_RESETHAND + [OK] sigaction to get current action + [OK] check current act +*** CT_006 PASSED + +*** CT_007 start ******************************* + [OK] sigaction with SA_RESETHAND + send 1st SIGUSR1 + [OK] invoked test_handler + [OK] sigaction to get current action + [OK] check current act (after reset) +*** CT_007 PASSED + +*** CT_008 start ******************************* + [OK] sigaction 0 failed + [OK] sigaction _NSIG failed + [OK] sigaction SIGKILL failed + [OK] sigaction SIGSTOP failed +*** CT_008 PASSED + +*** CT_009 start ******************************* + [OK] sigaction to get SIGKILL action + [OK] check SIGKILL act + [OK] sigaction to get SIGSTOP action + [OK] check SIGSTOP act +*** CT_009 PASSED + +*** CT_010 start ******************************* + [OK] SIGUSR1 is valid + [OK] SIGKILL is valid + [OK] SIGSTOP is valid + [OK] _NSIG is invalid +*** CT_010 PASSED + +TEST_SUITE: rt_sigaction +TEST_NUMBER: 4 +ARGS: +/-------- Signal handler will activate -------/ +sig#10 is handled. +/------ Process will terminate by signal -----/ +./run.sh: 19 行: 31921 ユーザー定義シグナル1 stdbuf -i0 -o0 -e0 ${MCEXEC} ${TESTMCK} -s rt_sigaction -n 4 +make: *** [test] エラー 138 diff --git a/test/mng_mod/issues/1031/arm64/run.sh b/test/mng_mod/issues/1031/arm64/run.sh new file mode 100755 index 00000000..75ec6536 --- /dev/null +++ b/test/mng_mod/issues/1031/arm64/run.sh @@ -0,0 +1,19 @@ +#!/bin/sh +## run.sh COPYRIGHT FUJITSU LIMITED 2018 ## + +USELTP=0 +USEOSTEST=1 + +. ../../../../common.sh + +${MCEXEC} ./CT_001 +${MCEXEC} ./CT_002 +${MCEXEC} ./CT_003 +${MCEXEC} ./CT_004 +${MCEXEC} ./CT_005 +${MCEXEC} ./CT_006 +${MCEXEC} ./CT_007 +${MCEXEC} ./CT_008 +${MCEXEC} ./CT_009 +${MCEXEC} ./CT_010 +stdbuf -i0 -o0 -e0 ${MCEXEC} ${TESTMCK} -s rt_sigaction -n 4 diff --git a/test/mng_mod/issues/1031/test_chk.h b/test/mng_mod/issues/1031/arm64/test_chk.h similarity index 100% rename from test/mng_mod/issues/1031/test_chk.h rename to test/mng_mod/issues/1031/arm64/test_chk.h diff --git a/test/mng_mod/issues/1031/x86_64/CT_001.c b/test/mng_mod/issues/1031/x86_64/CT_001.c new file mode 100644 index 00000000..b2c330f6 --- /dev/null +++ b/test/mng_mod/issues/1031/x86_64/CT_001.c @@ -0,0 +1,63 @@ +#include +#include +#include +#include +#include +#include "./test_chk.h" + +#define TEST_NAME "CT_001" + +int handled_cnt = 0; + +void test_handler(int sig) +{ + handled_cnt++; +} + +int main(int argc, char** argv) +{ + int rc = 0; + int pid = 0; + int status; + int tmp_flag = 0; + struct sigaction sa; + + printf("*** %s start *******************************\n", TEST_NAME); + + pid = fork(); + CHKANDJUMP(pid == -1, "fork"); + + if (pid == 0) { /* child */ + sa.sa_handler = test_handler; + sa.sa_flags = SA_RESETHAND; + + rc = sigaction(SIGUSR1, &sa, NULL); + OKNG(rc != 0, "sigaction with SA_RESETHAND"); + + printf(" send 1st SIGUSR1\n"); + kill(getpid(), SIGUSR1); + OKNG(handled_cnt != 1, "invoked test_handler"); + printf(" send 2nd SIGUSR1\n"); + kill(getpid(), SIGUSR1); + OKNG(1, "can't reach here"); + } else { /* parent */ + rc = waitpid(pid, &status, 0); + CHKANDJUMP(rc == -1, "waitpid"); + + if (WIFSIGNALED(status)) { + if (WTERMSIG(status) == SIGUSR1) { + tmp_flag = 1; + } + } + OKNG(tmp_flag != 1, "child is killed by SIGUSR1"); + } + + printf("*** %s PASSED\n\n", TEST_NAME); + + return 0; + +fn_fail: + printf("*** %s FAILED\n\n", TEST_NAME); + + return -1; +} diff --git a/test/mng_mod/issues/1031/x86_64/CT_002.c b/test/mng_mod/issues/1031/x86_64/CT_002.c new file mode 100644 index 00000000..c25aafb4 --- /dev/null +++ b/test/mng_mod/issues/1031/x86_64/CT_002.c @@ -0,0 +1,65 @@ +#include +#include +#include +#include +#include +#include "./test_chk.h" + +#define TEST_NAME "CT_002" + +int handled_cnt = 0; + +void test_handler(int sig) +{ + handled_cnt++; +} + +int main(int argc, char** argv) +{ + int rc = 0; + int pid = 0; + int status; + int tmp_flag = 0; + struct sigaction sa; + + printf("*** %s start *******************************\n", TEST_NAME); + + pid = fork(); + CHKANDJUMP(pid == -1, "fork"); + + if (pid == 0) { /* child */ + sa.sa_handler = test_handler; + sa.sa_flags = 0; + + rc = sigaction(SIGUSR1, &sa, NULL); + OKNG(rc != 0, "sigaction (no SA_RESETHAND)"); + + printf(" send 1st SIGUSR1\n"); + kill(getpid(), SIGUSR1); + OKNG(handled_cnt != 1, "invoked test_handler"); + printf(" send 2nd SIGUSR1\n"); + kill(getpid(), SIGUSR1); + OKNG(handled_cnt != 2, "invoked test_handler again"); + _exit(123); + } else { /* parent */ + rc = waitpid(pid, &status, 0); + CHKANDJUMP(rc == -1, "waitpid"); + + if (!WIFSIGNALED(status) && + WIFEXITED(status)) { + if (WEXITSTATUS(status) == 123) { + tmp_flag = 1; + } + } + OKNG(tmp_flag != 1, "child exited normaly"); + } + + printf("*** %s PASSED\n\n", TEST_NAME); + + return 0; + +fn_fail: + printf("*** %s FAILED\n\n", TEST_NAME); + + return -1; +} diff --git a/test/mng_mod/issues/1031/x86_64/CT_003.c b/test/mng_mod/issues/1031/x86_64/CT_003.c new file mode 100644 index 00000000..437e40d4 --- /dev/null +++ b/test/mng_mod/issues/1031/x86_64/CT_003.c @@ -0,0 +1,69 @@ +#include +#include +#include +#include +#include +#include "./test_chk.h" + +#define TEST_NAME "CT_003" + +int handled_cnt = 0; + +void test_handler(int sig) +{ + handled_cnt++; +} + +int main(int argc, char** argv) +{ + int rc = 0; + int pid = 0; + int status; + int tmp_flag = 0; + struct sigaction sa; + + printf("*** %s start *******************************\n", TEST_NAME); + + pid = fork(); + CHKANDJUMP(pid == -1, "fork"); + + if (pid == 0) { /* child */ + sa.sa_handler = test_handler; + sa.sa_flags |= SA_RESETHAND; + + rc = sigaction(SIGUSR1, &sa, NULL); + OKNG(rc != 0, "sigaction with SA_RESETHAND"); + + sa.sa_flags = 0; + rc = sigaction(SIGUSR1, &sa, NULL); + OKNG(rc != 0, "sigaction (rewrite no SA_RESETHAND)"); + + printf(" send 1st SIGUSR1\n"); + kill(getpid(), SIGUSR1); + OKNG(handled_cnt != 1, "invoked test_handler"); + printf(" send 2nd SIGUSR1\n"); + kill(getpid(), SIGUSR1); + OKNG(handled_cnt != 2, "invoked test_handler again"); + _exit(123); + } else { /* parent */ + rc = waitpid(pid, &status, 0); + CHKANDJUMP(rc == -1, "waitpid"); + + if (!WIFSIGNALED(status) && + WIFEXITED(status)) { + if (WEXITSTATUS(status) == 123) { + tmp_flag = 1; + } + } + OKNG(tmp_flag != 1, "child exited normaly"); + } + + printf("*** %s PASSED\n\n", TEST_NAME); + + return 0; + +fn_fail: + printf("*** %s FAILED\n\n", TEST_NAME); + + return -1; +} diff --git a/test/mng_mod/issues/1031/x86_64/CT_004.c b/test/mng_mod/issues/1031/x86_64/CT_004.c new file mode 100644 index 00000000..058d65df --- /dev/null +++ b/test/mng_mod/issues/1031/x86_64/CT_004.c @@ -0,0 +1,81 @@ +#include +#include +#include +#include +#include +#include "./test_chk.h" + +#define TEST_NAME "CT_004" + +int handled_cnt = 0; +int handled_cnt2 = 0; + +void test_handler(int sig) +{ + handled_cnt++; +} + +void test_handler2(int sig) +{ + handled_cnt2++; +} + +int main(int argc, char** argv) +{ + int rc = 0; + int pid = 0; + int status; + int tmp_flag = 0; + struct sigaction sa; + struct sigaction sa2; + + printf("*** %s start *******************************\n", TEST_NAME); + + pid = fork(); + CHKANDJUMP(pid == -1, "fork"); + + if (pid == 0) { /* child */ + sa.sa_handler = test_handler; + sa.sa_flags |= SA_RESETHAND; + + sa2.sa_handler = test_handler2; + sa2.sa_flags |= SA_RESETHAND; + + rc = sigaction(SIGUSR1, &sa, NULL); + OKNG(rc != 0, "sigaction with SA_RESETHAND to SIGUSR1"); + + rc = sigaction(SIGUSR2, &sa2, NULL); + OKNG(rc != 0, "sigaction with SA_RESETHAND to SIGUSR2"); + + printf(" send 1st SIGUSR1\n"); + kill(getpid(), SIGUSR1); + OKNG(handled_cnt != 1, "invoked test_handler"); + + printf(" send 1st SIGUSR2\n"); + kill(getpid(), SIGUSR2); + OKNG(handled_cnt2 != 1, "invoked test_handler2"); + + printf(" send 2nd SIGUSR1\n"); + kill(getpid(), SIGUSR1); + OKNG(1, "can't reach here"); + } else { /* parent */ + rc = waitpid(pid, &status, 0); + CHKANDJUMP(rc == -1, "waitpid"); + + if (WIFSIGNALED(status)) { + if (WTERMSIG(status) == SIGUSR1) { + tmp_flag = 1; + } + } + OKNG(tmp_flag != 1, "child is killed by SIGUSR1"); + } + + printf("*** %s PASSED\n\n", TEST_NAME); + + return 0; + +fn_fail: + printf("*** %s FAILED\n\n", TEST_NAME); + + return -1; +} diff --git a/test/mng_mod/issues/1031/x86_64/CT_005.c b/test/mng_mod/issues/1031/x86_64/CT_005.c new file mode 100644 index 00000000..fff26726 --- /dev/null +++ b/test/mng_mod/issues/1031/x86_64/CT_005.c @@ -0,0 +1,71 @@ +#include +#include +#include +#include +#include +#include "./test_chk.h" + +#define TEST_NAME "CT_005" + +int handled_cnt = 0; + +void test_handler(int sig) +{ + handled_cnt++; +} + +int main(int argc, char** argv) +{ + int rc = 0; + int pid = 0; + int status; + int tmp_flag = 0; + struct sigaction sa; + + printf("*** %s start *******************************\n", TEST_NAME); + + pid = fork(); + CHKANDJUMP(pid == -1, "fork"); + + if (pid == 0) { /* child */ + sa.sa_handler = test_handler; + sa.sa_flags = SA_RESETHAND; + + rc = sigaction(SIGUSR1, &sa, NULL); + OKNG(rc != 0, "sigaction with SA_RESETHAND"); + + printf(" send 1st SIGUSR1\n"); + kill(getpid(), SIGUSR1); + OKNG(handled_cnt != 1, "invoked test_handler"); + + rc = sigaction(SIGUSR1, &sa, NULL); + OKNG(rc != 0, "sigaction with SA_RESETHAND again"); + + printf(" send 2nd SIGUSR1\n"); + kill(getpid(), SIGUSR1); + OKNG(handled_cnt != 2, "invoked test_handler again"); + + printf(" send 3rd SIGUSR1\n"); + kill(getpid(), SIGUSR1); + OKNG(1, "can't reach here"); + } else { /* parent */ + rc = waitpid(pid, &status, 0); + CHKANDJUMP(rc == -1, "waitpid"); + + if (WIFSIGNALED(status)) { + if (WTERMSIG(status) == SIGUSR1) { + tmp_flag = 1; + } + } + OKNG(tmp_flag != 1, "child is killed by SIGUSR1"); + } + + printf("*** %s PASSED\n\n", TEST_NAME); + + return 0; + +fn_fail: + printf("*** %s FAILED\n\n", TEST_NAME); + + return -1; +} diff --git a/test/mng_mod/issues/1031/x86_64/CT_006.c b/test/mng_mod/issues/1031/x86_64/CT_006.c new file mode 100644 index 00000000..718bac07 --- /dev/null +++ b/test/mng_mod/issues/1031/x86_64/CT_006.c @@ -0,0 +1,49 @@ +#include +#include +#include +#include +#include +#include "./test_chk.h" + +#define TEST_NAME "CT_006" + +int handled_cnt = 0; + +void test_handler(int sig) +{ + handled_cnt++; +} + +int main(int argc, char** argv) +{ + int rc = 0; + int status; + int tmp_flag = 0; + struct sigaction sa, old_act; + + printf("*** %s start *******************************\n", TEST_NAME); + + sa.sa_handler = test_handler; + sa.sa_flags = SA_RESETHAND; + + rc = sigaction(SIGUSR1, &sa, NULL); + OKNG(rc != 0, "sigaction with SA_RESETHAND"); + + rc = sigaction(SIGUSR1, NULL, &old_act); + OKNG(rc != 0, "sigaction to get current action"); + + if (old_act.sa_handler == test_handler && + old_act.sa_flags & SA_RESETHAND) { + tmp_flag = 1; + } + OKNG(tmp_flag != 1, "check current act"); + + printf("*** %s PASSED\n\n", TEST_NAME); + + return 0; + +fn_fail: + printf("*** %s FAILED\n\n", TEST_NAME); + + return -1; +} diff --git a/test/mng_mod/issues/1031/x86_64/CT_007.c b/test/mng_mod/issues/1031/x86_64/CT_007.c new file mode 100644 index 00000000..dcf1634e --- /dev/null +++ b/test/mng_mod/issues/1031/x86_64/CT_007.c @@ -0,0 +1,52 @@ +#include +#include +#include +#include +#include +#include "./test_chk.h" + +#define TEST_NAME "CT_007" + +int handled_cnt = 0; + +void test_handler(int sig) +{ + handled_cnt++; +} + +int main(int argc, char** argv) +{ + int rc = 0; + int status; + int tmp_flag = 0; + struct sigaction sa, old_act; + + printf("*** %s start *******************************\n", TEST_NAME); + + sa.sa_handler = test_handler; + sa.sa_flags = SA_RESETHAND; + + rc = sigaction(SIGUSR1, &sa, NULL); + OKNG(rc != 0, "sigaction with SA_RESETHAND"); + + printf(" send 1st SIGUSR1\n"); + kill(getpid(), SIGUSR1); + OKNG(handled_cnt != 1, "invoked test_handler"); + + rc = sigaction(SIGUSR1, NULL, &old_act); + OKNG(rc != 0, "sigaction to get current action"); + + if (old_act.sa_handler == SIG_DFL) { + tmp_flag = 1; + } + OKNG(tmp_flag != 1, "check current act (after reset)"); + + printf("*** %s PASSED\n\n", TEST_NAME); + + return 0; + +fn_fail: + printf("*** %s FAILED\n\n", TEST_NAME); + + return -1; +} diff --git a/test/mng_mod/issues/1031/x86_64/CT_008.c b/test/mng_mod/issues/1031/x86_64/CT_008.c new file mode 100644 index 00000000..23d528be --- /dev/null +++ b/test/mng_mod/issues/1031/x86_64/CT_008.c @@ -0,0 +1,46 @@ +#include +#include +#include +#include +#include +#include "./test_chk.h" + +#define TEST_NAME "CT_008" + +int handled_cnt = 0; + +void test_handler(int sig) +{ + handled_cnt++; +} + +int main(int argc, char** argv) +{ + int rc = 0; + int status; + int tmp_flag = 0; + struct sigaction sa, old_act; + + printf("*** %s start *******************************\n", TEST_NAME); + + rc = sigaction(0, &sa, NULL); + OKNG(rc != -1, "sigaction 0 failed"); + + rc = sigaction(_NSIG, &sa, NULL); + OKNG(rc != -1, "sigaction _NSIG failed"); + + rc = sigaction(SIGKILL, &sa, NULL); + OKNG(rc != -1, "sigaction SIGKILL failed"); + + rc = sigaction(SIGSTOP, &sa, NULL); + OKNG(rc != -1, "sigaction SIGSTOP failed"); + + printf("*** %s PASSED\n\n", TEST_NAME); + + return 0; + +fn_fail: + printf("*** %s FAILED\n\n", TEST_NAME); + + return -1; +} diff --git a/test/mng_mod/issues/1031/x86_64/CT_009.c b/test/mng_mod/issues/1031/x86_64/CT_009.c new file mode 100644 index 00000000..0c26e9f0 --- /dev/null +++ b/test/mng_mod/issues/1031/x86_64/CT_009.c @@ -0,0 +1,44 @@ +#include +#include +#include +#include +#include +#include "./test_chk.h" + +#define TEST_NAME "CT_009" + +int main(int argc, char** argv) +{ + int rc = 0; + int status; + int tmp_flag = 0; + struct sigaction old_act; + + printf("*** %s start *******************************\n", TEST_NAME); + + rc = sigaction(SIGKILL, NULL, &old_act); + OKNG(rc != 0, "sigaction to get SIGKILL action"); + + if (old_act.sa_handler == SIG_DFL) { + tmp_flag = 1; + } + OKNG(tmp_flag != 1, "check SIGKILL act"); + + rc = sigaction(SIGSTOP, NULL, &old_act); + OKNG(rc != 0, "sigaction to get SIGSTOP action"); + + tmp_flag = 0; + if (old_act.sa_handler == SIG_DFL) { + tmp_flag = 1; + } + OKNG(tmp_flag != 1, "check SIGSTOP act"); + + printf("*** %s PASSED\n\n", TEST_NAME); + + return 0; + +fn_fail: + printf("*** %s FAILED\n\n", TEST_NAME); + + return -1; +} diff --git a/test/mng_mod/issues/1031/x86_64/CT_010.c b/test/mng_mod/issues/1031/x86_64/CT_010.c new file mode 100644 index 00000000..8229bb20 --- /dev/null +++ b/test/mng_mod/issues/1031/x86_64/CT_010.c @@ -0,0 +1,37 @@ +#include +#include +#include +#include +#include +#include "./test_chk.h" + +#define TEST_NAME "CT_010" + +int main(int argc, char** argv) +{ + int rc = 0; + int status; + + printf("*** %s start *******************************\n", TEST_NAME); + + rc = sigaction(SIGUSR1, NULL, NULL); + OKNG(rc != 0, "SIGUSR1 is valid"); + + rc = sigaction(SIGKILL, NULL, NULL); + OKNG(rc != 0, "SIGKILL is valid"); + + rc = sigaction(SIGSTOP, NULL, NULL); + OKNG(rc != 0, "SIGSTOP is valid"); + + rc = sigaction(_NSIG, NULL, NULL); + OKNG(rc != -1, "_NSIG is invalid"); + + printf("*** %s PASSED\n\n", TEST_NAME); + + return 0; + +fn_fail: + printf("*** %s FAILED\n\n", TEST_NAME); + + return -1; +} diff --git a/test/mng_mod/issues/1031/Makefile b/test/mng_mod/issues/1031/x86_64/Makefile similarity index 100% rename from test/mng_mod/issues/1031/Makefile rename to test/mng_mod/issues/1031/x86_64/Makefile diff --git a/test/mng_mod/issues/1031/README b/test/mng_mod/issues/1031/x86_64/README similarity index 100% rename from test/mng_mod/issues/1031/README rename to test/mng_mod/issues/1031/x86_64/README diff --git a/test/mng_mod/issues/1031/result.log b/test/mng_mod/issues/1031/x86_64/result.log similarity index 100% rename from test/mng_mod/issues/1031/result.log rename to test/mng_mod/issues/1031/x86_64/result.log diff --git a/test/mng_mod/issues/1031/x86_64/test_chk.h b/test/mng_mod/issues/1031/x86_64/test_chk.h new file mode 100644 index 00000000..e0f45e6e --- /dev/null +++ b/test/mng_mod/issues/1031/x86_64/test_chk.h @@ -0,0 +1,25 @@ +#ifndef HEADER_TEST_CHK_H +#define HEADER_TEST_CHK_H + +#define CHKANDJUMP(cond, ...) \ + do { \ + if (cond) { \ + fprintf(stderr, " [NG] "); \ + fprintf(stderr, __VA_ARGS__); \ + fprintf(stderr, " failed\n"); \ + goto fn_fail; \ + } \ + } while(0); + +#define OKNG(cond, ...) \ + do { \ + if (cond) { \ + CHKANDJUMP(cond, __VA_ARGS__); \ + } else { \ + fprintf(stdout, " [OK] "); \ + fprintf(stdout, __VA_ARGS__); \ + fprintf(stdout, "\n"); \ + } \ + } while(0); + +#endif