public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v1 0/2] Refactor personality testing suite
@ 2023-08-30 13:25 Andrea Cervesato
  2023-08-30 13:25 ` [LTP] [PATCH v1 1/2] Refactor personality01 using new API Andrea Cervesato
  2023-08-30 13:25 ` [LTP] [PATCH v1 2/2] Refactor personality02 " Andrea Cervesato
  0 siblings, 2 replies; 5+ messages in thread
From: Andrea Cervesato @ 2023-08-30 13:25 UTC (permalink / raw)
  To: ltp

From: Andrea Cervesato <andrea.cervesato@suse.com>

Refactor personality01|02 tests using new LTP API

Andrea Cervesato (2):
  Refactor personality01 using new API
  Refactor personality02 using new API

 .../syscalls/personality/personality01.c      | 93 +++++--------------
 .../syscalls/personality/personality02.c      | 64 +++++--------
 2 files changed, 45 insertions(+), 112 deletions(-)

-- 
2.35.3


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [LTP] [PATCH v1 1/2] Refactor personality01 using new API
  2023-08-30 13:25 [LTP] [PATCH v1 0/2] Refactor personality testing suite Andrea Cervesato
@ 2023-08-30 13:25 ` Andrea Cervesato
  2023-08-31  9:47   ` Richard Palethorpe
  2023-08-30 13:25 ` [LTP] [PATCH v1 2/2] Refactor personality02 " Andrea Cervesato
  1 sibling, 1 reply; 5+ messages in thread
From: Andrea Cervesato @ 2023-08-30 13:25 UTC (permalink / raw)
  To: ltp

From: Andrea Cervesato <andrea.cervesato@suse.com>

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 .../syscalls/personality/personality01.c      | 93 +++++--------------
 1 file changed, 23 insertions(+), 70 deletions(-)

diff --git a/testcases/kernel/syscalls/personality/personality01.c b/testcases/kernel/syscalls/personality/personality01.c
index b646e2a9b..47fb66256 100644
--- a/testcases/kernel/syscalls/personality/personality01.c
+++ b/testcases/kernel/syscalls/personality/personality01.c
@@ -1,24 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
+ * Copyright (c) 2016 Linux Test Project
  * Copyright (c) International Business Machines  Corp., 2001
  *  03/2001 - Written by Wayne Boyer
  * Copyright (c) 2016 Cyril Hrubis <chrubis@suse.cz>
- *
- * 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
+ * Copyright (C) 2023 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
  */
 
-/*
+/*\
+ * [Description]
+ *
  * Tries to set different personalities.
  *
  * We set the personality in a child process since it's not guaranteed that we
@@ -26,19 +17,17 @@
  * bit archs.
  */
 
-#include "test.h"
-#include <sys/personality.h>
-
-char *TCID = "personality01";
+#include "tst_test.h"
+#include "lapi/personality.h"
 
 #define PAIR(id) {id, #id}
 
 struct personalities {
-	unsigned long int pers;
+	unsigned long pers;
 	const char *name;
 };
 
-struct personalities pers[] = {
+static struct personalities pers[] = {
 	PAIR(PER_LINUX),
 	PAIR(PER_LINUX_32BIT),
 	PAIR(PER_SVR4),
@@ -62,60 +51,24 @@ struct personalities pers[] = {
 	PAIR(PER_HPUX),
 };
 
-int TST_TOTAL = ARRAY_SIZE(pers);
-
-static void do_child(unsigned int i)
+static void run(unsigned int i)
 {
-	int ret;
+	pid_t pid;
 
-	ret = personality(pers[i].pers);
-	if (ret < 0) {
-		tst_resm(TFAIL | TERRNO, "personality(%s) failed", pers[i].name);
-		return;
-	}
+	pid = SAFE_FORK();
+	if (!pid) {
+		SAFE_PERSONALITY(pers[i].pers);
 
-	ret = personality(0xffffffff);
+		TST_EXP_EXPR((unsigned long)SAFE_PERSONALITY(0xffffffff) == pers[i].pers,
+			"%s personality is set",
+			 pers[i].name);
 
-	if ((unsigned long)ret != pers[i].pers) {
-		tst_resm(TFAIL,
-			 "%s: wrong personality read back %d expected %lu",
-			 pers[i].name, ret, pers[i].pers);
 		return;
 	}
-
-	tst_resm(TPASS, "personality(%s)", pers[i].name);
-}
-
-static void verify_personality(unsigned int i)
-{
-	pid_t pid;
-
-	pid = tst_fork();
-	switch (pid) {
-	case 0:
-		do_child(i);
-		tst_exit();
-	break;
-	case -1:
-		tst_brkm(TBROK | TERRNO, NULL, "fork() failed");
-	break;
-	default:
-		tst_record_childstatus(NULL, pid);
-	break;
-	}
 }
 
-int main(int ac, char **av)
-{
-	int i, lc;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		for (i = 0; i < TST_TOTAL; i++) {
-			verify_personality(i);
-		}
-	}
-
-	tst_exit();
-}
+static struct tst_test test = {
+	.test = run,
+	.tcnt = ARRAY_SIZE(pers),
+	.forks_child = 1,
+};
-- 
2.35.3


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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [LTP] [PATCH v1 2/2] Refactor personality02 using new API
  2023-08-30 13:25 [LTP] [PATCH v1 0/2] Refactor personality testing suite Andrea Cervesato
  2023-08-30 13:25 ` [LTP] [PATCH v1 1/2] Refactor personality01 using new API Andrea Cervesato
