From mboxrd@z Thu Jan 1 00:00:00 1970 From: nils.carlson@ericsson.com (Nils Carlson) Date: Tue, 22 Feb 2011 09:28:15 +0100 Subject: [ltt-dev] [UST PATCH] TESTS: Add a delay at the start of the fork test for a more uniform testing. In-Reply-To: <1298316969-17543-1-git-send-email-yannick.brosseau@gmail.com> References: <1298316969-17543-1-git-send-email-yannick.brosseau@gmail.com> Message-ID: <4D63739F.8040201@ericsson.com> Yannick Brosseau wrote: > Add a sleep to leave time for the ustconsumer thread to initialize correctly > before the fork. > Most of the time the consumer was not yet started at the time of the fork so > a bunch of initializations were not done and the fork code path was not > tested properly. > > I'm afraid we're falling into a bit of a trap here. The trap is called "fixing the test-case instead of fixing the code". It's quite typical for an application to fork right after startup. In fact, this is probably by far the most common place where applications fork when going into a daemon mode. So we should probably focus on fixing the problem instead, probably by detecting that we are following forks with UST and if we are somehow slowing down the initialisation functions so that everything has started up properly by the time we enter main(). /Nils > Signed-off-by: Yannick Brosseau > --- > tests/fork/fork.c | 3 +++ > 1 files changed, 3 insertions(+), 0 deletions(-) > > diff --git a/tests/fork/fork.c b/tests/fork/fork.c > index 5ce3d6d..a80518d 100644 > --- a/tests/fork/fork.c > +++ b/tests/fork/fork.c > @@ -34,6 +34,9 @@ int main(int argc, char **argv, char *env[]) > printf("Fork test program, parent pid is %d\n", getpid()); > trace_mark(ust, before_fork, MARK_NOARGS); > > + /* Sleep here to make sure the consumer is initialized before we fork */ > + sleep(1); > + > result = fork(); > if(result == -1) { > perror("fork"); >