/// <summary>
    /// pdf/font_mapping/test-embedded.pdf : bc31582e,f892ac0d,
    /// MERGE INTO TESTCASE_CHECKSUMS_VIEW using dual on (TGUID=? AND PID=? AND PAGE_NO=?)
    /// WHEN NOT matched THEN INSERT (TGUID,PID,PAGE_NO,CHECKSUM) VALUES (?,?,?,?)
    /// WHEN matched then UPDATE SET CHECKSUM=?"
    /// </summary>
    /// <param name="PID"></param>
    /// <param name="stream"></param>
    /// <returns></returns>
    public bool update_checksums(string user_id, int PID, string location, StreamReader stream)
    {
        string line;
        string table_name = this.TableName;
        string testcase   = string.Empty;

        try
        {
            this.TableName = "TESTCASE_CHECKSUMS";

            do
            {
                line = stream.ReadLine();
                if (line == null)
                {
                    continue;
                }

                try
                {
                    line = line.Trim();
                    if (line.StartsWith("#"))
                    {
                        Console.WriteLine("{0}\n", line);
                        continue;
                    }

                    String[] splitString = Regex.Split(line, @"\s*[: ]\s*");
                    if (0 < splitString.Length)
                    {
                        testcase = location + splitString[0];
                        string checksums = splitString[1];
                        string tguid     = TESTCASE.lookup_tguid(testcase);

                        TESTCASE_CHECKSUMS_VIEW.Row rec = NewRow();
                        rec.TGUID = tguid;

                        // rec.TNAME = match.Index + 1;
                        rec.MODIFIED_BY = user_id;
                        rec.PID         = PID;
                        rec.CHECKSUMS   = checksums;

                        merge(rec);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(testcase + " ERROR: " + e.StackTrace);
                }
            } while (line != null);
        }
        finally
        {
            this.TableName = table_name;
        }

        return(true);
    }
Esempio n. 2
0
    protected void ExportToExcel(object sender, EventArgs e)
    {
        try
        {
            Response.Clear();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment;filename=Testcases.csv");
            Response.Charset     = "";
            Response.ContentType = "text/csv";
            using (StringWriter sw = new StringWriter())
            {
                HtmlTextWriter hw   = new HtmlTextWriter(sw);
                TESTCASE       tcdb = new TESTCASE();

                var lines = new List <string>();

                int       fetchCount = tcdb.SelectCount(txtFilter.Text);
                DataTable dt         = (fetchCount > 0) ? tcdb.QueryTestcases(txtFilter.Text, null, 0, fetchCount) : null;

                if (null != dt)
                {
                    string[] columnNames = dt.Columns.Cast <DataColumn>().Select(column => column.ColumnName).ToArray();
                    var      header      = string.Join(",", columnNames);
                    lines.Add(header);

                    var valueLines = dt.AsEnumerable().Select(row => string.Join(",", row.ItemArray));
                    lines.AddRange(valueLines);

                    foreach (string s in lines)
                    {
                        sw.WriteLine(s);
                    }
                }
                else
                {
                    sw.WriteLine("No results!");
                }

                //style to format numbers to string
                //string style = @"<style> .textmode { } </style>";
                //Response.Write(style);
                //Response.Output.Write(sw.ToString());

                byte[] bytes = System.Text.Encoding.UTF8.GetBytes(sw.ToString());
                Response.OutputStream.Write(bytes, 0, bytes.Length);

                Response.Flush();
                Response.End();
            }
        }
        catch (Exception ex)
        {
            //querySQL.Text = totalLbl.Text + " = " + TestcaseProfileData.querySQL;
            //throw new Exception(querySQL.Text, ex);
            throw ex;
        }
    }
Esempio n. 3
0
    public static string lookup_tguid(string testcase)
    {
        TESTCASE tbl = new TESTCASE();
        Row      row = tbl.NewRow();

        row.TLOC = testcase;

        row = tbl.findSingleResult(row);
        if (null != row)
        {
            return(row.TGUID);
        }
        return(string.Empty);
    }
Esempio n. 4
0
    /// <summary>
    /// pdf/font_mapping/test-embedded.pdf : bc31582e,f892ac0d,
    /// MERGE INTO TESTCASE_CHECKSUM using dual on (TGUID=? AND PID=? AND PAGE_NO=?)
    /// WHEN NOT matched THEN INSERT (TGUID,PID,PAGE_NO,CHECKSUM) VALUES (?,?,?,?)
    /// WHEN matched then UPDATE SET CHECKSUM=?"
    /// </summary>
    /// <param name="PID"></param>
    /// <param name="stream"></param>
    /// <returns></returns>
    public bool update_checksums(int PID, string location, StreamReader stream)
    {
        string pattern = @"([a-z\d]+)";
        string line;

        do
        {
            line = stream.ReadLine();
            if (line != null)
            {
                line = line.Trim();
                if (line.StartsWith("#"))
                {
                    Console.WriteLine("{0}\n", line);
                    continue;
                }

                String[] splitString = Regex.Split(line, @"\s*:\s*");
                if (2 == splitString.Length)
                {
                    string testcase  = location + splitString[0];
                    string checksums = splitString[1];
                    string tguid     = TESTCASE.lookup_tguid(testcase);

                    MatchCollection matches = Regex.Matches(checksums, pattern);
                    foreach (Match match in matches)
                    {
                        TESTCASE_CHECKSUM.Row rec = NewRow();
                        rec.TGUID    = tguid;
                        rec.PAGE_NO  = match.Index + 1;
                        rec.PID      = PID;
                        rec.CHECKSUM = match.Value;

                        merge(rec);
                    }
                }
            }
        } while (line != null);

        return(true);
    }
Esempio n. 5
0
 internal Row(DataRowBuilder rb)
     : base(rb)
 {
     this.table = ((TESTCASE)(this.Table));
 }
Esempio n. 6
0
    public bool update_func_mappings(string user_id, string filename)
    {
        string testcase = string.Empty;
        string line     = string.Empty;

        StreamReader stream = new StreamReader(filename);

        try
        {
            TESTCASE_FUNC test_func = new TESTCASE_FUNC();
            TESTCASE      tcases    = new TESTCASE();
            while (null != (line = stream.ReadLine()))
            {
                MatchCollection matches;
                if (string.Empty == testcase)
                {
                    // "Profiled target:  ./pdls -s -e pdf /m/tcases/futures/next/wip/pdf/fonts/report.pdf (PID 23196, part 1)"
                    matches = Regex.Matches(line, "Profiled target:.*-e\\s*(?<emul>[^\\s]+)\\s*(?<testcase>[^\\s]+)", RegexOptions.IgnoreCase);
                    foreach (Match match in matches)
                    {
                        TESTCASE.Row t = tcases.NewRow();
                        t.TLOC   = match.Groups["testcase"].Value;
                        t.TTYPE  = match.Groups["emul"].Value.ToUpper();
                        t.TNAME  = t.TLOC.Substring(t.TLOC.LastIndexOf('/') + 1);
                        t.HIDDEN = 'N';
                        tcases.merge(t);
                        t        = tcases.lookup(t);
                        testcase = t.TGUID;
                    }
                }
                else
                {
                    // /usr/src/debug/graphen/0.0+gitAUTOINC+a8befc5ef3-r0/git/xi/fonts.c:AddName
                    matches = Regex.Matches(line, "\\s*(?<path>/.*)/(?<file>.*):(?<func>\\w+)", RegexOptions.IgnoreCase);
                    foreach (Match match in matches)
                    {
                        try
                        {
                            FUNC.Row func = NewRow();
                            string   file = string.Format("{0}/{1}", match.Groups["path"].Value, match.Groups["file"].Value);
                            string   name = match.Groups["func"].Value;

                            func.SOURCE_FILE = file;
                            func.FUNC_NAME   = name;
                            func.LINE_NO     = 0;
                            func.FID         = lookup_fid(func);

                            Console.WriteLine("{0} ==> {1}", func.SOURCE_FILE, func.FUNC_NAME);

                            merge(func);

                            test_func.update(testcase, func);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(testcase + " ERROR: " + e.StackTrace);
                            throw e;
                        }
                        break;
                    }
                }
            }

            return(true);
        }
        finally
        {
            stream.Close();
        }
    }