Exemplo n.º 1
0
        public static bool ExecuteReflectionCall(CodeToExecute call, TextWriter writer, out Exception exceptionThrown)
        {
            long startTime = 0;
            Timer.QueryPerformanceCounter(ref startTime);

            if (usingRandoopDebugListener) fdebugListener.Reset();
            bool invocationOk = true;
            exceptionThrown = null;

            try
            {
                //new PermissionSet(null).PermitOnly();
                call();
                //CodeAccessPermission.RevertAll();
                //CodeAccessPermission.RevertPermitOnly();

            }
            catch (TargetInvocationException e)
            {
                exceptionThrown = e.InnerException;
                Util.Assert(exceptionThrown != null);
                writer.WriteLine("e : " + e);
                invocationOk = false;
                writer.WriteLine("Execution failed.");


            }
            catch (SecurityException e)
            {
                exceptionThrown = e;
                writer.WriteLine("e : " + e);
                invocationOk = false;
                writer.WriteLine("Execution failed.");

            }
            catch (Exception e)
            {
                exceptionThrown = e;
                writer.WriteLine("e : " + e);
                invocationOk = false;
                writer.WriteLine("execution failed.");
            }

            if (usingRandoopDebugListener && fdebugListener.FailWasCalled)
            {
                invocationOk = false;
                exceptionThrown = new AssertionViolation("An assertion was violated: "
                    + fdebugListener.FailureMessage);
            }

            long endTime = 0;
            Timer.QueryPerformanceCounter(ref endTime);

            try
            {
                ;
            }
            catch (SecurityException e)
            {
                exceptionThrown = e;
                writer.WriteLine("e : " + e);
                invocationOk = false;
                writer.WriteLine("Execution failed.");
            }
            SecondsSpentInCalls += ((double)(endTime - startTime)) / ((double)(Timer.PerfTimerFrequency));

            if (!invocationOk)
                return false;

            return true;
        }
