public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
* [SCM]  master: Add HpdTestbed.hpdTerminatingProgram(String).
@ 2007-11-12 16:58 cagney
  0 siblings, 0 replies; only message in thread
From: cagney @ 2007-11-12 16:58 UTC (permalink / raw)
  To: frysk-cvs

The branch, master has been updated
       via  e1b21136210c5575307114bbb0a66545b141470d (commit)
      from  65cc62fab99852356333ed0dc98bb91118d4e021 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit e1b21136210c5575307114bbb0a66545b141470d
Author: Andrew Cagney <cagney@redhat.com>
Date:   Mon Nov 12 11:56:08 2007 -0500

    Add HpdTestbed.hpdTerminatingProgram(String).
    
    frysk-core/frysk/hpd/ChangeLog
    2007-11-12  Andrew Cagney  <cagney@redhat.com>
    
    	* HpdTestbed.java (HpdTestbed(String[])): Make private.
    	(hpdTerminatingProgram(String)): New.
    	* HpdCoreFileTestbed.java: Delete.
    	* TestWhereCommand.java (testFhpdVirtualStackTrace()): Use.
    	(testFhpdVirtualStackTraceWithScopes()): Ditto.
    
    frysk-core/frysk/testbed/ChangeLog
    2007-11-12  Andrew Cagney  <cagney@redhat.com>
    
    	* DaemonBlockedAtSignal.java (DaemonBlockedAtSignal(File)): New.
    	* TestCoreFileAtSignal.java (testCoreFileAtSignal()): Enable;
    	simplify.
    	* CoreFileAtSignal.java (constructCore(File)): New.
    	(constructCore(String)): Use.

-----------------------------------------------------------------------

Summary of changes:
 frysk-core/frysk/hpd/ChangeLog                     |    6 ++
 frysk-core/frysk/hpd/HpdCoreFileTestbed.java       |   60 --------------------
 frysk-core/frysk/hpd/HpdTestbed.java               |   25 ++++++++-
 frysk-core/frysk/hpd/TestWhereCommand.java         |   19 +------
 frysk-core/frysk/testbed/ChangeLog                 |    8 +++
 frysk-core/frysk/testbed/CoreFileAtSignal.java     |   40 +++++++------
 .../frysk/testbed/DaemonBlockedAtSignal.java       |    5 ++
 frysk-core/frysk/testbed/TestCoreFileAtSignal.java |   32 +++--------
 8 files changed, 75 insertions(+), 120 deletions(-)
 delete mode 100644 frysk-core/frysk/hpd/HpdCoreFileTestbed.java

First 500 lines of diff:
diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog
index 5fdd4a2..71e39f5 100644
--- a/frysk-core/frysk/hpd/ChangeLog
+++ b/frysk-core/frysk/hpd/ChangeLog
@@ -1,5 +1,11 @@
 2007-11-12  Andrew Cagney  <cagney@redhat.com>
 
+	* HpdTestbed.java (HpdTestbed(String[])): Make private.
+	(hpdTerminatingProgram(String)): New.
+	* HpdCoreFileTestbed.java: Delete.
+	* TestWhereCommand.java (testFhpdVirtualStackTrace()): Use.
+	(testFhpdVirtualStackTraceWithScopes()): Ditto.
+	
 	* TestWhereCommand.java: Update; funit-inlined renamed to
 	funit-stack-inlined.
 
