Exemplo n.º 1
0
 private void InitializeTestParams(_Test t)
 {
     t.TestPlatforms = GetAllPlatforms(t.TestIdentifier);
     t.DebugMode     = _debugMode;
     t.TestDuration  = _testDuration;
     t.MountFlag     = _mountFlag;
 }
Exemplo n.º 2
0
 private void SetFailedMessage(_Test t)
 {
     _testsGroupStatus = TestsGroupStatus.FAILED;
     if (_stopOnFailure)
     {
         lock (locker)
         {
             if (!_Test.IsCanceled)
             {
                 _Test.IsCanceled = true;
                 _Test.CancellationToken.Cancel();
                 _Test.CancelationReason = "Cancel Test Because of " + t.TestName + " Failure";
             }
         }
     }
 }
Exemplo n.º 3
0
        private int RunTest(object _args, int identifier, string callingAssembly)
        {
            var    args     = (Dictionary <string, string>)_args;
            string testName = "";
            _Test  t        = null;

            if (args.ContainsKey("-t"))
            {
                testName = args["-t"];
            }
            else
            {
                Console.WriteLine(@"USAGE : <File.exe> -t TestName -g IEXServer IEXNumber [-s IEXServer IEXNumber]");
                return(-1);
            }

            if (args.ContainsKey("mountFlag"))
            {
                switch (args["mountFlag"])
                {
                case "/n":
                    _mountFlag = EnumMountAs.NOFORMAT;
                    break;

                case "/r":
                    _mountFlag = EnumMountAs.FACTORY_RESET;
                    break;

                case "/b":
                    _mountFlag = EnumMountAs.NOFORMAT_NOREBOOT;
                    break;

                case "/nw":
                    _mountFlag = EnumMountAs.NOFORMAT_WAKEUP;
                    break;

                case "/f":
                default:
                    _mountFlag = EnumMountAs.FORMAT;
                    break;
                }
            }

            try
            {
                var testWrapper = Activator.CreateInstance(callingAssembly, testName);      //create test instance
                t = (_Test)testWrapper.Unwrap();
                t.TestIdentifier = identifier;

                InitializeTestParams(t);
                try
                {
                    t.Init();
                    SynchronizeTestsAfterMount();
                    t.Run();
                }
                catch (Exception ex)
                {
                    SetFailedMessage(t);
                    throw ex;
                }
                return(0);
            }
            catch (Exception ex)
            {
                if (ex is MountException)
                {
                    Console.WriteLine(@"Mount Failed " + ex.Message);
                    return(MOUNT_FAILURE);
                }
                else if (!(ex is FailureException))
                {
                    Console.WriteLine(@"Exception Occurred While Executing The Program: " + ex.Message);
                }
                return(-1);
            }
            finally
            {
                try
                {
                    foreach (var platformContext in t.TestPlatforms)
                    {
                        TearDownPlatform(platformContext.Platform);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(@"Exception Occurred While Executing Tear Down: " + ex.Message);
                }
            }
        }