Example #1
0
File: Test.cs Project: ynkbt/moon
        private void RunLocationServerIfNeeded()
        {
            if (location == null)
            {
                return;
            }

            Console.WriteLine("Harness: Trying to start xsp on port {0}", LocationPort);
            do
            {
                string args = String.Format("--applications '{0}:{1},/:.' --nonstop --port {2}", location_uri.AbsolutePath, base_directory, LocationPort);
                location_xsp = new ExternalProcess("xsp2", args, -1);
                location_xsp.RedirectStdOut = true;
                location_xsp.Run(false);

                if (!WaitForXsp(location_xsp))
                {
                    Console.WriteLine("Harness: Could not start xsp at port {0}, trying port {1}", LocationPort, AvailableLocationPort);
                    LocationPort = AvailableLocationPort++;
                    continue;
                }
                else
                {
                    Console.WriteLine("Harness. Started xsp on port {0} (args: {1})", LocationPort, args);
                    break;
                }
            } while (true);
        }
Example #2
0
File: Test.cs Project: ynkbt/moon
        private void CodeBehindCompileIfNeeded()
        {
            if (codebehind == null)
            {
                return;
            }

            string [] pieces   = codebehind.Split(',');
            string    cs_file  = Path.Combine(base_directory, pieces [0].Trim());
            string    lib_name = null;

            if (pieces.Length > 1)
            {
                lib_name = pieces [1].Trim();
            }

            string args = String.Format("-pkg:silver /target:library {0} {1}", lib_name != null ? String.Concat("/out:", lib_name) : String.Empty, cs_file);

            using (ExternalProcess gmcs = new ExternalProcess("gmcs", args, -1)) {
                gmcs.Run(true);
                if (gmcs.ExitCode < 0)
                {
                    SetFailedReason(String.Format("Unable to compile codebehind file: {0}.", gmcs.Stderr));
                    return;
                }
            }
        }
Example #3
0
		public static TestResult RunTest (Test test, int timeout, out string stdout, out string stderr)
		{
			if (agviewer_process == null || !agviewer_process.IsRunning) {

				if (agviewer_process != null) {
					agviewer_process.Kill ();
				}
				
				string args = String.Format ("-working-dir {0} {1}", Path.GetFullPath (Path.GetDirectoryName (test.InputFile)),
						Path.GetFullPath (test.InputFile));

				agviewer_process = new ExternalProcess (GetProcessPath (), args, timeout);
				if (!string.IsNullOrEmpty (Environment.GetEnvironmentVariable ("MOON_PATH")))
					agviewer_process.EnvironmentVariables ["MONO_PATH"] = Environment.GetEnvironmentVariable ("MOON_PATH") + ":" + Environment.GetEnvironmentVariable ("MONO_PATH");
				agviewer_process.Run (false);
			} else {
				Console.WriteLine ("agviewer process not shutdown:  {0}.", agviewer_process.IsRunning);
//				logging_server.RunNextTest (Path.GetFullPath (test.InputFile));
			}

			stdout = String.Empty; // ep.Stdout;
			stderr = String.Empty; // ep.Stder;	

			/*
			if (!logging_server.WaitForTestToComplete (test.InputFileName, agviewer_process, timeout)) {
				test.SetFailedReason ("Test timed out.");
				return TestResult.Fail;
			}
			*/

			return TestResult.Pass;
		}
Example #4
0
File: Test.cs Project: ynkbt/moon
 private void StopXsp(ExternalProcess xsp)
 {
     try {
         if (xsp != null)
         {
             xsp.Kill();
             xsp.Dispose();
         }
     } catch (Exception ex) {
         Console.WriteLine("Exception while trying to stop XSP: " + ex.Message + " (" + ex.GetType().FullName + ")");
     }
 }
Example #5
0
File: Test.cs Project: ynkbt/moon
        private void RunXspIfNeeded()
        {
            if (xsp_exec_dir == null)
            {
                return;
            }

            string args = String.Format("--root {0} --nonstop", Path.Combine(Path.GetDirectoryName(LocalFilePath), xsp_exec_dir));

            xsp = new ExternalProcess("xsp", args, -1);
            xsp.RedirectStdOut = true;
            xsp.Run(false);

            if (!WaitForXsp(xsp))
            {
                // We can't try another port, given that tests assume xsp is running on 8080.
                Console.WriteLine("Harness: xsp didn't startup correctly, assuming there already is an xsp process running.");
            }
        }