@ 2023-08-30 13:25 ` Andrea Cervesato
  2023-08-31  9:53   ` Richard Palethorpe
  1 sibling, 1 reply; 5+ messages in thread
From: Andrea Cervesato @ 2023-08-30 13:25 UTC (permalink / raw)
  To: ltp

From: Andrea Cervesato <andrea.cervesato@suse.com>

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 .../syscalls/personality/personality02.c      | 64 +++++++------------
 1 file changed, 22 insertions(+), 42 deletions(-)

diff --git a/testcases/kernel/syscalls/personality/personality02.c b/testcases/kernel/syscalls/personality/personality02.c
index eb18c9951..e080284f4 100644
--- a/testcases/kernel/syscalls/personality/personality02.c
+++ b/testcases/kernel/syscalls/personality/personality02.c
@@ -1,62 +1,42 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
+ * Copyright (c) 2016 Linux Test Project
  * Copyright (c) 2016 Cyril Hrubis <chrubis@suse.cz>
- *
- * 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, see <http://www.gnu.org/licenses/>.
+ * Copyright (C) 2023 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
  */
 
-/*
- * If personality with STICKY_TIMEOUTS is used select() timeout is not updated.
+/*\
+ * [Description]
+ *
+ * This test checks if select() timeout is not updated when personality with
+ * STICKY_TIMEOUTS is used.
  */
 
-#include "test.h"
-#include <sys/personality.h>
+#include "tst_test.h"
+#include "lapi/personality.h"
 #include <sys/select.h>
 
-char *TCID = "personality02";
-int TST_TOTAL = 1;
-
 #define USEC 10
 
-static void verify_personality(void)
+static void run(void)
 {
-	struct timeval tv = {.tv_sec = 0, .tv_usec = USEC};
-	int ret;
+	struct timeval tv = { .tv_sec = 0, .tv_usec = USEC };
 	fd_set rfds;
 
 	FD_ZERO(&rfds);
 	FD_SET(1, &rfds);
 
-	personality(PER_LINUX | STICKY_TIMEOUTS);
-	ret = select(2, &rfds, NULL, NULL, &tv);
-	personality(PER_LINUX);
-	if (ret < 0)
-		tst_resm(TBROK | TERRNO, "select()");
+	SAFE_PERSONALITY(PER_LINUX | STICKY_TIMEOUTS);
 
-	if (tv.tv_usec != USEC)
-		tst_resm(TFAIL, "Timeout was modified");
-	else
-		tst_resm(TPASS, "Timeout wasn't modified");
-}
-
-int main(int ac, char **av)
-{
-	int lc;
+	TEST(select(2, &rfds, NULL, NULL, &tv));
+	if (TST_RET == -1)
+		tst_brk(TBROK | TERRNO, "select() error");
 
-	tst_parse_opts(ac, av, NULL, NULL);
+	SAFE_PERSONALITY(PER_LINUX);
 
-	for (lc = 0; TEST_LOOPING(lc); lc++)
-		verify_personality();
-
-	tst_exit();
+	TST_EXP_EQ_LI(tv.tv_usec, USEC);
 }
+
+static struct tst_test test = {
+	.test_all = run,
+};
-- 
2.35.3


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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [LTP] [PATCH v1 1/2] Refactor personality01 using new API
  2023-08-30 13:25 ` [LTP] [PATCH v1 1/2] Refactor personality01 using new API Andrea Cervesato
@ 2023-08-31  9:47   ` Richard Palethorpe
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Palethorpe @ 2023-08-31  9:47 UTC (permalink / raw)
  To: Andrea Cervesato; +Cc: ltp

Hello,

Pushed!

-- 
Thank you,
Richard.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [LTP] [PATCH v1 2/2] Refactor personality02 using new API
  2023-08-30 13:25 ` [LTP] [PATCH v1 2/2] Refactor personality02 " Andrea Cervesato
@ 2023-08-31  9:53   ` Richard Palethorpe
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Palethorpe @ 2023-08-31  9:53 UTC (permalink / raw)
  To: Andrea Cervesato; +Cc: ltp

Pushed!

-- 
Thank you,
Richard.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-08-31  9:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-30 13:25 [LTP] [PATCH v1 0/2] Refactor personality testing suite Andrea Cervesato
2023-08-30 13:25 ` [LTP] [PATCH v1 1/2] Refactor personality01 using new API Andrea Cervesato
2023-08-31  9:47   ` Richard Palethorpe
2023-08-30 13:25 ` [LTP] [PATCH v1 2/2] Refactor personality02 " Andrea Cervesato
2023-08-31  9:53   ` Richard Palethorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox