[PATCH v5 3/3] Add tests for the -l/--syscall-limit option

Dmitry V. Levin ldv at strace.io
Sun Mar 26 10:55:52 UTC 2023


On Sun, Mar 26, 2023 at 04:12:01PM +0530, Sahil Siddiq wrote:
> On Sunday, 26 March 2023 01:28:02 IST Dmitry V. Levin wrote:
> > On Mon, Mar 20, 2023 at 11:10:58AM +0530, Sahil Siddiq wrote:
> > [...]
> > > +	FILE *f = fopen("dummy.file", "w");
> > > +	fclose(f);
> > > +
> > > +	return WEXITSTATUS(status);
> > > +}
> > 
> > There is a problem with this approach: it's racy, because the expected
> > output is partially printed asynchronously.  For the same reason, the exit
> > status is ignored.  I suggest writing the exit status into a file, and in
> > the test script wait for this file, check the exit status, and then
> > compare the expected and the actual output.
> 
> Sorry, I am still a little unfamiliar with this. Could you please explain the racy
> part. While the parent is in the following loop:
> 
>         while ((waitpid(child, &status, 0)) != child) {
>                 if (errno == EINTR)
>                         continue;
>                 perror_msg_and_fail("waitpid: %d", child);
>         }
> 
> the child process will be busy printing output. After the child terminates, the
> parent process will resume. The "dummy.file" is created after that. I didn't
> understand which part runs asynchronously and why.

As strace detaches their tracees before they terminate, they finish their
printing after they are detached, so there is a race between them
finishing printing and the test script comparing the expected output with
the actual output.


-- 
ldv


More information about the Strace-devel mailing list