summaryrefslogtreecommitdiffstats
path: root/pts-core
diff options
context:
space:
mode:
Diffstat (limited to 'pts-core')
-rw-r--r--pts-core/functions/pts-functions-run.php15
-rwxr-xr-xpts-core/test-libraries/root-access.sh22
2 files changed, 36 insertions, 1 deletions
diff --git a/pts-core/functions/pts-functions-run.php b/pts-core/functions/pts-functions-run.php
index a1caa36..cff7971 100644
--- a/pts-core/functions/pts-functions-run.php
+++ b/pts-core/functions/pts-functions-run.php
@@ -449,6 +449,7 @@ function pts_run_test($test_identifier, $extra_arguments = "", $arguments_descri
$execute_path = $xml_parser->getXMLValue(P_TEST_POSSIBLEPATHS);
$default_arguments = $xml_parser->getXMLValue(P_TEST_DEFAULTARGUMENTS);
$test_type = $xml_parser->getXMLValue(P_TEST_HARDWARE_TYPE);
+ $root_required = $xml_parser->getXMLValue(P_TEST_ROOTNEEDED) == "TRUE";
if(($test_type == "Graphics" && getenv("DISPLAY") == false) || getenv("NO_" . strtoupper($test_type) . "_TESTS") != false)
{
@@ -522,6 +523,18 @@ function pts_run_test($test_identifier, $extra_arguments = "", $arguments_descri
$runtime_identifier = pts_unique_runtime_identifier();
+ $execute_binary_prepend = "";
+
+ if($root_required)
+ {
+ $execute_binary_prepend = TEST_LIBRARIES_DIR . "root-access.sh";
+ }
+
+ if(!empty($execute_binary_prepend))
+ {
+ $execute_binary_prepend .= " ";
+ }
+
for($i = 0; $i < $times_to_run; $i++)
{
$benchmark_log_file = TEST_ENV_DIR . $test_identifier . "/" . $test_identifier . "-" . $runtime_identifier . "-" . ($i + 1) . ".log";
@@ -533,7 +546,7 @@ function pts_run_test($test_identifier, $extra_arguments = "", $arguments_descri
echo pts_string_header($test_title . " (Run " . ($i + 1) . " of " . $times_to_run . ")");
$result_output = array();
- echo $test_results = pts_exec("cd " . $to_execute . " && ./" . $execute_binary . " " . $pts_test_arguments, $test_extra_runtime_variables);
+ echo $test_results = pts_exec("cd " . $to_execute . " && " . $execute_binary_prepend . "./" . $execute_binary . " " . $pts_test_arguments, $test_extra_runtime_variables);
if(is_file($benchmark_log_file) && trim($test_results) == "")
{
diff --git a/pts-core/test-libraries/root-access.sh b/pts-core/test-libraries/root-access.sh
new file mode 100755
index 0000000..c662596
--- /dev/null
+++ b/pts-core/test-libraries/root-access.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+if [ `whoami` != "root" ]; then
+ if [ -x /usr/bin/gksudo ] && [ ! -z "$DISPLAY" ]; then
+ ROOT="/usr/bin/gksudo --preserve-env"
+ elif [ -x /usr/bin/kdesu ] && [ ! -z "$DISPLAY" ]; then
+ ROOT="/usr/bin/kdesu"
+ elif [ -x /usr/bin/sudo ]; then
+ ROOT="/usr/bin/sudo"
+ fi
+else
+ ROOT=""
+fi
+
+TMPRUN=`mktemp`
+
+echo "#!/bin/sh\n\n$@" > $TMPRUN
+chmod +x $TMPRUN
+
+echo "\nThis test requires root access to run.\n" 1>&2
+$ROOT $TMPRUN
+rm -f $TMPRUN