Ejemplo n.º 1
0
        /**
         * Evaluate the unit test of a specific test. When evaluating the unit
         * test, the user has the option of either aggregating the results, or
         * getting back the raw data for the result.
         *
         * @param[in]       test       Test number of interest
         * @param[in]       utid       Unit test of interest
         * @param[in]       aggr       Apply aggregation function
         * @param[out]      eval       Evaluation function
         */
        public UnitTestResult Evaluate(string testdata,
                                       int utid,
                                       bool aggr)
        {
            // Create a new variable table for this unit test.
            UnitTestVariableTable vtable =
                new UnitTestVariableTable(this.location_);

            try
            {
                this.test_db_.Open(testdata);
                string test_uuid = this.test_db_.GetTestUUID();

                // Open the variable table.
                vtable.Open(test_uuid, utid);
                DataTable table = vtable.Data;

                // Begin a new transaction.
                return(this.evaluate_i(vtable, aggr));
            }
            finally
            {
                this.test_db_.Close();
                vtable.Close();
            }
        }
Ejemplo n.º 2
0
        /**
         * Re-evaluate a unit test.
         */
        public UnitTestResult Reevaluate(string test_datafile,
                                         int utid,
                                         bool aggr)
        {
            // Create a new variable table for this unit test.
            UnitTestVariableTable vtable = new UnitTestVariableTable(this.location_);

            try
            {
                // Open the test database.
                this.test_db_.Open(test_datafile);
                string test_uuid = this.test_db_.GetTestUUID();

                vtable.Open(test_uuid, utid);
                DbTransaction transaction = vtable.BeginTransaction();

                try
                {
                    // Get the variable table for this unit test. This table is then sent
                    // back to the database for processing, i.e., to execute the user-defined
                    // expression to evaluate the unit test.
                    this.create_variable_table(test_datafile, ref vtable);

                    // Delete rows with incomplete data.
                    vtable.Compact();

                    // Commit the transaction.
                    transaction.Commit();
                    return(this.evaluate_i(vtable, aggr));
                }
                catch (Exception)
                {
                    transaction.Rollback();
                    throw;
                }
            }
            finally
            {
                this.test_db_.Close();
                vtable.Close();
            }
        }
Ejemplo n.º 3
0
        /**
         * Get the data trend for the unit test.
         */
        public UnitTestDataTrend GetDataTrend(string testdata, int utid)
        {
            // First, get the SQL string for selecting the data trend.
            List <string> groups;
            string        sqlstr = this.create_evaluation_query(utid, true, out groups);

            // Create a new variable table for this unit test.
            UnitTestVariableTable vtable = new UnitTestVariableTable(this.location_);

            // Get the UUID for this test.
            this.test_db_.Open(testdata);
            string test_uuid = this.test_db_.GetTestUUID();

            // Open the variable table.
            vtable.Open(test_uuid, utid);

            DbTransaction transaction = vtable.BeginTransaction();

            try
            {
                // Evalute the unit test.
                DataTable results = new DataTable();
                vtable.Evaluate(sqlstr, ref results);

                // Commit the transaction.
                transaction.Commit();

                UnitTestDataTrend trend = new UnitTestDataTrend();

                if (groups.Count == 0)
                {
                    // Write the data set for the single group.
                    foreach (DataRow row in results.Rows)
                    {
                        trend.Data.Add(row["result"]);
                    }
                }
                else
                {
                    string    current_group = String.Empty;
                    DataTrend group_data    = new DataTrend();

                    foreach (DataRow grprow in results.Rows)
                    {
                        // First, construct the name of the group for this row in
                        // the data table.
                        List <string> name_list = new List <string> ();

                        foreach (string name in groups)
                        {
                            name_list.Add((string)grprow[name]);
                        }

                        string grp_name = String.Join(".", name_list.ToArray());

                        if (grp_name != current_group)
                        {
                            if (current_group != String.Empty)
                            {
                                // Insert the group data into the collection.
                                trend.GroupData.Add(current_group, group_data);

                                // End the current group's data by creating.
                                group_data = new DataTrend();
                            }

                            // Save the new group name.
                            current_group = grp_name;
                        }

                        // Insert the value into the group's result.
                        group_data.Add(grprow["result"]);
                    }

                    if (group_data.Count > 0)
                    {
                        trend.GroupData.Add(current_group, group_data);
                    }
                }

                return(trend);
            }
            catch (Exception)
            {
                transaction.Rollback();
                throw;
            }
            finally
            {
                this.test_db_.Close();
                vtable.Close();
            }
        }