projects / phoronix-test-suite.git / commitdiff
Build Results
 
Summary

Description: Phoronix Test Suite open-source benchmarking development
Last Change: Wed 7/23/14 10:50

Recent Commits
Time
Signed-Off By
Description
Commit Diff
Wed 7/23/14 10:50
Michael Larabel  
pts_webui: SERVER_ADDR... 
Fri 7/18/14 8:58
Michael Larabel  
pts-core: Sanitize... 
Fri 7/11/14 8:58
Michael Larabel  
Phoronix Test Suite 5.2.1... 
Sun 7/6/14 16:07
Michael Larabel  
phodevi: Add DDE / Deepin... 
Wed 6/25/14 10:04
Michael Larabel  
pts-core: Rework... 
Wed 6/25/14 9:25
Michael Larabel  
pts-core: Don't check... 
 
> --git a/pts-core/functions/pts-functions.php b/pts-core/functions/pts-functions.php
index 64bfe6f
..6da66d2 100644
--- a/pts-core/functions/pts-functions.php
+++ b/pts-core/functions/pts-functions.php
@@ -185,10 +185,@@ function pts_process_active($process)
 }
 function 
display_web_browser($URL)
 {
-    echo 
"Do you want to view the results in your web browser (Y/n)? ";
-    
$VIEW_RESULTS strtolower(trim(fgets(STDIN)));
+    
$view_results pts_bool_question("Do you want to view the results in your web browser (Y/n)?");

-    if(
$VIEW_RESULTS == "y")
+    if(
$view_results)
         
shell_exec("firefox $URL &");
 }
 function 
pts_env_variables()
@@ -
317,+316,23 @@ function pts_trim_double($double$accuracy 2)

     return 
$return;
 }
+function 
pts_bool_question($question$default true)
+{
+    do
+    {
+        echo 
$question " ";
+        
$input trim(strtolower(fgets(STDIN)));
+    }
+    while(
$input != "y" && $input != "n" && $input != "");
+
+    if(
$input == "y")
+        
$answer true;
+    else if(
$intput == "n")
+        
$answer false;
+    else
+        
$answer $default;
+
+    return 
$answer;
+}

 
?>
diff --git a/pts-core/pts-run-benchmark.php b/pts-core/pts-run-benchmark.php
index ad463b2..35c891e 100644
--- a/pts-core/pts-run-benchmark.php
+++ b/pts-core/pts-run-benchmark.php
@@ -74,23 +74,12 @@ if(!$TO_RUN_TYPE)
 }
 else
 {
-    echo "Would you like to save these benchmark results (Y/n)? ";
-    $SAVE_RESULTS = trim(fgets(STDIN));
+    $SAVE_RESULTS = pts_bool_question("Would you like to save these benchmark results (Y/n)?");

-    if(strtolower($SAVE_RESULTS) == "y")
-    {
-        $SAVE_RESULTS = true;
-    }
-    else if(strtolower($SAVE_RESULTS) == "n")
-    {
-        echo "Benchmark results will NOT be saved!\n";
-        $SAVE_RESULTS = false;
-    }
+    if($SAVE_RESULTS)
+        echo "Benchmark results will be saved.\n";
     else
-    {
-        echo "\nInput not understood. Results will not be saved.\n";
-        $SAVE_RESULTS = false;
-    }
+        echo "Benchmark results will NOT be saved!\n";

     if($SAVE_RESULTS)
     {
@@ -139,17 +128,18 @@ if($TO_RUN_TYPE == "BENCHMARK")
             $option_names = $xml_parser->getXMLArrayValues("Entry/Name");
             $option_values = $xml_parser->getXMLArrayValues("Entry/Value");

-            echo "\n";
-            for($i = 0; $i < count($option_names); $i++)
-            {
-                echo ($i + 1) . ": " . $option_names[$i] . "\n";
-            }
-
             do
             {
+                echo "\n";
+                for($i = 0; $i < count($option_names); $i++)
+                {
+                    echo ($i + 1) . ": " . $option_names[$i] . "\n";
+                }
                 echo "\nPlease Enter Your Choice: ";
                 $bench_choice = strtolower(trim(fgets(STDIN)));
-            }while($bench_choice < 1 || $bench_choice > count($option_names));
+            }
+            while($bench_choice < 1 || $bench_choice > count($option_names));
+
             $TEXT_ARGS .= "$settings_name[$option_count]: " . $option_names[($bench_choice - 1)];
             $USER_ARGS .= $settings_argument[$option_count] . $option_values[($bench_choice - 1)] . " ";

@@ -252,10 +242,9 @@ if($SAVE_RESULTS)
         echo "Results Saved To: " . SAVE_RESULTS_LOCATION . "$PROPOSED_FILE_NAME.xml\n";
         display_web_browser(SAVE_RESULTS_LOCATION . "$PROPOSED_FILE_NAME.xml");

-        echo "\nWould you like to upload these results to PTS Global (Y/n)? ";
-        $upload_results = strtolower(trim(fgets(STDIN)));
+        $upload_results = pts_bool_question("Would you like to upload these results to PTS Global (y/N)?", false);

-        if($upload_results == "y")
+        if($upload_results)
             echo "Results Uploaded To: " . pts_global_upload_result(SAVE_RESULTS_LOCATION . "$PROPOSED_FILE_NAME.xml") . "\n";

       
 
Phoronix.com
Linux Driver Forums
Copyright © 2014 by Phoronix Media