public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Cagney <cagney@redhat.com>
To: Nurdin Premji <npremji@redhat.com>
Cc: frysk <frysk@sourceware.org>
Subject: Re: How to send signals to test programs?
Date: Wed, 26 Mar 2008 13:32:00 -0000	[thread overview]
Message-ID: <47EA502A.1040306@redhat.com> (raw)
In-Reply-To: <47E9AA37.3080908@redhat.com>

Nurdin,

For this sort of testing, determinism is the key, so you'll want to have 
the program directly generate the signal, two ways:

-> cause an npe or similar
-> execute the kill system-call instruction

this can be done in assembler (see frysk-asm.h, and frysk-raise.S for 
example system calls).

Andrew


Nurdin Premji wrote:
> 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();
>    }
>

      parent reply	other threads:[~2008-03-26 13:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-26  1:43 Nurdin Premji
2008-03-26 12:36 ` Mark Wielaard
2008-03-26 13:32 ` Andrew Cagney [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47EA502A.1040306@redhat.com \
    --to=cagney@redhat.com \
    --cc=frysk@sourceware.org \
    --cc=npremji@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).