public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
* [SCM]  master: Tests for passing parameters with start/run commands.
@ 2008-01-23 19:53 rmoseley
  0 siblings, 0 replies; only message in thread
From: rmoseley @ 2008-01-23 19:53 UTC (permalink / raw)
  To: frysk-cvs

The branch, master has been updated
       via  60417d494d83e0ab894361b57493198a205c9d61 (commit)
      from  5e7303f366dbcbf9ca9456bc9ec15b40e27dda5a (commit)

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

- Log -----------------------------------------------------------------
commit 60417d494d83e0ab894361b57493198a205c9d61
Author: Rick Moseley <rmoseley@localhost.localdomain>
Date:   Wed Jan 23 13:52:37 2008 -0600

    Tests for passing parameters with start/run commands.
    
    * funit-parameters.c: New for testing Start/RunCommand.java.
    * TestRunCommand.java (testRunCommandParamter): New.
    * TestStartCommand.java (testStartCommandParameter): New.

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

Summary of changes:
 frysk-core/frysk/hpd/ChangeLog                     |    5 +
 frysk-core/frysk/hpd/TestRunCommand.java           |   82 +++++++++++++++++---
 frysk-core/frysk/hpd/TestStartCommand.java         |   47 +++++++++++-
 frysk-core/frysk/pkglibdir/ChangeLog               |    4 +
 .../{funit-vfork.c => funit-parameters.c}          |   50 +++++++------
 5 files changed, 153 insertions(+), 35 deletions(-)
 copy frysk-core/frysk/pkglibdir/{funit-vfork.c => funit-parameters.c} (76%)

First 500 lines of diff:
diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog
index 8054272..d984f64 100644
--- a/frysk-core/frysk/hpd/ChangeLog
+++ b/frysk-core/frysk/hpd/ChangeLog
@@ -1,3 +1,8 @@
+2008-01-23  Rick Moseley  <rmoseley@redhat.com>
+
+	* TestRunCommand.java (testRunCommandParamter): New.
+	* TestStartCommand.java (testStartCommandParameter): New.
+
 2008-01-21  Andrew Cagney  <cagney@redhat.com>
 
 	* TestSysRoot.java: Mark as unresolved, bug #5657.
diff --git a/frysk-core/frysk/hpd/TestRunCommand.java b/frysk-core/frysk/hpd/TestRunCommand.java
index 7342391..076316b 100644
--- a/frysk-core/frysk/hpd/TestRunCommand.java
+++ b/frysk-core/frysk/hpd/TestRunCommand.java
@@ -1,6 +1,6 @@
 // This file is part of the program FRYSK.
 //
-// Copyright 2007 Red Hat Inc.
+// Copyright 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
@@ -39,6 +39,10 @@
 
 package frysk.hpd;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.FileNotFoundException;
 import frysk.Config;
 
 /**
@@ -56,7 +60,7 @@ public class TestRunCommand extends TestLib {
 	e.sendCommandExpectPrompt("focus","Target set.*\\[0\\.0\\]\t\t([0-9]+)" +
 		"\t([0-9]+)\r\n" + "\\[0\\.1\\]\t\t([0-9]+)\t([0-9]+)\r\n");
 	e.send("quit\n");
-	e.expect("Quitting...");
+	e.expect("Quitting\\.\\.\\.");
 	e.close();
     }
     
@@ -68,17 +72,73 @@ public class TestRunCommand extends TestLib {
 	if (unresolved(5615))
 	    return;
 	e = new HpdTestbed();
-	e.sendCommandExpectPrompt("load " + Config.getPkgLibFile("funit-threads-looper").getPath(),
+	e.send("load " + Config.getPkgLibFile("funit-threads-looper").getPath() + "\n");
+	e.expect("Loaded executable file.*" + prompt);
+	e.send("run\n");
+	e.expect("Attached to process ([0-9]+).*");
+	e.expect("Running process ([0-9]+).*" + prompt);
+	//e.sendCommandExpectPrompt("load " + Config.getPkgLibFile("funit-threads-looper").getPath(),
+	//"Loaded executable file.*");
+	//e.sendCommandExpectPrompt("run ",
+	//	"Attached to process ([0-9]+).*Running process ([0-9]+).*");
+	//try { Thread.sleep(1000); } catch (Exception e) {}
+	e.send("viewset \\[0\\.0\\]\n");
+	e.expect("Set \\[0\\.0\\].*");
+	//e.expect(5,"Target set.*\\[0\\.0\\]\t\t([0-9]+)\t([0-9]+)\r\n" +
+	//	"\\[0\\.1\\]\t\t([0-9]+)\t([0-9]+)\r\n" + prompt);
+	//e.sendCommandExpectPrompt("focus","Target set.*\\[0\\.0\\]\t\t([0-9]+)" +
+	//	"\t([0-9]+)\r\n" + "\\[0\\.1\\]\t\t([0-9]+)\t([0-9]+)\r\n");
+	//try { Thread.sleep(1000); } catch (Exception e) {}
+	e.send("run\n");
+	e.expect(".*Killing process ([0-9])+.*");
+	e.expect("Loaded executable file.*");
+	e.expect("Attached to process ([0-9])+.*");
+	e.expect("Running process ([0-9])+.*");
+	//e.sendCommandExpectPrompt("run", "Killing process ([0-9])+.*" +
+	//	"Loaded executable file.*" + "Attached to process ([0-9])+.*" +
+	//	"Running process ([0-9])+.*");
+	//e.send("quit\n");
+	//e.expect("Quitting\\.\\.\\.");
+	e.close();
+    }
+    
+    public void testRunCommandParameter() {
+	e = new HpdTestbed();
+	String[] param = { "testing", "parameter2"};
+	e.sendCommandExpectPrompt("load " + Config.getPkgLibFile("funit-parameters").getPath(),
 	"Loaded executable file.*");
-	e.sendCommandExpectPrompt("run ",
+	e.sendCommandExpectPrompt("run " + param[0] + " " + param[1],
 		"Attached to process ([0-9]+).*Running process ([0-9]+).*");
-	try { Thread.sleep(1000); } catch (Exception e) {}
-	e.sendCommandExpectPrompt("focus","Target set.*\\[0\\.0\\]\t\t([0-9]+)" +
-		"\t([0-9]+)\r\n" + "\\[0\\.1\\]\t\t([0-9]+)\t([0-9]+)\r\n");
-	try { Thread.sleep(1000); } catch (Exception e) {}
-	e.sendCommandExpectPrompt("run", "Killing process ([0-9])+.*" +
-		"Loaded executable file.*" + "Attached to process ([0-9])+.*" +
-		"Running process ([0-9])+.*");
+	/*
+	 * The following wait is added to make the test pass.  It seems on a dual-core
+	 * machine the funit-parameters process gets put into a different CPU and gets behind
+	 * the test case.  funit-parameters creates a file that this test checks and when this
+	 * test gets ahead of it that, the test fails beause it cannot find it.  Delaying
+	 * 1/10 of a second seems to fix that problem.
+	 */
+	try { Thread.sleep(100); } catch (Exception e) {}
+	int file_length = 0;
+	String compare = "";
+	for (int i = 0; i < param.length; i++) {
+	    compare = compare + param[i];
+	    file_length = file_length + param[i].length();
+	}
+	byte[] buffer = new byte[file_length];
+	String paramlist = "";
+	try {
+	    File f = new File("param-test");
+	    FileInputStream fin = new FileInputStream(f);
+	    fin.read(buffer);
+	    paramlist = new String(buffer, 0, buffer.length);
+	    f.delete();
+	} catch (FileNotFoundException e) {
+	    System.out.println("Could not find param-test");
+	} catch (IOException e) {
+	    System.out.println("Error reading file param-test");
+	}
+	assertTrue("Testing passed parameters", paramlist.equals(compare));
+	e.send("quit\n");
+	e.expect("Quitting\\.\\.\\.");
 	e.close();
     }
 }
\ No newline at end of file
diff --git a/frysk-core/frysk/hpd/TestStartCommand.java b/frysk-core/frysk/hpd/TestStartCommand.java
index a9fab5c..24a0824 100644
--- a/frysk-core/frysk/hpd/TestStartCommand.java
+++ b/frysk-core/frysk/hpd/TestStartCommand.java
@@ -1,6 +1,6 @@
 // This file is part of the program FRYSK.
 //
