Source-Changes-D archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: CVS commit: src/tests/kernel
On Tue, 19 Feb 2013, Joerg Sonnenberger wrote:
Wait a little bit after fork()ing the lockers to give them a chance to
get started before trying to ptrace(ATTACH).
What about using a pipe to make this an explicit barrier?
You mean something like this? :)
Index: t_lockf.c
===================================================================
RCS file: /cvsroot/src/tests/kernel/t_lockf.c,v
retrieving revision 1.3
diff -u -p -r1.3 t_lockf.c
--- t_lockf.c 19 Feb 2013 00:54:47 -0000 1.3
+++ t_lockf.c 19 Feb 2013 03:24:01 -0000
@@ -118,8 +118,10 @@ ATF_TC_HEAD(randlock, tc)
ATF_TC_BODY(randlock, tc)
{
int i, j, fd;
+ int pipe_fd[2];
pid_t *pid;
int status;
+ char pipe_in, pipe_out;
(void)unlink(lockfile);
@@ -132,19 +134,30 @@ ATF_TC_BODY(randlock, tc)
fsync(fd);
close(fd);
+ ATF_REQUIRE_MSG(pipe(pipe_fd) == 0, "pipe: %s", strerror(errno));
+
pid = malloc(nprocs * sizeof(pid_t));
for (i=0; i<nprocs; i++) {
+ pipe_out = (char)('A' + i);
pid[i] = fork();
switch (pid[i]) {
case 0:
- trylocks(i);
+ if (write(pipe_fd[1], &pipe_out, 1) != 1)
+ printf("write_pipe(%i): %s", i,
+ strerror(errno));
+ else
+ trylocks(i);
_exit(0);
break;
case -1:
atf_tc_fail("fork %d failed", i);
break;
default:
+ ATF_REQUIRE_MSG(read(pipe_fd[0], &pipe_in, 1) == 1,
+ "parent: read_pipe(%i): %s", i, strerror(errno));
+ ATF_REQUIRE_MSG(pipe_in == pipe_out,
+ "parent: pipe does not match");
break;
}
}
-------------------------------------------------------------------------
| Paul Goyette | PGP Key fingerprint: | E-mail addresses: |
| Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com |
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net |
| Kernel Developer | | pgoyette at netbsd.org |
-------------------------------------------------------------------------
Home |
Main Index |
Thread Index |
Old Index