summaryrefslogtreecommitdiffstats
path: root/pts-core
diff options
context:
space:
mode:
authorMichael Larabel <michael@phx-laptop.(none)>2008-11-20 22:03:34 -0500
committerMichael Larabel <michael@phx-laptop.(none)>2008-11-20 22:03:34 -0500
commitd100fa6b0f19cb257bb4667543851a815b114fc2 (patch)
tree537952580eab2bd418cb79142f3fd54e779c8a93 /pts-core
parentb4bc4d902cc65d39dda6ceaa4b4bdd7543579e1e (diff)
downloadphoronix-test-suite-upstream-d100fa6b0f19cb257bb4667543851a815b114fc2.tar.gz
phoronix-test-suite-upstream-d100fa6b0f19cb257bb4667543851a815b114fc2.tar.xz
phoronix-test-suite-upstream-d100fa6b0f19cb257bb4667543851a815b114fc2.zip
pts-core: Implement RequiresRoot tag that has been part of the PTS test
profile specification for some time
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