diff options
author | Michael Larabel <michael@phx-laptop.(none)> | 2008-12-05 17:46:42 -0500 |
---|---|---|
committer | Michael Larabel <michael@phx-laptop.(none)> | 2008-12-05 17:46:42 -0500 |
commit | 253c6841ecf315bb068d39e8071146590639ebec (patch) | |
tree | 0b84d5c65fe23382e2f04fe07d180590c10298b4 /pts-core | |
parent | a109aa2766f33a4ec332b4e1a70095ecfce8f572 (diff) | |
download | phoronix-test-suite-upstream-253c6841ecf315bb068d39e8071146590639ebec.tar.gz phoronix-test-suite-upstream-253c6841ecf315bb068d39e8071146590639ebec.tar.xz phoronix-test-suite-upstream-253c6841ecf315bb068d39e8071146590639ebec.zip |
pts-core: Allow multiple tests/suites/identifiers to be passed using the
run and benchmark options
Diffstat (limited to 'pts-core')
-rw-r--r-- | pts-core/functions/pts-functions-install.php | 2 | ||||
-rw-r--r-- | pts-core/functions/pts-functions-merge.php | 4 | ||||
-rw-r--r-- | pts-core/functions/pts-functions-run.php | 188 | ||||
-rw-r--r-- | pts-core/functions/pts-functions_global.php | 4 | ||||
-rw-r--r-- | pts-core/options/run_test.php | 472 |
5 files changed, 369 insertions, 301 deletions
diff --git a/pts-core/functions/pts-functions-install.php b/pts-core/functions/pts-functions-install.php index 230aa35..4348b7a 100644 --- a/pts-core/functions/pts-functions-install.php +++ b/pts-core/functions/pts-functions-install.php @@ -53,7 +53,7 @@ function pts_start_install($to_install) if(pts_read_assignment("COMMAND") != "benchmark") { - echo pts_string_header("\nNot recognized: $TO_INSTALL\n"); + echo pts_string_header("\nNot recognized: " . $TO_INSTALL . "\n"); } return false; } diff --git a/pts-core/functions/pts-functions-merge.php b/pts-core/functions/pts-functions-merge.php index 8d81fd8..1424486 100644 --- a/pts-core/functions/pts-functions-merge.php +++ b/pts-core/functions/pts-functions-merge.php @@ -103,7 +103,7 @@ function pts_merge_test_results($OLD_RESULTS, $NEW_RESULTS) } unset($OLD_RESULTS, $original_xml_reader, $original_results_raw); - if(!pts_is_assignment("GLOBAL_COMPARISON") && getenv("PTS_MERGE") != "custom") + /*if(!pts_is_assignment("GLOBAL_COMPARISON") && getenv("PTS_MERGE") != "custom") { if($original_suite_name != $new_suite_name && !pts_global_valid_id_string($original_suite_name) && !pts_global_valid_id_string($new_suite_name)) { @@ -113,7 +113,7 @@ function pts_merge_test_results($OLD_RESULTS, $NEW_RESULTS) { // echo "Merge Failed! The test versions don't match: $original_suite_version - $new_suite_version\n"; } - } + }*/ // Write the new merge diff --git a/pts-core/functions/pts-functions-run.php b/pts-core/functions/pts-functions-run.php index d177320..b6cb116 100644 --- a/pts-core/functions/pts-functions-run.php +++ b/pts-core/functions/pts-functions-run.php @@ -140,50 +140,6 @@ function pts_prompt_svg_result_options($svg_file) return $test_to_run; } -function pts_validate_save_results_name($proposed_save_name, $to_run, $to_run_type) -{ - $custom_title = null; - - do - { - if(is_file(SAVE_RESULTS_DIR . $proposed_save_name . "/composite.xml")) - { - $xml_parser = new tandem_XmlReader(SAVE_RESULTS_DIR . $proposed_save_name . "/composite.xml"); - $test_suite = $xml_parser->getXMLValue(P_RESULTS_SUITE_NAME); - - if($to_run_type != "GLOBAL_COMPARISON") - { - if($test_suite != $to_run) - { - $is_validated = false; - } - else - { - $is_validated = true; - } - } - else - { - $is_validated = true; //TODO: add type comparison check when doing a global comparison - } - } - else - { - $is_validated = true; - } - - if(!$is_validated) - { - echo pts_string_header("This saved file-name is associated with a different test (" . $test_suite . ") from " . $to_run . ". Enter a new name for saving the results."); - $new_name = pts_prompt_save_file_name(false); - $proposed_save_name = $new_name[0]; - $custom_title = $new_name[1]; - } - } - while(!$is_validated); - - return array($proposed_save_name, $custom_title); -} function pts_prompt_test_options($identifier) { $xml_parser = new pts_test_tandem_XmlReader(pts_location_test($identifier)); @@ -350,55 +306,74 @@ function pts_swap_user_variables($user_str) return $user_str; } -function pts_prompt_save_file_name($check_env = true) +function pts_prompt_save_file_name($check_env = true, $to_run) { // Prompt to save a file when running a test - if($check_env && ($save_name = getenv("TEST_RESULTS_NAME")) != false) + $PROPOSED_FILE_NAME = null; + $CUSTOM_TITLE = null; + + if($check_env != false) { - $CUSTOM_TITLE = $save_name; - $PROPOSED_FILE_NAME = pts_input_string_to_identifier($save_name); - echo "Saving Results To: " . $PROPOSED_FILE_NAME . "\n"; + if(!empty($check_env) || ($check_env = getenv("TEST_RESULTS_NAME")) != false) + { + $CUSTOM_TITLE = $check_env; + $PROPOSED_FILE_NAME = pts_input_string_to_identifier($check_env); + //echo "Saving Results To: " . $PROPOSED_FILE_NAME . "\n"; + } } - else + + if(!IS_BATCH_MODE || pts_read_user_config(P_OPTION_BATCH_PROMPTSAVENAME, "FALSE") == "TRUE") { - if(!IS_BATCH_MODE || pts_read_user_config(P_OPTION_BATCH_PROMPTSAVENAME, "FALSE") == "TRUE") - { - $is_reserved_word = false; + $is_reserved_word = pts_is_test($PROPOSED_FILE_NAME) || pts_is_suite($PROPOSED_FILE_NAME); - do + while(empty($PROPOSED_FILE_NAME) || $is_reserved_word || !pts_validate_save_file_name($PROPOSED_FILE_NAME, $to_run)) + { + if($is_reserved_word) { - if($is_reserved_word) - { - echo "\n\nThe name of the saved file cannot be the same as a test/suite: " . $PROPOSED_FILE_NAME . "\n"; - $is_reserved_word = false; - } + echo "\n\nThe name of the saved file cannot be the same as a test/suite: " . $PROPOSED_FILE_NAME . "\n"; + $is_reserved_word = false; + } - echo "Enter a name to save these results: "; - $PROPOSED_FILE_NAME = trim(fgets(STDIN)); - $CUSTOM_TITLE = $PROPOSED_FILE_NAME; - $PROPOSED_FILE_NAME = pts_input_string_to_identifier($PROPOSED_FILE_NAME); + echo "Enter a name to save these results: "; + $PROPOSED_FILE_NAME = trim(fgets(STDIN)); + $CUSTOM_TITLE = $PROPOSED_FILE_NAME; + $PROPOSED_FILE_NAME = pts_input_string_to_identifier($PROPOSED_FILE_NAME); - $is_reserved_word = pts_is_test($PROPOSED_FILE_NAME) || pts_is_suite($PROPOSED_FILE_NAME); - } - while(empty($PROPOSED_FILE_NAME) || $is_reserved_word); - } - else - { - $PROPOSED_FILE_NAME = ""; + $is_reserved_word = pts_is_test($PROPOSED_FILE_NAME) || pts_is_suite($PROPOSED_FILE_NAME); } } - if(!isset($PROPOSED_FILE_NAME) || empty($PROPOSED_FILE_NAME)) + if(empty($PROPOSED_FILE_NAME)) { $PROPOSED_FILE_NAME = date("Y-m-d-Hi"); } - if(!isset($PROPOSED_FILE_NAME) || empty($CUSTOM_TITLE)) + if(empty($CUSTOM_TITLE)) { $CUSTOM_TITLE = $PROPOSED_FILE_NAME; } return array($PROPOSED_FILE_NAME, $CUSTOM_TITLE); } +function pts_validate_save_file_name($proposed_save_name, $to_run) +{ + $is_validated = true; + + if(is_file(SAVE_RESULTS_DIR . $proposed_save_name . "/composite.xml")) + { + $xml_parser = new tandem_XmlReader(SAVE_RESULTS_DIR . $proposed_save_name . "/composite.xml"); + $test_suite = $xml_parser->getXMLValue(P_RESULTS_SUITE_NAME); + + if(!pts_is_assignment("GLOBAL_COMPARISON")) + { + if($test_suite != $to_run && !pts_is_assignment("MULTI_TYPE_RUN")) + { + $is_validated = false; + } + } + } + + return $is_validated; +} function pts_promt_user_tags($default_tags = "") { $tags_input = ""; @@ -534,50 +509,72 @@ function pts_input_string_to_identifier($input) return $input; } -function pts_verify_test_installation($identifier) +function pts_verify_test_installation($identifiers) { // Verify a test is installed - $tests = pts_contained_tests($identifier); + $identifiers_o = $identifiers; + $tests = array(); + + if(!is_array($identifiers)) + { + $identifiers = array($identifiers); + } + + foreach($identifiers as $identifier) + { + foreach(pts_contained_tests($identifier) as $this_test) + { + array_push($tests, $this_test); + } + } + + $tests = array_unique($tests); $needs_installing = array(); + $pass_count = 0; + $fail_count = 0; $valid_op = true; foreach($tests as $test) { if(!is_file(TEST_ENV_DIR . $test . "/pts-install.xml")) { - if(!pts_test_architecture_supported($test) || !pts_test_platform_supported($test)) + $fail_count++; + if(pts_test_supported($test)) { array_push($needs_installing, $test); } } else { - pts_set_assignment_once("TEST_INSTALL_PASS", true); + $pass_count++; } } - if(count($needs_installing) > 0) + if($fail_count > 0) { $needs_installing = array_unique($needs_installing); - if(count($needs_installing) == 1) + if(count($needs_installing) > 0) { - echo pts_string_header($needs_installing[0] . " isn't installed on this system.\nTo install this test, run: phoronix-test-suite install " . $needs_installing[0]); - } - else - { - $message = "Multiple tests need to be installed before proceeding:\n\n"; - foreach($needs_installing as $single_package) + if(count($needs_installing) == 1) { - $message .= "- " . $single_package . "\n"; + echo pts_string_header($needs_installing[0] . " isn't installed.\nTo install, run: phoronix-test-suite install " . $needs_installing[0]); } + else + { + $message = "Multiple tests need to be installed before proceeding:\n\n"; + foreach($needs_installing as $single_package) + { + $message .= "- " . $single_package . "\n"; + } - $message .= "\nTo install these tests, run: phoronix-test-suite install " . $identifier; + $message .= "\nTo install these tests, run: phoronix-test-suite install " . implode(" ", $identifiers); - echo pts_string_header($message); + echo pts_string_header($message); + } } - if(!pts_is_assignment("TEST_INSTALL_PASS") && pts_read_assignment("COMMAND") != "benchmark") + if(pts_is_test($identifiers_o)) { $valid_op = false; } @@ -608,11 +605,15 @@ function pts_recurse_call_tests($tests_to_run, $arguments_array, $save_results = else if(pts_is_test($tests_to_run[$i])) { $test_result = pts_run_test($tests_to_run[$i], $arguments_array[$i], $arguments_description[$i]); - $end_result = $test_result->get_result(); - if($save_results && count($test_result) > 0 && ((is_numeric($end_result) && $end_result > 0) || (!is_numeric($end_result) && strlen($end_result) > 2))) + if($test_result instanceof pts_test_result) { - pts_record_test_result($tandem_xml, $test_result, $results_identifier, pts_request_new_id()); + $end_result = $test_result->get_result(); + + if($save_results && count($test_result) > 0 && ((is_numeric($end_result) && $end_result > 0) || (!is_numeric($end_result) && strlen($end_result) > 2))) + { + pts_record_test_result($tandem_xml, $test_result, $results_identifier, pts_request_new_id()); + } } if($i != (count($tests_to_run) - 1)) @@ -958,6 +959,11 @@ function pts_run_test($test_identifier, $extra_arguments = "", $arguments_descri pts_module_process("__post_test_run", $pts_test_result); pts_test_refresh_install_xml($test_identifier, ($time_test_end - $time_test_start)); + if($result_format == "NO_RESULT") + { + $pts_test_result = false; + } + return $pts_test_result; } function pts_global_auto_tags($extra_attr = null) diff --git a/pts-core/functions/pts-functions_global.php b/pts-core/functions/pts-functions_global.php index 61b4ae9..8de5501 100644 --- a/pts-core/functions/pts-functions_global.php +++ b/pts-core/functions/pts-functions_global.php @@ -31,6 +31,10 @@ function pts_global_download_xml($global_id) // Download a saved test result from Phoronix Global return @file_get_contents("http://www.phoronix-test-suite.com/global/pts-results-viewer.php?id=" . $global_id); } +function pts_clone_from_global($global_id) +{ + return pts_save_result($global_id . "/composite.xml", pts_global_download_xml($global_id)); +} function pts_global_valid_id_string($global_id) { // Basic checking to see if the string is possibly a Global ID diff --git a/pts-core/options/run_test.php b/pts-core/options/run_test.php index 7475454..8cff4ec 100644 --- a/pts-core/options/run_test.php +++ b/pts-core/options/run_test.php @@ -22,7 +22,7 @@ class run_test implements pts_option_interface { - public static function run($r) + public static function run($to_run_identifiers) { pts_load_function_set("run"); pts_load_function_set("merge"); @@ -35,298 +35,356 @@ class run_test implements pts_option_interface $MODULE_STORE = pts_module_store_var("TO_STRING"); $TEST_PROPERTIES = array(); + $types_of_tests = array(); - if(!isset($r[0]) || empty($r[0])) + if(count($to_run_identifiers) == 0 || empty($to_run_identifiers[0])) { - echo pts_string_header("The test, suite, or saved file name must be supplied."); + echo pts_string_header("The test, suite, or saved identifier must be supplied."); return false; } - $TO_RUN = strtolower($r[0]); - - if(is_file($r[0]) && substr(basename($r[0]), -4) == ".svg") + for($i = 0; $i < count($to_run_identifiers); $i++) { - $test_extracted = pts_prompt_svg_result_options($r[0]); + // Clean up tests + $lower_identifier = strtolower($to_run_identifiers[$i]); - if(!empty($test_extracted)) + if(pts_is_test($lower_identifier)) { - $TO_RUN = $test_extracted; - } - } + $xml_parser = new pts_test_tandem_XmlReader(pts_location_test($lower_identifier)); + $test_title = $xml_parser->getXMLValue(P_TEST_TITLE); - $TO_RUN_TYPE = pts_test_type($TO_RUN); - - if(IS_SCTP_MODE) - { - $TO_RUN = basename($TO_RUN); - } - - pts_set_assignment("TO_RUN", $TO_RUN); + if(empty($test_title)) + { + echo pts_string_header($lower_identifier . " is not a test."); + unset($to_run_identifiers[$i]); + break; + } + } - if(pts_is_test($TO_RUN)) - { - $xml_parser = new pts_test_tandem_XmlReader(pts_location_test($TO_RUN)); - $test_title = $xml_parser->getXMLValue(P_TEST_TITLE); + if(pts_verify_test_installation($lower_identifier) == false) + { + // Eliminate this test, it's not properly installed + unset($to_run_identifiers[$i]); + break; + } + + if(is_file($to_run_identifiers[$i]) && substr(basename($to_run_identifiers[$i]), -4) == ".svg") + { + // One of the arguments was an SVG results file, do prompts + $test_extracted = pts_prompt_svg_result_options($to_run_identifiers[$i]); - if(empty($test_title)) + if(!empty($test_extracted)) + { + $to_run_identifiers[$i] = $test_extracted; + } + } + else if(IS_SCTP_MODE) { - echo pts_string_header($TO_RUN . " is not a test."); - return false; + $to_run_identifiers[$i] = basename($to_run_identifiers[$i]); } } - // Make sure tests are installed - $verify_result = pts_verify_test_installation($TO_RUN); + $unique_test_names = count(array_unique($to_run_identifiers)); + $test_names_r = array(); + $test_arguments_r = array(); + $test_arguments_description_r = array(); - if($verify_result == false) + foreach($to_run_identifiers as $to_run) { - return false; - } + $to_run = strtolower($to_run); + $to_run_type = pts_test_type($to_run); + pts_set_assignment_once("TO_RUN", $to_run); - if(!$TO_RUN_TYPE) - { - if(is_file(SAVE_RESULTS_DIR . $TO_RUN . "/composite.xml")) - { - $TO_RUN_TYPE = "LOCAL_COMPARISON"; - } - else if(is_file(pts_input_correct_results_path($TO_RUN))) + if(!$to_run_type) { - $TO_RUN_TYPE = "LOCAL_COMPARISON"; - } - else if(pts_is_global_id($TO_RUN)) - { - $TO_RUN_TYPE = "GLOBAL_COMPARISON"; - pts_set_assignment("GLOBAL_COMPARISON", 1); - pts_save_result($TO_RUN . "/composite.xml", pts_global_download_xml($TO_RUN)); + if(is_file(SAVE_RESULTS_DIR . $to_run . "/composite.xml")) + { + $to_run_type = "LOCAL_COMPARISON"; + } + else if(is_file(pts_input_correct_results_path($to_run))) + { + $to_run_type = "LOCAL_COMPARISON"; + } + else if(pts_is_global_id($to_run)) + { + $to_run_type = "GLOBAL_COMPARISON"; + pts_set_assignment_once("GLOBAL_COMPARISON", true); + pts_clone_from_global($to_run); + } + else + { + echo pts_string_header("Not Recognized: " . $to_run); + break; + } + + pts_set_assignment_once("AUTO_SAVE_NAME", $to_run); } else { - echo pts_string_header("Not Recognized: " . $TO_RUN); - return false; - } + if(IS_SCTP_MODE) + { + pts_set_assignment_once("AUTO_SAVE_NAME", $to_run); + pts_set_assignment_once("AUTO_SAVE_NAME", $to_run); + $to_run_type = "SCTP_COMPARISON"; + } + else + { + if(pts_is_test($to_run) && !pts_is_assignment("RUN_CONTAINS_A_NO_RESULT_TYPE")) + { + $xml_parser = new pts_test_tandem_XmlReader(pts_location_test($to_run)); + $result_format = $xml_parser->getXMLValue(P_TEST_RESULTFORMAT); - $SAVE_RESULTS = true; - $PROPOSED_FILE_NAME = $TO_RUN; - $RES_NULL = null; - } - else - { - echo "\n"; - if(IS_SCTP_MODE) - { - $SAVE_RESULTS = true; - $CUSTOM_TILE = $TO_RUN; - $TO_RUN_TYPE = "SCTP_COMPARISON"; - $PROPOSED_FILE_NAME = $TO_RUN; - $RES_NULL = null; - } - else if(getenv("PTS_SAVE_RESULTS") == "NO") - { - $SAVE_RESULTS = false; - } - else if(getenv("TEST_RESULTS_NAME") != false) - { - $SAVE_RESULTS = true; + if($result_format == "NO_RESULT") + { + pts_set_assignment("RUN_CONTAINS_A_NO_RESULT_TYPE", true); + } + } + } } - else + + if(pts_is_test($to_run)) { - $save_option = true; + if(!IS_BATCH_MODE) + { + $option_output = pts_prompt_test_options($to_run); - if(pts_is_test($TO_RUN)) + $TEST_RUN = array($to_run); + $TEST_ARGS = array($option_output[0]); + $TEST_ARGS_DESCRIPTION = array($option_output[1]); + } + else { - $xml_parser = new pts_test_tandem_XmlReader(pts_location_test($TO_RUN)); - $result_format = $xml_parser->getXMLValue(P_TEST_RESULTFORMAT); + $option_output = pts_generate_batch_run_options($to_run); - if($result_format == "NO_RESULT") + $TEST_RUN = array(); + $TEST_ARGS = $option_output[0]; + $TEST_ARGS_DESCRIPTION = $option_output[1]; + + for($i = 0; $i < count($TEST_ARGS); $i++) { - $save_option = false; + array_push($TEST_RUN, $to_run); } } - if($save_option) + if($unique_test_names == 1) { - $SAVE_RESULTS = pts_bool_question("Would you like to save these test results (Y/n)?", true, "SAVE_RESULTS"); - } - else - { - $SAVE_RESULTS = false; + $xml_parser = new pts_test_tandem_XmlReader(pts_location_test($to_run)); + $test_description = $xml_parser->getXMLValue(P_TEST_DESCRIPTION); + $test_version = $xml_parser->getXMLValue(P_TEST_PTSVERSION); + $test_type = $xml_parser->getXMLValue(P_TEST_HARDWARE_TYPE); + unset($xml_parser); } } - - if($SAVE_RESULTS) + else if(pts_is_suite($to_run)) { - $FILE_NAME = pts_prompt_save_file_name(); - $PROPOSED_FILE_NAME = $FILE_NAME[0]; - $CUSTOM_TITLE = $FILE_NAME[1]; + echo pts_string_header("Test Suite: " . $to_run); - $validate_r = pts_validate_save_results_name($PROPOSED_FILE_NAME, $TO_RUN, $TO_RUN_TYPE); + $xml_parser = new tandem_XmlReader(pts_location_suite($to_run)); - if($PROPOSED_FILE_NAME != $validate_r[0] && !empty($validate_r[1])) + if($unique_test_names == 1) { - $PROPOSED_FILE_NAME = $validate_r[0]; - $CUSTOM_TITLE = $validate_r[1]; + $test_description = $xml_parser->getXMLValue(P_SUITE_DESCRIPTION); + $test_version = $xml_parser->getXMLValue(P_SUITE_VERSION); + $test_type = $xml_parser->getXMLValue(P_SUITE_TYPE); } - } - } - $RESULTS = new tandem_XmlWriter(); - $RESULTS_IDENTIFIER = ""; + $TEST_RUN = $xml_parser->getXMLArrayValues(P_SUITE_TEST_NAME); + $TEST_ARGS = $xml_parser->getXMLArrayValues(P_SUITE_TEST_ARGUMENTS); + $TEST_ARGS_DESCRIPTION = $xml_parser->getXMLArrayValues(P_SUITE_TEST_DESCRIPTION); - if($SAVE_RESULTS) - { - if(is_file(SAVE_RESULTS_DIR . $PROPOSED_FILE_NAME . "/composite.xml")) - { - $xml_parser = new tandem_XmlReader(SAVE_RESULTS_DIR . $PROPOSED_FILE_NAME . "/composite.xml"); - $raw_results = $xml_parser->getXMLArrayValues(P_RESULTS_RESULTS_GROUP); - $result_identifiers = array(); + $PRE_RUN_MESSAGE = $xml_parser->getXMLValue(P_SUITE_PRERUNMSG); + $POST_RUN_MESSAGE = $xml_parser->getXMLValue(P_SUITE_POSTRUNMSG); + $SUITE_RUN_MODE = $xml_parser->getXMLValue(P_SUITE_RUNMODE); - for($i = 0; $i < count($raw_results); $i++) + if($SUITE_RUN_MODE == "PCQS") + { + pts_set_assignment_once("IS_PCQS_MODE", true); + } + + unset($xml_parser); + } + else if($to_run_type == "GLOBAL_COMPARISON" || $to_run_type == "LOCAL_COMPARISON") + { + echo pts_string_header("Comparison: " . $to_run); + + $xml_parser = new tandem_XmlReader(SAVE_RESULTS_DIR . $to_run . "/composite.xml"); + $custom_title = $xml_parser->getXMLValue(P_RESULTS_SUITE_TITLE); + $test_description = $xml_parser->getXMLValue(P_RESULTS_SUITE_DESCRIPTION); + $test_extensions = $xml_parser->getXMLValue(P_RESULTS_SUITE_EXTENSIONS); + $test_previous_properties = $xml_parser->getXMLValue(P_RESULTS_SUITE_PROPERTIES); + $test_version = $xml_parser->getXMLValue(P_RESULTS_SUITE_VERSION); + $test_type = $xml_parser->getXMLValue(P_RESULTS_SUITE_TYPE); + $TEST_RUN = $xml_parser->getXMLArrayValues(P_RESULTS_TEST_TESTNAME); + $TEST_ARGS = $xml_parser->getXMLArrayValues(P_RESULTS_TEST_ARGUMENTS); + $TEST_ARGS_DESCRIPTION = $xml_parser->getXMLArrayValues(P_RESULTS_TEST_ATTRIBUTES); + + pts_set_assignment_once("AUTO_SAVE_NAME", $to_run); + + foreach(explode(";", $test_previous_properties) as $test_prop) { - $results_xml = new tandem_XmlReader($raw_results[$i]); - array_push($result_identifiers, $results_xml->getXMLArrayValues(S_RESULTS_RESULTS_GROUP_IDENTIFIER)); + if(!in_array($test_prop, $TEST_PROPERTIES)) + { + array_push($TEST_PROPERTIES, $test_prop); + } } + + pts_module_process_extensions($test_extensions, $MODULE_STORE); } else { - $result_identifiers = array(); + echo pts_string_header("\nUnrecognized option: " . $to_run . "\n"); + break; } - $RESULTS_IDENTIFIER = pts_prompt_results_identifier($result_identifiers); - pts_set_assignment("SAVE_FILE_NAME", $PROPOSED_FILE_NAME); - } - else - { - pts_set_assignment("SAVE_FILE_NAME", null); - } - - if(pts_is_test($TO_RUN)) - { - if(!IS_BATCH_MODE) + for($i = 0; $i < count($TEST_ARGS) && $i < count($TEST_RUN); $i++) { - $option_output = pts_prompt_test_options($TO_RUN); + array_push($test_names_r, $TEST_RUN[$i]); - $TEST_RUN = array($TO_RUN); - $TEST_ARGS = array($option_output[0]); - $TEST_ARGS_DESCRIPTION = array($option_output[1]); - } - else - { - $option_output = pts_generate_batch_run_options($TO_RUN); + $argument = $TEST_ARGS[$i]; + array_push($test_arguments_r, $argument); - $TEST_RUN = array(); - $TEST_ARGS = $option_output[0]; - $TEST_ARGS_DESCRIPTION = $option_output[1]; - for($i = 0; $i < count($TEST_ARGS); $i++) + if(isset($TEST_ARGS_DESCRIPTION[$i])) { - array_push($TEST_RUN, $TO_RUN); + $argument = $TEST_ARGS_DESCRIPTION[$i]; } + array_push($test_arguments_description_r, $argument); } + } - if($SAVE_RESULTS) - { - $xml_parser = new pts_test_tandem_XmlReader(pts_location_test($TO_RUN)); - $test_description = $xml_parser->getXMLValue(P_TEST_DESCRIPTION); - $test_version = $xml_parser->getXMLValue(P_TEST_PTSVERSION); - $test_type = $xml_parser->getXMLValue(P_TEST_HARDWARE_TYPE); - unset($xml_parser); - } + if(count($to_run_identifiers) == 0 || count($test_names_r) == 0) + { + return false; } - else if(pts_is_suite($TO_RUN)) + $unique_test_names = count(array_unique($to_run_identifiers)); + + if($unique_test_names > 1) { - echo pts_string_header("Test Suite: " . $TO_RUN); + pts_set_assignment("MULTI_TYPE_RUN", true); + } - $xml_parser = new tandem_XmlReader(pts_location_suite($TO_RUN)); + $RESULTS = new tandem_XmlWriter(); - if($SAVE_RESULTS) + echo "\n"; + $save_results = false; + if(!pts_read_assignment("RUN_CONTAINS_A_NO_RESULT_TYPE") || $unique_test_names > 1) + { + if(pts_is_assignment("AUTO_SAVE_NAME") || getenv("TEST_RESULTS_NAME") != false) { - $test_description = $xml_parser->getXMLValue(P_SUITE_DESCRIPTION); - $test_version = $xml_parser->getXMLValue(P_SUITE_VERSION); - $test_type = $xml_parser->getXMLValue(P_SUITE_TYPE); + $save_results = true; } - - $TEST_RUN = $xml_parser->getXMLArrayValues(P_SUITE_TEST_NAME); - $TEST_ARGS = $xml_parser->getXMLArrayValues(P_SUITE_TEST_ARGUMENTS); - $TEST_ARGS_DESCRIPTION = $xml_parser->getXMLArrayValues(P_SUITE_TEST_DESCRIPTION); - - $SUITE_PRE_RUN_MESSAGE = $xml_parser->getXMLValue(P_SUITE_PRERUNMSG); - $SUITE_POST_RUN_MESSAGE = $xml_parser->getXMLValue(P_SUITE_POSTRUNMSG); - $SUITE_RUN_MODE = $xml_parser->getXMLValue(P_SUITE_RUNMODE); - - if($SUITE_RUN_MODE == "PCQS") + else { - pts_set_assignment("IS_PCQS_MODE", true); + $save_results = pts_bool_question("Would you like to save these test results (Y/n)?", true, "SAVE_RESULTS"); } - unset($xml_parser); - } - else if($SAVE_RESULTS && ($TO_RUN_TYPE == "GLOBAL_COMPARISON" || $TO_RUN_TYPE == "LOCAL_COMPARISON")) - { - echo pts_string_header("PTS Comparison: " . $TO_RUN); - - $xml_parser = new tandem_XmlReader(SAVE_RESULTS_DIR . $TO_RUN . "/composite.xml"); - $CUSTOM_TITLE = $xml_parser->getXMLValue(P_RESULTS_SUITE_TITLE); - $test_description = $xml_parser->getXMLValue(P_RESULTS_SUITE_DESCRIPTION); - $test_extensions = $xml_parser->getXMLValue(P_RESULTS_SUITE_EXTENSIONS); - $test_previous_properties = $xml_parser->getXMLValue(P_RESULTS_SUITE_PROPERTIES); - $test_version = $xml_parser->getXMLValue(P_RESULTS_SUITE_VERSION); - $test_type = $xml_parser->getXMLValue(P_RESULTS_SUITE_TYPE); - $TEST_RUN = $xml_parser->getXMLArrayValues(P_RESULTS_TEST_TESTNAME); - $TEST_ARGS = $xml_parser->getXMLArrayValues(P_RESULTS_TEST_ARGUMENTS); - $TEST_ARGS_DESCRIPTION = $xml_parser->getXMLArrayValues(P_RESULTS_TEST_ATTRIBUTES); - unset($xml_parser); - - foreach(explode(";", $test_previous_properties) as $test_prop) + if($save_results) { - if(!in_array($test_prop, $TEST_PROPERTIES)) + if($unique_test_names == 1 && ($ra = pts_read_assignment("AUTO_SAVE_NAME")) != false) { - array_push($TEST_PROPERTIES, $test_prop); + $auto_name = $ra; + } + else + { + $auto_name = null; } - } - pts_module_process_extensions($test_extensions, $MODULE_STORE); - } - else - { - echo pts_string_header("\nUnrecognized option: " . $TO_RUN_TYPE . "\n"); - return false; - } + // Prompt Save File Name + $file_name_result = pts_prompt_save_file_name($auto_name, $TEST_RUN[0]); + $PROPOSED_FILE_NAME = $file_name_result[0]; + $CUSTOM_TITLE = $file_name_result[1]; - if($SAVE_RESULTS && (!IS_BATCH_MODE || pts_read_user_config(P_OPTION_BATCH_PROMPTDESCRIPTION, "FALSE") == "TRUE")) - { - if(empty($test_description)) - { - $test_description = "N/A"; - } + // Prompt Identifiers + if(is_file(SAVE_RESULTS_DIR . $PROPOSED_FILE_NAME . "/composite.xml")) + { + $xml_parser = new tandem_XmlReader(SAVE_RESULTS_DIR . $PROPOSED_FILE_NAME . "/composite.xml"); + $raw_results = $xml_parser->getXMLArrayValues(P_RESULTS_RESULTS_GROUP); + $result_identifiers = array(); - echo pts_string_header("If you wish, enter a new description below.\nPress ENTER to proceed without changes.", "#"); - echo "Current Description: " . $test_description; - echo "\n\nNew Description: "; - $new_test_description = trim(fgets(STDIN)); + for($i = 0; $i < count($raw_results); $i++) + { + $results_xml = new tandem_XmlReader($raw_results[$i]); + array_push($result_identifiers, $results_xml->getXMLArrayValues(S_RESULTS_RESULTS_GROUP_IDENTIFIER)); + } + } + else + { + $result_identifiers = array(); + } - if(!empty($new_test_description)) - { - $test_description = $new_test_description; + $RESULTS_IDENTIFIER = pts_prompt_results_identifier($result_identifiers); + pts_set_assignment("SAVE_FILE_NAME", $PROPOSED_FILE_NAME); + + // Prompt Description + + if(!IS_BATCH_MODE || pts_read_user_config(P_OPTION_BATCH_PROMPTDESCRIPTION, "FALSE") == "TRUE") + { + if($unique_test_names > 1) + { + $unique_tests_r = array_unique($to_run_identifiers); + $last = array_pop($unique_tests_r); + array_push($unique_tests_r, "and " . $last); + + $test_description = "Running "; + + if($unique_test_names == 2) + { + $test_description .= implode(" ", $unique_tests_r); + } + else + { + $test_description .= implode(", ", $unique_tests_r); + } + $test_description .= "."; + } + if(empty($test_description)) + { + $test_description = "N/A"; + } + + echo pts_string_header("If you wish, enter a new description below.\nPress ENTER to proceed without changes.", "#"); + echo "Current Description: " . $test_description; + echo "\n\nNew Description: "; + $new_test_description = trim(fgets(STDIN)); + + if(!empty($new_test_description)) + { + $test_description = $new_test_description; + } + } + + if($unique_test_names > 1) + { + $test_version = "1.0.0"; + $test_type = "System"; + } } } - if(pts_is_suite($TO_RUN)) + if(!$save_results) { - pts_user_message($SUITE_PRE_RUN_MESSAGE); + $RESULTS_IDENTIFIER = ""; + $save_results = false; + pts_set_assignment("SAVE_FILE_NAME", null); } // Run the test process - pts_recurse_call_tests($TEST_RUN, $TEST_ARGS, $SAVE_RESULTS, $RESULTS, $RESULTS_IDENTIFIER, $TEST_ARGS_DESCRIPTION); + if(isset($PRE_RUN_MESSAGE)) + { + pts_user_message($PRE_RUN_MESSAGE); + } + + pts_recurse_call_tests($test_names_r, $test_arguments_r, $save_results, $RESULTS, $RESULTS_IDENTIFIER, $test_arguments_description_r); - if(pts_is_suite($TO_RUN)) + if(isset($POST_RUN_MESSAGE)) { - pts_user_message($SUITE_POST_RUN_MESSAGE); + pts_user_message($POST_RUN_MESSAGE); } pts_set_assignment("PTS_TESTING_DONE", 1); - pts_module_process("__post_run_process", $TEST_RUN); + pts_module_process("__post_run_process", $test_names_r); - if($SAVE_RESULTS) + if($save_results) { if(IS_BATCH_MODE) { @@ -347,7 +405,7 @@ class run_test implements pts_option_interface $id = pts_request_new_id(); $RESULTS->addXmlObject(P_RESULTS_SUITE_TITLE, $id, $CUSTOM_TITLE); - $RESULTS->addXmlObject(P_RESULTS_SUITE_NAME, $id, $TO_RUN); + $RESULTS->addXmlObject(P_RESULTS_SUITE_NAME, $id, pts_read_assignment("TO_RUN")); $RESULTS->addXmlObject(P_RESULTS_SUITE_VERSION, $id, $test_version); $RESULTS->addXmlObject(P_RESULTS_SUITE_DESCRIPTION, $id, $test_description); $RESULTS->addXmlObject(P_RESULTS_SUITE_TYPE, $id, $test_type); |