Skip to contentSkip to conversation

syscalls: add rt_tgsigqueueinfo() test-case

PATCH New Sumit Garg 3 participants 4 messages Feb 25, 2019 – Mar 5, 2019

lore
Share & tools
lore

Sumit Garg

author
#0 lore raw

PATCH 1/1 syscalls: add rt_tgsigqueueinfo() test-case

This tests the rt_tgsigqueueinfo() syscall used to queue a signal and data to the single thread specified by the combination of tgid, a thread group ID, and tid, a thread in that thread group.

---
 runtest/syscalls                                   |  1 +
 .../kernel/syscalls/rt_tgsigqueueinfo/.gitignore   |  1 +
 .../kernel/syscalls/rt_tgsigqueueinfo/Makefile     | 10 ++++
 .../rt_tgsigqueueinfo/rt_tgsigqueueinfo01.c        | 53 ++++++++++++++++++++++
 4 files changed, 65 insertions(+)
 create mode 100644 testcases/kernel/syscalls/rt_tgsigqueueinfo/.gitignore
 create mode 100644 testcases/kernel/syscalls/rt_tgsigqueueinfo/Makefile
 create mode 100644 testcases/kernel/syscalls/rt_tgsigqueueinfo/rt_tgsigqueueinfo01.c
runtest/syscalls +1 -0
index 70d3561..861c0a6 100644
@@ -996,6 +996,7 @@ rt_sigprocmask01 rt_sigprocmask01
 rt_sigprocmask02 rt_sigprocmask02
 rt_sigqueueinfo01 rt_sigqueueinfo01
 rt_sigsuspend01 rt_sigsuspend01
+rt_tgsigqueueinfo01 rt_tgsigqueueinfo01
 
 sbrk01 sbrk01
 sbrk02 sbrk02
testcases/kernel/syscalls/rt_tgsigqueueinfo/.gitignore new file +1 -0
new file mode 100644
index 0000000..f9ffa58
@@ -0,0 +1 @@
+rt_tgsigqueueinfo01
testcases/kernel/syscalls/rt_tgsigqueueinfo/Makefile new file +10 -0
new file mode 100644
index 0000000..035ca64
@@ -0,0 +1,10 @@
+# Copyright (c) 2019 - Linaro Limited. All rights reserved.
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+top_srcdir             ?= ../../../..
+
+rt_tgsigqueueinfo01: CFLAGS+=-pthread
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/rt_tgsigqueueinfo/rt_tgsigqueueinfo01.c new file +53 -0

53 lines not on this page · raw message

Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 syscalls: add rt_tgsigqueueinfo() test-case

Hi Sumit,

Quoted 75 lines · Sumit Garg

This tests the rt_tgsigqueueinfo() syscall used to queue a signal and data to the single thread specified by the combination of tgid, a thread group ID, and tid, a thread in that thread group.

---
  runtest/syscalls                                   |  1 +
  .../kernel/syscalls/rt_tgsigqueueinfo/.gitignore   |  1 +
  .../kernel/syscalls/rt_tgsigqueueinfo/Makefile     | 10 ++++
  .../rt_tgsigqueueinfo/rt_tgsigqueueinfo01.c        | 53 ++++++++++++++++++++++
  4 files changed, 65 insertions(+)

create mode 100644 testcases/kernel/syscalls/rt_tgsigqueueinfo/.gitignore create mode 100644 testcases/kernel/syscalls/rt_tgsigqueueinfo/Makefile create mode 100644 testcases/kernel/syscalls/rt_tgsigqueueinfo/rt_tgsigqueueinfo01.c

runtest/syscalls +1 -0
index 70d3561..861c0a6 100644
@@ -996,6 +996,7 @@ rt_sigprocmask01 rt_sigprocmask01
  rt_sigprocmask02 rt_sigprocmask02
  rt_sigqueueinfo01 rt_sigqueueinfo01
  rt_sigsuspend01 rt_sigsuspend01
+rt_tgsigqueueinfo01 rt_tgsigqueueinfo01
 
  sbrk01 sbrk01
  sbrk02 sbrk02
testcases/kernel/syscalls/rt_tgsigqueueinfo/.gitignore new file +1 -0
new file mode 100644
index 0000000..f9ffa58
@@ -0,0 +1 @@
+rt_tgsigqueueinfo01
testcases/kernel/syscalls/rt_tgsigqueueinfo/Makefile new file +10 -0
new file mode 100644
index 0000000..035ca64
@@ -0,0 +1,10 @@
+# Copyright (c) 2019 - Linaro Limited. All rights reserved.
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+top_srcdir             ?= ../../../..
+
+rt_tgsigqueueinfo01: CFLAGS+=-pthread
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/rt_tgsigqueueinfo/rt_tgsigqueueinfo01.c new file +19 -0
new file mode 100644
index 0000000..336b968
@@ -0,0 +1,53 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2019 Linaro Limited. All rights reserved.
+ * Author: Sumit Garg <[email protected]>
+ */
+
+/*
+ * Test rt_tgsigqueueinfo
+ *
+ * This tests the rt_tgsigqueueinfo() syscall. It sends the signal and data
+ * to the single thread specified by the combination of tgid, a thread group
+ * ID, and tid, a thread in that thread group.
+ */
+
+#define _GNU_SOURCE
+#include <err.h>
+#include <pthread.h>
+#include "tst_test.h"
+#include "lapi/syscalls.h"

