Skip to contentSkip to conversation

Refactor mqns testing suite

PATCH Applied Andrea Cervesato via ltp 3 participants 23 messages Jul 22, 2022 – Nov 1, 2022

lore
Share & tools
lore
#0 lore raw

v3 cover Refactor mqns testing suite

mqns testing suite has been refactored using new LTP API

Andrea Cervesato (7):
Add more safe macros for mqueue API
Refactor mqns_01 using new LTP API
Refactor mqns_02 using new LTP API
Refactor mqns_03 using new LTP API
Refactor mqns_04 using new LTP API
Delete deprecated mqns header files
Rename common.h into mqns.h for mqns suite

 include/tst_safe_posix_ipc.h                  |  45 +++
 runtest/containers                            |  12 +-
 testcases/kernel/containers/mqns/Makefile     |  27 +-
 testcases/kernel/containers/mqns/mqns.h       | 108 ++++++-
 testcases/kernel/containers/mqns/mqns_01.c    | 185 ++++--------
 testcases/kernel/containers/mqns/mqns_02.c    | 217 ++++----------
 testcases/kernel/containers/mqns/mqns_03.c    | 269 +++++++-----------
 testcases/kernel/containers/mqns/mqns_04.c    | 263 ++++++++---------
 .../kernel/containers/mqns/mqns_helper.h      |  56 ----
 9 files changed, 485 insertions(+), 697 deletions(-)
 delete mode 100644 testcases/kernel/containers/mqns/mqns_helper.h
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

PATCH v3 1/7 Add more safe macros for mqueue API

Added SAFE_MQ_UNLINK and SAFE_MQ_CLOSE in tst_safe_posix_ipc.h

---
 include/tst_safe_posix_ipc.h | 45 ++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
include/tst_safe_posix_ipc.h +45 -0
index b60c12c9e..5bfef03a9 100644
@@ -12,6 +12,12 @@
 #define SAFE_MQ_OPEN(pathname, oflags, ...) \
 	safe_mq_open(__FILE__, __LINE__, (pathname), (oflags), ##__VA_ARGS__)
 
+#define SAFE_MQ_CLOSE(__mqdes) \
+	safe_mq_close(__FILE__, __LINE__, (__mqdes))
+
+#define SAFE_MQ_UNLINK(name) \
+	safe_mq_unlink(__FILE__, __LINE__, (name))
+
 static inline int safe_mq_open(const char *file, const int lineno,
 			       const char *pathname, int oflags, ...)
 {
@@ -41,6 +47,45 @@ static inline int safe_mq_open(const char *file, const int lineno,
 		tst_brk_(file, lineno, TBROK | TERRNO,
 			"mq_open(%s,%d,%04o,%p) failed", pathname, oflags,
 			mode, attr);
+	} else if (rval < 0) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			"Invalid mq_open(%s) return value %d", pathname, rval);
+	}
+
+	return rval;
+}
+
+static inline int safe_mq_close(const char *file, const int lineno,
+				mqd_t __mqdes)
+{
+	int rval;
+
+	rval = mq_close(__mqdes);
+
+	if (rval == -1) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			"mq_close(%d) failed", __mqdes);
+	} else if (rval < 0) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			"Invalid mq_close(%d) return value %d", __mqdes, rval);
+	}
+
+	return rval;
+}
+
+static inline int safe_mq_unlink(const char *file, const int lineno,
+				const char* name)
+{
+	int rval;
+
+	rval = mq_unlink(name);
+
+	if (rval == -1) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			"mq_unlink(%s) failed", name);
+	} else if (rval < 0) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			"Invalid mq_unlink(%s) return value %d", name, rval);
 	}
 
 	return rval;
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v3 1/7
#2 lore raw

Re: [LTP] [PATCH v3 1/7] Add more safe macros for mqueue API

Hi Andrea,

Quoted 1 line

Added SAFE_MQ_UNLINK and SAFE_MQ_CLOSE in tst_safe_posix_ipc.h

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw

Re: [LTP] [PATCH v3 1/7] Add more safe macros for mqueue API

In reply to Andrea Cervesato via ltp

Hello,

Merged, thanks!

Quoted 72 lines · Andrea Cervesato via ltp

Added SAFE_MQ_UNLINK and SAFE_MQ_CLOSE in tst_safe_posix_ipc.h

---
 include/tst_safe_posix_ipc.h | 45 ++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
include/tst_safe_posix_ipc.h +45 -0
index b60c12c9e..5bfef03a9 100644
@@ -12,6 +12,12 @@
 #define SAFE_MQ_OPEN(pathname, oflags, ...) \
 	safe_mq_open(__FILE__, __LINE__, (pathname), (oflags), ##__VA_ARGS__)
 
+#define SAFE_MQ_CLOSE(__mqdes) \
+	safe_mq_close(__FILE__, __LINE__, (__mqdes))
+
+#define SAFE_MQ_UNLINK(name) \
+	safe_mq_unlink(__FILE__, __LINE__, (name))
+
 static inline int safe_mq_open(const char *file, const int lineno,
 			       const char *pathname, int oflags, ...)
 {
@@ -41,6 +47,45 @@ static inline int safe_mq_open(const char *file, const int lineno,
 		tst_brk_(file, lineno, TBROK | TERRNO,
 			"mq_open(%s,%d,%04o,%p) failed", pathname, oflags,
 			mode, attr);
+	} else if (rval < 0) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			"Invalid mq_open(%s) return value %d", pathname, rval);
+	}
+
+	return rval;
+}
+
+static inline int safe_mq_close(const char *file, const int lineno,
+				mqd_t __mqdes)
+{
+	int rval;
+
+	rval = mq_close(__mqdes);
+
+	if (rval == -1) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			"mq_close(%d) failed", __mqdes);
+	} else if (rval < 0) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			"Invalid mq_close(%d) return value %d", __mqdes, rval);
+	}
+
+	return rval;
+}
+
+static inline int safe_mq_unlink(const char *file, const int lineno,
+				const char* name)
+{
+	int rval;
+
+	rval = mq_unlink(name);
+
+	if (rval == -1) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			"mq_unlink(%s) failed", name);
+	} else if (rval < 0) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			"Invalid mq_unlink(%s) return value %d", name, rval);
 	}
 
 	return rval;