Example #6
0
        private void EnsureAgviewerProcess()
        {
            if (agviewer_process != null && !agviewer_process.IsRunning)
            {
                agviewer_process.Kill();
                agviewer_process = null;
            }

            if (agviewer_process == null)
            {
                string args = String.Format("-working-dir {0}", Path.GetFullPath(working_dir));
                string valgrind_args;
                string gdb_args;

                if (driver != null && driver.UseValgrind)
                {
                    valgrind_args = string.Format("{0} {1} {2}",
                                                  System.Environment.GetEnvironmentVariable("MOONLIGHT_VALGRIND_OPTIONS"),
                                                  GetProcessPath(), args);

                    agviewer_process = new ExternalProcess("valgrind", valgrind_args, -1);
                }
                else if (driver != null && driver.UseGdb)
                {
                    gdb_args = string.Format("--batch --eval-command=run --args {0} {1}",
                                             GetProcessPath(), args);

                    agviewer_process = new ExternalProcess("gdb", gdb_args, -1);
                }
                else
                {
                    agviewer_process = new ExternalProcess(GetProcessPath(), args, -1);
                }
                if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("MOON_PATH")))
                {
                    agviewer_process.EnvironmentVariables ["MONO_PATH"] = Environment.GetEnvironmentVariable("MOON_PATH") + ":" + Environment.GetEnvironmentVariable("MONO_PATH");
                }
                agviewer_process.Run(false);
            }
        }
Example #7
0
        public static TestResult RunTest(Test test, int timeout, out string stdout, out string stderr)
        {
            if (agviewer_process == null || !agviewer_process.IsRunning)
            {
                if (agviewer_process != null)
                {
                    agviewer_process.Kill();
                }

                string args = String.Format("-working-dir {0} {1}", Path.GetFullPath(Path.GetDirectoryName(test.InputFile)),
                                            Path.GetFullPath(test.InputFile));

                agviewer_process = new ExternalProcess(GetProcessPath(), args, timeout);
                if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("MOON_PATH")))
                {
                    agviewer_process.EnvironmentVariables ["MONO_PATH"] = Environment.GetEnvironmentVariable("MOON_PATH") + ":" + Environment.GetEnvironmentVariable("MONO_PATH");
                }
                agviewer_process.Run(false);
            }
            else
            {
                Console.WriteLine("agviewer process not shutdown:  {0}.", agviewer_process.IsRunning);
//				logging_server.RunNextTest (Path.GetFullPath (test.InputFile));
            }

            stdout = String.Empty;             // ep.Stdout;
            stderr = String.Empty;             // ep.Stder;

            /*
             * if (!logging_server.WaitForTestToComplete (test.InputFileName, agviewer_process, timeout)) {
             *      test.SetFailedReason ("Test timed out.");
             *      return TestResult.Fail;
             * }
             */

            return(TestResult.Pass);
        }
Example #8
0
File: Test.cs Project: ynkbt/moon
        private static bool WaitForXsp(ExternalProcess process)
        {
            DateTime start = DateTime.Now;
            string   stdout;

            while (true)
            {
                Thread.Sleep(100);
                if (start.AddSeconds(5) < DateTime.Now)
                {
                    Console.WriteLine("Harness: timeout while waiting for xsp to start. Assuming xsp started successfully.");
                    return(true);
                }

                stdout = process.Stdout;
                if (string.IsNullOrEmpty(stdout))
                {
                    continue;
                }

                if (stdout.Contains("Listening on port:"))
                {
                    return(true);
                }

                if (stdout.Contains("Address already in use"))
                {
                    return(false);
                }

                if (!process.IsRunning)
                {
                    Console.WriteLine("Harness: xsp quitted unexpectedly.");
                    return(true);
                }
            }
        }
Example #9
0
File: Test.cs Project: dfr0/moon
		private void StopXsp (ExternalProcess xsp)
		{
			try {
				if (xsp != null) {
					xsp.Kill ();
					xsp.Dispose ();
				}
			} catch (Exception ex) {
				Console.WriteLine ("Exception while trying to stop XSP: " + ex.Message + " (" + ex.GetType ().FullName + ")");
			}
		}
Example #10
0
File: Test.cs Project: dfr0/moon
		private void RunLocationServerIfNeeded ()
		{
			if (location == null)
				return;

			Console.WriteLine ("Harness: Trying to start xsp on port {0}", LocationPort);
			do {
				string args = String.Format ("--applications '{0}:{1},/:.' --nonstop --port {2}", location_uri.AbsolutePath, base_directory, LocationPort);
				location_xsp = new ExternalProcess ("xsp2", args, -1);
				location_xsp.RedirectStdOut = true;
				location_xsp.Run (false);
				
				if (!WaitForXsp (location_xsp)) {
					Console.WriteLine ("Harness: Could not start xsp at port {0}, trying port {1}", LocationPort, AvailableLocationPort);
					LocationPort = AvailableLocationPort++;
					continue;
				} else {
					Console.WriteLine ("Harness. Started xsp on port {0} (args: {1})", LocationPort, args);
					break;
				}
			} while (true);
		}
Example #11
0
File: Test.cs Project: dfr0/moon
		private static bool WaitForXsp (ExternalProcess process)
		{
			DateTime start = DateTime.Now;
			string stdout;
			while (true) {
				Thread.Sleep (100);
				if (start.AddSeconds (5) < DateTime.Now) {
					Console.WriteLine ("Harness: timeout while waiting for xsp to start. Assuming xsp started successfully.");
					return true;
				}
				
				stdout = process.Stdout;
				if (string.IsNullOrEmpty (stdout))
					continue;

				if (stdout.Contains ("Listening on port:"))
					return true;

				if (stdout.Contains ("Address already in use"))
					return false;

				if (!process.IsRunning) {
					Console.WriteLine ("Harness: xsp quitted unexpectedly.");
					return true;
				}
			}
		}
Example #12
0
File: Test.cs Project: dfr0/moon
		private void RunXspIfNeeded ()
		{
			if (xsp_exec_dir == null)
				return;

			string args = String.Format ("--root {0} --nonstop", Path.Combine (Path.GetDirectoryName (LocalFilePath), xsp_exec_dir));

			xsp = new ExternalProcess ("xsp", args, -1);
			xsp.RedirectStdOut = true;
			xsp.Run (false);

			if (!WaitForXsp (xsp)) {
				// We can't try another port, given that tests assume xsp is running on 8080.
				Console.WriteLine ("Harness: xsp didn't startup correctly, assuming there already is an xsp process running.");
			}
		}
Example #13
0
File: Test.cs Project: dfr0/moon
		private void CodeBehindCompileIfNeeded ()
		{
			if (codebehind == null)
				return;

			string [] pieces = codebehind.Split (',');
			string cs_file = Path.Combine (base_directory, pieces [0].Trim ());
			string lib_name = null;

			if (pieces.Length > 1)
				lib_name = pieces [1].Trim ();			

			string args = String.Format ("-pkg:silver /target:library {0} {1}", lib_name != null ? String.Concat ("/out:", lib_name) : String.Empty, cs_file);
			using (ExternalProcess gmcs = new ExternalProcess ("gmcs", args, -1)) {

				gmcs.Run (true);
				if (gmcs.ExitCode < 0) {
					SetFailedReason (String.Format ("Unable to compile codebehind file: {0}.", gmcs.Stderr));
					return;
				}
			}
		}
Example #14
0
		private void EnsureAgviewerProcess ()
		{
			if (agviewer_process != null && !agviewer_process.IsRunning) {
				agviewer_process.Kill ();
				agviewer_process = null;
			}

			if (agviewer_process == null) {
				string args = String.Format ("-working-dir {0}", Path.GetFullPath (working_dir));
				string valgrind_args;
				string gdb_args;
				
				if (driver != null && driver.UseValgrind) {
					valgrind_args = string.Format ("{0} {1} {2}", 
					                               System.Environment.GetEnvironmentVariable ("MOONLIGHT_VALGRIND_OPTIONS"), 
					                               GetProcessPath (), args);
					
					agviewer_process = new ExternalProcess ("valgrind", valgrind_args, -1);
				} else if (driver != null && driver.UseGdb) {
					gdb_args = string.Format ("--batch --eval-command=run --args {0} {1}", 
					                               GetProcessPath (), args);
					
					agviewer_process = new ExternalProcess ("gdb", gdb_args, -1);
				} else {
					agviewer_process = new ExternalProcess (GetProcessPath (), args, -1);
				}
				if (!string.IsNullOrEmpty (Environment.GetEnvironmentVariable ("MOON_PATH")))
					agviewer_process.EnvironmentVariables ["MONO_PATH"] = Environment.GetEnvironmentVariable ("MOON_PATH") + ":" + Environment.GetEnvironmentVariable ("MONO_PATH");
				agviewer_process.Run (false);
			}
		}