testcases/kernel/syscalls/rt_tgsigqueueinfo/rt_tgsigqueueinfo01.c line 29

Quoted 10 lines
testcases/kernel/syscalls/rt_tgsigqueueinfo/rt_tgsigqueueinfo01.c new file +10 -0
+
+void *tfunc(void *arg LTP_ATTRIBUTE_UNUSED)
+{
+	siginfo_t uinfo;
+
+	uinfo.si_errno = 0;
+	uinfo.si_code = SI_QUEUE;
+
+	TEST(tst_syscall(__NR_rt_tgsigqueueinfo, getpid(),
+			 syscall(__NR_gettid), SIGCHLD, &uinfo));

It looks like the pthread here is sending the signal to itself which seems like a special case. Not that it isn't worth testing but I'd think there should be a test which sends the signal to a different thread. This (the self-send case) could be an additional test.

testcases/kernel/syscalls/rt_tgsigqueueinfo/rt_tgsigqueueinfo01.c line 33

Quoted 4 lines
testcases/kernel/syscalls/rt_tgsigqueueinfo/rt_tgsigqueueinfo01.c new file +4 -0
+	if (TST_RET)
+		tst_res(TFAIL, "Test Failed");
+	else
+		tst_res(TPASS, "Test Succeeded");

I recommend verifying the signal and its data (si_value) are delivered successfully prior to test completion.

Quoted 11 lines
testcases/kernel/syscalls/rt_tgsigqueueinfo/rt_tgsigqueueinfo01.c new file +10 -0
+
+	return NULL;
+}
+
+static void verify_rt_tgsigqueueinfo(void)
+{
+	pthread_t pt;
+
+	TEST(pthread_create(&pt, NULL, tfunc, NULL));
+	if (TST_RET)

testcases/kernel/syscalls/rt_tgsigqueueinfo/rt_tgsigqueueinfo01.c line 53

Quoted 10 lines
testcases/kernel/syscalls/rt_tgsigqueueinfo/rt_tgsigqueueinfo01.c new file +10 -0
+		tst_brk(TFAIL | TTERRNO, "pthread_create failed");
+
+	TEST(pthread_join(pt, NULL));
+	if (TST_RET)
+		tst_brk(TFAIL | TTERRNO, "pthread_join failed");
+}
+
+static struct tst_test test = {
+	.test_all = verify_rt_tgsigqueueinfo,
+};

thanks,
steve

author
#2 lore raw

PATCH 1/1 syscalls: add rt_tgsigqueueinfo() test-case

Thanks Steve for the review.

Quoted 86 lines · Steve Muckle

Hi Sumit,

Quoted 82 lines · Sumit Garg

This tests the rt_tgsigqueueinfo() syscall used to queue a signal and data to the single thread specified by the combination of tgid, a thread group ID, and tid, a thread in that thread group.

---
  runtest/syscalls                                   |  1 +
  .../kernel/syscalls/rt_tgsigqueueinfo/.gitignore   |  1 +
  .../kernel/syscalls/rt_tgsigqueueinfo/Makefile     | 10 ++++
  .../rt_tgsigqueueinfo/rt_tgsigqueueinfo01.c        | 53 ++++++++++++++++++++++
  4 files changed, 65 insertions(+)

create mode 100644 testcases/kernel/syscalls/rt_tgsigqueueinfo/.gitignore create mode 100644 testcases/kernel/syscalls/rt_tgsigqueueinfo/Makefile create mode 100644 testcases/kernel/syscalls/rt_tgsigqueueinfo/rt_tgsigqueueinfo01.c

runtest/syscalls +1 -0
index 70d3561..861c0a6 100644
@@ -996,6 +996,7 @@ rt_sigprocmask01 rt_sigprocmask01
  rt_sigprocmask02 rt_sigprocmask02
  rt_sigqueueinfo01 rt_sigqueueinfo01
  rt_sigsuspend01 rt_sigsuspend01
+rt_tgsigqueueinfo01 rt_tgsigqueueinfo01
 
  sbrk01 sbrk01
  sbrk02 sbrk02