Signature · 1 line
2.35.3
Signature · 5 lines
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw

PATCH v3 2/7 Refactor mqns_01 using new LTP API

In reply to Andrea Cervesato via ltp
---
 runtest/containers                         |   3 +-
 testcases/kernel/containers/mqns/common.h  | 101 +++++++++++
 testcases/kernel/containers/mqns/mqns_01.c | 193 +++++++--------------
 3 files changed, 166 insertions(+), 131 deletions(-)
 create mode 100644 testcases/kernel/containers/mqns/common.h
runtest/containers +2 -1
index 2637b62fe..863a964ad 100644
@@ -16,7 +16,8 @@ pidns31 pidns31
 pidns32 pidns32
 
 mqns_01 mqns_01
-mqns_01_clone mqns_01 -clone
+mqns_01_clone mqns_01 -m clone
+mqns_01_unshare mqns_01 -m unshare
 mqns_02 mqns_02
 mqns_02_clone mqns_02 -clone
 mqns_03 mqns_03
testcases/kernel/containers/mqns/common.h new file +101 -0

101 lines not on this page · raw message

testcases/kernel/containers/mqns/mqns_01.c +63 -130

211 lines not on this page · raw message

Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw

Re: [LTP] [PATCH v3 2/7] Refactor mqns_01 using new LTP API

Hello,

Quoted 49 lines · Andrea Cervesato via ltp
---
 runtest/containers                         |   3 +-
 testcases/kernel/containers/mqns/common.h  | 101 +++++++++++
 testcases/kernel/containers/mqns/mqns_01.c | 193 +++++++--------------
 3 files changed, 166 insertions(+), 131 deletions(-)
 create mode 100644 testcases/kernel/containers/mqns/common.h
runtest/containers +2 -1
index 2637b62fe..863a964ad 100644
@@ -16,7 +16,8 @@ pidns31 pidns31
 pidns32 pidns32
 
 mqns_01 mqns_01
-mqns_01_clone mqns_01 -clone
+mqns_01_clone mqns_01 -m clone
+mqns_01_unshare mqns_01 -m unshare
 mqns_02 mqns_02
 mqns_02_clone mqns_02 -clone
 mqns_03 mqns_03