diff --git a/frysk-core/frysk/hpd/HpdCoreFileTestbed.java b/frysk-core/frysk/hpd/HpdCoreFileTestbed.java
deleted file mode 100644
index b080f5f..0000000
--- a/frysk-core/frysk/hpd/HpdCoreFileTestbed.java
+++ /dev/null
@@ -1,60 +0,0 @@
-// This file is part of the program FRYSK.
-//
-// Copyright 2007 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
-// the Free Software Foundation; version 2 of the License.
-//
-// FRYSK is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-// 
-// You should have received a copy of the GNU General Public License
-// along with FRYSK; if not, write to the Free Software Foundation,
-// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-// 
-// In addition, as a special exception, Red Hat, Inc. gives You the
-// additional right to link the code of FRYSK with code not covered
-// under the GNU General Public License ("Non-GPL Code") and to
-// distribute linked combinations including the two, subject to the
-// limitations in this paragraph. Non-GPL Code permitted under this
-// exception must only link to the code of FRYSK through those well
-// defined interfaces identified in the file named EXCEPTION found in
-// the source code files (the "Approved Interfaces"). The files of
-// Non-GPL Code may instantiate templates or use macros or inline
-// functions from the Approved Interfaces without causing the
-// resulting work to be covered by the GNU General Public
-// License. Only Red Hat, Inc. may make changes or additions to the
-// list of Approved Interfaces. You must obey the GNU General Public
-// License in all respects for all of the FRYSK code and other code
-// used in conjunction with FRYSK except the Non-GPL Code covered by
-// this exception. If you modify this file, you may extend this
-// exception to your version of the file, but you are not obligated to
-// do so. If you do not wish to provide this exception without
-// modification, you must delete this exception statement from your
-// version and license this file solely under the GPL without
-// exception.
-
-package frysk.hpd;
-
-import java.io.File;
-
-import frysk.Config;
-
-/**
- * For fhpd tests that are based on core files.
- */
-public class HpdCoreFileTestbed
-    extends HpdTestbed
-{
-    public HpdCoreFileTestbed(File coreFile, File exeFile, String startup) {
-	super(new String[] {
-		Config.getBinFile("fhpd").getPath (),
-		coreFile.toString(),
-		exeFile.toString()
-	      });
-	expectPrompt(startup);
-    }
-}
diff --git a/frysk-core/frysk/hpd/HpdTestbed.java b/frysk-core/frysk/hpd/HpdTestbed.java
index a6ccc73..9914ee5 100644
--- a/frysk-core/frysk/hpd/HpdTestbed.java
+++ b/frysk-core/frysk/hpd/HpdTestbed.java
@@ -41,6 +41,7 @@ package frysk.hpd;
 
 import frysk.junit.TestCase;
 import frysk.Config;
+import frysk.testbed.CoreFileAtSignal;
 import frysk.expunit.Expect;
 import frysk.expunit.Match;
 import frysk.expunit.Regex;
@@ -63,7 +64,7 @@ public class HpdTestbed
      */
     private final String prompt = "\\(fhpd\\) ";
 