testcases/kernel/syscalls/rt_tgsigqueueinfo/.gitignore new file +1 -0
new file mode 100644
index 0000000..f9ffa58
@@ -0,0 +1 @@
+rt_tgsigqueueinfo01
testcases/kernel/syscalls/rt_tgsigqueueinfo/Makefile new file +10 -0
new file mode 100644
index 0000000..035ca64
@@ -0,0 +1,10 @@
+# Copyright (c) 2019 - Linaro Limited. All rights reserved.
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+top_srcdir             ?= ../../../..
+
+rt_tgsigqueueinfo01: CFLAGS+=-pthread
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/rt_tgsigqueueinfo/rt_tgsigqueueinfo01.c new file +26 -0
new file mode 100644
index 0000000..336b968
@@ -0,0 +1,53 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2019 Linaro Limited. All rights reserved.
+ * Author: Sumit Garg <[email protected]>
+ */
+
+/*
+ * Test rt_tgsigqueueinfo
+ *
+ * This tests the rt_tgsigqueueinfo() syscall. It sends the signal and data
+ * to the single thread specified by the combination of tgid, a thread group
+ * ID, and tid, a thread in that thread group.
+ */
+
+#define _GNU_SOURCE
+#include <err.h>
+#include <pthread.h>
+#include "tst_test.h"
+#include "lapi/syscalls.h"
+
+void *tfunc(void *arg LTP_ATTRIBUTE_UNUSED)
+{
+     siginfo_t uinfo;
+
+     uinfo.si_errno = 0;
+     uinfo.si_code = SI_QUEUE;
Quoted 9 lines

testcases/kernel/syscalls/rt_tgsigqueueinfo/rt_tgsigqueueinfo01.c line 29

Quoted 3 lines
testcases/kernel/syscalls/rt_tgsigqueueinfo/rt_tgsigqueueinfo01.c new file +3 -0
+
+     TEST(tst_syscall(__NR_rt_tgsigqueueinfo, getpid(),
+                      syscall(__NR_gettid), SIGCHLD, &uinfo));

It looks like the pthread here is sending the signal to itself which seems like a special case. Not that it isn't worth testing but I'd think there should be a test which sends the signal to a different thread. This (the self-send case) could be an additional test.

Hmm. So do you suggest to add following cases?

1. parent -> thread
2. thread1 -> thread2

BTW, in above cases I think we need to communicate "tid" obtained via gettid() to parent and other thread to queue signal which could be done via "arg" parameter in pthread_create().

Quoted 8 lines

testcases/kernel/syscalls/rt_tgsigqueueinfo/rt_tgsigqueueinfo01.c line 33

Quoted 4 lines
testcases/kernel/syscalls/rt_tgsigqueueinfo/rt_tgsigqueueinfo01.c new file +4 -0
+     if (TST_RET)
+             tst_res(TFAIL, "Test Failed");
+     else
+             tst_res(TPASS, "Test Succeeded");

I recommend verifying the signal and its data (si_value) are delivered successfully prior to test completion.

Ok, will add this verification via signal handler.

-Sumit

Quoted 25 lines
Quoted 11 lines
testcases/kernel/syscalls/rt_tgsigqueueinfo/rt_tgsigqueueinfo01.c new file +10 -0
+
+     return NULL;
+}
+
+static void verify_rt_tgsigqueueinfo(void)
+{
+     pthread_t pt;
+
+     TEST(pthread_create(&pt, NULL, tfunc, NULL));
+     if (TST_RET)

testcases/kernel/syscalls/rt_tgsigqueueinfo/rt_tgsigqueueinfo01.c line 53

Quoted 10 lines
testcases/kernel/syscalls/rt_tgsigqueueinfo/rt_tgsigqueueinfo01.c new file +10 -0
+             tst_brk(TFAIL | TTERRNO, "pthread_create failed");
+
+     TEST(pthread_join(pt, NULL));
+     if (TST_RET)
+             tst_brk(TFAIL | TTERRNO, "pthread_join failed");
+}
+
+static struct tst_test test = {
+     .test_all = verify_rt_tgsigqueueinfo,
+};

thanks,
steve

#3 lore raw

PATCH 1/1 syscalls: add rt_tgsigqueueinfo() test-case

In reply to Steve Muckle

Hi!

Quoted 5 lines

It looks like the pthread here is sending the signal to itself which seems like a special case. Not that it isn't worth testing but I'd think there should be a test which sends the signal to a different thread. This (the self-send case) could be an additional test.

Quoted 7 lines

testcases/kernel/syscalls/rt_tgsigqueueinfo/rt_tgsigqueueinfo01.c line 33

Quoted 4 lines
testcases/kernel/syscalls/rt_tgsigqueueinfo/rt_tgsigqueueinfo01.c new file +4 -0
+	if (TST_RET)
+		tst_res(TFAIL, "Test Failed");
+	else
+		tst_res(TPASS, "Test Succeeded");

I recommend verifying the signal and its data (si_value) are delivered successfully prior to test completion.

Agreed.

Also we do have rt_sigqueueinfo01.c tests that lacks these checks as well, it may be a good idea to rewrite that test as well, quite possibly some code could be shared between these two as well.

Signature · 2 lines
Cyril Hrubis
[email protected]