test: sigaltstack -- Drop useless test of a leader stack

Submitted by Cyrill Gorcunov on Nov. 6, 2017, 2:13 p.m.

Details

Message ID 1509977593-7099-1-git-send-email-gorcunov@openvz.org
State New
Series "test: sigaltstack -- Drop useless test of a leader stack"
Headers show

Commit Message

Cyrill Gorcunov Nov. 6, 2017, 2:13 p.m.
From: Cyrill Gorcunov <gorcunov@virtuozzo.com>

In CRIU we use sigalstack call to fetch current sas state,
but this syscall is simply return info about alternate
signal stack which took place prior sigalstack call
itself. So that to make test validate values we
need to make sure the sigalstack is called inside
signal handler itself. So drop unneded calls in
a leader.

Note the kernel itself figures out if it should swith
signal handler ta alternate stack from sigaction
descriptor.

Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
---
 test/zdtm/static/sigaltstack.c | 41 +----------------------------------------
 1 file changed, 1 insertion(+), 40 deletions(-)

Patch hide | download patch | download mbox

diff --git a/test/zdtm/static/sigaltstack.c b/test/zdtm/static/sigaltstack.c
index 3ccd182..be7599c 100644
--- a/test/zdtm/static/sigaltstack.c
+++ b/test/zdtm/static/sigaltstack.c
@@ -15,11 +15,8 @@  const char *test_doc	= "Check for alternate signal stack";
 const char *test_author	= "Cyrill Gorcunov <gorcunov@openvz.org>";
 
 static char stack_thread[SIGSTKSZ + TEST_MSG_BUFFER_SIZE] __stack_aligned__;
-static char stack_main[SIGSTKSZ + TEST_MSG_BUFFER_SIZE] __stack_aligned__;
 
 enum {
-	SAS_MAIN_OLD,
-	SAS_MAIN_NEW,
 	SAS_THRD_OLD,
 	SAS_THRD_NEW,
 
@@ -91,49 +88,18 @@  static void *thread_func(void *arg)
 	return NULL;
 }
 
-void leader_sigaction(int signo, siginfo_t *info, void *context)
-{
-	if (sigaltstack(NULL, &sas_state[SAS_MAIN_NEW]))
-		pr_perror("leader sigaltstack");
-
-	show_ss("leader in sas", &sas_state[SAS_MAIN_NEW]);
-}
-
 int main(int argc, char *argv[])
 {
 	pthread_t thread;
 
-	sas_state[SAS_MAIN_OLD] = (stack_t) {
-		.ss_size	= sizeof(stack_main) - 8,
-		.ss_sp		= stack_main,
-		.ss_flags	= SS_ONSTACK,
-	};
-
-	struct sigaction sa = {
-		.sa_sigaction	= leader_sigaction,
-		.sa_flags	= SA_RESTART | SA_ONSTACK,
-	};
-
-	sigemptyset(&sa.sa_mask);
-
 	test_init(argc, argv);
 	task_waiter_init(&t);
 
-	if (sigaction(SIGUSR1, &sa, NULL)) {
-		pr_perror("Can't set SIGUSR1 handler");
-		exit(-1);
-	}
-
 	if (pthread_create(&thread, NULL, &thread_func, NULL)) {
 		pr_perror("Can't create thread");
 		exit(-1);
 	}
 
-	if (sigaltstack(&sas_state[SAS_MAIN_OLD], NULL)) {
-		pr_perror("sigaltstack");
-		exit(-1);
-	}
-
 	task_waiter_complete(&t, 1);
 	task_waiter_wait4(&t, 2);
 
@@ -143,21 +109,16 @@  int main(int argc, char *argv[])
 	test_msg("Thread may leave SAS\n");
 	task_waiter_complete(&t, 3);
 
-	syscall(__NR_tkill, gettid(), SIGUSR1);
-
 	if (pthread_join(thread, NULL)) {
 		fail("Error joining thread");
 		exit(-1);
 	}
 	task_waiter_fini(&t);
 
-	show_ss("main old", &sas_state[SAS_MAIN_OLD]);
-	show_ss("main new", &sas_state[SAS_MAIN_NEW]);
 	show_ss("thrd old", &sas_state[SAS_THRD_OLD]);
 	show_ss("thrd new", &sas_state[SAS_THRD_NEW]);
 
-	if (sascmp(&sas_state[SAS_MAIN_OLD], &sas_state[SAS_MAIN_NEW]) ||
-	    sascmp(&sas_state[SAS_THRD_OLD], &sas_state[SAS_THRD_NEW])) {
+	if (sascmp(&sas_state[SAS_THRD_OLD], &sas_state[SAS_THRD_NEW])) {
 		fail("sas not restored");
 	} else
 		pass();