----- Original Message -----
> From: "zenglg.jy" <[email protected]>
> To: "Jan Stancek" <[email protected]>
> Cc: "ltp-list" <[email protected]>
> Sent: Monday, 9 December, 2013 1:06:26 PM
> Subject: [PATCH v3 2/2] clone/clone08.c: Add new flags
>
Hi,
<snip>
> +#if defined UCLINUX && !__THROW
> +/* workaround for libc bug */
> +#define __THROW
> +#endif
This workaround appeared again in v3, while the v2 has it removed after comment
from Cyril.
> +#include <errno.h>
> +#include <linux/sched.h>
> +#include <sched.h>
> +#include <sys/wait.h>
> +#include "test.h"
> +#include "usctest.h"
> +#include "clone_platform.h"
> +#include "safe_macros.h"
> +#include "linux_syscall_numbers.h"
> +
> +#define PASS 0
> +#define FAIL 1
I think TPASS and TFAIL are defined exactly the same.
> +int main(int ac, char **av)
> +{
> + char *msg;
> + pid_t child_pid;
> + pid_t exit_child_pid;
> + int status;
> +
> + msg = parse_opts(ac, av, NULL, NULL);
> + if (msg != NULL)
> + tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
> +
> + setup();
> +
> + child_pid = FORK_OR_VFORK();
> + if (child_pid < 0) {
> + tst_brkm(TBROK, cleanup, "Fork failed");
> + } else if (child_pid == 0) {
> + do_master_child();
> + } else {
> + /* wait child and CLONE_PARENT */
> + while (1) {
> + exit_child_pid = waitpid(-1, &status, WNOHANG);
> + if (exit_child_pid == -1) {
> + break;
> + } else if (exit_child_pid == 0) {
> + sched_yield();
> + usleep(1000);
> + } else {
> + if (!WIFEXITED(status) ||
> + (WEXITSTATUS(status) != 0)) {
> + tst_resm(TFAIL,
> + "son process exits error");
Printing the actual 'status' value could be helpful if it fails.
> +static void do_master_child(void)
> +{
> + int lc;
> + int i;
> + int status;
> +
> + do_master_child_setup();
> +
> + for (lc = 0; TEST_LOOPING(lc); lc++) {
> + tst_count = 0;
> +
> +#ifdef CLONE_STOPPED
> + stopped_flag = 0;
> +#endif
> + for (i = 0; i < TST_TOTAL; i++) {
> + tst_result = FAIL;
> +
> + TEST(ltp_clone(test_cases[i].flags,
> + test_cases[i].do_child, NULL, CHILD_STACK_SIZE,
> + child_stack, &ptid, NULL, &ctid));
> +
> + if (TEST_RETURN == -1) {
> + tst_resm(TFAIL | TTERRNO, "%s clone() failed",
> + test_cases[i].name);
> + continue;
> + }
> +
> + if (test_cases[i].testfunc != NULL)
> + test_cases[i].testfunc(TEST_RETURN);
> +
> + if (test_cases[i].flags & CLONE_PARENT) {
> + wait_process_terminated(TEST_RETURN);
> + } else if (test_cases[i].flags & CLONE_THREAD) {
> + TST_CHECKPOINT_PARENT_WAIT(NULL,
> + &checkpoint);
> + } else {
> + if (wait(&status) == -1) {
> + tst_brkm(TBROK | TERRNO, NULL,
> + "wait failed, status: %d",
> + status);
> + }
> + }
> +
> + if (tst_result == PASS) {
> + tst_resm(TPASS, "test %s success",
> + test_cases[i].name);
> + } else {
> + tst_resm(TFAIL, "test %s fail",
> + test_cases[i].name);
> + }
> + }
> + }
> +
> + tst_exit();
> +}
Use of tst_ functions in child processes is discouraged.
+static int child_clone_thread(void)
+{
+ if (tgid == getpid())
+ tst_result = PASS;
+ else
+ tst_result = FAIL;
+
+ TST_CHECKPOINT_SIGNAL_PARENT(&checkpoint);
+
+ ltp_syscall(__NR_exit);
Exit syscall is defined with parameter "error_code":
SYSCALL_DEFINE1(exit, int, error_code)
+ return 0;
+}
I was running v3 with only "CLONE_THREAD" testcase enabled:
- {"CLONE_PARENT", CLONE_PARENT | CLONE_VM | SIGCHLD, NULL,
- child_clone_parent},
- {"CLONE_CHILD_SETTID", CLONE_CHILD_SETTID | CLONE_VM | SIGCHLD, NULL,
- child_clone_child_settid},
- {"CLONE_PARENT_SETTID", CLONE_PARENT_SETTID | CLONE_VM | SIGCHLD, NULL,
- child_clone_parent_settid},
-#ifdef CLONE_STOPPED
- {"CLONE_STOPPED", CLONE_STOPPED | CLONE_VM | SIGCHLD,
- test_clone_stopped, child_clone_stopped},
-#endif
and I see it failing/crashing sometimes. I usually see one of these failures:
1. clone08 4 TBROK : Failed to read from pipe at clone08.c:168:
errno=EAGAIN(11): Resource temporarily unavailable
2. clone08 1 TBROK : The other end of the pipe was closed unexpectedly
at clone08.c:168
3. clone08 4 TPASS : test CLONE_THREAD success
clone08 1 TBROK : unexpected signal 11 received (pid = 8234).
clone08 2 TBROK : Remaining cases broken
clone08 1 TFAIL : son process exits error
4. no error, but test doesn't execute as many times as specified on command line
I'm running it on RHEL6.5 (2.6.32-431.el6) as unprivileged user in following
way:
# ./clone08 -i 1000
or
# ./clone08 -i 1000 | grep TPASS | wc -l
and expecting to get number 1000 on output, but I'm getting random numbers
I tried also RHEL7 Beta as root user and saw one more:
5. clone08 1 TBROK : unexpected signal 4 received (pid = 28936).
Regards,
Jan
------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list