From: Petr Vorel <pvorel@suse.cz>
To: Yang Xu <xuyang2018.jy@fujitsu.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] syscalls/fork03: Convert into new api
Date: Wed, 21 Jun 2023 14:44:23 +0200 [thread overview]
Message-ID: <20230621124423.GB407092@pevik> (raw)
In-Reply-To: <1685699755-4766-1-git-send-email-xuyang2018.jy@fujitsu.com>
Hi Xu,
...
> #include <sys/types.h>
nit: I don't think this is needed
> +#include <unistd.h>
> #include <sys/wait.h>
> -#include <stdio.h>
> -#include "test.h"
...
> +#include <stdlib.h>
> +#include "tst_test.h"
...
> + pid1 = SAFE_FORK();
> + if (!pid1) {
> + /* child uses some cpu time slices */
> + for (i = 1; i < 32767; i++) {
> + fl1 = 0.000001;
> + fl1 = fl2 = 0.000001;
> + fl1 = fl1 * 10.0;
> + fl2 = fl1 / 1.232323;
> + fl1 = fl2 - fl2;
> + fl1 = fl2;
> }
> + if (!pid1)
> + exit(0);
> + else
> + exit(1);
nit: maybe just
exit(!!pid1);
Reviewed-by: Petr Vorel <pvorel@suse.cz>
I suggest further tiny space cleanups.
You can download it or use diff below.
https://github.com/pevik/ltp/raw/4788c24a97c2f0885a2da3a8930f27d2f15f93d3/testcases/kernel/syscalls/fork/fork03.c
Kind regards,
Petr
diff --git testcases/kernel/syscalls/fork/fork03.c testcases/kernel/syscalls/fork/fork03.c
index 072f12797..9f04c113b 100644
--- testcases/kernel/syscalls/fork/fork03.c
+++ testcases/kernel/syscalls/fork/fork03.c
@@ -1,20 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (c) International Business Machines Corp., 2001
- *
- * AUTHOR
- * 07/2001 Ported by Wayne Boyer
+ * Copyright (c) Linux Test Project, 2003-2023
+ * Author: 2001 Ported by Wayne Boyer
*/
/*\
*[Description]
*
* Check that child process can use a large text space and do a large number
- * of operations. In this situation, Check for pid == 0 in child and check
- * for pid > 0 in parent after wait.
+ * of operations. In this situation, check for PID == 0 in child and check
+ * for PID > 0 in parent after wait.
*/
-#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>
#include <stdlib.h>
@@ -36,22 +34,23 @@ static void verify_fork(void)
fl1 = fl2 - fl2;
fl1 = fl2;
}
- if (!pid1)
- exit(0);
- else
- exit(1);
+
+ exit(!!pid1);
}
- tst_res(TINFO, "process id in parent of child from fork : %d", pid1);
+ tst_res(TINFO, "process id in parent of child from fork: %d", pid1);
pid2 = SAFE_WAIT(&status);
+
if (pid1 != pid2) {
- tst_res(TFAIL, "pids don't match : %d vs %d", pid1, pid2);
+ tst_res(TFAIL, "pids don't match: %d vs %d", pid1, pid2);
return;
}
+
if ((status >> 8) != 0) {
tst_res(TFAIL, "child exited with failure");
return;
}
+
tst_res(TPASS, "test PASSED");
}
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2023-06-21 12:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-02 9:55 [LTP] [PATCH] syscalls/fork03: Convert into new api Yang Xu
2023-06-21 12:44 ` Petr Vorel [this message]
2023-06-25 14:48 ` Yang Xu (Fujitsu)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230621124423.GB407092@pevik \
--to=pvorel@suse.cz \
--cc=ltp@lists.linux.it \
--cc=xuyang2018.jy@fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).