* [LTP] [PATCH v2 0/2] mkdir09: rewrite in new LTP API
@ 2022-02-04 13:14 Jan Stancek
2022-02-04 13:14 ` [LTP] [PATCH v2 1/2] tst_test_macros: add TST_EXP_FAIL_SILENT Jan Stancek
2022-02-04 13:14 ` [LTP] [PATCH v2 2/2] syscalls/mkdir09: rewrite in new LTP API Jan Stancek
0 siblings, 2 replies; 8+ messages in thread
From: Jan Stancek @ 2022-02-04 13:14 UTC (permalink / raw)
To: ltp
Changes:
- 'use all_filesystems = 1'
This gives us back reproducer we used to have before statx04 rewrite for commit
07bfa4415ab6 ("fat: work around race with userspace's read via blockdev while mounting")
- fix description comment
- comments moved before functions
- separate loop with SAFE_MKDIR moved to setup
- introduce TST_EXP_FAIL_SILENT (patch 1/2)
- used TST_EXP_PASS_SILENT in test2 and test3
- fixed TPASS message in test2 to say "remove dirs"
Jan Stancek (2):
tst_test_macros: add TST_EXP_FAIL_SILENT
syscalls/mkdir09: rewrite in new LTP API
doc/c-test-api.txt | 3 +
include/tst_test_macros.h | 15 +-
testcases/kernel/syscalls/mkdir/Makefile | 2 +
testcases/kernel/syscalls/mkdir/mkdir09.c | 494 ++++------------------
4 files changed, 106 insertions(+), 408 deletions(-)
--
2.27.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [PATCH v2 1/2] tst_test_macros: add TST_EXP_FAIL_SILENT
2022-02-04 13:14 [LTP] [PATCH v2 0/2] mkdir09: rewrite in new LTP API Jan Stancek
@ 2022-02-04 13:14 ` Jan Stancek
2022-02-05 3:07 ` Li Wang
2022-02-04 13:14 ` [LTP] [PATCH v2 2/2] syscalls/mkdir09: rewrite in new LTP API Jan Stancek
1 sibling, 1 reply; 8+ messages in thread
From: Jan Stancek @ 2022-02-04 13:14 UTC (permalink / raw)
To: ltp
This variant does not print TPASS messages when
SCALL fails as expected.
Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
doc/c-test-api.txt | 3 +++
include/tst_test_macros.h | 15 ++++++++++-----
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/doc/c-test-api.txt b/doc/c-test-api.txt
index 6f4de3f80f95..9119e094dbfd 100644
--- a/doc/c-test-api.txt
+++ b/doc/c-test-api.txt
@@ -298,6 +298,9 @@ The 'TST_EXP_FAIL2()' is the same as 'TST_EXP_FAIL()' except the return value is
expected to be non-negative integer if call passes. These macros build upon the
+TEST()+ macro and associated variables.
+'TST_EXP_FAIL_SILENT()' and 'TST_EXP_FAIL2_SILENT()' variants are less verbose
+and do not print TPASS messages when SCALL fails as expected.
+
[source,c]
-------------------------------------------------------------------------------
TEST(socket(AF_INET, SOCK_RAW, 1));
diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
index ec8c38523344..f7de8d00a666 100644
--- a/include/tst_test_macros.h
+++ b/include/tst_test_macros.h
@@ -163,7 +163,7 @@ extern void *TST_RET_PTR;
TST_MSG_(TPASS, " passed", #SCALL, ##__VA_ARGS__); \
} while (0) \
-#define TST_EXP_FAIL_(PASS_COND, SCALL, SSCALL, ERRNO, ...) \
+#define TST_EXP_FAIL_(SILENT, PASS_COND, SCALL, SSCALL, ERRNO, ...) \
do { \
TEST(SCALL); \
\
@@ -181,8 +181,9 @@ extern void *TST_RET_PTR;
} \
\
if (TST_ERR == (ERRNO)) { \
- TST_MSG_(TPASS | TTERRNO, " ", \
- SSCALL, ##__VA_ARGS__); \
+ if (!SILENT) \
+ TST_MSG_(TPASS | TTERRNO, " ", \
+ SSCALL, ##__VA_ARGS__); \
TST_PASS = 1; \
} else { \
TST_MSGP_(TFAIL | TTERRNO, " expected %s", \
@@ -191,9 +192,13 @@ extern void *TST_RET_PTR;
} \
} while (0)
-#define TST_EXP_FAIL(SCALL, ERRNO, ...) TST_EXP_FAIL_(TST_RET == 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__)
+#define TST_EXP_FAIL(SCALL, ERRNO, ...) TST_EXP_FAIL_(0, TST_RET == 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__)
-#define TST_EXP_FAIL2(SCALL, ERRNO, ...) TST_EXP_FAIL_(TST_RET >= 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__)
+#define TST_EXP_FAIL2(SCALL, ERRNO, ...) TST_EXP_FAIL_(0, TST_RET >= 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__)
+
+#define TST_EXP_FAIL_SILENT(SCALL, ERRNO, ...) TST_EXP_FAIL_(1, TST_RET == 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__)
+
+#define TST_EXP_FAIL2_SILENT(SCALL, ERRNO, ...) TST_EXP_FAIL_(1, TST_RET >= 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__)
#define TST_EXP_EXPR(EXPR, FMT, ...) \
tst_res_(__FILE__, __LINE__, (EXPR) ? TPASS : TFAIL, "Expect: " FMT, ##__VA_ARGS__);
--
2.27.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [LTP] [PATCH v2 2/2] syscalls/mkdir09: rewrite in new LTP API
2022-02-04 13:14 [LTP] [PATCH v2 0/2] mkdir09: rewrite in new LTP API Jan Stancek
2022-02-04 13:14 ` [LTP] [PATCH v2 1/2] tst_test_macros: add TST_EXP_FAIL_SILENT Jan Stancek
@ 2022-02-04 13:14 ` Jan Stancek
2022-02-05 4:19 ` Li Wang
2022-02-07 12:55 ` Cyril Hrubis
1 sibling, 2 replies; 8+ messages in thread
From: Jan Stancek @ 2022-02-04 13:14 UTC (permalink / raw)
To: ltp
'jump' variable is not initialized, which I suspect is behind
rare failures of this test. The original test is using longjmp,
processes and signals to sychronize couple processes that
exercise mkdir/rmdir calls.
Rewrite it using threads and new LTP API, drop all parameters,
because no runtest is using them, and make new default test time
just 1 second.
Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
testcases/kernel/syscalls/mkdir/Makefile | 2 +
testcases/kernel/syscalls/mkdir/mkdir09.c | 494 ++++------------------
2 files changed, 93 insertions(+), 403 deletions(-)
diff --git a/testcases/kernel/syscalls/mkdir/Makefile b/testcases/kernel/syscalls/mkdir/Makefile
index 044619fb8724..881b087c6c1a 100644
--- a/testcases/kernel/syscalls/mkdir/Makefile
+++ b/testcases/kernel/syscalls/mkdir/Makefile
@@ -3,6 +3,8 @@
top_srcdir ?= ../../../..
+mkdir09: CFLAGS += -pthread
+
include $(top_srcdir)/include/mk/testcases.mk
include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/mkdir/mkdir09.c b/testcases/kernel/syscalls/mkdir/mkdir09.c
index 88034d29ed89..a2870ae94df8 100644
--- a/testcases/kernel/syscalls/mkdir/mkdir09.c
+++ b/testcases/kernel/syscalls/mkdir/mkdir09.c
@@ -1,460 +1,148 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
/*
- *
- * Copyright (c) International Business Machines Corp., 2002
- *
- * 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) International Business Machines Corp., 2001
+ * Copyright (c) Linux Test Project, 2022
*/
-/* 06/30/2001 Port to Linux nsharoff@us.ibm.com */
-/* 10/30/2002 Port to LTP dbarrera@us.ibm.com */
-
-/*
- * Stress test of mkdir call.
- *
- * ALGORITHM
- * Create multiple processes which create subdirectories in the
- * same directory multiple times. On exit of all child processes,
- * make sure all subdirectories can be removed.
- *
- * USAGE: mkdir09 -c # -t # -d #
- * -c = number of children groups
- * -t = number of seconds to run test
- * -d = number of directories created in test directory
+/*\
+ * [Description]
*
+ * Create multiple processes which create subdirectories in the
+ * same directory multiple times within test time.
*/
#include <stdio.h>
-#include <sys/wait.h>
-#include <sys/types.h>
#include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <errno.h>
-#include <signal.h>
-#include <unistd.h>
-#include <setjmp.h>
-#include "test.h"
-
-#include <stdlib.h>
-#include <stdlib.h>
-#include <string.h>
-
-#define NCHILD 3
+#include "tst_test.h"
+#include "tst_safe_pthread.h"
+#define MNTPOINT "mntpoint"
#define MODE_RWX 07770
-#define DIR_NAME "./X.%d"
-
-char *TCID = "mkdir09";
-int TST_TOTAL = 1;
-
-char testdir[MAXPATHLEN];
-int parent_pid, sigchld, sigterm, jump;
-void term(int sig);
-void chld(int sig);
-int *pidlist, child_count;
-jmp_buf env_buf;
-
-int getchild(int group, int child, int children);
-int dochild1(void);
-int dochild2(void);
-int dochild3(int group);
-int massmurder(void);
-int runtest(void);
-void setup(void);
-void cleanup(void);
+#define DIR_NAME MNTPOINT "/X.%d"
+#define DIR_NAME_GROUP MNTPOINT "/X.%d.%d"
+#define NCHILD 3
static int child_groups = 2;
-static int test_time = 5;
+static int test_time = 1;
static int nfiles = 5;
+static volatile int done;
-static char *opt_child_groups;
-static char *opt_test_time;
-static char *opt_nfiles;
-
-static option_t options[] = {
- {"c:", NULL, &opt_child_groups},
- {"t:", NULL, &opt_test_time},
- {"d:", NULL, &opt_nfiles},
- {NULL, NULL, NULL}
-};
-
-static void usage(void)
-{
- printf(" -c Child groups\n");
- printf(" -t Test runtime\n");
- printf(" -d Directories\n");
-}
-
-int main(int argc, char *argv[])
-{
- tst_parse_opts(argc, argv, options, usage);
-
- if (opt_child_groups)
- child_groups = atoi(opt_child_groups);
-
- if (opt_test_time)
- test_time = atoi(opt_test_time);
-
- if (opt_nfiles)
- nfiles = atoi(opt_nfiles);
-
- setup();
-
- if (signal(SIGTERM, term) == SIG_ERR) {
- tst_brkm(TFAIL, cleanup,
- "Error setting up SIGTERM signal, ERRNO = %d", errno);
-
- }
-
- if (signal(SIGCHLD, chld) == SIG_ERR) {
- tst_brkm(TFAIL, cleanup,
- "Error setting up SIGCHLD signal, ERRNO = %d", errno);
-
- }
-
- runtest();
- cleanup();
- tst_exit();
-}
-
-int runtest(void)
-{
- int i, j;
- int count, child, status;
- char tmpdir[MAXPATHLEN];
-
- /* Create permanent directories with holes in directory structure */
-
- for (j = 0; j < nfiles; j++) {
- sprintf(tmpdir, DIR_NAME, j);
- TEST(mkdir(tmpdir, MODE_RWX));
-
- if (TEST_RETURN < 0) {
- tst_brkm(TFAIL, cleanup,
- "Error creating permanent directories, ERRNO = %d",
- TEST_ERRNO);
- }
- if ((j % NCHILD) != 0) {
- if (rmdir(tmpdir) < 0) {
- tst_brkm(TFAIL, cleanup,
- "Error removing directory, ERRNO = %d",
- errno);
- }
- }
- }
-
- parent_pid = getpid();
-
- /* allocate space for list of child pid's */
-
- if ((pidlist = malloc((child_groups * NCHILD) * sizeof(int))) ==
- NULL) {
- tst_brkm(TWARN, NULL,
- "\tMalloc failed (may be OK if under stress)");
- }
-
- child_count = 0;
- for (j = 0; j < child_groups; j++) {
- for (i = 0; i < NCHILD; i++) {
- getchild(j, i, child_count);
- child_count++;
- }
- }
-
- /* If signal already received, skip to cleanup */
-
- if (!sigchld && !sigterm) {
- if (test_time) {
- /* To get out of sleep if signal caught */
- if (!setjmp(env_buf)) {
- jump++;
- sleep(test_time);
- }
- } else {
- pause();
- }
- }
-
- /* Reset signals since we are about to clean-up and to avoid
- * problem with wait call * $
- * */
-
- if (signal(SIGTERM, SIG_IGN) == SIG_ERR) {
- tst_brkm(TFAIL, cleanup,
- "Error resetting SIGTERM signal, ERRNO = %d", errno);
- }
- if (signal(SIGCHLD, SIG_DFL) == SIG_ERR) {
- tst_brkm(TFAIL, cleanup,
- "Error resetting SIGCHLD signal, ERRNO = %d", errno);
- }
-
- if (test_time) {
- sleep(test_time);
- }
-
- /* Clean up children */
- massmurder();
- /*
- * Watch children finish and show returns.
- */
-
- count = 0;
- while (1) {
- if ((child = wait(&status)) > 0) {
- if (status != 0) {
- tst_brkm(TWARN,
- NULL,
- "\tChild{%d} exited status = %0x",
- child, status);
- }
- count++;
- } else {
- if (errno != EINTR) {
- break;
- }
- tst_resm(TINFO, "\tSignal detected during wait");
- }
- }
-
- /*
- * Make sure correct number of children exited.
- */
-
- if (count != child_count) {
- tst_resm(TWARN, "\tWrong number of children waited on!");
- tst_brkm(TWARN, NULL, "\tSaw %d, expected %d", count,
- NCHILD);
- }
-
- /* Check for core file in test directory. */
-
- if (access("core", 0) == 0) {
- tst_brkm(TWARN, NULL, "\tCore file found in test directory.");
- }
-
- /* Remove expected files */
-
- for (j = 0; j < nfiles; j += NCHILD) {
- sprintf(tmpdir, DIR_NAME, j);
- if (rmdir(tmpdir) < 0) {
- tst_brkm(TWARN,
- NULL,
- "\tError removing expected directory, ERRNO = %d",
- errno);
- }
- }
-
- tst_resm(TPASS, "PASS");
-
- return 0;
-}
-
-int getchild(int group, int child, int children)
-{
- int pid;
-
- pid = FORK_OR_VFORK();
-
- if (pid < 0) {
-
- massmurder(); /* kill the kids */
- tst_brkm(TBROK, cleanup,
- "\tFork failed (may be OK if under stress)");
- } else if (pid == 0) { /* child does this */
- switch (children % NCHILD) {
- case 0:
- dochild1(); /* create existing directories */
- break; /* so lint won't complain */
- case 1:
- dochild2(); /* remove nonexistant directories */
- break;
- case 2:
- dochild3(group); /* create/delete directories */
- break;
- default:
- tst_brkm(TFAIL, cleanup,
- "Test not inplemented for child %d", child);
- exit(1);
- break;
- }
- exit(1); /* If child gets here, something wrong */
- }
- pidlist[children] = pid;
- return 0;
-}
-
-void term(int sig)
-{
- /* Routine to handle SIGTERM signal. */
-
- if (parent_pid == getpid()) {
- tst_brkm(TWARN, NULL, "\tsignal SIGTERM received by parent.");
- }
- sigterm++;
- if (jump) {
- longjmp(env_buf, 1);
- }
-}
-
-void chld(int sig)
-{
- /* Routine to handle SIGCHLD signal. */
-
- sigchld++;
- if (jump) {
- longjmp(env_buf, 1);
- }
-}
-
-int dochild1(void)
+/*
+ * Routine which attempts to create directories in the test
+ * directory that already exist.
+ */
+static void test1(int child_num)
{
- /* Child routine which attempts to create directories in the test
- * directory that already exist. Runs until a SIGTERM signal is
- * received. Will exit with an error if it is able to create the
- * directory or if the expected error is not received.
- */
-
int j;
char tmpdir[MAXPATHLEN];
- while (!sigterm) {
+ while (!done) {
for (j = 0; j < nfiles; j += NCHILD) {
sprintf(tmpdir, DIR_NAME, j);
- TEST(mkdir(tmpdir, MODE_RWX));
-
- if (TEST_RETURN < 0) {
-
- if (TEST_ERRNO != EEXIST) {
- tst_brkm(TFAIL, cleanup,
- "MKDIR %s, errno = %d; Wrong error detected.",
- tmpdir, TEST_ERRNO);
- exit(1);
- }
- } else {
- tst_brkm(TFAIL, cleanup,
- "MKDIR %s succeded when it shoud have failed.",
- tmpdir);
- exit(1);
- }
+ TST_EXP_FAIL_SILENT(mkdir(tmpdir, MODE_RWX), EEXIST);
+ if (!TST_PASS)
+ break;
}
}
- exit(0);
+ tst_res(TPASS, "[%d] create dirs that already exist", child_num);
}
-int dochild2(void)
+/*
+ * Child routine which attempts to remove directories from the
+ * test directory which do not exist.
+ */
+static void test2(int child_num)
{
- /* Child routine which attempts to remove directories from the
- * test directory which do not exist. Runs until a SIGTERM
- * signal is received. Exits with an error if the proper
- * error is not detected or if the remove operation is
- * successful.
- */
int j;
char tmpdir[MAXPATHLEN];
- while (!sigterm) {
+ while (!done) {
for (j = 1; j < nfiles; j += NCHILD) {
sprintf(tmpdir, DIR_NAME, j);
- if (rmdir(tmpdir) < 0) {
- if (errno != ENOENT) {
- tst_brkm(TFAIL, cleanup,
- "RMDIR %s, errno = %d; Wrong error detected.",
- tmpdir, errno);
- exit(1);
- }
- } else {
- tst_brkm(TFAIL, cleanup,
- "RMDIR %s succeded when it should have failed.",
- tmpdir);
- exit(1);
- }
+ TST_EXP_FAIL_SILENT(rmdir(tmpdir), ENOENT);
+ if (!TST_PASS)
+ break;
}
}
- exit(0);
- return 0;
+ tst_res(TPASS, "[%d] remove dirs that do not exist", child_num);
}
-int dochild3(int group)
+/*
+ * Child routine which creates and deletes directories in the
+ * test directory.
+ */
+static void test3(int child_num)
{
- /* Child routine which creates and deletes directories in the
- * test directory. Runs until a SIGTERM signal is received, then
- * cleans up and exits. Detects error if the expected condition
- * is not encountered.
- */
int j;
-
char tmpdir[MAXPATHLEN];
- char tmp[MAXPATHLEN];
- while (!sigterm) {
+ while (!done) {
for (j = 2; j < nfiles; j += NCHILD) {
- strcpy(tmp, DIR_NAME);
- strcat(tmp, ".%d");
- sprintf(tmpdir, tmp, j, group);
-
- TEST(mkdir(tmpdir, MODE_RWX));
-
- if (TEST_RETURN < 0) {
- tst_brkm(TFAIL, cleanup,
- "MKDIR %s, errno = %d; Wrong error detected.",
- tmpdir, TEST_ERRNO);
- exit(1);
- }
+ sprintf(tmpdir, DIR_NAME_GROUP, j, child_num / NCHILD);
+ TST_EXP_PASS_SILENT(mkdir(tmpdir, MODE_RWX));
+ if (!TST_PASS)
+ break;
}
for (j = 2; j < nfiles; j += NCHILD) {
- strcpy(tmp, DIR_NAME);
- strcat(tmp, ".%d");
- sprintf(tmpdir, tmp, j, group);
- if (rmdir(tmpdir) < 0) {
- tst_brkm(TFAIL, cleanup,
- "RMDIR %s, errno = %d; Wrong error detected.",
- tmpdir, errno);
- exit(1);
- }
+ sprintf(tmpdir, DIR_NAME_GROUP, j, child_num / NCHILD);
+ TST_EXP_PASS_SILENT(rmdir(tmpdir));
+ if (!TST_PASS)
+ break;
}
}
- exit(0);
+ tst_res(TPASS, "[%d] create/remove dirs", child_num);
}
-int massmurder(void)
+static void *child_thread_func(void *arg)
{
- register int j;
- for (j = 0; j < child_count; j++) {
- if (pidlist[j] > 0) {
- if (kill(pidlist[j], SIGTERM) < 0) {
- tst_brkm(TFAIL, cleanup,
- "Error killing child %d, ERRNO = %d",
- j, errno);
- }
- }
- }
- return 0;
+ void (*tests[NCHILD])(int) = { test1, test2, test3 };
+ int child_num = (long)arg;
+
+ tests[child_num % NCHILD](child_num);
+
+ /* if any thread failed, make other finish as well */
+ done = 1;
+
+ return NULL;
}
-void setup(void)
+static void verify_mkdir(void)
{
- tst_sig(NOFORK, DEF_HANDLER, cleanup);
+ pthread_t child_thread[NCHILD * child_groups];
+ long i;
+
+ done = 0;
+ for (i = 0; i < child_groups * NCHILD; i++) {
+ SAFE_PTHREAD_CREATE(&child_thread[i], NULL,
+ child_thread_func, (void *)i);
+ }
- TEST_PAUSE;
+ sleep(test_time);
+ done = 1;
- tst_tmpdir();
+ for (i = 0; i < child_groups * NCHILD; i++)
+ SAFE_PTHREAD_JOIN(child_thread[i], NULL);
}
-void cleanup(void)
+static void setup(void)
{
- tst_rmdir();
+ int j;
+ char tmpdir[MAXPATHLEN];
+
+ for (j = 0; j < nfiles; j += NCHILD) {
+ sprintf(tmpdir, DIR_NAME, j);
+ SAFE_MKDIR(tmpdir, MODE_RWX);
+ }
}
+
+static struct tst_test test = {
+ .test_all = verify_mkdir,
+ .needs_tmpdir = 1,
+ .needs_root = 1,
+ .setup = setup,
+ .mount_device = 1,
+ .mntpoint = MNTPOINT,
+ .all_filesystems = 1,
+};
--
2.27.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [LTP] [PATCH v2 1/2] tst_test_macros: add TST_EXP_FAIL_SILENT
2022-02-04 13:14 ` [LTP] [PATCH v2 1/2] tst_test_macros: add TST_EXP_FAIL_SILENT Jan Stancek
@ 2022-02-05 3:07 ` Li Wang
2022-02-07 9:17 ` Jan Stancek
0 siblings, 1 reply; 8+ messages in thread
From: Li Wang @ 2022-02-05 3:07 UTC (permalink / raw)
To: Jan Stancek; +Cc: ltp
[-- Attachment #1.1: Type: text/plain, Size: 4169 bytes --]
On Fri, Feb 4, 2022 at 9:14 PM Jan Stancek <jstancek@redhat.com> wrote:
> This variant does not print TPASS messages when
> SCALL fails as expected.
>
> Signed-off-by: Jan Stancek <jstancek@redhat.com>
> ---
> doc/c-test-api.txt | 3 +++
> include/tst_test_macros.h | 15 ++++++++++-----
> 2 files changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/doc/c-test-api.txt b/doc/c-test-api.txt
> index 6f4de3f80f95..9119e094dbfd 100644
> --- a/doc/c-test-api.txt
> +++ b/doc/c-test-api.txt
> @@ -298,6 +298,9 @@ The 'TST_EXP_FAIL2()' is the same as 'TST_EXP_FAIL()'
> except the return value is
> expected to be non-negative integer if call passes. These macros build
> upon the
> +TEST()+ macro and associated variables.
>
> +'TST_EXP_FAIL_SILENT()' and 'TST_EXP_FAIL2_SILENT()' variants are less
> verbose
> +and do not print TPASS messages when SCALL fails as expected.
> +
> [source,c]
>
> -------------------------------------------------------------------------------
> TEST(socket(AF_INET, SOCK_RAW, 1));
> diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
> index ec8c38523344..f7de8d00a666 100644
> --- a/include/tst_test_macros.h
> +++ b/include/tst_test_macros.h
> @@ -163,7 +163,7 @@ extern void *TST_RET_PTR;
> TST_MSG_(TPASS, " passed", #SCALL,
> ##__VA_ARGS__); \
> } while (0)
> \
>
> -#define TST_EXP_FAIL_(PASS_COND, SCALL, SSCALL, ERRNO, ...)
> \
> +#define TST_EXP_FAIL_(SILENT, PASS_COND, SCALL, SSCALL, ERRNO, ...)
> \
>
I think maybe the better way is to define TST_EXP_FAIL_SILENT_
but not add a new SILENT parameter. So that it keeps consistent with
the existing TST_EXP_PASS_SILENT_ macros.
How about this:
(changed base on your patch)
--- a/include/tst_test_macros.h
+++ b/include/tst_test_macros.h
@@ -163,7 +163,7 @@ extern void *TST_RET_PTR;
TST_MSG_(TPASS, " passed", #SCALL, ##__VA_ARGS__);
\
} while (0)
\
-#define TST_EXP_FAIL_(SILENT, PASS_COND, SCALL, SSCALL, ERRNO, ...)
\
+#define TST_EXP_FAIL_SILENT_(PASS_COND, SCALL, SSCALL, ERRNO, ...)
\
do {
\
TEST(SCALL);
\
\
@@ -181,9 +181,6 @@ extern void *TST_RET_PTR;
}
\
\
if (TST_ERR == (ERRNO)) {
\
- if (!SILENT)
\
- TST_MSG_(TPASS | TTERRNO, " ",
\
- SSCALL, ##__VA_ARGS__);
\
TST_PASS = 1;
\
} else {
\
TST_MSGP_(TFAIL | TTERRNO, " expected %s",
\
@@ -192,13 +189,23 @@ extern void *TST_RET_PTR;
}
\
} while (0)
-#define TST_EXP_FAIL(SCALL, ERRNO, ...) TST_EXP_FAIL_(0, TST_RET == 0,
SCALL, #SCALL, ERRNO, ##__VA_ARGS__)
+#define TST_EXP_FAIL(SCALL, ERRNO, ...)
\
+ do {
\
+ TST_EXP_FAIL_SILENT_(TST_RET == 0, SCALL, #SCALL, ERRNO,
##__VA_ARGS__); \
+ if (TST_PASS)
\
+ TST_MSG_(TPASS | TTERRNO, " ", #SCALL,
##__VA_ARGS__); \
+ } while (0)
-#define TST_EXP_FAIL2(SCALL, ERRNO, ...) TST_EXP_FAIL_(0, TST_RET >= 0,
SCALL, #SCALL, ERRNO, ##__VA_ARGS__)
+#define TST_EXP_FAIL2(SCALL, ERRNO, ...)
\
+ do {
\
+ TST_EXP_FAIL_SILENT_(TST_RET >= 0, SCALL, #SCALL, ERRNO,
##__VA_ARGS__); \
+ if (TST_PASS)
\
+ TST_MSG_(TPASS | TTERRNO, " ", #SCALL,
##__VA_ARGS__); \
+ } while (0)
-#define TST_EXP_FAIL_SILENT(SCALL, ERRNO, ...) TST_EXP_FAIL_(1, TST_RET ==
0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__)
+#define TST_EXP_FAIL_SILENT(SCALL, ERRNO, ...)
TST_EXP_FAIL_SILENT_(TST_RET == 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__) \
-#define TST_EXP_FAIL2_SILENT(SCALL, ERRNO, ...) TST_EXP_FAIL_(1, TST_RET
>= 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__)
+#define TST_EXP_FAIL2_SILENT(SCALL, ERRNO, ...)
TST_EXP_FAIL_SILENT_(TST_RET >= 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__) \
#define TST_EXP_EXPR(EXPR, FMT, ...)
\
tst_res_(__FILE__, __LINE__, (EXPR) ? TPASS : TFAIL, "Expect: "
FMT, ##__VA_ARGS__);
--
Regards,
Li Wang
[-- Attachment #1.2: Type: text/html, Size: 7269 bytes --]
[-- Attachment #2: Type: text/plain, Size: 60 bytes --]
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [LTP] [PATCH v2 2/2] syscalls/mkdir09: rewrite in new LTP API
2022-02-04 13:14 ` [LTP] [PATCH v2 2/2] syscalls/mkdir09: rewrite in new LTP API Jan Stancek
@ 2022-02-05 4:19 ` Li Wang
2022-02-07 12:55 ` Cyril Hrubis
1 sibling, 0 replies; 8+ messages in thread
From: Li Wang @ 2022-02-05 4:19 UTC (permalink / raw)
To: Jan Stancek; +Cc: LTP List
[-- Attachment #1.1: Type: text/plain, Size: 747 bytes --]
Jan Stancek <jstancek@redhat.com> wrote:
> +#include "tst_test.h"
> +#include "tst_safe_pthread.h"
>
> +#define MNTPOINT "mntpoint"
> #define MODE_RWX 07770
>
> +#define DIR_NAME MNTPOINT "/X.%d"
> +#define DIR_NAME_GROUP MNTPOINT "/X.%d.%d"
> +#define NCHILD 3
>
> static int child_groups = 2;
> -static int test_time = 5;
> +static int test_time = 1;
> static int nfiles = 5;
>
I think initialize 'nfiles' to 10 will be better.
As we can see the test3 starts from 'j=2' and only creates
one directory for testing, but the comment says many
directories. Also, it will test more dirs in test1 and test2.
Otherwise, this patch looks pretty good.
Reviewed-by: Li Wang <liwang@redhat.com>
--
Regards,
Li Wang
[-- Attachment #1.2: Type: text/html, Size: 2129 bytes --]
[-- Attachment #2: Type: text/plain, Size: 60 bytes --]
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [LTP] [PATCH v2 1/2] tst_test_macros: add TST_EXP_FAIL_SILENT
2022-02-05 3:07 ` Li Wang
@ 2022-02-07 9:17 ` Jan Stancek
0 siblings, 0 replies; 8+ messages in thread
From: Jan Stancek @ 2022-02-07 9:17 UTC (permalink / raw)
To: Li Wang; +Cc: LTP List
On Sat, Feb 5, 2022 at 4:07 AM Li Wang <liwang@redhat.com> wrote:
>
>
>
> On Fri, Feb 4, 2022 at 9:14 PM Jan Stancek <jstancek@redhat.com> wrote:
>>
>> This variant does not print TPASS messages when
>> SCALL fails as expected.
>>
>> Signed-off-by: Jan Stancek <jstancek@redhat.com>
>> ---
>> doc/c-test-api.txt | 3 +++
>> include/tst_test_macros.h | 15 ++++++++++-----
>> 2 files changed, 13 insertions(+), 5 deletions(-)
>>
>> diff --git a/doc/c-test-api.txt b/doc/c-test-api.txt
>> index 6f4de3f80f95..9119e094dbfd 100644
>> --- a/doc/c-test-api.txt
>> +++ b/doc/c-test-api.txt
>> @@ -298,6 +298,9 @@ The 'TST_EXP_FAIL2()' is the same as 'TST_EXP_FAIL()' except the return value is
>> expected to be non-negative integer if call passes. These macros build upon the
>> +TEST()+ macro and associated variables.
>>
>> +'TST_EXP_FAIL_SILENT()' and 'TST_EXP_FAIL2_SILENT()' variants are less verbose
>> +and do not print TPASS messages when SCALL fails as expected.
>> +
>> [source,c]
>> -------------------------------------------------------------------------------
>> TEST(socket(AF_INET, SOCK_RAW, 1));
>> diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
>> index ec8c38523344..f7de8d00a666 100644
>> --- a/include/tst_test_macros.h
>> +++ b/include/tst_test_macros.h
>> @@ -163,7 +163,7 @@ extern void *TST_RET_PTR;
>> TST_MSG_(TPASS, " passed", #SCALL, ##__VA_ARGS__); \
>> } while (0) \
>>
>> -#define TST_EXP_FAIL_(PASS_COND, SCALL, SSCALL, ERRNO, ...) \
>> +#define TST_EXP_FAIL_(SILENT, PASS_COND, SCALL, SSCALL, ERRNO, ...) \
>
>
> I think maybe the better way is to define TST_EXP_FAIL_SILENT_
> but not add a new SILENT parameter. So that it keeps consistent with
> the existing TST_EXP_PASS_SILENT_ macros.
It looked like smaller change, but I can update it (Along with the
suggestion to create/delete more directories)
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [LTP] [PATCH v2 2/2] syscalls/mkdir09: rewrite in new LTP API
2022-02-04 13:14 ` [LTP] [PATCH v2 2/2] syscalls/mkdir09: rewrite in new LTP API Jan Stancek
2022-02-05 4:19 ` Li Wang
@ 2022-02-07 12:55 ` Cyril Hrubis
2022-02-07 15:04 ` Jan Stancek
1 sibling, 1 reply; 8+ messages in thread
From: Cyril Hrubis @ 2022-02-07 12:55 UTC (permalink / raw)
To: Jan Stancek; +Cc: ltp
Hi!
> +/*
> + * Child routine which attempts to remove directories from the
> + * test directory which do not exist.
> + */
> +static void test2(int child_num)
> {
> - /* Child routine which attempts to remove directories from the
> - * test directory which do not exist. Runs until a SIGTERM
> - * signal is received. Exits with an error if the proper
> - * error is not detected or if the remove operation is
> - * successful.
> - */
>
This empty line here looks a bit strange and the same for the test3().
Other than that and the suggestion from Li it looks good.
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [LTP] [PATCH v2 2/2] syscalls/mkdir09: rewrite in new LTP API
2022-02-07 12:55 ` Cyril Hrubis
@ 2022-02-07 15:04 ` Jan Stancek
0 siblings, 0 replies; 8+ messages in thread
From: Jan Stancek @ 2022-02-07 15:04 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: LTP List
On Mon, Feb 7, 2022 at 1:53 PM Cyril Hrubis <chrubis@suse.cz> wrote:
>
> Hi!
> > +/*
> > + * Child routine which attempts to remove directories from the
> > + * test directory which do not exist.
> > + */
> > +static void test2(int child_num)
> > {
> > - /* Child routine which attempts to remove directories from the
> > - * test directory which do not exist. Runs until a SIGTERM
> > - * signal is received. Exits with an error if the proper
> > - * error is not detected or if the remove operation is
> > - * successful.
> > - */
> >
>
> This empty line here looks a bit strange and the same for the test3().
> Other than that and the suggestion from Li it looks good.
>
> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Thanks, pushed with suggested changes.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-02-07 15:04 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-04 13:14 [LTP] [PATCH v2 0/2] mkdir09: rewrite in new LTP API Jan Stancek
2022-02-04 13:14 ` [LTP] [PATCH v2 1/2] tst_test_macros: add TST_EXP_FAIL_SILENT Jan Stancek
2022-02-05 3:07 ` Li Wang
2022-02-07 9:17 ` Jan Stancek
2022-02-04 13:14 ` [LTP] [PATCH v2 2/2] syscalls/mkdir09: rewrite in new LTP API Jan Stancek
2022-02-05 4:19 ` Li Wang
2022-02-07 12:55 ` Cyril Hrubis
2022-02-07 15:04 ` Jan Stancek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox