From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23982 invoked by alias); 5 Mar 2008 00:03:41 -0000 Received: (qmail 23866 invoked by uid 9514); 5 Mar 2008 00:03:39 -0000 Date: Wed, 05 Mar 2008 00:03:00 -0000 Message-ID: <20080305000339.23803.qmail@sourceware.org> From: pmuldoon@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Add absolutePath versus relative guard test. X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 8e6e5493dbea1a24856b4dd70bbeeeff95903819 X-Git-Newrev: 79400a6b6d06ba2a36277ffd27326aac38cff336 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/msg00308.txt.bz2 The branch, master has been updated via 79400a6b6d06ba2a36277ffd27326aac38cff336 (commit) from 8e6e5493dbea1a24856b4dd70bbeeeff95903819 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 79400a6b6d06ba2a36277ffd27326aac38cff336 Author: Phil Muldoon Date: Wed Mar 5 00:02:59 2008 +0000 Add absolutePath versus relative guard test. 2008-03-04 Phil Muldoon * TestLinuxCore.java (testRelativePath): New. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/proc/dead/ChangeLog | 2 + frysk-core/frysk/proc/dead/TestLinuxCore.java | 73 +++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 0 deletions(-) First 500 lines of diff: diff --git a/frysk-core/frysk/proc/dead/ChangeLog b/frysk-core/frysk/proc/dead/ChangeLog index da0bf18..12c2afe 100644 --- a/frysk-core/frysk/proc/dead/ChangeLog +++ b/frysk-core/frysk/proc/dead/ChangeLog @@ -1,5 +1,7 @@ 2008-03-04 Phil Muldoon + * TestLinuxCore.java (testRelativePath): New. + * LinuxCoreInfo.java (getExeFile): Return a File derived from the absolute path. diff --git a/frysk-core/frysk/proc/dead/TestLinuxCore.java b/frysk-core/frysk/proc/dead/TestLinuxCore.java index a128c33..519f7dc 100644 --- a/frysk-core/frysk/proc/dead/TestLinuxCore.java +++ b/frysk-core/frysk/proc/dead/TestLinuxCore.java @@ -75,6 +75,79 @@ public class TestLinuxCore extends TestLib { private Proc coreProc = LinuxCoreFactory.createProc(Config.getPkgDataFile("test-core-x86")); + + public void testRelativePath() { + + // Test a relative path. This exercises sourcware bz 5864. + // Providing a relative path with the backing executable + // causes the find elf map to fail. It manifests itself + // when an stacktrace is performed. + + Proc ackProc = giveMeAProc(); + File coreFileName = new File(constructCore(ackProc)); + + // Get pwd of Test runner. + File countPath = new File(System.getProperty("user.dir")); + + // Calculate how many legs in the path from root to + // Test runner, and add one '../' per segment. + String segment = countPath.getParent(); + StringBuffer relativeIntro = new StringBuffer(); + while (segment != null) { + relativeIntro.append("../"); + countPath = new File(segment); + segment = countPath.getParent(); + } + + // Build relative exe path, and model core. + countPath = new File(relativeIntro+ackProc.getExe()); + Proc coreProc = LinuxCoreFactory.createProc(coreFileName, countPath); + + // Guard: Build a stack trace. If a relative path is not being + // converted to an absolute path in the Corefile code, the + // backtrace will fail as it infers that ../foo/bar is not a + // file (see 5864) and refers to the maps as an internal map + // with no backing file. If a backtrace is built, then the + // relative -> absolute converstion is occuring. + StacktraceAction coreStacktrace; + StringWriter coreStackOutput = new StringWriter(); + PrintStackOptions options = new PrintStackOptions(); + options.setNumberOfFrames(20); + options.setElfOnly(true); + + // Create a stackktrace of a the corefile process + coreStacktrace = new StacktraceAction(new PrintWriter(coreStackOutput), + coreProc, + new PrintEvent(),options) + { + + public void addFailed (Object observable, Throwable w) + { + fail("Proc add failed: " + w.getMessage()); + } + }; + + // And run .... + new ProcCoreAction(coreProc, coreStacktrace); + assertRunUntilStop("Perform corefile Backtrace"); + + String mainThread = "Task #\\d+\n" + + "(#[\\d]+ 0x[\\da-f]+ in .*\n)*" + + "#[\\d]+ 0x[\\da-f]+ in server \\(\\).*\n" + + "#[\\d]+ 0x[\\da-f]+ in main \\(\\).*\n" + + "#[\\d]+ 0x[\\da-f]+ in __libc_start_main \\(\\).*\n" + + "#[\\d]+ 0x[\\da-f]+ in _start \\(\\).*\n\n"; + + String regex = new String(); + regex += "(" + mainThread + ")"; + + String result = coreStackOutput.getBuffer().toString(); + + assertTrue(result + "should match: " + regex + " threads", + result.matches(regex)); + + } + public void testLinuxCoreFileMaps() { // Remove the hasIsa test as on -r test runs the singleton // maintains reference in between runs. hooks/post-receive -- frysk system monitor/debugger