Ejemplo n.º 1
0
		protected virtual bool ExecuteTestFile (TestCase test, string binaryFileName)
		{
			string filename = test.FileName;

			AppDomain domain = null;
#if !NET_2_1
			if (safe_execution) {
				// Create a new AppDomain, with the current directory as the base.
				AppDomainSetup setupInfo = new AppDomainSetup ();
				setupInfo.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
				setupInfo.LoaderOptimization = LoaderOptimization.SingleDomain;
				domain = AppDomain.CreateDomain (Path.GetFileNameWithoutExtension (binaryFileName), null, setupInfo);
			}
#endif
			try {
				DomainTester tester;
				try {
#if !NET_2_1
					if (domain != null)
						tester = (DomainTester) domain.CreateInstanceAndUnwrap (typeof (PositiveChecker).Assembly.FullName, typeof (DomainTester).FullName);
					else
#endif
						tester = new DomainTester ();

					if (!tester.Test (binaryFileName))
						return false;

				} catch (ApplicationException e) {
					HandleFailure (filename, TestResult.ExecError, e.Message);
					return false;
				} catch (Exception e) {
					HandleFailure (filename, TestResult.LoadError, e.ToString ());
					return false;
				}

				if (doc_output != null) {
					string ref_file = filename.Replace (".cs", "-ref.xml");
					try {
#if !NET_2_1
						new XmlComparer ("doc").Compare (ref_file, doc_output);
#endif
					} catch (Exception e) {
						HandleFailure (filename, TestResult.XmlError, e.Message);
						return false;
					}
				} else {
					if (verif_file != null) {
						PositiveTestCase pt = (PositiveTestCase) test;
						pt.VerificationProvider = (PositiveTestCase.VerificationData) verif_data[filename];

						if (!tester.CheckILSize (pt, this, binaryFileName))
							return false;
					}

					if (filename.StartsWith ("test-debug", StringComparison.OrdinalIgnoreCase)) {
						var mdb_file_name = binaryFileName + ".mdb";
						MonoSymbolFile mdb_file = MonoSymbolFile.ReadSymbolFile (mdb_file_name);
						var mdb_xml_file = mdb_file_name + ".xml";
						ConvertSymbolFileToXml (mdb_file, mdb_xml_file);

						var ref_file = filename.Replace(".cs", "-ref.xml");
						try {
							new XmlComparer ("symbols").Compare (ref_file, mdb_xml_file);
						} catch (Exception e) {
							HandleFailure (filename, TestResult.DebugError, e.Message);
							return false;
						}
					}

				}
			} finally {
				if (domain != null)
					AppDomain.Unload (domain);
			}

			HandleFailure (filename, TestResult.Success, null);
			return true;
		}
Ejemplo n.º 2
0
		protected override bool Check(TestCase test)
		{
			string filename = test.FileName;
			try {
				if (!base.Check (test)) {
					HandleFailure (filename, TestResult.CompileError, tester.Output);
					return false;
				}
			}
			catch (Exception e) {
				if (e.InnerException != null)
					e = e.InnerException;
				
				HandleFailure (filename, TestResult.CompileError, e.ToString ());
				return false;
			}

			// Test setup
			if (filename.EndsWith ("-lib.cs") || filename.EndsWith ("-mod.cs")) {
				if (verbose)
					LogFileLine (filename, "OK");
				--total;
				return true;
			}

			string file = Path.Combine (files_folder, Path.GetFileNameWithoutExtension (filename) + ".exe");

			// Enable .dll only tests (no execution required)
			if (!File.Exists(file)) {
				HandleFailure (filename, TestResult.Success, null);
				return true;
			}

			AppDomain domain = null;
#if !NET_2_1
			if (safe_execution) {
				// Create a new AppDomain, with the current directory as the base.
				AppDomainSetup setupInfo = new AppDomainSetup ();
				setupInfo.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
				setupInfo.LoaderOptimization = LoaderOptimization.SingleDomain;
				domain = AppDomain.CreateDomain (Path.GetFileNameWithoutExtension (file), null, setupInfo);
			}
#endif
			try {
				DomainTester tester;
				try {
#if !NET_2_1
					if (domain != null)
						tester = (DomainTester) domain.CreateInstanceAndUnwrap (typeof (PositiveChecker).Assembly.FullName, typeof (DomainTester).FullName);
					else
#endif
						tester = new DomainTester ();

					if (!tester.Test (file))
						return false;

				} catch (ApplicationException e) {
					HandleFailure (filename, TestResult.ExecError, e.Message);
					return false;
				} catch (Exception e) {
					HandleFailure (filename, TestResult.LoadError, e.ToString ());
					return false;
				}

				if (doc_output != null) {
					string ref_file = filename.Replace (".cs", "-ref.xml");
					try {
#if !NET_2_1
						new XmlComparer ("doc").Compare (ref_file, doc_output);
#endif
					} catch (Exception e) {
						HandleFailure (filename, TestResult.XmlError, e.Message);
						return false;
					}
				} else {
					if (verif_file != null) {
						PositiveTestCase pt = (PositiveTestCase) test;
						pt.VerificationProvider = (PositiveTestCase.VerificationData) verif_data[filename];

						if (!tester.CheckILSize (pt, this, file))
							return false;
					}

					if (filename.StartsWith ("test-debug", StringComparison.OrdinalIgnoreCase)) {
						var mdb_file_name = file + ".mdb";
						MonoSymbolFile mdb_file = MonoSymbolFile.ReadSymbolFile (mdb_file_name);
						var mdb_xml_file = mdb_file_name + ".xml";
						ConvertSymbolFileToXml (mdb_file, mdb_xml_file);

						var ref_file = filename.Replace(".cs", "-ref.xml");
						try {
							new XmlComparer ("symbols").Compare (ref_file, mdb_xml_file);
						} catch (Exception e) {
							HandleFailure (filename, TestResult.DebugError, e.Message);
							return false;
						}
					}

				}
			} finally {
				if (domain != null)
					AppDomain.Unload (domain);
			}

			HandleFailure (filename, TestResult.Success, null);
			return true;
		}