Exemple #1
0
 /// <summary>
 /// Closes the TestLog
 /// </summary>
 /// <returns>true</returns>
 protected override bool EndStep()
 {
     if ((log != null) && (CloseTestLog))
     {
         log.Close();
     }
     return(true);
 }
Exemple #2
0
        public static void Main(string wait)
        {
            DrtRunner driver = new DrtRunner();

            try
            {
                GlobalLog.LogStatus("Clearing click once cache.");
                //


                string exeName = DriverState.DriverParameters["exe"];
                string exeArgs = DriverState.DriverParameters["args"];

                if (exeArgs == null)
                {
                    exeArgs = "-catchexceptions";
                }
                else if (!exeArgs.Contains("-catchexceptions"))
                {
                    exeArgs += " -catchexceptions";
                }

                exeArgs += $" {wait}";

                TestLog log       = new TestLog(DriverState.TestName);
                long    startTime = DateTime.Now.Ticks;
                driver.Run(log, exeName, exeArgs);
                long endTime = DateTime.Now.Ticks;
                log.Close();
            }
            catch (Exception e)
            {
                // Driver should always handle its exceptions becuase it is vastly more performant
                // then making a JitDebugger do it.
                GlobalLog.LogEvidence("Driver Error: " + e.ToString());
            }
        }
Exemple #3
0
        public void Run(int detectionCycles, int actionsPerCycle)
        {
            //TODO1: Launch memorysnapshot monitor as a seperate process so as not to incur extra load.

            Type     type     = this.GetType();
            LeakTest leakTest = (LeakTest)Activator.CreateInstance(type);

            // Create new memory snapshot collection and get a handle to the process.
            MemorySnapshotCollection collection = new MemorySnapshotCollection();
            Process process = Process.GetCurrentProcess();

            //TODO2: Add GC cleanup / get ready logic.

            leakTest.Initialize();
            collection.Add(MemorySnapshot.FromProcess(process.Id));

            // Rinse and repeat the following as requested by the user.
            for (int i = 0; i < detectionCycles; i++)
            {
                for (int j = 0; j < actionsPerCycle; j++)
                {
                    // Perform and undo action followed by a snapshot.
                    leakTest.PerformAction();
                    leakTest.UndoAction();
                }
                collection.Add(MemorySnapshot.FromProcess(process.Id));
            }

            // Log collection to file.
            string filePath = Path.Combine(Environment.CurrentDirectory, @"snapshots.xml");

            collection.ToFile(filePath);
            TestLog log = new TestLog("LeakLog");

            log.LogFile(filePath);
            log.Close();
        }
Exemple #4
0
        protected override bool BeginStep()
        {
            bool tempBool = false;

            if (DotNetVersion.Length > 0)
            {
                string[] version = DotNetVersion.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);

                try
                {
                    if ((Environment.Version.Major == int.Parse(version[0]) && (Environment.Version.Minor == int.Parse(version[1]))))
                    {
                        GlobalLog.LogEvidence("Test specified to not run on .NET Version " + DotNetVersion);
                        shouldRunChildSteps = false;
                    }
                }
                catch (Exception ex)
                {
                    GlobalLog.LogDebug("Hit exception trying to filter on .NET version:\n" + ex.Message + "\n" + ex.StackTrace);
                }
            }

            if (SystemInformation.Current.IEVersion.StartsWith(IEVersion))
            {
                GlobalLog.LogEvidence("Test specified to not run on IE Version " + IEVersion + " ( Detected : " + SystemInformation.Current.IEVersion + ")");
                shouldRunChildSteps = false;
            }

            if (bool.TryParse(IsServer, out tempBool))
            {
                if (tempBool == SystemInformation.Current.IsServer)
                {
                    GlobalLog.LogEvidence("Test specified to " + (tempBool ? "not" : "only") + " run on Server SKUs.");
                    shouldRunChildSteps = false;
                }
            }

            if (bool.TryParse(NeedsMediaPlayer, out tempBool))
            {
                if (tempBool)
                {
                    GlobalLog.LogEvidence("Test is specified to require Media Player to function properly.");
                    RegistryKey wmvClassOpenWith = Registry.ClassesRoot.OpenSubKey(".wmv\\OpenWithProgIds");
                    if ((wmvClassOpenWith != null) && (wmvClassOpenWith.ValueCount > 0))
                    {
                        GlobalLog.LogEvidence("WMV File handlers detected, media player appears to be present.  Will run child steps");
                    }
                    else
                    {
                        GlobalLog.LogEvidence("It looks like there aren't .wmv handlers on the system, so disabling child steps.");
                        GlobalLog.LogEvidence("(Many Server SKUs lack Windows Media Player by default)");
                        shouldRunChildSteps = false;
                    }
                }
            }

            if (bool.TryParse(IsPersonalEdition, out tempBool))
            {
                if (tempBool == SystemInformation.Current.IsPersonalEdition)
                {
                    GlobalLog.LogEvidence("Test specified to " + (tempBool ? "not" : "only") + " run on Home/Personal Edition SKUs ");
                    shouldRunChildSteps = false;
                }
            }

            if (bool.TryParse(IsWow64Process, out tempBool))
            {
                if (tempBool == SystemInformation.Current.IsWow64Process)
                {
                    GlobalLog.LogEvidence("Test specified to " + (tempBool ? "not" : "only") + " run in WOW64 process");
                    shouldRunChildSteps = false;
                }
            }

            if (SystemInformation.Current.MajorVersion == OSMajorVersion)
            {
                if ((OSMinorVersion == -1))
                {
                    GlobalLog.LogEvidence("Test specified to not run in OS version " + OSMajorVersion);
                    shouldRunChildSteps = false;
                }
                else if (SystemInformation.Current.MinorVersion == OSMinorVersion)
                {
                    GlobalLog.LogEvidence("Test specified to not run in OS version " + OSMajorVersion + "." + OSMinorVersion);
                    shouldRunChildSteps = false;
                }
            }

            if ((UICulture != null) && SystemInformation.Current.UICulture == UICulture)
            {
                GlobalLog.LogEvidence("Test specified to not run in UI Culture " + UICulture.ToString());
                shouldRunChildSteps = false;
            }

            if (ProcessorArch.ToLowerInvariant() == SystemInformation.Current.ProcessorArchitecture.ToString().ToLowerInvariant())
            {
                GlobalLog.LogEvidence("Test specified to not run on Processor Architecture " + ProcessorArch.ToString());
                shouldRunChildSteps = false;
            }

            if (shouldRunChildSteps)
            {
                return(true);
            }
            else
            {
                GlobalLog.LogEvidence("Cannot execute test.  This test is blocked because: " + DoNotRunReason);
                if (TestLog.Current == null)
                {
                    TestLog log = new TestLog("Ignored Test: " + DoNotRunReason);
                    log.Result = TestResult.Ignore;
                    log.Close();
                    return(false);
                }
                TestLog.Current.Result = TestResult.Ignore;
                return(false);
            }
        }
