Exemple #1
0
        private static void WriteTestData(TestSystem ts, StreamWriter w)
        {
            for (int i = 0; i < ts.TestResultList.Count; i++)
            {
                if (ts.TestResultList[i] is MicroFrameworkTest)
                {
                    MicroFrameworkTest test = ts.TestResultList[i] as MicroFrameworkTest;
                    char[] splitChar = { '|' };
                    string bgColor = string.Empty;

                    try
                    {
                        if (string.Compare(test.Result, "pass", true) == 0)
                        {
                            bgColor = "#99FF99";
                        }
                        else if (string.Compare(test.Result, "fail", true) == 0)
                        {
                            bgColor = "#FE1B42";
                        }
                        else if (string.Compare(test.Result, "skip", true) == 0)
                        {
                            bgColor = "#CFCFCF";
                        }
                        else if (string.Compare(test.Result, "knownfailure", true) == 0)
                        {
                            bgColor = "#99FF90";
                        }
                        else
                        {
                            bgColor = "white";
                        }
                    }
                    catch
                    {
                        bgColor = "#FE1B42";
                        test.Result = "fail";
                    }

                    w.WriteLine("<tr bgcolor=\"" + bgColor + "\">");
                    w.WriteLine("<td align=\"center\" bordercolor=\"white\" width = \"18%\">");
                    w.WriteLine("<font size=\"2\">");

                    // If a UNC path is not specified, do not hyperlink the sln file. Assume that
                    // the test is being run locally and keep all the links local.
                    if (string.IsNullOrEmpty(ts.ResultsFolder))
                    {
                        w.WriteLine("<a href=");
                        if (ts.IsDevEnvironment)
                        {
                            // The test path already contains the local drive information.
                            if (test.Name.Contains(@":\"))
                            {
                                w.WriteLine("\"" + test.Name + "\"");
                            }
                            else
                            {
                                // The test path is relative from the platform tests root.
                                w.WriteLine("\"" + TestSystem.RunMFTests.InstallRoot + @"Tests" + test.Name + "\"");
                            }
                        }
                        else
                        {
                            w.WriteLine("\"" + TestSystem.RunMFTests.InstallRoot + @"\TestCases\" + test.Name + "\"");
                        }

                        int idx = test.Name.LastIndexOf(@"\");
                        w.WriteLine("><b><font color=\"black\">" + test.Name.Substring(idx + 1) + "</font></b></a>");
                    }
                    else
                    {
                        w.WriteLine("<b><u>" + test.Name + "</u></b>");
                    }
                    w.WriteLine("</font></td>");

                    w.WriteLine("<td align=\"center\" bordercolor=\"white\" width = \"4%\"><b>");
                    w.WriteLine("<font size=\"2\">");
                    string result;
                    try
                    {
                        if (test.EmulatorCrashed)
                        {
                            result = test.Result + " (DEVICE CRASH)";
                        }
                        else if (test.TimedOut)
                        {
                            result = test.Result + " (TIMED OUT)";
                        }
                        else
                        {
                            result = test.Result;
                        }
                    }
                    catch
                    {
                        result = "Fail";
                    }

                    w.WriteLine(result);
                    w.WriteLine("</font></b></td>");

                    w.WriteLine("<td align=\"center\" bordercolor=\"white\" width = \"8%\"><b>");
                    w.WriteLine("<font size=\"2\">");
                    w.WriteLine(test.TotalTestCases);
                    w.WriteLine("</font></b></td>");

                    w.WriteLine("<td align=\"center\" bordercolor=\"white\" width = \"8%\"><b>");
                    w.WriteLine("<font size=\"2\">");
                    w.WriteLine(test.TestMethodPassCount);
                    w.WriteLine("</font></b></td>");

                    w.WriteLine("<td align=\"center\" bordercolor=\"white\" width = \"8%\"><b>");
                    w.WriteLine("<font size=\"2\">");
                    w.WriteLine(test.TestMethodFailCount);
                    w.WriteLine("</font></b></td>");

                    w.WriteLine("<td align=\"center\" bordercolor=\"white\" width = \"8%\"><b>");
                    w.WriteLine("<font size=\"2\">");
                    w.WriteLine(test.TestMethodSkipCount);
                    w.WriteLine("</font></b></td>");

                    w.WriteLine("<td align=\"center\" bordercolor=\"white\" width = \"14%\"><b>");
                    w.WriteLine("<font size=\"2\">");
                    w.WriteLine(test.TestMethodKnownFailureCount);
                    w.WriteLine("</font></b></td>");

                    w.WriteLine("<td align=\"center\" bordercolor=\"white\" width = \"6%\">");
                    w.WriteLine("<font size=\"2\">");
                    w.WriteLine("<a href=");

                    // If a UNC path is not specified, assume that the test is being run locally 
                    // and keep all the links local.
                    if (!string.IsNullOrEmpty(ts.ResultsFolder))
                    {
                        w.WriteLine("file:" + ts.ResultsFolder.Replace('\\', '/').TrimEnd('/').Replace(" ", "&#32;") + "/" 
                            + test.LogFile);
                    }
                    else
                    {
                        w.WriteLine(test.LogFile);
                    }
                    w.WriteLine("><b>" + "Open log" + "</b></a>");
                    w.WriteLine("</font></td>");

                    w.WriteLine("<td align=\"center\" bordercolor=\"white\" width = \"12%\"><b>");
                    w.WriteLine("<font size=\"2\">");
                    w.WriteLine(test.StartTime);
                    w.WriteLine("</font></b></td>");

                    w.WriteLine("<td align=\"center\" bordercolor=\"white\" width = \"12%\"><b>");
                    w.WriteLine("<font size=\"2\">");
                    w.WriteLine(test.EndTime);
                    w.WriteLine("</font></b></td>");

                    w.WriteLine("</tr>");
                }
            }

            w.WriteLine("</table>");
            w.WriteLine("</html>");
            w.Close();
        }
Exemple #2
0
        internal static void CreateTestLog(string path, TestSystem ts)
        {
            string device = "Emulator";
            string name = string.Empty;
            
            if (!string.IsNullOrEmpty(ts.FullDeviceName))
            {
                Utils.WriteToEventLog("Full device name = " + ts.FullDeviceName);
                name = ts.FullDeviceName.ToLower().Trim();
            }

            if (name.StartsWith("imxs_net"))
            {
                device = "iMXS Freescale";
            }
            else if (name.StartsWith("at91sam9261_ek"))
            {
                device = "Sam9";
            }
            else if (name.StartsWith("phytecpcm023"))
            {
                device = "PCM023";
            }            

            StreamWriter w = WriteTestLogHeaders(path, ts, string.Format("{0}{1}", device, " Run Results"));

            w.WriteLine("<tr><td bordercolor=\"white\">");
            w.WriteLine("<table border=\"1\" bordercolor=\"white\" width=\"100%\" align=\"center\">");
            w.WriteLine("<tr><td align=\"center\" bordercolor=\"white\"><b>");
            w.WriteLine("Total test cases executed in this run: " + ts.TotalTestCases);
            w.WriteLine("</b></td></tr>");
            w.WriteLine("<tr><td align=\"center\" bordercolor=\"white\"><font color=\"green\"><b>");
            w.WriteLine("Test Suites Passed: " + ts.PassCount);
            w.WriteLine("</b></font></td></tr>");
            w.WriteLine("<tr><td align=\"center\" bordercolor=\"white\"><font color=\"red\"><b>");
            w.WriteLine("Test Suites Failed: " + ts.FailCount);
            w.WriteLine("</b></font></td></tr>");
            if (ts.SkipCount > 0)
            {
                w.WriteLine("<tr><td align=\"center\" bordercolor=\"white\"><font color=\"gray\"><b>");
                w.WriteLine("Test Suites Skipped: " + ts.SkipCount);
                w.WriteLine("</b></font></td></tr>");
            }
            if (ts.KnownFailureCount > 0)
            {
                w.WriteLine("<tr><td align=\"center\" bordercolor=\"white\"><font color=\"#99FF99\"><b>");
                w.WriteLine("Test Suites with Known Failures: " + ts.KnownFailureCount);
                w.WriteLine("</b></font></td></tr>");
            }
            w.WriteLine("</table>");
            w.WriteLine("</td></tr>");
            w.WriteLine("</table>");
            w.WriteLine("<br>");

            w.WriteLine("<table border=\"3\" bordercolor=\"black\" width=\"100%\" align=\"left\">");

            w.WriteLine("<td align=\"center\" bordercolor=\"black\" width = \"18%\">");
            w.WriteLine("<font size=\"2\">");
            w.WriteLine("<b>Test</b>");
            w.WriteLine("</font>");
            w.WriteLine("</td>");

            w.WriteLine("<td align=\"center\" bordercolor=\"black\" width = \"4%\">");
            w.WriteLine("<font size=\"2\">");
            w.WriteLine("<b>Result</b>");
            w.WriteLine("</font>");
            w.WriteLine("</td>");

            w.WriteLine("<td align=\"center\" bordercolor=\"black\" width = \"8%\">");
            w.WriteLine("<font size=\"2\">");
            w.WriteLine("<b>Total Test Cases</b>");
            w.WriteLine("</font>");
            w.WriteLine("</td>");

            w.WriteLine("<td align=\"center\" bordercolor=\"black\" width = \"8%\">");
            w.WriteLine("<font size=\"2\">");
            w.WriteLine("<b>Total Passed</b>");
            w.WriteLine("</font>");
            w.WriteLine("</td>");

            w.WriteLine("<td align=\"center\" bordercolor=\"black\" width = \"8%\">");
            w.WriteLine("<font size=\"2\">");
            w.WriteLine("<b>Total Failed</b>");
            w.WriteLine("</font>");
            w.WriteLine("</td>");

            w.WriteLine("<td align=\"center\" bordercolor=\"black\" width = \"8%\">");
            w.WriteLine("<font size=\"2\">");
            w.WriteLine("<b>Total Skipped</b>");
            w.WriteLine("</font>");
            w.WriteLine("</td>");

            w.WriteLine("<td align=\"center\" bordercolor=\"black\" width = \"14%\">");
            w.WriteLine("<font size=\"2\">");
            w.WriteLine("<b>Total Known Failures</b>");
            w.WriteLine("</font>");
            w.WriteLine("</td>");

            w.WriteLine("<td align=\"center\" bordercolor=\"black\" width = \"6%\">");
            w.WriteLine("<font size=\"2\">");
            w.WriteLine("<b>Log File</b>");
            w.WriteLine("</font>");
            w.WriteLine("</td>");

            w.WriteLine("<td align=\"center\" bordercolor=\"black\" width = \"12%\">");
            w.WriteLine("<font size=\"2\">");
            w.WriteLine("<b>Start Time</b>");
            w.WriteLine("</font>");
            w.WriteLine("</td>");

            w.WriteLine("<td align=\"center\" bordercolor=\"black\" width = \"12%\">");
            w.WriteLine("<font size=\"2\">");
            w.WriteLine("<b>End Time</b>");
            w.WriteLine("</font>");
            w.WriteLine("</td>");

            WriteTestData(ts, w);

            // Reset the values since the tests are done running.
            ts.Device = string.Empty;
            ts.Transport = TestSystem.TransportType.Emulator;
        }
Exemple #3
0
        private static StreamWriter WriteTestLogHeaders(string path, TestSystem ts, string title)
        {
            FileInfo file = new FileInfo(path + @"\" + TestSystem.ResultsFile);
            StreamWriter w = file.CreateText();
            w.WriteLine("<html>");
            w.WriteLine("<title>");
            w.WriteLine(title);
            w.WriteLine("</title>");
            w.WriteLine("<table border=\"2\" bordercolor=\"gray\" width=\"40%\" align=\"center\">");
            w.WriteLine("<tr><td align=\"center\" bordercolor=\"white\"><b><font size=\"6\">");
            w.WriteLine(title);
            w.WriteLine("</font></b></td></tr>");

            // Write the test automation machine name to the log.
            w.WriteLine("<tr><td align=\"center\" bordercolor=\"white\"><b><font size=\"4\" color=\"#006666\">");
            w.WriteLine("Machine Information");
            w.WriteLine("</font><br/>");
            w.WriteLine("<font size=\"2\" color=\"#3374EC\">");
            w.WriteLine(Environment.MachineName);
            OsInfo osInformation = GetOSInformation();
            string procArch = Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER");
            string[] procInfoArray = procArch.Split(' ');
            w.WriteLine("<br/>");
            w.WriteLine(osInformation.OS
                + " (" + osInformation.OSLocale + ")"
                + " " + procInfoArray[0]
                + " " + procInfoArray[procInfoArray.Length - 1]);                     

            if (!string.IsNullOrEmpty(VisualStudioSkew))
            {
                w.WriteLine("<br/>");
                w.WriteLine(VisualStudioSkew);
            }
            w.WriteLine("</font></b></td></tr>");

            if (!string.IsNullOrEmpty(ts.FullDeviceName))
            {
                w.WriteLine("<tr><td align=\"center\" bordercolor=\"white\"><b><font size=\"3\" color=\"brown\">");
                w.WriteLine("Device: " + ts.FullDeviceName);
                w.WriteLine("</font></b></td></tr>");
            }

            if (!string.IsNullOrEmpty(ts.Transport.ToString()) &&
                !string.Equals(ts.Transport.ToString().ToLower(), "none"))
            {
                w.WriteLine("<tr><td align=\"center\" bordercolor=\"white\"><b><font size=\"3\" color=\"brown\">");
                w.WriteLine("Transport: " + ts.Transport);
                w.WriteLine("</font></b></td></tr>");
            }

            if (!string.IsNullOrEmpty(TestSystem.BuildNumber))
            {
                w.WriteLine("<tr><td align=\"center\" bordercolor=\"white\"><b><font size=\"3\">");
                if (!string.IsNullOrEmpty(ts.BuildFlavor))
                {
                    w.Write(ts.BuildFlavor);
                }
                w.WriteLine(" build " + TestSystem.BuildNumber + "<br>");
                if (!string.IsNullOrEmpty(ts.Branch))
                {
                    w.WriteLine(ts.Branch);
                }
                w.WriteLine("</font></b></td></tr>");
            }

            return w;
        }
Exemple #4
0
        internal static void CreateProfilerLog(string path, TestSystem ts)
        {
            StreamWriter w = WriteTestLogHeaders(path, ts, "iMXS Freescale Profiler Run Results");
            w.WriteLine("</table>");
            w.WriteLine("<br>");

            w.WriteLine("<table border=\"3\" bordercolor=\"black\" width=\"100%\" align=\"left\">");

            w.WriteLine("<td align=\"center\" bordercolor=\"black\" width = \"30%\">");
            w.WriteLine("<font size=\"2\">");
            w.WriteLine("<b>Test</b>");
            w.WriteLine("</font>");
            w.WriteLine("</td>");

            w.WriteLine("<td align=\"center\" bordercolor=\"black\" width = \"40%\">");
            w.WriteLine("<font size=\"2\">");
            w.WriteLine("<b>Location</b>");
            w.WriteLine("</font>");
            w.WriteLine("</td>");

            w.WriteLine("<td align=\"center\" bordercolor=\"black\" width = \"30%\">");
            w.WriteLine("<font size=\"2\">");
            w.WriteLine("<b>Log</b>");
            w.WriteLine("</font>");
            w.WriteLine("</td>");

            for (int i = 0; i < ts.TestResultList.Count; i++)
            {
                if (ts.TestResultList[i] is ProfilerTest)
                {
                    ProfilerTest test = ts.TestResultList[i] as ProfilerTest;
                    w.WriteLine("<tr bgcolor=\"#CCCCC1\">");
                    w.WriteLine("<td align=\"center\" bordercolor=\"white\" width = \"30%\">");
                    w.WriteLine("<font size=\"2\">");
                    w.WriteLine(test.Name);
                    w.WriteLine("</font></td>");

                    w.WriteLine("<td align=\"center\" bordercolor=\"white\" width = \"40%\">");
                    w.WriteLine("<font size=\"2\">");
                    w.WriteLine(test.Location);
                    w.WriteLine("</font></td>");

                    w.WriteLine("<td align=\"center\" bordercolor=\"white\" width = \"30%\">");
                    w.WriteLine("<font size=\"2\">");
                    w.WriteLine("<a href=");

                    // If a UNC path is not specified, assume that the test is being run locally 
                    // and keep all the links local.
                    if (!string.IsNullOrEmpty(ts.ResultsFolder) && ts.IsAlternateLogStoreSpecified)
                    {
                        string[] split = test.LogFile.Split('\\');
                        test.LogFile = ts.ResultsFolder.TrimEnd('\\') + "\\" + split[split.Length - 1];
                        w.WriteLine("file:" + ts.ResultsFolder.Replace('\\', '/').TrimEnd('/') + "/" + split[split.Length - 1]);
                    }
                    else
                    {
                        string[] frag = test.LogFile.Split('\\');
                        w.WriteLine(frag[frag.Length - 1]);
                    }
                    w.WriteLine("><b>" + "Open log" + "</b></a>");
                    w.WriteLine("</font></td>");
                    w.WriteLine("</tr>");
                }
            }

            w.WriteLine("</table>");
            w.WriteLine("</html>");
            w.Close();

            // Reset the values since the tests are done running.
            ts.Device = string.Empty;
            ts.Transport = TestSystem.TransportType.Emulator;
        }