From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25309 invoked by alias); 17 Jan 2008 22:49:29 -0000 Received: (qmail 25281 invoked by uid 367); 17 Jan 2008 22:49:27 -0000 Date: Thu, 17 Jan 2008 22:49:00 -0000 Message-ID: <20080117224927.25261.qmail@sourceware.org> From: cagney@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Add attatch/detach + repeated signal stress test (part 2). X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: fed9329f52e8140d87c4e5dbfb6096e0f20f326b X-Git-Newrev: 4a5a9f45ef25a717ed2e7c5b03d96a972f3ee393 Mailing-List: contact frysk-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-cvs-owner@sourceware.org Reply-To: frysk@sourceware.org X-SW-Source: 2008-q1/txt/msg00088.txt.bz2 The branch, master has been updated via 4a5a9f45ef25a717ed2e7c5b03d96a972f3ee393 (commit) via 5d7da0f494d47ccf94506a318c030a3336d35458 (commit) from fed9329f52e8140d87c4e5dbfb6096e0f20f326b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 4a5a9f45ef25a717ed2e7c5b03d96a972f3ee393 Author: Andrew Cagney Date: Thu Jan 17 17:44:46 2008 -0500 Add attatch/detach + repeated signal stress test (part 2). frysk-core/frysk/pkglibdir/ChangeLog 2008-01-17 Andrew Cagney * funit-hups.c: New file. frysk-core/frysk/proc/ChangeLog 2008-01-17 Andrew Cagney * StressAttachDetachSignaledTask.java (stressSignalStorm(Action)) (SignalStorm, testBlockedSignalStorm()) (testUnblockedSignalStorm()): New. commit 5d7da0f494d47ccf94506a318c030a3336d35458 Author: Andrew Cagney Date: Thu Jan 17 17:42:40 2008 -0500 Add repeated signal + attach-detach stress tests. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/pkglibdir/ChangeLog | 4 + .../frysk/pkglibdir/funit-hups.c | 118 ++++++++++---------- frysk-core/frysk/proc/ChangeLog | 4 + .../frysk/proc/StressAttachDetachSignaledTask.java | 61 ++++++++++- 4 files changed, 128 insertions(+), 59 deletions(-) copy frysk-imports/tests/frysk3381/f3381.c => frysk-core/frysk/pkglibdir/funit-hups.c (65%) First 500 lines of diff: diff --git a/frysk-core/frysk/pkglibdir/ChangeLog b/frysk-core/frysk/pkglibdir/ChangeLog index 7e2c667..65ebc99 100644 --- a/frysk-core/frysk/pkglibdir/ChangeLog +++ b/frysk-core/frysk/pkglibdir/ChangeLog @@ -1,3 +1,7 @@ +2008-01-17 Andrew Cagney + + * funit-hups.c: New file. + 2008-01-17 Stan Cox * gen-type-funit-tests.py: Add copyright notice. diff --git a/frysk-imports/tests/frysk3381/f3381.c b/frysk-core/frysk/pkglibdir/funit-hups.c similarity index 65% copy from frysk-imports/tests/frysk3381/f3381.c copy to frysk-core/frysk/pkglibdir/funit-hups.c index 9dd4e41..36c0d2c 100644 --- a/frysk-imports/tests/frysk3381/f3381.c +++ b/frysk-core/frysk/pkglibdir/funit-hups.c @@ -1,6 +1,6 @@ // This file is part of the program FRYSK. // -// Copyright 2006, Red Hat Inc. +// Copyright 2008, Red Hat Inc. // // FRYSK is free software; you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by @@ -37,77 +37,79 @@ // version and license this file solely under the GPL without // exception. -/* - * frysk-imports/tests/frysk3381 - */ +/* Until the timeout, keep signalling thy self. Check that no signals + are lost. */ #define _GNU_SOURCE -#include -#include -#include + +#include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include -#define NR_CHILDREN 3 +#include "funit-util.h" -int -main (int ac, char * av[]) + + +static void +usage () { - int i; - pid_t dpids[NR_CHILDREN]; + printf ("\ +Usage: funit-hups [OPTION]\n\ +Send SIGHUPS to self, repeatedly.\n\ +Where valid options are:\n\ + -t TIMEOUT Set an ALARM to TIMEOUT seconds; after which exit\n\ + Default is to not exit\n\ +"); + exit (1); +} - for (i = 0; i < NR_CHILDREN; i++) { - pid_t pid = fork (); - switch (pid) { - case -1: - perror ("fork"); - exit (1); - case 0: // child - { - while (1) { - usleep (250000); - } - } - break; - default: // Parent - dpids[i] = pid; - break; - } - } + - for (i = 0; i < NR_CHILDREN; i++) { - int status; - - if (ptrace (PTRACE_ATTACH, dpids[i], NULL, NULL) < 0) { - perror ("ptrace -- for attach"); - exit (1); - } - if (waitpid (dpids[i], &status, __WALL) < 0) { - perror ("waitpid -- for attach"); - exit (1); - } +static volatile int count; + +static void +handler(int sig) { + if ((count & 1) == 0) { + fprintf(stdout, "even count %d in signal handler\n", count); + kill(getpid(), SIGTERM); } + count++; +} - for (i = 0; i < NR_CHILDREN; i++) { - if (kill (dpids[i], SIGKILL)) - perror ("kill SIGKILL"); +int +main (int argc, char *argv[], char *envp[]) +{ + if (argc <= 1) { + usage(); + exit(1); } - sleep (2); + int opt; + int timeout = 0; - { - int nr_resps; + while ((opt = getopt(argc, argv, "+t:h")) != -1) { + switch (opt) { + case 't': // timeout + timeout = atoi (optarg); + break; + case 'h': + case '?': + usage(); + exit(1); + } + } - for (nr_resps = 0; 0 < waitpid (-1, NULL, WNOHANG); nr_resps++) {} - exit ((0 == nr_resps) ? 1 : 0); + alarm(timeout); + signal(SIGHUP, handler); + + while (1) { + if (count & 1) { + fprintf(stdout, "odd count %d in main\n", count); + kill(getpid(), SIGTERM); + } + count++; + kill(getpid(), SIGHUP); } } diff --git a/frysk-core/frysk/proc/ChangeLog b/frysk-core/frysk/proc/ChangeLog index 3628748..eae536d 100644 --- a/frysk-core/frysk/proc/ChangeLog +++ b/frysk-core/frysk/proc/ChangeLog @@ -1,5 +1,9 @@ 2008-01-17 Andrew Cagney + * StressAttachDetachSignaledTask.java (stressSignalStorm(Action)) + (SignalStorm, testBlockedSignalStorm()) + (testUnblockedSignalStorm()): New. + * TestProcStopped.java: Move to frysk.proc.live. 2008-01-16 Andrew Cagney diff --git a/frysk-core/frysk/proc/StressAttachDetachSignaledTask.java b/frysk-core/frysk/proc/StressAttachDetachSignaledTask.java index b5867ba..73f0746 100644 --- a/frysk-core/frysk/proc/StressAttachDetachSignaledTask.java +++ b/frysk-core/frysk/proc/StressAttachDetachSignaledTask.java @@ -1,6 +1,6 @@ // This file is part of the program FRYSK. // -// Copyright 2005, 2006, 2007, Red Hat Inc. +// Copyright 2005, 2006, 2007, 2008, Red Hat Inc. // // FRYSK is free software; you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by @@ -42,6 +42,9 @@ package frysk.proc; import frysk.testbed.SlaveOffspring; import frysk.testbed.TestLib; import frysk.testbed.TaskObserverBase; +import frysk.Config; +import frysk.testbed.DaemonBlockedAtEntry; +import frysk.sys.Signal; /** * Test attaching to a process with many many tasks. @@ -166,4 +169,60 @@ public class StressAttachDetachSignaledTask } }; } + + /** + * A signal class; that just adds then delets itself. If an ABORT + * signal is seen (the child panics) fail the test. + */ + private static class SignalStorm + extends TaskObserverBase implements TaskObserver.Signaled + { + private int count = 1000; + private final Action action; + SignalStorm(Action action) { + this.action = action; + } + public Action updateSignaled(Task task, int signal) { + if (Signal.TERM.equals(signal)) + fail("child aborted"); + assertTrue("signal HUP", Signal.HUP.equals(signal)); + task.requestDeleteSignaledObserver(this); + return action; + } + public void deletedFrom(Object o) { + if (--count == 0) + Manager.eventLoop.requestStop(); + Task task = (Task)o; + task.requestAddSignaledObserver(this); + } + } + private void stressSignalStorm(Action action) { + DaemonBlockedAtEntry daemon + = new DaemonBlockedAtEntry(new String[] { + Config.getPkgLibFile("funit-hups").getAbsolutePath(), + "-t", + "" + getTimeoutSeconds() + }); + daemon.requestRemoveBlock(); + SignalStorm storm = new SignalStorm(action); + daemon.getMainTask().requestAddSignaledObserver(storm); + assertRunUntilStop("storming"); + } + + /** + * Stress attaching and detaching a task that is constantly + * signalling itself. If a signal is lost, the child process will + * abort. + */ + public void testBlockedSignalStorm() { + stressSignalStorm(Action.BLOCK); + } + /** + * Stress attaching and detaching a task that is constantly + * signalling itself. If a signal is lost, the child process will + * abort. + */ + public void testUnblockedSignalStorm() { + stressSignalStorm(Action.CONTINUE); + } } hooks/post-receive -- frysk system monitor/debugger