This is the mail archive of the
frysk@sourceware.org
mailing list for the frysk project.
How to send signals to test programs?
- From: Nurdin Premji <npremji at redhat dot com>
- To: frysk <frysk at sourceware dot org>
- Date: Tue, 25 Mar 2008 21:43:19 -0400
- Subject: How to send signals to test programs?
Trying to create a test for stepping over and through signals. I have a
simple the test program and I'm copying testcases from
frysk-core/frysk/stepping/TestStepping.java
How do I send a signal to my test program from the TestStepping test?
Thank you,
Nurdin
funit-signal.c:
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <signal.h>
volatile int j = 0;
void catch_usr (int sig_num)
{
signal(SIGUSR1,
catch_usr); //
_signalSigHandlerEntry_
--j;
++j;
}
int
main ( int argc, char *argv[]) {
signal(SIGUSR1, catch_usr);
--j;
// _startTestEntry_
++j;
return 0;
}
TestStepping.java addition:
public void testStepThroughSignal() {
/** Variable setup */
String source = Config.getRootSrcDir()
+ "frysk-core/frysk/pkglibdir/funit-signal.c";
this.scanner = new TestfileTokenScanner(new File(source));
/* The line number where the test begins */
int start = this.scanner.findTokenLine("_startTestEntry_");
/* The line number the test should end up at */
int end = this.scanner.findTokenLine("_signalSigHandlerEntry_");
/* The test process */
SynchronizedOffspring process
= new SynchronizedOffspring(Signal.USR1,
new String[] {
getExecPath("funit-signal")
});
this.testStarted = false;
/** Test initialization */
Task myTask = initTask(process, source, start, end);
this.currentTest = new AssertLine(end, myTask);
DebugInfoFrame frame = DebugInfoStackFactory
.createDebugInfoStackTrace(myTask);
assertTrue("Line information present", frame.getLine() !=
SourceLocation.UNKNOWN);
/** The stepping operation */
this.se.stepLine(myTask);
/* TODO: Send Signal to myTask */
this.testStarted = true;
/** Run to completion */
assertRunUntilStop("Running test");
cleanup();
}