-// Copyright 2007 Red Hat Inc.
+// Copyright 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
@@ -39,6 +39,10 @@
 
 package frysk.hpd;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.FileNotFoundException;
 import frysk.Config;
 
 /**
@@ -56,4 +60,45 @@ public class TestStartCommand extends TestLib {
 	e.expect("Quitting...");
 	e.close();
     }
+    
+    public void testStartCommandParameter() {
+	e = new HpdTestbed();
+	String[] param = { "teststart", "parameter2start"};
+	e.sendCommandExpectPrompt("load " + Config.getPkgLibFile("funit-parameters").getPath(),
+	"Loaded executable file.*");
+	e.sendCommandExpectPrompt("start " + param[0] + " " + param[1], "Attached to process.*");
+	e.sendCommandExpectPrompt("go",
+		"Running process ([0-9]+).*");
+	/*
+	 * The following wait is added to make the test pass.  It seems on a dual-core
+	 * machine the funit-parameters process gets put into a different CPU and gets behind
+	 * the test case.  funit-parameters creates a file that this test checks and when this
+	 * test gets ahead of it that, the test fails beause it cannot find it.  Delaying
+	 * 1/10 of a second seems to fix that problem.
+	 */
+	try { Thread.sleep(100); } catch (Exception e) {}
+	int file_length = 0;
+	String compare = "";
+	for (int i = 0; i < param.length; i++) {
+	    compare = compare + param[i];
+	    file_length = file_length + param[i].length();
+	}
+	byte[] buffer = new byte[file_length];
+	String paramlist = "";
+	try {
+	    File f = new File("param-test");
+	    FileInputStream fin = new FileInputStream(f);
+	    fin.read(buffer);
+	    paramlist = new String(buffer, 0, buffer.length);
+	    f.delete();
+	} catch (FileNotFoundException e) {
+	    System.out.println("Could not find param-test");
+	} catch (IOException e) {
+	    System.out.println("Error reading file param-test");
+	}
+	assertTrue("Testing passed parameters", paramlist.equals(compare));
+	e.send("quit\n");
+	e.expect("Quitting\\.\\.\\.");
+	e.close();
+    }
 }
\ No newline at end of file
diff --git a/frysk-core/frysk/pkglibdir/ChangeLog b/frysk-core/frysk/pkglibdir/ChangeLog
index 430e2c4..74af801 100644
--- a/frysk-core/frysk/pkglibdir/ChangeLog
+++ b/frysk-core/frysk/pkglibdir/ChangeLog
@@ -1,3 +1,7 @@
+2008-01-23  Rick Moseley  <rmoseley@redhat.com>
+
+	* funit-parameters.c: New for testing Start/RunCommand.java.
+
 2008-01-18  Mark Wielaard  <mwielaard@redhat.com>
 	
 	* funit-class-static.cxx: Add copyright boilerplate.
diff --git a/frysk-core/frysk/pkglibdir/funit-vfork.c b/frysk-core/frysk/pkglibdir/funit-parameters.c
similarity index 76%
copy from frysk-core/frysk/pkglibdir/funit-vfork.c
copy to frysk-core/frysk/pkglibdir/funit-parameters.c
index d40b923..9c3350b 100644
--- a/frysk-core/frysk/pkglibdir/funit-vfork.c
+++ b/frysk-core/frysk/pkglibdir/funit-parameters.c
@@ -1,6 +1,6 @@
 // This file is part of the program FRYSK.
 //
-// Copyright 2007 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,30 +37,34 @@
 // version and license this file solely under the GPL without
 // exception.
 
-#include <sys/types.h>
-#include <sys/wait.h>
+#include <unistd.h>
+#include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+
+/*
+ * The purpose of this test is to accept parameters from TestRunCommand and TestStartCommand
+ * and write them to a file that they can check to see if indeed the parameters that they
+ * passed to here are indeed the ones it received.
+ */
 
-int
-main(void)
+int main(int argc, char *argv[])
 {
-  pid_t pid = vfork();
-  if (pid == -1)
-    {
-      perror ("vfork");
-      exit (1);
-    }
-  else if (pid == 0)
-    {
-      puts ("child");
-      _exit (1);
-    }
-  else
-    {
-      waitpid (pid, NULL, 0);
-      puts ("child done");
-    }
-  return 0;
+	int fd;
+	
+	if ((fd = open("param-test", O_TRUNC | O_CREAT | O_WRONLY | O_SYNC, 0644)) < 0) {
+		perror("Error opening param-test file");
+		exit(1);
+	}
+	int i;
+	for (i = 0; i < argc - 1; i++) {
+		int l = strlen(argv[i+1]);
+		write(fd, argv[i+1], l);
+	}
+	fsync(fd);
+	close(fd);
+	
+	return 0;
 }


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


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

only message in thread, other threads:[~2008-01-23 19:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-23 19:53 [SCM] master: Tests for passing parameters with start/run commands rmoseley

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