Beispiel #1
0
sort($tests);
// run tests
$total_tests = 0;
$total_tests_failed = 0;
$total_subtests = 0;
$total_subtests_failed = 0;
foreach ($tests as $test) {
    if ($windows) {
        // avoid an issue with daemons stuck in exit(0) for some seconds
        $sd_port += 10;
        $agent_port += 10;
        $agents = array(array("address" => $sd_address, "port" => $sd_port), array("address" => $agent_address, "port" => $agent_port));
    }
    if (file_exists($test . "/test.xml")) {
        $total_tests++;
        $res = RunTest($test);
        if (!is_array($res)) {
            // failed to run that test at all
            $total_tests_failed++;
            continue;
        }
        $total_subtests += $res["tests_total"];
        if ($res["tests_failed"]) {
            $total_tests_failed++;
            $total_subtests_failed += $res["tests_failed"];
            if ($g_strict) {
                break;
            }
        }
    } elseif (file_exists($test . "/test.inc")) {
        $run_func = create_function('$test_path', file_get_contents($test . "/test.inc"));
function CheckConditions($m_conditions, $a_vars, &$s_missing, &$a_missing_list, $m_id = false)
{
    if (is_array($m_conditions)) {
        //
        // Sort the conditions by their numeric value.  This ensures
        // conditions are executed in the right order.
        //
        ksort($m_conditions, SORT_NUMERIC);
        foreach ($m_conditions as $m_key => $s_cond) {
            if (!CheckConditions($s_cond, $a_vars, $s_missing, $a_missing_list, $m_key)) {
                return false;
            }
        }
        return true;
    }
    $s_fld_name = "conditions" . ($m_id === false ? "" : $m_id + 1);
    if (!is_string($m_conditions)) {
        SendAlert(GetMessage(MSG_INV_COND, array("FLD" => $s_fld_name)));
        return true;
        // pass invalid conditions
    }
    if ($m_conditions == "") {
        return true;
    }
    // pass empty conditions
    $s_cond = $m_conditions;
    //
    // extract the separator characters
    //
    if (strlen($s_cond) < 2) {
        SendAlert(GetMessage(MSG_COND_CHARS, array("FLD" => $s_fld_name, "COND" => $s_cond)));
        return true;
        // pass invalid conditions
    }
    $s_list_sep = $s_cond[0];
    $s_int_sep = $s_cond[1];
    $s_full_cond = $s_cond = substr($s_cond, 2);
    $b_bad = false;
    $a_list = TrimArray(explode($s_list_sep, $s_cond));
    $s_missing = "";
    $a_missing_list = array();
    for ($ii = 0; $ii < count($a_list); $ii++) {
        $s_cond = $a_list[$ii];
        $i_len = strlen($s_cond);
        if ($i_len <= 0) {
            continue;
        }
        //
        // split the condition into its internal components
        //
        $a_components = TrimArray(explode($s_int_sep, $s_cond));
        if (count($a_components) < 5) {
            SendAlert(GetMessage(MSG_COND_INVALID, array("FLD" => $s_fld_name, "COND" => $s_cond, "SEP" => $s_int_sep)));
            //
            // the smallest condition has 5 components
            //
            continue;
        }
        //
        // first component is ignored (it's blank)
        //
        $a_components = array_slice($a_components, 1);
        switch ($a_components[0]) {
            case "TEST":
                if (count($a_components) > 5) {
                    SendAlert(GetMessage(MSG_COND_TEST_LONG, array("FLD" => $s_fld_name, "COND" => $s_cond, "SEP" => $s_list_sep)));
                    continue;
                }
                if (!RunTest($a_components[1], $a_vars)) {
                    $s_missing .= $a_components[2] . "\n";
                    $a_missing_list[] = $a_components[2];
                    $b_bad = true;
                }
                break;
            case "IF":
                if (count($a_components) < 6) {
                    SendAlert(GetMessage(MSG_COND_IF_SHORT, array("FLD" => $s_fld_name, "COND" => $s_cond, "SEP" => $s_int_sep)));
                    continue;
                }
                if (count($a_components) > 7) {
                    SendAlert(GetMessage(MSG_COND_IF_LONG, array("FLD" => $s_fld_name, "COND" => $s_cond, "SEP" => $s_list_sep)));
                    continue;
                }
                if (RunTest($a_components[1], $a_vars)) {
                    $b_test = RunTest($a_components[2], $a_vars);
                } else {
                    $b_test = RunTest($a_components[3], $a_vars);
                }
                if (!$b_test) {
                    $s_missing .= $a_components[4] . "\n";
                    $a_missing_list[] = $a_components[4];
                    $b_bad = true;
                }
                break;
            default:
                SendAlert(GetMessage(MSG_COND_UNK, array("FLD" => $s_fld_name, "COND" => $s_cond, "CMD" => $a_components[0])));
                break;
        }
    }
    return !$b_bad;
}
Beispiel #3
0
$total_tests_failed = 0;
$total_subtests = 0;
$total_subtests_failed = 0;
$total_skipped = $user_skipped;
$failed_tests = array();
foreach ($tests as $test) {
    if ($windows && !$sd_managed_searchd) {
        // avoid an issue with daemons stuck in exit(0) for some seconds
        $sd_port += 10;
        $agent_port += 10;
        $agent_port_sql += 10;
        $agents = array(array("address" => $sd_address, "port" => $sd_port, "sqlport" => $sd_sphinxql_port), array("address" => $agent_address, "port" => $agent_port, "sqlport" => $agent_port_sql), array("address" => $agent_address, "port" => $agent_port + 1, "sqlport" => $agent_port_sql + 1));
    }
    if (file_exists($test . "/test.xml")) {
        $total_tests++;
        $res = RunTest($test, $g_skipdemo, $g_usemarks);
        if (!is_array($res)) {
            // failed to run that test at all
            $total_tests_failed++;
            $failed_tests[] = ShortTestName($test);
            continue;
        }
        $total_subtests += $res["tests_total"];
        $total_skipped += $res["tests_skipped"];
        if ($res["tests_failed"]) {
            $total_tests_failed++;
            $total_subtests_failed += $res["tests_failed"];
            $failed_tests[] = ShortTestName($test);
            if ($g_strict) {
                if ($g_strictverbose) {
                    $report = file_get_contents("{$test}/report.txt");
Beispiel #4
0
        $install_test_result[$id] = "Topic tree is empty";
        $install_color[$id] = $install_red;
    } else {
        $install_test_result[$id] = "OK";
        $install_color[$id] = $install_green;
    }
}
PrintTitle($id);
print '<DIV ALIGN="center"><BR />
	<INPUT type="submit" name="delete_topic" value="Delete vocabularies">
	<INPUT type="submit" name="create_topic" value="Create vocabularies (topic tree, genres, roles)">
	</DIV>';
PrintButton($id);
////////////////////////// Test 8
$id = 8;
if (RunTest($id, "Node administrator", 7)) {
    dbug("TEST 8");
    require_once "../init.inc.php";
    // this will most probably cause an error if the connector class is configured properly!
    $res = sotf_User::findUsers("a");
    $res = NULL;
    $adminId = $db->getOne("SELECT user_id FROM sotf_user_permissions WHERE object_id='node' AND permission_id='1'");
    if (!$adminId && $admin_name && $admin_pass) {
        if (!sotf_User::getUserid($admin_name)) {
            // let's register the new admin user
            $error = sotf_User::register($admin_pass, $admin_name, '', 'en', '');
        }
        if (!$error) {
            $error = sotf_User::login($admin_name, $admin_pass);
        }
        if ($error) {
Beispiel #5
0
function CheckConditions($m_conditions, $a_vars, &$s_missing, &$a_missing_list)
{
    if (is_array($m_conditions)) {
        foreach ($m_conditions as $s_cond) {
            if (!CheckConditions($s_cond, $a_vars, $s_missing, $a_missing_list)) {
                return false;
            }
        }
        return true;
    }
    if (!is_string($m_conditions)) {
        SendAlert("Invalid 'conditions' field - not a string or array.");
        return true;
        // pass invalid conditions
    }
    if ($m_conditions == "") {
        return true;
    }
    // pass empty conditions
    $s_cond = $m_conditions;
    //
    // extract the separator characters
    //
    if (strlen($s_cond) < 2) {
        SendAlert("The 'conditions' field is not valid.  You must provide the two separator characters.\n'{$s_cond}'");
        return true;
        // pass invalid conditions
    }
    $s_list_sep = $s_cond[0];
    $s_int_sep = $s_cond[1];
    $s_full_cond = $s_cond = substr($s_cond, 2);
    $b_bad = false;
    $a_list = TrimArray(explode($s_list_sep, $s_cond));
    $s_missing = "";
    $a_missing_list = array();
    for ($ii = 0; $ii < count($a_list); $ii++) {
        $s_cond = $a_list[$ii];
        $i_len = strlen($s_cond);
        if ($i_len <= 0) {
            continue;
        }
        //
        // split the condition into its internal components
        //
        $a_components = TrimArray(explode($s_int_sep, $s_cond));
        if (count($a_components) < 5) {
            SendAlert("Condition '{$s_cond}' is not valid");
            //
            // the smallest condition has 5 components
            //
            continue;
        }
        //
        // first component is ignored (it's blank)
        //
        $a_components = array_slice($a_components, 1);
        switch ($a_components[0]) {
            case "TEST":
                if (count($a_components) > 5) {
                    SendAlert("Too many components to 'TEST' command '{$s_cond}'.\nAre you missing a '{$s_list_sep}'?");
                    continue;
                }
                if (!RunTest($a_components[1], $a_vars)) {
                    $s_missing .= $a_components[2] . "\n";
                    $a_missing_list[] = $a_components[2];
                    $b_bad = true;
                }
                break;
            case "IF":
                if (count($a_components) < 6) {
                    SendAlert("Condition '{$s_cond}' is not a valid IF command");
                    continue;
                }
                if (count($a_components) > 7) {
                    SendAlert("Too many components to 'IF' command '{$s_cond}'.\nAre you missing a '{$s_list_sep}'?");
                    continue;
                }
                if (RunTest($a_components[1], $a_vars)) {
                    $b_test = RunTest($a_components[2], $a_vars);
                } else {
                    $b_test = RunTest($a_components[3], $a_vars);
                }
                if (!$b_test) {
                    $s_missing .= $a_components[4] . "\n";
                    $a_missing_list[] = $a_components[4];
                    $b_bad = true;
                }
                break;
            default:
                SendAlert("Condition '{$s_cond}' has an unknown command '" . $a_components[0] . "'");
                break;
        }
    }
    return !$b_bad;
}
Beispiel #6
0
PrintTitle($id);
print '
	Username: <INPUT type="text" name="node_user" value="' . $install_node_user . '"><BR />
	Password: <INPUT type="password" name="node_pass" value="' . $install_node_pass . '"><BR />
	Hostname: <INPUT type="text" name="node_host" value="' . $install_node_host . '"> Port: <INPUT type="text" name="node_port" value="' . $install_node_port . '" SIZE=5><BR />
	Database name: <INPUT type="text" name="node_db_name" value="' . $install_node_db_name . '"><BR />';
if ($install_color[$id] == $install_green and ($install_node_user != $nodeDbUser or $install_node_pass != $nodeDbPasswd or $install_node_host != $nodeDbHost or $install_node_port != $nodeDbPort or $install_node_db_name != $nodeDbName)) {
    print '<DIV ALIGN="center"><BR /><INPUT type="submit" name="writeback_node" value="Write new values to config.inc.php" disabled=true></DIV>';
}
if ($install_color[$id] == $install_red) {
    print '<DIV ALIGN="center"><BR /><INPUT type="submit" name="createdb" value="Create NODE db"></DIV>';
}
PrintButton($id);
$id = 7;
//////////////////////////Test 7
if (RunTest($id, "TopicTree", 6) or isset($install_create_topic) or isset($install_delete_topic)) {
    if (isset($install_create_topic)) {
        require "init.inc.php";
        $id = addParent("development", "Development");
        addChild($id, "agriculture", "Agriculture");
        addChild($id, "aid", "Aid");
        addChild($id, "capacity building", "Capacity Building");
        addChild($id, "children", "Children");
        addChild($id, "cities", "Cities");
        addChild($id, "education", "Education");
        addChild($id, "emergency relief", "Emergency Relief");
        addChild($id, "energy", "Energy");
        addChild($id, "fisheries", "Fisheries");
        addChild($id, "food", "Food");
        addChild($id, "gender", "Gender");
        addChild($id, "intermediate technology", "Intermediate Technology");
Beispiel #7
0
</p>
<?php 
$cnt = 0;
$oParse = new sqlParse();
RunTest("select col1,col2 as 'Column 2',col3 as 'Column 3' from Table1 order by 1");
RunTest("select col1,[ from here],col2,[ to there] as 'Description' from Table1 order by 1");
RunTest("select col1,\" from here\",col2,\" to there\" as 'Description' from AnsiTable1 order by 1");
RunTest("select distinct col1,col2 as 'Column 2',col3 as 'Column 3' from Table1 order by 1");
RunTest("SELECT name, qty, descr, color FROM s, sp, p " . "WHERE s.sno = sp.sno AND sp.pno = p.pno");
RunTest("SELECT DISTINCT a.pno FROM sp a, sp b " . "WHERE a.pno = b.pno AND a.sno <> b.sno");
RunTest("SELECT DISTINCT pno FROM sp a " . "WHERE pno IN (SELECT pno FROM sp b WHERE a.sno <> b.sno)");
RunTest("SELECT pno, qty, (SELECT city FROM s WHERE s.sno = sp.sno) FROM sp");
RunTest("SELECT pno, MIN(sno), MAX(qty), AVG(qty), COUNT(DISTINCT sno) " . "FROM sp GROUP BY pno");
RunTest("SELECT sno, COUNT(*) as parts " . "FROM sp " . "GROUP BY sno " . "HAVING COUNT(*) > 1");
RunTest("SELECT `ActiveBatches`.`id`, IFNULL(`ActiveBatches`.`DisplayName`, `ActiveBatches`.`Name`) AS `Name`, `ActiveBatches`.`CreationTime`, `u1`.`DisplayName` AS `CreationUser`, COUNT(*) AS `loanCount`, SUM(ActiveLoans.ErrorCount > 0) AS `errorLoanCount`, SUM(ActiveLoans.ErrorCount) AS `errorCount`, SUM(ActiveLoans.MissingCount) AS `missingCount`, `ActiveBatches`.`Status` AS `BatchStatus`, `ActiveBatches`.`Comments`, `ActiveBatches`.`Last Modified Time`, `u2`.`DisplayName` AS `Last Modified User` " . "FROM `ActiveBatches` " . "INNER JOIN `ActiveLoans` ON `ActiveLoans`.`BatchID`=`ActiveBatches`.`id` " . "LEFT JOIN `Users` AS `u1` ON `ActiveBatches`.`CreationUser`=`u1`.`id` " . "LEFT JOIN `Users` AS `u2` ON `ActiveBatches`.`LastModifiedUser`=`u2`.`id` GROUP BY `ActiveBatches`.`id`");
RunTest("SELECT CatId,CatName,EntryType,BuildDays,TaskAlias,1 as 'ALL'," . "(select top 1 TargetDate from DueDates where TaskId in (select TaskId from vTaskDays where Alias=pbc.TaskAlias and '20080101' between EffFrom and EffTo)) as TargetDate " . "FROM BuildCat pbc ORDER BY BuildDays,SortOrder");
function RunTest($sqltext)
{
    global $oParse, $cnt;
    $cnt++;
    echo "<hr style='height:5px;margin-top:25px;background-color:navy;'><p>Test #" . $cnt . "<br>" . htmlspecialchars($sqltext);
    $oParse->Init(0);
    $oParse->ParseSelect($sqltext);
    $oParse->DebugPrint();
}
?>

</body>
</html>