Exemple #5
0
        /// <summary>
        /// Parses Args for path to master bmp and source xaml, as a limited scenario replacement to VScanLoader
        /// </summary>
        public static void Launch()
        {
            TestLog log = new TestLog("XamlVisual Verification Test");

            log.Result = TestResult.Unknown;
            String args = null;
            int    windowsMediaPlayerVersion = 0;
            bool   hasMedia = false;

            try
            {
                args = DriverState.DriverParameters["Args"];
                log.LogStatus("Running with Arguments: " + args);

                masterDpiX         = double.Parse(GetFlag(args, "DpiX"), System.Globalization.CultureInfo.InvariantCulture);
                masterDpiY         = double.Parse(GetFlag(args, "DpiY"), System.Globalization.CultureInfo.InvariantCulture);
                xtcContainsDpiInfo = true;
            }
            catch (System.ArgumentException)
            {
                log.LogStatus("No master image Dpi info found in test definition");
            }
            catch
            {
                log.LogStatus("ERROR: Ignoring master image Dpi info due to parsing error");
            }

            DriverState.DriverParameters["ShowsNavigationUI"] = GetFlag(args, "ShowsNavigationUI");
            if (DriverState.DriverParameters["ShowsNavigationUI"] != null && String.Compare(DriverState.DriverParameters["ShowsNavigationUI"], "false", StringComparison.InvariantCultureIgnoreCase).Equals(0))
            {
                log.LogStatus("Xbap Navigation Chrome will be HIDDEN");
            }
            else
            {
                log.LogStatus("Xbap Navigation Chrome will be SHOWN");
            }

            // Parse IsHostedInNavigationWindow.

            string isHostedInNavigationWindowStr = GetFlag(args, "IsHostedInNavigationWindow");

            if (!string.IsNullOrEmpty(isHostedInNavigationWindowStr) && string.Compare(isHostedInNavigationWindowStr, "false", StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                isHostedInNavigationWindow = false;
            }
            log.LogStatus("Hosted in Nabigation window: " + isHostedInNavigationWindow);

            // if windows media player is installed, lets get the version
            if (Microsoft.Test.Diagnostics.SystemInformation.WindowsMediaPlayerVersion != null)
            {
                windowsMediaPlayerVersion = ((System.Version)Microsoft.Test.Diagnostics.SystemInformation.WindowsMediaPlayerVersion).Major;
            }

            // get the containsMedia flag to determine if we need to check for media player 10+

            bool.TryParse(GetFlag(args, "containsMedia"), out hasMedia);

            if (hasMedia && (windowsMediaPlayerVersion < 10))
            {
                TestLog.Current.LogStatus("Windows Media Player version is not 10+ Ignoring media containing XAML case");
                TestLog.Current.Result = TestResult.Ignore;
            }
            else
            {
                try
                {
                    IImageAdapter testImageAdapter = PrepareXamlImageAdapter(GetFlag(args, "capture"));

                    IImageAdapter materImageAdapter = PrepareBitmapImageAdapter(GetFlag(args, "master"));

                    ((ImageAdapter)materImageAdapter).DpiX = masterDpiX;
                    ((ImageAdapter)materImageAdapter).DpiY = masterDpiY;

                    toleranceFilePath = GetFlag(args, "tolerance");

                    if (materImageAdapter == null)
                    {
                        log.LogStatus("Test Problem - master image adapter is null");
                    }
                    else if (testImageAdapter == null)
                    {
                        log.LogStatus("Test Problem - test image adapter is null");
                    }
                    else
                    {
                        //Run visual verification
                        if (Compare(testImageAdapter, materImageAdapter))
                        {
                            log.LogStatus("Test Pass - Image comparison is a match");
                            log.Result = TestResult.Pass;
                        }
                        else
                        {
                            log.LogStatus("Test Failure - Image comparison is a mismatch");
                            log.Result = TestResult.Fail;
                        }
                    }
                }
                catch (Exception e)
                {
                    log.LogStatus(e.ToString());
                }
            }

            log.Close();
        }