Esempio n. 1
0
 //: base(types, filter)
 /// <summary>
 /// Initializes all the components of the explorer.
 /// </summary>
 /// <param name="userParams"></param>
 public RandomExplorer(Collection<Type> types, IReflectionFilter filter, bool exceptionLearning,
     int randomSeed, int arrayMaxSize, StatsManager stats, ActionSet actions)
 {
     this.actions = actions;
     this.filter = filter;
     this.arrayMaxSize = arrayMaxSize;
     this.stats = stats;
 }
Esempio n. 2
0
        private static void Main2(string[] args)
        {
            if (args.Length != 1)
            {
                throw new InvalidUserParamsException(
                    "RandoopBare takes exactly one argument but was "
                    + "given the following arguments:"
                    + System.Environment.NewLine
                    + Util.PrintArray(args));;
            }

            // Parse XML file with generation parameters.
            String configFileName = Common.ConfigFileName.Parse(args[0]);
            RandoopConfiguration config = LoadConfigFile(configFileName);

            // Set the random number generator.
            if (config.randomSource == RandomSource.SystemRandom)
            {
                Console.WriteLine("Randoom seed = " + config.randomseed);
                Common.SystemRandom random = new Common.SystemRandom();
                random.Init(config.randomseed);
                Common.Enviroment.Random = random;
            }
            else
            {
                Util.Assert(config.randomSource == RandomSource.Crypto);
                Console.WriteLine("Randoom seed = new System.Security.Cryptography.RNGCryptoServiceProvider()");
                Common.Enviroment.Random = new CryptoRandom();
            }

            if (!Directory.Exists(config.outputdir))
                throw new Common.RandoopBareExceptions.InvalidUserParamsException("output directory does not exist: "
                    + config.outputdir);

            Collection<Assembly> assemblies = Common.Misc.LoadAssemblies(config.assemblies);

            ////[email protected] for substituting MessageBox.Show() - start
            ////Instrument instrumentor = new Instrument();
            //foreach (FileName asm in config.assemblies)
            //{
            //    Instrument.MethodInstrument(asm.fileName, "System.Windows.Forms.MessageBox::Show", "System.Console.Writeline");
            //}            
            ////[email protected] for substituting MessageBox.Show() - end

            IReflectionFilter filter1 = new VisibilityFilter(config);
            ConfigFilesFilter filter2 = new ConfigFilesFilter(config);

            Console.WriteLine("========== REFLECTION PATTERNS:");
            filter2.PrintFilter(Console.Out);

            IReflectionFilter filter = new ComposableFilter(filter1, filter2);

            Collection<Type> typesToExplore = ReflectionUtils.GetExplorableTypes(assemblies);

            PlanManager planManager = new PlanManager(config);
            planManager.builderPlans.AddEnumConstantsToPlanDB(typesToExplore);
            planManager.builderPlans.AddConstantsToTDB(config);

            Console.WriteLine("========== INITIAL PRIMITIVE VALUES:");
            planManager.builderPlans.PrintPrimitives(Console.Out);

            StatsManager stats = new StatsManager(config);

            Console.WriteLine("Analyzing assembly.");

            ActionSet actions = null;
            try
            {
                actions = new ActionSet(typesToExplore, filter);
            }
            catch (EmpytActionSetException)
            {
                string msg = "After filtering based on configuration files, no remaining methods or constructors to explore.";
                throw new Common.RandoopBareExceptions.InvalidUserParamsException(msg);
            }

            Console.WriteLine();
            Console.WriteLine("Generating tests.");

            RandomExplorer explorer =
                new RandomExplorer(typesToExplore, filter, true, config.randomseed, config.arraymaxsize, stats, actions);
            ITimer t = new Timer(config.timelimit);
            try
            {
                explorer.Explore(t, planManager, config.methodweighing, config.forbidnull, true, config.fairOpt);
            }
            catch (Exception e)
            {
                Console.WriteLine("Explorer raised exception {0}", e.ToString());
            }

            //Mono.Cecil.Cil.
        }
Esempio n. 3
0
 public RRTimer(ActionSet context)
 {
     this.context = context;
 }
Esempio n. 4
0
 public RRTimer(ActionSet context)
 {
     this.context = context;
 }