Exemplo n.º 2
0
        public static bool ExecuteReflectionCall(CodeToExecute call, TextWriter writer, out Exception exceptionThrown)
        {
            long startTime = 0;

            Timer.QueryPerformanceCounter(ref startTime);

            if (usingRandoopDebugListener)
            {
                fdebugListener.Reset();
            }
            bool invocationOk = true;

            exceptionThrown = null;

            try
            {
                //new PermissionSet(null).PermitOnly();
                call();
                //CodeAccessPermission.RevertAll();
                //CodeAccessPermission.RevertPermitOnly();
            }
            catch (TargetInvocationException e)
            {
                exceptionThrown = e.InnerException;
                Util.Assert(exceptionThrown != null);
                writer.WriteLine("e : " + e);
                invocationOk = false;
                writer.WriteLine("Execution failed.");
            }
            catch (SecurityException e)
            {
                exceptionThrown = e;
                writer.WriteLine("e : " + e);
                invocationOk = false;
                writer.WriteLine("Execution failed.");
            }
            catch (Exception e)
            {
                exceptionThrown = e;
                writer.WriteLine("e : " + e);
                invocationOk = false;
                writer.WriteLine("execution failed.");
            }

            if (usingRandoopDebugListener && fdebugListener.FailWasCalled)
            {
                invocationOk    = false;
                exceptionThrown = new AssertionViolation("An assertion was violated: "
                                                         + fdebugListener.FailureMessage);
            }

            long endTime = 0;

            Timer.QueryPerformanceCounter(ref endTime);

            try
            {
                ;
            }
            catch (SecurityException e)
            {
                exceptionThrown = e;
                writer.WriteLine("e : " + e);
                invocationOk = false;
                writer.WriteLine("Execution failed.");
            }
            SecondsSpentInCalls += ((double)(endTime - startTime)) / ((double)(Timer.PerfTimerFrequency));

            if (!invocationOk)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
        public static bool ExecuteReflectionCall(CodeToExecute call, TextWriter writer, out Exception exceptionThrown)
        {
            long startTime = 0;
            Timer.QueryPerformanceCounter(ref startTime);

            if (usingRandoopDebugListener) fdebugListener.Reset();
            bool invocationOk = true;
            exceptionThrown = null;
            
            //[email protected] for substituting MessageBox.Show() - start
            ////MethodInfo call_info = call.Method;
            //var dynMeth = new DynamicMethod("Test", null, null, typeof(void));
            //ILGenerator gen = dynMeth.GetILGenerator();
            //ConstructorInfo ci = typeof(System.Windows.Forms.MessageBox).GetConstructor(new Type[0]);
            //gen.Emit(OpCodes.Newobj, ci);
            //[email protected] for substituting MessageBox.Show() - end

            try
            {
                //new PermissionSet(null).PermitOnly();
                //writer.WriteLine("call execution begins."); //[email protected] added for debug                
                call(); 
                //CodeAccessPermission.RevertAll();
                //CodeAccessPermission.RevertPermitOnly();

            }
            catch (TargetInvocationException e)
            {
                exceptionThrown = e.InnerException;
                Util.Assert(exceptionThrown != null);
                writer.WriteLine("e : " + e);
                invocationOk = false;
                writer.WriteLine("Execution failed.");


            }
            catch (SecurityException e)
            {
                exceptionThrown = e;
                writer.WriteLine("e : " + e);
                invocationOk = false;
                writer.WriteLine("Execution failed.");

            }
            catch (Exception e)
            {
                exceptionThrown = e;
                writer.WriteLine("e : " + e);
                invocationOk = false;
                writer.WriteLine("execution failed.");
            }

            if (usingRandoopDebugListener && fdebugListener.FailWasCalled)
            {
                invocationOk = false;
                exceptionThrown = new AssertionViolation("An assertion was violated: "
                    + fdebugListener.FailureMessage);
            }

            long endTime = 0;
            Timer.QueryPerformanceCounter(ref endTime);

            try
            {
                ;
            }
            catch (SecurityException e)
            {
                exceptionThrown = e;
                writer.WriteLine("e : " + e);
                invocationOk = false;
                writer.WriteLine("Execution failed.");
            }
            SecondsSpentInCalls += ((double)(endTime - startTime)) / ((double)(Timer.PerfTimerFrequency));

            if (!invocationOk)
                return false;

            return true;
        }
Exemplo n.º 4
0
        public static bool ExecuteReflectionCall(CodeToExecute call, TextWriter writer, out Exception exceptionThrown)
        {
            long startTime = 0;

            Timer.QueryPerformanceCounter(ref startTime);

            if (usingRandoopDebugListener)
            {
                fdebugListener.Reset();
            }
            bool invocationOk = true;

            exceptionThrown = null;

            //[email protected] for substituting MessageBox.Show() - start
            ////MethodInfo call_info = call.Method;
            //var dynMeth = new DynamicMethod("Test", null, null, typeof(void));
            //ILGenerator gen = dynMeth.GetILGenerator();
            //ConstructorInfo ci = typeof(System.Windows.Forms.MessageBox).GetConstructor(new Type[0]);
            //gen.Emit(OpCodes.Newobj, ci);
            //[email protected] for substituting MessageBox.Show() - end

            try
            {
                //new PermissionSet(null).PermitOnly();
                //writer.WriteLine("call execution begins."); //[email protected] added for debug
                call();
                //CodeAccessPermission.RevertAll();
                //CodeAccessPermission.RevertPermitOnly();
            }
            catch (TargetInvocationException e)
            {
                exceptionThrown = e.InnerException;
                Util.Assert(exceptionThrown != null);
                writer.WriteLine("e : " + e);
                invocationOk = false;
                writer.WriteLine("Execution failed.");
            }
            catch (SecurityException e)
            {
                exceptionThrown = e;
                writer.WriteLine("e : " + e);
                invocationOk = false;
                writer.WriteLine("Execution failed.");
            }
            catch (Exception e)
            {
                exceptionThrown = e;
                writer.WriteLine("e : " + e);
                invocationOk = false;
                writer.WriteLine("execution failed.");
            }

            if (usingRandoopDebugListener && fdebugListener.FailWasCalled)
            {
                invocationOk    = false;
                exceptionThrown = new AssertionViolation("An assertion was violated: "
                                                         + fdebugListener.FailureMessage);
            }

            long endTime = 0;

            Timer.QueryPerformanceCounter(ref endTime);

            try
            {
                ;
            }
            catch (SecurityException e)
            {
                exceptionThrown = e;
                writer.WriteLine("e : " + e);
                invocationOk = false;
                writer.WriteLine("Execution failed.");
            }
            SecondsSpentInCalls += ((double)(endTime - startTime)) / ((double)(Timer.PerfTimerFrequency));

            if (!invocationOk)
            {
                return(false);
            }

            return(true);
        }