Bug 3126 - funit frysk.sys.TestCallPtrace produces "ghosts"
Summary: funit frysk.sys.TestCallPtrace produces "ghosts"
Status: RESOLVED DUPLICATE of bug 3121
Alias: None
Product: frysk
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Mike Cvet
URL:
Keywords:
Depends on:
Blocks: 3121
  Show dependency treegraph
 
Reported: 2006-08-25 04:10 UTC by Andrew Cagney
Modified: 2006-12-08 18:56 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Cagney 2006-08-25 04:10:51 UTC
Description of problem:

Running the frysk testsuite seems to produce ghost versions of TestRunner.

Version-Release number of selected component (if applicable):

[mwielaar@outgrabe ~]$ uname -a
Linux outgrabe.boston.redhat.com 2.6.17-1.2519.4.9.el5 #1 SMP Wed Aug 23
11:17:45 EDT 2006 i686 i686 i386 GNU/Linux

[mwielaar@outgrabe ~]$ rpm -qv frysk
frysk-0.0.1.2006.07.25.rh1-4.fc6

This is also reproducable with frysk CVS with TestRunner as described in the
external bug reference.

How reproducible:

Always.

Steps to Reproduce:
1. $ /usr/libexec/frysk/funit frysk.sys.TestCallPtrace

Actual results:

[mwielaar@outgrabe frysk-obj]$ /usr/libexec/frysk/funit frysk.sys.TestCallPtrace
Running testChildContinue(frysk.sys.TestCallPtrace) ...PASS
Running testAttach(frysk.sys.TestCallPtrace) ...PASS

Time: 0.036

OK (2 tests)

[mwielaar@outgrabe frysk-obj]$ DETACHED PROCESS: EXITING
FAIL
  junit.framework.AssertionFailedError

Time: 5.045
There was 1 failure:
1) testAttach(frysk.sys.TestCallPtrace)junit.framework.AssertionFailedError
   at frysk.sys.TestCallPtrace.testAttach(funit)
   at frysk.junit.Runner.<init>(funit)
   at funit.main(funit)

FAILURES!!!
Tests run: 2,  Failures: 1,  Errors: 0

Expected results:

Running testChildContinue(frysk.sys.TestCallPtrace) ...PASS
Running testAttach(frysk.sys.TestCallPtrace) ...PASS

Time: 0.036

OK (2 tests)

Additional info:

Note that it takes a little while before the "ghost" funit shows up.
Afterwards ps x will show one or more <defunct> funit processes.
Comment 1 Andrew Cagney 2006-08-25 04:12:20 UTC
Downstream bug:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=203902
Comment 2 Andrew Cagney 2006-08-25 04:18:19 UTC
Mike,

This code has a few problems:

/* Create a dummy process to attach to */
jint
frysk::sys::TestLib::forkIt ()
{
  jint pid;
  if ((pid = fork()) < 0) {
    perror("Error: could not fork child process");
    exit(1);
  } else if (pid == 0) { /* Child */
    sleep(5);
    printf("DETACHED PROCESS: EXITING\n");
  }
  return pid;
}

- if ((pid = fork ())...)
assignment in if() violates GNU coding standards, and is accepted as just making
the code harder to read

- the printf, shouldn't - tests shouldn't use printf

- the perror shouldn't - have a look at other cni/ files, they throw an error

- the child doesn't exit, instead returning - which is why there's a shadow fork
(reason one :-)

- the code using this can't be killing off the child during tearDown - the
shadow fork reason two?

Perhaps restructure this to use a switch:

   pid = fork ();
   switch (pid) {
     case -1:
       throw exceptioni;
     case 0:
       sleep (...);
       exit (0);
     default:
       return pid;
Comment 3 Mark Wielaard 2006-08-25 07:53:32 UTC
Already reported as bug #3121

*** This bug has been marked as a duplicate of 3121 ***