-    protected HpdTestbed(String[] command) {
+    private HpdTestbed(String[] command) {
 	super(command);
 	TearDownExpect.add(this);
 	TearDownProcess.add(getPid());
@@ -207,4 +208,26 @@ public class HpdTestbed
     static HpdTestbed run(String program) {
 	return run(program, null);
     }
+
+    /**
+     * Start HPD attatched to PROGRAM that is crashing (due to a
+     * signal).
+     *
+     * XXX: The current implementation runs the program until it
+     * crashes and then pulls a core file from it; the code then loads
+     * the core-file into the HPD.  A future implementation may just
+     * run the program to the terminating event.
+     */
+    static HpdTestbed hpdTerminatingProgram(String program) {
+	File exeFile = Config.getPkgLibFile(program);
+	File coreFile = CoreFileAtSignal.constructCore(exeFile);
+	HpdTestbed hpd
+	    = new HpdTestbed(new String[] {
+				 Config.getBinFile("fhpd").getPath (),
+				 coreFile.toString(),
+				 exeFile.toString()
+			     });
+	hpd.expectPrompt("Attached to core file.*");
+	return hpd;
+    }
 }
diff --git a/frysk-core/frysk/hpd/TestWhereCommand.java b/frysk-core/frysk/hpd/TestWhereCommand.java
index 1beb993..9b30104 100644
--- a/frysk-core/frysk/hpd/TestWhereCommand.java
+++ b/frysk-core/frysk/hpd/TestWhereCommand.java
@@ -39,11 +39,6 @@
 
 package frysk.hpd;
 
-import java.io.File;
-
-import frysk.Config;
-import frysk.testbed.CoreFileAtSignal;
-
 public class TestWhereCommand extends TestLib {
     public void testHpdTraceStack () {
 	e = HpdTestbed.attachXXX("hpd-c");
@@ -53,12 +48,7 @@ public class TestWhereCommand extends TestLib {
     }
 
     public void testFhpdVirtualStackTrace () {
-
-	File coreFile = CoreFileAtSignal
-	    .constructCore("funit-stack-inlined");
-        e = new HpdCoreFileTestbed(coreFile,
-		Config.getPkgLibFile("funit-stack-inlined"),
-		"Attached to core file.*");
+        e = HpdTestbed.hpdTerminatingProgram("funit-stack-inlined");
         e.send("where\n");
 	e.expect("\\#0 .*third[^\\r\\n]*\\[inline\\]");
 	e.expect("\\#1 .*second[^\\r\\n]*\\[inline\\]");
@@ -68,12 +58,7 @@ public class TestWhereCommand extends TestLib {
     }
     
     public void testFhpdVirtualStackTraceWithScopes () {
-	
-	File coreFile = CoreFileAtSignal
-	    .constructCore("funit-stack-inlined");
-        e = new HpdCoreFileTestbed(coreFile,
-		Config.getPkgLibFile("funit-stack-inlined"),
-	"Attached to core file.*");
+	e = HpdTestbed.hpdTerminatingProgram("funit-stack-inlined");
         e.send("where -scopes\n");
         e.expect(".*var3");
 	e.expect(".*var2");
diff --git a/frysk-core/frysk/testbed/ChangeLog b/frysk-core/frysk/testbed/ChangeLog
index b58b912..01c6bb7 100644
--- a/frysk-core/frysk/testbed/ChangeLog
+++ b/frysk-core/frysk/testbed/ChangeLog
@@ -1,3 +1,11 @@
+2007-11-12  Andrew Cagney  <cagney@redhat.com>
+
+	* DaemonBlockedAtSignal.java (DaemonBlockedAtSignal(File)): New.
+	* TestCoreFileAtSignal.java (testCoreFileAtSignal()): Enable;
+	simplify.
+	* CoreFileAtSignal.java (constructCore(File)): New.
+	(constructCore(String)): Use.
+	
 2007-11-09  Sami Wagiaalla  <swagiaal@redhat.com>
 
 	* CoreFileAtSignal.java	(constructCore): Now return core file
diff --git a/frysk-core/frysk/testbed/CoreFileAtSignal.java b/frysk-core/frysk/testbed/CoreFileAtSignal.java
index 707f5b8..8d058fc 100644
--- a/frysk-core/frysk/testbed/CoreFileAtSignal.java
+++ b/frysk-core/frysk/testbed/CoreFileAtSignal.java
@@ -40,12 +40,12 @@
 package frysk.testbed;
 
 import java.io.File;
-
 import frysk.event.Event;
 import frysk.proc.Manager;
 import frysk.proc.Proc;
 import frysk.proc.ProcBlockAction;
 import frysk.util.CoredumpAction;
+import frysk.Config;
 
 public class CoreFileAtSignal extends TestLib {
     
@@ -55,27 +55,31 @@ public class CoreFileAtSignal extends TestLib {
      * extracts a corefile at that point, and return a Proc representing
      * that core file.
      */
-    public static File constructCore(String process) {
-	
-	final Proc ackProc = (new DaemonBlockedAtSignal(process)).getMainTask().getProc();
-
-	final CoredumpAction coreDump = new CoredumpAction(ackProc,
-		new Event() {
-	    
-	    public void execute() {
-		Manager.eventLoop.requestStop();
-	    }
-	}, false);
-
+    public static File constructCore(File exeFile) {
+	final Proc ackProc
+	    = new DaemonBlockedAtSignal(exeFile).getMainTask().getProc();
+	final CoredumpAction coreDump
+	    = new CoredumpAction(ackProc, new Event() {
+		    public void execute() {
+			Manager.eventLoop.requestStop();
+		    }
+		}, false);
 	new ProcBlockAction(ackProc, coreDump);
 	assertRunUntilStop("Running event loop for core file");
-
 	String coreFileName = coreDump.getConstructedFileName();
+	// XXX: File.deleteOnExit() isn't reliable - for instance it
+	// isn't run between test-cases.
+	TearDownFile core = new TearDownFile(coreFileName);
+	return core;
+    }
 
-	File xtestCore = new File(coreFileName);
-	xtestCore.deleteOnExit();
-	
-	return xtestCore;
+    /**
+     * Given a path to an executable it will run it until it sigfaults then
+     * extracts a corefile at that point, and return a Proc representing
+     * that core file.
+     */
+    public static File constructCore(String process) {
+	return constructCore(Config.getPkgLibFile(process));
     }
 
 }
diff --git a/frysk-core/frysk/testbed/DaemonBlockedAtSignal.java b/frysk-core/frysk/testbed/DaemonBlockedAtSignal.java
index 32afe8f..c44e319 100644
--- a/frysk-core/frysk/testbed/DaemonBlockedAtSignal.java
+++ b/frysk-core/frysk/testbed/DaemonBlockedAtSignal.java
@@ -43,6 +43,7 @@ import frysk.proc.Action;
 import frysk.proc.TaskObserver;
 import frysk.proc.Task;
 import frysk.proc.Manager;
+import java.io.File;
 
 /**
  * Creates an attached process that is blocked at a signal. 
@@ -83,6 +84,10 @@ public class DaemonBlockedAtSignal {
 	this(new DaemonBlockedAtEntry(program));
     }
 
+    public DaemonBlockedAtSignal(File exe) {
+	this(new DaemonBlockedAtEntry(exe));
+    }
+
     public Task getMainTask () {
 	return this.mainTask;
     }
diff --git a/frysk-core/frysk/testbed/TestCoreFileAtSignal.java b/frysk-core/frysk/testbed/TestCoreFileAtSignal.java
index 6246f26..c4ed8f6 100644
--- a/frysk-core/frysk/testbed/TestCoreFileAtSignal.java
+++ b/frysk-core/frysk/testbed/TestCoreFileAtSignal.java
@@ -40,35 +40,19 @@
 package frysk.testbed;
 
 import java.io.File;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-
 import frysk.Config;
 import frysk.proc.Proc;
-import frysk.stack.StackFactory;
 import frysk.util.Util;
+import frysk.proc.Task;
 
-public class TestCoreFileAtSignal extends TestLib
-
-{
-
+public class TestCoreFileAtSignal extends TestLib {
     public void testCoreFileAtSignal() {
-	if (unresolved (4953))
-	    return;
-
-	StringWriter stringWriter = new StringWriter();
-	File coreFile = CoreFileAtSignal.constructCore("funit-stacks");
-	
-	Proc coreProc = Util.getProcFromCoreFile(coreFile, Config.getPkgLibFile("funit-stacks"));
-	StackFactory.printTaskStackTrace(new PrintWriter(stringWriter), coreProc
-		.getMainTask(), false);
-
-	String stackString = stringWriter.getBuffer().toString();
-	
-	assertTrue("Correct stack trace extracted from core file", stackString.contains("fourth"));
-	assertTrue("Correct stack trace extracted from core file", stackString.contains("third"));
-	assertTrue("Correct stack trace extracted from core file", stackString.contains("second"));
-	assertTrue("Correct stack trace extracted from core file", stackString.contains("first"));	
+	File coreExe = Config.getPkgLibFile("funit-asm");
+	File coreFile = CoreFileAtSignal.constructCore(coreExe);
+	Proc coreProc = Util.getProcFromCoreFile(coreFile, coreExe);
+	Task coreTask = coreProc.getMainTask();
+	FryskAsm regs = FryskAsm.createFryskAsm(coreTask.getISA());
+	assertEquals("REG0", 1, coreTask.getRegister(regs.REG0));
     }
 
 }


hooks/post-receive
--
frysk system monitor/debugger


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-11-12 16:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-12 16:58 [SCM] master: Add HpdTestbed.hpdTerminatingProgram(String) cagney

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).