testcases/kernel/containers/mqns/common.h new file +21 -0
new file mode 100644
index 000000000..92a77b566
@@ -0,0 +1,101 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2022 SUSE LLC Andrea Cervesato <[email protected]>
+ */
+
+#ifndef MQNS_H
+#define MQNS_H
+
+#include <stdlib.h>
+#include "lapi/namespaces_constants.h"
+#include "tst_test.h"
+#include "tst_safe_posix_ipc.h"
+
+enum {
+	T_CLONE,
+	T_UNSHARE,
+	T_NONE,
+};
+
+static int dummy_child1(void *v)
+{

testcases/kernel/containers/mqns/common.h

Quoted 10 lines
testcases/kernel/containers/mqns/common.h new file +9 -0
+	(void)v;
+	return 0;
+}
+
+static inline void check_newipc(void)
+{
+	int pid, status;
+
+	pid = ltp_clone_quick(CLONE_NEWIPC | SIGCHLD, dummy_child1,
 NULL);

ltp_clone_quick is still part of the old API and only uses clone2. I think it should be replaced with tst_clone. This may require extending tst_clone. In fact we probably need a test variant to switch between the clone2 and clone3 syscalls when using tst_clone.

I'll leave it to you whether you want to try that and rebase this patch set on it.

Signature · 5 lines
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#6 lore raw

Re: [LTP] [PATCH v3 2/7] Refactor mqns_01 using new LTP API

Hi!

Quoted 68 lines · Richard Palethorpe

Hello,

Quoted 49 lines · Andrea Cervesato via ltp
---
  runtest/containers                         |   3 +-
  testcases/kernel/containers/mqns/common.h  | 101 +++++++++++
  testcases/kernel/containers/mqns/mqns_01.c | 193 +++++++--------------
  3 files changed, 166 insertions(+), 131 deletions(-)

create mode 100644 testcases/kernel/containers/mqns/common.h

runtest/containers +2 -1
index 2637b62fe..863a964ad 100644
@@ -16,7 +16,8 @@ pidns31 pidns31
  pidns32 pidns32
 
  mqns_01 mqns_01
-mqns_01_clone mqns_01 -clone
+mqns_01_clone mqns_01 -m clone
+mqns_01_unshare mqns_01 -m unshare
  mqns_02 mqns_02
  mqns_02_clone mqns_02 -clone
  mqns_03 mqns_03
testcases/kernel/containers/mqns/common.h new file +21 -0
new file mode 100644
index 000000000..92a77b566
@@ -0,0 +1,101 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2022 SUSE LLC Andrea Cervesato <[email protected]>
+ */
+
+#ifndef MQNS_H
+#define MQNS_H
+
+#include <stdlib.h>
+#include "lapi/namespaces_constants.h"
+#include "tst_test.h"
+#include "tst_safe_posix_ipc.h"
+
+enum {
+	T_CLONE,
+	T_UNSHARE,
+	T_NONE,
+};
+
+static int dummy_child1(void *v)
+{

testcases/kernel/containers/mqns/common.h

Quoted 10 lines
testcases/kernel/containers/mqns/common.h new file +9 -0
+	(void)v;
+	return 0;
+}
+
+static inline void check_newipc(void)
+{
+	int pid, status;
+
+	pid = ltp_clone_quick(CLONE_NEWIPC | SIGCHLD, dummy_child1,
  NULL);

ltp_clone_quick is still part of the old API and only uses clone2. I think it should be replaced with tst_clone. This may require extending tst_clone. In fact we probably need a test variant to switch between the clone2 and clone3 syscalls when using tst_clone.

Quoted 3 lines

I'll leave it to you whether you want to try that and rebase this patch set on it.

I see ltp_clone_quick as wrapper of ltp_clone, since it's using ltp_alloc_stack without calling it explicitly all the times before ltp_clone.

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#7 lore raw

Re: [LTP] [PATCH v3 2/7] Refactor mqns_01 using new LTP API

Hello,

Quoted 70 lines · Andrea Cervesato

Hi!

Quoted 67 lines · Richard Palethorpe

Hello,

Quoted 48 lines · Andrea Cervesato via ltp
---
  runtest/containers                         |   3 +-
  testcases/kernel/containers/mqns/common.h  | 101 +++++++++++
  testcases/kernel/containers/mqns/mqns_01.c | 193 +++++++--------------
  3 files changed, 166 insertions(+), 131 deletions(-)

create mode 100644 testcases/kernel/containers/mqns/common.h

runtest/containers +2 -1
index 2637b62fe..863a964ad 100644
@@ -16,7 +16,8 @@ pidns31 pidns31
  pidns32 pidns32
    mqns_01 mqns_01
-mqns_01_clone mqns_01 -clone
+mqns_01_clone mqns_01 -m clone
+mqns_01_unshare mqns_01 -m unshare
  mqns_02 mqns_02
  mqns_02_clone mqns_02 -clone
  mqns_03 mqns_03
testcases/kernel/containers/mqns/common.h new file +21 -0
new file mode 100644
index 000000000..92a77b566
@@ -0,0 +1,101 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2022 SUSE LLC Andrea Cervesato <[email protected]>
+ */
+
+#ifndef MQNS_H
+#define MQNS_H
+
+#include <stdlib.h>
+#include "lapi/namespaces_constants.h"
+#include "tst_test.h"
+#include "tst_safe_posix_ipc.h"
+
+enum {
+	T_CLONE,
+	T_UNSHARE,
+	T_NONE,
+};
+
+static int dummy_child1(void *v)
+{

testcases/kernel/containers/mqns/common.h

Quoted 10 lines
testcases/kernel/containers/mqns/common.h new file +9 -0
+	(void)v;
+	return 0;
+}
+
+static inline void check_newipc(void)
+{
+	int pid, status;
+
+	pid = ltp_clone_quick(CLONE_NEWIPC | SIGCHLD, dummy_child1,
  NULL);

ltp_clone_quick is still part of the old API and only uses clone2. I think it should be replaced with tst_clone. This may require extending tst_clone. In fact we probably need a test variant to switch between the clone2 and clone3 syscalls when using tst_clone.

Quoted 6 lines
Quoted 3 lines

I'll leave it to you whether you want to try that and rebase this patch set on it.

I see ltp_clone_quick as wrapper of ltp_clone, since it's using ltp_alloc_stack without calling it explicitly all the times before ltp_clone.

ltp_clone is also part of the old API. At some point we should remove that.

Signature · 5 lines
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#8 lore raw

Re: [LTP] [PATCH v3 2/7] Refactor mqns_01 using new LTP API

Hello,

Quoted 77 lines · Richard Palethorpe

Hello,

Quoted 73 lines · Andrea Cervesato

Hi!

Quoted 70 lines · Richard Palethorpe

Hello,

Quoted 48 lines · Andrea Cervesato via ltp
---
  runtest/containers                         |   3 +-
  testcases/kernel/containers/mqns/common.h  | 101 +++++++++++
  testcases/kernel/containers/mqns/mqns_01.c | 193 +++++++--------------
  3 files changed, 166 insertions(+), 131 deletions(-)

create mode 100644 testcases/kernel/containers/mqns/common.h

runtest/containers +2 -1
index 2637b62fe..863a964ad 100644
@@ -16,7 +16,8 @@ pidns31 pidns31
  pidns32 pidns32
    mqns_01 mqns_01
-mqns_01_clone mqns_01 -clone
+mqns_01_clone mqns_01 -m clone
+mqns_01_unshare mqns_01 -m unshare
  mqns_02 mqns_02
  mqns_02_clone mqns_02 -clone
  mqns_03 mqns_03
testcases/kernel/containers/mqns/common.h new file +21 -0
new file mode 100644
index 000000000..92a77b566
@@ -0,0 +1,101 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2022 SUSE LLC Andrea Cervesato <[email protected]>
+ */
+
+#ifndef MQNS_H
+#define MQNS_H
+
+#include <stdlib.h>
+#include "lapi/namespaces_constants.h"
+#include "tst_test.h"
+#include "tst_safe_posix_ipc.h"
+
+enum {
+	T_CLONE,
+	T_UNSHARE,
+	T_NONE,
+};
+
+static int dummy_child1(void *v)
+{

testcases/kernel/containers/mqns/common.h

Quoted 10 lines
testcases/kernel/containers/mqns/common.h new file +9 -0
+	(void)v;
+	return 0;
+}
+
+static inline void check_newipc(void)
+{
+	int pid, status;
+
+	pid = ltp_clone_quick(CLONE_NEWIPC | SIGCHLD, dummy_child1,
  NULL);

ltp_clone_quick is still part of the old API and only uses clone2. I think it should be replaced with tst_clone. This may require extending tst_clone. In fact we probably need a test variant to switch between the clone2 and clone3 syscalls when using tst_clone.

I'll leave it to you whether you want to try that and rebase this patch set on it.

Quoted 6 lines
Quoted 3 lines

I see ltp_clone_quick as wrapper of ltp_clone, since it's using ltp_alloc_stack without calling it explicitly all the times before ltp_clone.

ltp_clone is also part of the old API. At some point we should remove that.

I'm marking this as changes requested. tst_clone should be made to support this scenario.

Signature · 5 lines
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#9 lore raw

Re: [LTP] [PATCH v3 2/7] Refactor mqns_01 using new LTP API

Hi

Are we sure that we don't need this modification before adding tst_clone? We can add the patch and then starting to think how to replace tst_clone_quick with tst_clone in all tests.

Andrea

Quoted 89 lines · Richard Palethorpe

Hello,

Quoted 74 lines · Richard Palethorpe

Hello,

Quoted 70 lines · Andrea Cervesato

Hi!

Quoted 67 lines · Richard Palethorpe

Hello,

Quoted 48 lines · Andrea Cervesato via ltp
---
   runtest/containers                         |   3 +-
   testcases/kernel/containers/mqns/common.h  | 101 +++++++++++
   testcases/kernel/containers/mqns/mqns_01.c | 193 +++++++--------------
   3 files changed, 166 insertions(+), 131 deletions(-)

create mode 100644 testcases/kernel/containers/mqns/common.h

runtest/containers +2 -1
index 2637b62fe..863a964ad 100644
@@ -16,7 +16,8 @@ pidns31 pidns31
   pidns32 pidns32
     mqns_01 mqns_01
-mqns_01_clone mqns_01 -clone
+mqns_01_clone mqns_01 -m clone
+mqns_01_unshare mqns_01 -m unshare
   mqns_02 mqns_02
   mqns_02_clone mqns_02 -clone
   mqns_03 mqns_03
testcases/kernel/containers/mqns/common.h new file +21 -0
new file mode 100644
index 000000000..92a77b566
@@ -0,0 +1,101 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2022 SUSE LLC Andrea Cervesato <[email protected]>
+ */
+
+#ifndef MQNS_H
+#define MQNS_H
+
+#include <stdlib.h>
+#include "lapi/namespaces_constants.h"
+#include "tst_test.h"
+#include "tst_safe_posix_ipc.h"
+
+enum {
+	T_CLONE,
+	T_UNSHARE,
+	T_NONE,
+};
+
+static int dummy_child1(void *v)
+{

testcases/kernel/containers/mqns/common.h

Quoted 10 lines
testcases/kernel/containers/mqns/common.h new file +9 -0
+	(void)v;
+	return 0;
+}
+
+static inline void check_newipc(void)
+{
+	int pid, status;
+
+	pid = ltp_clone_quick(CLONE_NEWIPC | SIGCHLD, dummy_child1,
   NULL);

ltp_clone_quick is still part of the old API and only uses clone2. I think it should be replaced with tst_clone. This may require extending tst_clone. In fact we probably need a test variant to switch between the clone2 and clone3 syscalls when using tst_clone.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

I'll leave it to you whether you want to try that and rebase this patch set on it.

I see ltp_clone_quick as wrapper of ltp_clone, since it's using ltp_alloc_stack without calling it explicitly all the times before ltp_clone.

ltp_clone is also part of the old API. At some point we should remove that.

I'm marking this as changes requested. tst_clone should be made to support this scenario.

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#10 lore raw

Re: [LTP] [PATCH v3 2/7] Refactor mqns_01 using new LTP API

Hello,

Quoted 5 lines · Andrea Cervesato

Hi

Are we sure that we don't need this modification before adding tst_clone? We can add the patch and then starting to think how to replace tst_clone_quick with tst_clone in all tests.

You're not the first person to use this argument. So it's actually important for precisely the reason you don't want to do it. The next person wont' want to do it either and we'll sleep walk into never replacing it.

Meanwhile there are solid reasons why clone3 exists and why we should test it. That's possibly more important than the API conversion.

BTW I could take over one of these patches and do the work on tst_clone? I'm pretty familiar with it.

Quoted 93 lines

Andrea

Quoted 89 lines · Richard Palethorpe

Hello,

Quoted 74 lines · Richard Palethorpe

Hello,

Quoted 70 lines · Andrea Cervesato

Hi!

Quoted 67 lines · Richard Palethorpe

Hello,

Quoted 48 lines · Andrea Cervesato via ltp
---
   runtest/containers                         |   3 +-
   testcases/kernel/containers/mqns/common.h  | 101 +++++++++++
   testcases/kernel/containers/mqns/mqns_01.c | 193 +++++++--------------
   3 files changed, 166 insertions(+), 131 deletions(-)

create mode 100644 testcases/kernel/containers/mqns/common.h

runtest/containers +2 -1
index 2637b62fe..863a964ad 100644
@@ -16,7 +16,8 @@ pidns31 pidns31
   pidns32 pidns32
     mqns_01 mqns_01
-mqns_01_clone mqns_01 -clone
+mqns_01_clone mqns_01 -m clone
+mqns_01_unshare mqns_01 -m unshare
   mqns_02 mqns_02
   mqns_02_clone mqns_02 -clone
   mqns_03 mqns_03
testcases/kernel/containers/mqns/common.h new file +21 -0
new file mode 100644
index 000000000..92a77b566
@@ -0,0 +1,101 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2022 SUSE LLC Andrea Cervesato <[email protected]>
+ */
+
+#ifndef MQNS_H
+#define MQNS_H
+
+#include <stdlib.h>
+#include "lapi/namespaces_constants.h"
+#include "tst_test.h"
+#include "tst_safe_posix_ipc.h"
+
+enum {
+	T_CLONE,
+	T_UNSHARE,
+	T_NONE,
+};
+
+static int dummy_child1(void *v)
+{

testcases/kernel/containers/mqns/common.h

Quoted 10 lines
testcases/kernel/containers/mqns/common.h new file +9 -0
+	(void)v;
+	return 0;
+}
+
+static inline void check_newipc(void)
+{
+	int pid, status;
+
+	pid = ltp_clone_quick(CLONE_NEWIPC | SIGCHLD, dummy_child1,
   NULL);

ltp_clone_quick is still part of the old API and only uses clone2. I think it should be replaced with tst_clone. This may require extending tst_clone. In fact we probably need a test variant to switch between the clone2 and clone3 syscalls when using tst_clone.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

I'll leave it to you whether you want to try that and rebase this patch set on it.

I see ltp_clone_quick as wrapper of ltp_clone, since it's using ltp_alloc_stack without calling it explicitly all the times before ltp_clone.

ltp_clone is also part of the old API. At some point we should remove that.

I'm marking this as changes requested. tst_clone should be made to support this scenario.

Signature · 5 lines
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#11 lore raw

Re: [LTP] [PATCH v3 2/7] Refactor mqns_01 using new LTP API

Hi

Quoted 14 lines · Richard Palethorpe

Hello,

Quoted 5 lines · Andrea Cervesato

Hi

Are we sure that we don't need this modification before adding tst_clone? We can add the patch and then starting to think how to replace tst_clone_quick with tst_clone in all tests.

You're not the first person to use this argument. So it's actually important for precisely the reason you don't want to do it. The next person wont' want to do it either and we'll sleep walk into never replacing it.

Quoted 5 lines

Meanwhile there are solid reasons why clone3 exists and why we should test it. That's possibly more important than the API conversion.

BTW I could take over one of these patches and do the work on tst_clone? I'm pretty familiar with it.

I can take care to change all tst_quick_clone after pushing these patches, no problem.
If you have an example how to use tst_clone, please do so. I will repeat the same patter to all remaining tests. Thanks!

Andrea

Quoted 93 lines
Quoted 92 lines

Andrea

Quoted 89 lines · Richard Palethorpe

Hello,

Quoted 74 lines · Richard Palethorpe

Hello,

Quoted 70 lines · Andrea Cervesato

Hi!

Quoted 67 lines · Richard Palethorpe

Hello,

Quoted 48 lines · Andrea Cervesato via ltp
---
    runtest/containers                         |   3 +-
    testcases/kernel/containers/mqns/common.h  | 101 +++++++++++
    testcases/kernel/containers/mqns/mqns_01.c | 193 +++++++--------------
    3 files changed, 166 insertions(+), 131 deletions(-)

create mode 100644 testcases/kernel/containers/mqns/common.h

runtest/containers +2 -1
index 2637b62fe..863a964ad 100644
@@ -16,7 +16,8 @@ pidns31 pidns31
    pidns32 pidns32
      mqns_01 mqns_01
-mqns_01_clone mqns_01 -clone
+mqns_01_clone mqns_01 -m clone
+mqns_01_unshare mqns_01 -m unshare
    mqns_02 mqns_02
    mqns_02_clone mqns_02 -clone
    mqns_03 mqns_03
testcases/kernel/containers/mqns/common.h new file +21 -0
new file mode 100644
index 000000000..92a77b566
@@ -0,0 +1,101 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2022 SUSE LLC Andrea Cervesato <[email protected]>
+ */
+
+#ifndef MQNS_H
+#define MQNS_H
+
+#include <stdlib.h>
+#include "lapi/namespaces_constants.h"
+#include "tst_test.h"
+#include "tst_safe_posix_ipc.h"
+
+enum {
+	T_CLONE,
+	T_UNSHARE,
+	T_NONE,
+};
+
+static int dummy_child1(void *v)
+{

testcases/kernel/containers/mqns/common.h

Quoted 10 lines
testcases/kernel/containers/mqns/common.h new file +9 -0
+	(void)v;
+	return 0;
+}
+
+static inline void check_newipc(void)
+{
+	int pid, status;
+
+	pid = ltp_clone_quick(CLONE_NEWIPC | SIGCHLD, dummy_child1,
    NULL);

ltp_clone_quick is still part of the old API and only uses clone2. I think it should be replaced with tst_clone. This may require extending tst_clone. In fact we probably need a test variant to switch between the clone2 and clone3 syscalls when using tst_clone.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

I'll leave it to you whether you want to try that and rebase this patch set on it.

I see ltp_clone_quick as wrapper of ltp_clone, since it's using ltp_alloc_stack without calling it explicitly all the times before ltp_clone.

ltp_clone is also part of the old API. At some point we should remove that.

I'm marking this as changes requested. tst_clone should be made to support this scenario.

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#12 lore raw

PATCH v3 3/7 Refactor mqns_02 using new LTP API

In reply to Andrea Cervesato via ltp
---
 runtest/containers                         |   3 +-
 testcases/kernel/containers/mqns/mqns_02.c | 225 ++++++---------------
 2 files changed, 67 insertions(+), 161 deletions(-)
runtest/containers +2 -1
index 863a964ad..4042ced4c 100644
@@ -19,7 +19,8 @@ mqns_01 mqns_01
 mqns_01_clone mqns_01 -m clone
 mqns_01_unshare mqns_01 -m unshare
 mqns_02 mqns_02
-mqns_02_clone mqns_02 -clone
+mqns_02_clone mqns_02 -m clone
+mqns_02_unshare mqns_02 -m unshare
 mqns_03 mqns_03
 mqns_03_clone mqns_03 -clone
 mqns_04 mqns_04
testcases/kernel/containers/mqns/mqns_02.c +65 -160

245 lines not on this page · raw message

Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#13 lore raw

PATCH v3 4/7 Refactor mqns_03 using new LTP API

In reply to Andrea Cervesato via ltp
---
 runtest/containers                         |   3 +-
 testcases/kernel/containers/mqns/mqns_03.c | 271 ++++++++-------------
 2 files changed, 100 insertions(+), 174 deletions(-)
runtest/containers +2 -1
index 4042ced4c..496b47037 100644
@@ -22,7 +22,8 @@ mqns_02 mqns_02
 mqns_02_clone mqns_02 -m clone
 mqns_02_unshare mqns_02 -m unshare
 mqns_03 mqns_03
-mqns_03_clone mqns_03 -clone
+mqns_03_clone mqns_03 -m clone
+mqns_03_unshare mqns_03 -m unshare
 mqns_04 mqns_04
 mqns_04_clone mqns_04 -clone
 
testcases/kernel/containers/mqns/mqns_03.c +98 -173

305 lines not on this page · raw message

Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#14 lore raw

PATCH v3 5/7 Refactor mqns_04 using new LTP API

In reply to Andrea Cervesato via ltp
---
 runtest/containers                         |   3 +-
 testcases/kernel/containers/mqns/mqns_04.c | 265 +++++++++------------
 2 files changed, 114 insertions(+), 154 deletions(-)
runtest/containers +2 -1
index 496b47037..6728cb50c 100644
@@ -25,7 +25,8 @@ mqns_03 mqns_03
 mqns_03_clone mqns_03 -m clone
 mqns_03_unshare mqns_03 -m unshare
 mqns_04 mqns_04
-mqns_04_clone mqns_04 -clone
+mqns_04_clone mqns_04 -m clone
+mqns_04_unshare mqns_04 -m unshare
 
 netns_netlink netns_netlink
 netns_breakns_ip_ipv4_netlink netns_breakns.sh
testcases/kernel/containers/mqns/mqns_04.c +112 -153

299 lines not on this page · raw message

Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#15 lore raw

PATCH v3 6/7 Delete deprecated mqns header files

In reply to Andrea Cervesato via ltp
---
 testcases/kernel/containers/mqns/Makefile     | 27 ++-------
 testcases/kernel/containers/mqns/mqns.h       | 11 ----
 .../kernel/containers/mqns/mqns_helper.h      | 56 -------------------
 3 files changed, 5 insertions(+), 89 deletions(-)
 delete mode 100644 testcases/kernel/containers/mqns/mqns.h
 delete mode 100644 testcases/kernel/containers/mqns/mqns_helper.h
testcases/kernel/containers/mqns/Makefile +5 -22
index 64c3763ee..eb0f97c2b 100644
@@ -1,29 +1,12 @@
-################################################################################
-##                                                                            ##
-## Copyright (c) International Business Machines  Corp., 2009                 ##
-## Copyright (c) Nadia Derbey, 2009                                           ##
-##                                                                            ##
-## This program is free software;  you can redistribute it and#or modify      ##
-## it under the terms of the GNU General Public License as published by       ##
-## the Free Software Foundation; either version 2 of the License, or          ##
-## (at your option) any later version.                                        ##
-##                                                                            ##
-## This program is distributed in the hope that it will be useful, but        ##
-## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
-## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
-## for more details.                                                          ##
-##                                                                            ##
-## You should have received a copy of the GNU General Public License          ##
-## along with this program;  if not, write to the Free Software               ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
-##                                                                            ##
-################################################################################
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) International Business Machines  Corp., 2009
+# Copyright (c) Nadia Derbey, 2009 
+# Copyright (C) 2021 SUSE LLC Andrea Cervesato <[email protected]>
 
 top_srcdir		?= ../../../..
 
 include $(top_srcdir)/include/mk/testcases.mk
-include $(abs_srcdir)/../Makefile.inc
 
-LDLIBS			:= -lpthread -lrt -lclone $(LDLIBS)
+LDLIBS			:= -lpthread -lrt $(LDLIBS)
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/containers/mqns/mqns.h deleted +0 -11
deleted file mode 100644
index 5a9056838..000000000
@@ -1,11 +0,0 @@
-#ifndef __MQNS_H
-#define __MQNS_H
-
-#define DEV_MQUEUE "/dev/mqueue"
-#define DEV_MQUEUE2 "/dev/mqueue2"
-#define SLASH_MQ1 "/MQ1"
-#define NOSLASH_MQ1 "MQ1"
-#define SLASH_MQ2 "/MQ2"
-#define NOSLASH_MQ2 "MQ2"
-
-#endif /* __MQNS_H */
testcases/kernel/containers/mqns/mqns_helper.h deleted +0 -56

56 lines not on this page · raw message

Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#16 lore raw

PATCH v3 7/7 Rename common.h into mqns.h for mqns suite

In reply to Andrea Cervesato via ltp
---
 testcases/kernel/containers/mqns/{common.h => mqns.h} | 0
 testcases/kernel/containers/mqns/mqns_01.c            | 2 +-
 testcases/kernel/containers/mqns/mqns_02.c            | 2 +-
 testcases/kernel/containers/mqns/mqns_03.c            | 2 +-
 testcases/kernel/containers/mqns/mqns_04.c            | 2 +-
 5 files changed, 4 insertions(+), 4 deletions(-)
 rename testcases/kernel/containers/mqns/{common.h => mqns.h} (100%)
testcases/kernel/containers/mqns/mqns.h renamed from testcases/kernel/containers/mqns/common.h +0 -0
similarity index 100%
rename from testcases/kernel/containers/mqns/common.h
rename to testcases/kernel/containers/mqns/mqns.h
testcases/kernel/containers/mqns/mqns_01.c +1 -1
index a34dc4f66..7e62ab3d6 100644
@@ -12,7 +12,7 @@
  * the isolated/forked child namespace.
  */
 
-#include "common.h"
+#include "mqns.h"
 
 #define MQNAME "/MQ1"
 
testcases/kernel/containers/mqns/mqns_02.c +1 -1
index 4383fef73..59d483be7 100644
@@ -12,7 +12,7 @@
  * then check namespace isolation.
  */
 
-#include "common.h"
+#include "mqns.h"
 
 #define MQNAME "/MQ1"
 
testcases/kernel/containers/mqns/mqns_03.c +1 -1
index 5914a2a9b..54ba54304 100644
@@ -25,7 +25,7 @@
 #define _GNU_SOURCE
 
 #include <stdio.h>
-#include "common.h"
+#include "mqns.h"
 #include "tst_safe_stdio.h"
 
 #define MQNAME1 "/MQ1"
testcases/kernel/containers/mqns/mqns_04.c +1 -1
index 95ff18ef2..b3f538592 100644
@@ -24,7 +24,7 @@
 #define _GNU_SOURCE
 
 #include <stdio.h>
-#include "common.h"
+#include "mqns.h"
 #include "tst_safe_stdio.h"
 
 #define CHECK_MQ_OPEN_RET(x) ((x) >= 0 || ((x) == -1 && errno != EMFILE))
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v3 7/7
#17 lore raw

Re: [LTP] [PATCH v3 7/7] Rename common.h into mqns.h for mqns suite

Hi Andrea,

Quoted 3 lines
---
 testcases/kernel/containers/mqns/{common.h => mqns.h} | 0

could you please also fix this checkpatch error (preferably as a separate patch):

mqns.h:37: ERROR: "foo* bar" should be "foo *bar"
mqns.h:96: WARNING: __func__ should be used instead of gcc specific __FUNCTION__

Checkpatch also reports wrong comment style, but I'd ignore it (complains for *.h, it's ok for *.c):
mqns.h:1: WARNING: Improper SPDX comment style for 'mqns.h', please use '/*' instead

@Richie: not sure I might have asked before: it'd be great to have make target also for header files, so that they are checked with make check. Now we have to run checkpatch manually to check them.

Kind regards,
Petr

Quoted 6 lines
 testcases/kernel/containers/mqns/mqns_01.c            | 2 +-
 testcases/kernel/containers/mqns/mqns_02.c            | 2 +-
 testcases/kernel/containers/mqns/mqns_03.c            | 2 +-
 testcases/kernel/containers/mqns/mqns_04.c            | 2 +-
 5 files changed, 4 insertions(+), 4 deletions(-)
 rename testcases/kernel/containers/mqns/{common.h => mqns.h} (100%)

...

Patch itself it's obviously correct.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#18 lore raw

PATCH 1/1 tools: Check headers with checkpatch.pl

checkpatch.pl doesn't load included headers so they must be passed to it specifically. This change automatically includes headers from the current directory. Manual intervention is still required if a test author changes a header located elsewhere. However you can now write 'make check-header.h', once in the correct directory.

Note that our Sparse based tool (amongst others) loads headers and checks at least some of the content.

---
 include/mk/env_post.mk             | 1 +
 include/mk/generic_leaf_target.inc | 2 +-
 include/mk/rules.mk                | 9 +++++++++
 3 files changed, 11 insertions(+), 1 deletion(-)
include/mk/env_post.mk +1 -0
index dc4df41d3..a00f31b08 100644
@@ -92,6 +92,7 @@ endif
 
 CHECK_TARGETS			?= $(addprefix check-,$(notdir $(patsubst %.c,%,$(sort $(wildcard $(abs_srcdir)/*.c)))))
 CHECK_TARGETS			:= $(filter-out $(addprefix check-, $(FILTER_OUT_MAKE_TARGETS)), $(CHECK_TARGETS))
+CHECK_HEADER_TARGETS		?= $(addprefix check-,$(notdir $(sort $(wildcard $(abs_srcdir)/*.h))))
 CHECK				?= $(abs_top_srcdir)/tools/sparse/sparse-ltp
 CHECK_NOFLAGS			?= $(abs_top_srcdir)/scripts/checkpatch.pl -f --no-tree --terse --no-summary --ignore CONST_STRUCT,VOLATILE,SPLIT_STRING
 SHELL_CHECK			?= $(abs_top_srcdir)/scripts/checkbashisms.pl --force --extra
include/mk/generic_leaf_target.inc +1 -1
index 33e9c9ea0..565a282bb 100644
@@ -110,6 +110,6 @@ $(INSTALL_FILES): | $(INSTALL_DEPS)
 install: $(INSTALL_FILES)
 
 $(CHECK_TARGETS): | $(CHECK_DEPS)
-check: $(CHECK_TARGETS) $(SHELL_CHECK_TARGETS)
+check: $(CHECK_HEADER_TARGETS) $(CHECK_TARGETS) $(SHELL_CHECK_TARGETS)
 
 # vim: syntax=make
include/mk/rules.mk +9 -0
index 32d8d05a7..517863c04 100644
@@ -57,6 +57,15 @@ else
 	@-$(CHECK) $(CHECK_FLAGS) $(CPPFLAGS) $(CFLAGS) $<
 endif
 
+.PHONY: $(CHECK_HEADER_TARGETS)
+$(CHECK_HEADER_TARGETS): check-%.h: %.h
+ifdef VERBOSE
+	-$(CHECK_NOFLAGS) $<
+else
+	@echo CHECK $(target_rel_dir)$<
+	@-$(CHECK_NOFLAGS) $<
+endif
+
 .PHONY: $(SHELL_CHECK_TARGETS)
 $(SHELL_CHECK_TARGETS): check-%.sh: %.sh
 ifdef VERBOSE
Signature · 5 lines
2.36.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 1/1
#19 lore raw

Re: [LTP] [PATCH] tools: Check headers with checkpatch.pl

Hi Richie,

Quoted 8 lines

checkpatch.pl doesn't load included headers so they must be passed to it specifically. This change automatically includes headers from the current directory. Manual intervention is still required if a test author changes a header located elsewhere. However you can now write 'make check-header.h', once in the correct directory.

Note that our Sparse based tool (amongst others) loads headers and checks at least some of the content.

Thanks a lot for implementing this.

LGTM, just a small nit: target for headers contain .h extension. Shouldn't we add .c for C sources for consistency?

It'đ strange, that make check in testcases/misc/math/float/ does not include tfloat.h, but make check-tfloat.h prints errors. But make check in lib/ works as expected (adds also *.h).

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#20 lore raw

Re: [LTP] [PATCH] tools: Check headers with checkpatch.pl

Hello,

Quoted 11 lines · Petr Vorel

Hi Richie,

Quoted 8 lines

checkpatch.pl doesn't load included headers so they must be passed to it specifically. This change automatically includes headers from the current directory. Manual intervention is still required if a test author changes a header located elsewhere. However you can now write 'make check-header.h', once in the correct directory.

Note that our Sparse based tool (amongst others) loads headers and checks at least some of the content.

Quoted 8 lines

Thanks a lot for implementing this.

LGTM, just a small nit: target for headers contain .h extension. Shouldn't we add .c for C sources for consistency?

It'đ strange, that make check in testcases/misc/math/float/ does not include tfloat.h, but make check-tfloat.h prints errors. But make check in lib/ works as expected (adds also *.h).

The Sparse based tool does include headers though. So really we are checking the target which includes more than just a single c file.

Quoted 5 lines

Kind regards,
Petr

Signature · 5 lines
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#21 lore raw

Re: [LTP] [PATCH] tools: Check headers with checkpatch.pl

...

Quoted 9 lines
Quoted 6 lines

LGTM, just a small nit: target for headers contain .h extension. Shouldn't we add .c for C sources for consistency?

It'd strange, that make check in testcases/misc/math/float/ does not include tfloat.h, but make check-tfloat.h prints errors. But make check in lib/ works as expected (adds also *.h).

The Sparse based tool does include headers though. So really we are checking the target which includes more than just a single c file.

Ah, that makes sense then. Thanks!

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#22 lore raw
In reply to Andrea Cervesato via ltp

Hello,

Quoted 1 line · Andrea Cervesato via ltp

mqns testing suite has been refactored using new LTP API

It would be easier to just submit one test for review and iterate on it. This follows the principal of breaking work down into the smallest chunk practically possible.

Sometimes submitting a large patchset is unavoidable, but this is not the case here.

I'm setting all of these to "changes requested".

Quoted 24 lines

Andrea Cervesato (7):
Add more safe macros for mqueue API
Refactor mqns_01 using new LTP API
Refactor mqns_02 using new LTP API
Refactor mqns_03 using new LTP API
Refactor mqns_04 using new LTP API
Delete deprecated mqns header files
Rename common.h into mqns.h for mqns suite

 include/tst_safe_posix_ipc.h                  |  45 +++
 runtest/containers                            |  12 +-
 testcases/kernel/containers/mqns/Makefile     |  27 +-
 testcases/kernel/containers/mqns/mqns.h       | 108 ++++++-
 testcases/kernel/containers/mqns/mqns_01.c    | 185 ++++--------
 testcases/kernel/containers/mqns/mqns_02.c    | 217 ++++----------
 testcases/kernel/containers/mqns/mqns_03.c    | 269 +++++++-----------
 testcases/kernel/containers/mqns/mqns_04.c    | 263 ++++++++---------
 .../kernel/containers/mqns/mqns_helper.h      |  56 ----
 9 files changed, 485 insertions(+), 697 deletions(-)
 delete mode 100644 testcases/kernel/containers/mqns/mqns_helper.h
Signature · 1 line
2.35.3
Signature · 5 lines
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp