예제 #1
0
		public static CoverHost CreateHost (string covfile, string program, params string[] arguments)
		{
            if (covfile == null)
                throw new ArgumentNullException ("covfile");

			if (program == null)
				throw new ArgumentNullException ("program");

			var args = new List<string> {program};
			args.AddRange (arguments);

            var data = new CodeRecordData();
            data.Open( covfile );

            var logfile = covfile + ".log";
            var log = new StreamWriter( logfile );
            data.SaveMeta("logfile", logfile);
            data.SaveMeta("dbfile", covfile);
            data.SaveMeta("testmachine", Environment.MachineName );

            var rv = new CoverHost ( args.ToArray() ) { 
                DataStore = data,
                LogFile = log,
            };
			return rv;
		}
예제 #2
0
        public CoverHost (params string[] args)
        {
            cmdargs = args;
            VirtualMachine = VirtualMachineManager.Launch (args, new LaunchOptions() { AgentArgs = "suspend=y" } );
            VirtualMachine.EnableEvents (
                EventType.VMStart,
				EventType.VMDeath,
                EventType.VMDisconnect,
				EventType.AssemblyLoad,
                EventType.TypeLoad
            );
            Singleton = this;
        }
예제 #3
0
 public CoverHost(params string[] args)
 {
     cmdargs        = args;
     VirtualMachine = VirtualMachineManager.Launch(args, new LaunchOptions()
     {
         AgentArgs = "suspend=y"
     });
     VirtualMachine.EnableEvents(
         EventType.VMStart,
         EventType.VMDeath,
         EventType.VMDisconnect,
         EventType.AssemblyLoad,
         EventType.TypeLoad
         );
     Singleton = this;
 }
예제 #4
0
        public static CoverHost CreateHost(string covfile, System.Net.IPEndPoint ip)
        {
            if (covfile == null)
            {
                throw new ArgumentNullException("covfile");
            }

            if (ip == null)
            {
                throw new ArgumentNullException("ip");
            }

            var rv = new CoverHost(ip);

            PrepareHost(rv, covfile);
            return(rv);
        }
예제 #5
0
        private static void PrepareHost(CoverHost host, string covfile)
        {
            if (covfile == null)
            {
                throw new ArgumentNullException("covfile");
            }

            var data = new CodeRecordData();

            data.Open(covfile);

            var logfile = covfile + ".log";
            var log     = new StreamWriter(logfile);

            data.SaveMeta("logfile", logfile);
            data.SaveMeta("dbfile", covfile);
            data.SaveMeta("testmachine", Environment.MachineName);

            host.DataStore = data;
            host.LogFile   = log;
        }
예제 #6
0
        public static CoverHost CreateHost(string covfile, string program, params string[] arguments)
        {
            if (covfile == null)
            {
                throw new ArgumentNullException("covfile");
            }

            if (program == null)
            {
                throw new ArgumentNullException("program");
            }

            var args = new List <string> {
                program
            };

            args.AddRange(arguments);

            var rv = new CoverHost(args.ToArray());

            PrepareHost(rv, covfile);
            return(rv);
        }
예제 #7
0
        public static CoverHost CreateHost(string covfile, string program, params string[] arguments)
        {
            if (covfile == null)
            {
                throw new ArgumentNullException("covfile");
            }

            if (program == null)
            {
                throw new ArgumentNullException("program");
            }

            var args = new List <string> {
                program
            };

            args.AddRange(arguments);

            var data = new CodeRecordData();

            data.Open(covfile);

            var logfile = covfile + ".log";
            var log     = new StreamWriter(logfile);

            data.SaveMeta("logfile", logfile);
            data.SaveMeta("dbfile", covfile);
            data.SaveMeta("testmachine", Environment.MachineName);

            var rv = new CoverHost(args.ToArray())
            {
                DataStore = data,
                LogFile   = log,
            };

            return(rv);
        }
예제 #8
0
		public static int Main (string[] vargs)
		{
            if ( vargs.Length == 0 ) return Usage();
            if ( Regex.IsMatch( vargs[0], "-h$|-help$" ) ) return Usage();
            if (!System.IO.File.Exists(vargs[0])) return Usage();

            // the first thing is the mono EXE we are running, everything else are args passed to it
            // we do no argument processing at all.

            var program = vargs[0];
            var args = vargs.Skip(1);
            var patterns = new List<string> ();

            // we look in BABOON_CFG for a config file
            var env = Environment.GetEnvironmentVariable("BABOON_CFG");
            // else we look for a file in the same folder as the EXE named EXE.covcfg
            var cfgfile = program + ".covcfg";

            if ( !string.IsNullOrEmpty( env ) ){
                cfgfile = env;
            }

            if ( File.Exists( cfgfile ) ) {
                using ( var f = File.OpenText( cfgfile ) ) {
                    string l = null;
                    do {
                        l = f.ReadLine();
                        if ( !string.IsNullOrWhiteSpace( l ) ) {
                            patterns.Add(l);
                        }
                    } while ( l != null );
                }
            }

            CoverHost.RenameBackupFile( cfgfile + ".covdb" );
            CoverHost.RenameBackupFile( cfgfile + ".covreport" );

            covertool = CoverHostFactory.CreateHost ( cfgfile  + ".covdb", program, args.ToArray() );
            covertool.DataStore.SaveMeta( "config", cfgfile );
            debugee = covertool.VirtualMachine.Process;
            ThreadPool.QueueUserWorkItem( (x) => SignalHandler(), null );
            ThreadPool.QueueUserWorkItem( (x) => PumpStdin(x), null );
			covertool.Cover (patterns.ToArray ());
            covertool.Report ( cfgfile + ".covreport" );

            return covertool.VirtualMachine.Process.ExitCode;
		}