diff --git a/mysql-test/include/not_as_root.inc b/mysql-test/include/not_as_root.inc new file mode 100644 index 00000000000..315963d824e --- /dev/null +++ b/mysql-test/include/not_as_root.inc @@ -0,0 +1,4 @@ +-- require r/not_as_root.require +disable_query_log; +select $MYSQL_TEST_ROOT as running_as_root; +enable_query_log; diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index a045441e046..9a801884855 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -338,6 +338,7 @@ sub environment_setup (); sub kill_running_server (); sub kill_and_cleanup (); sub check_ssl_support (); +sub check_running_as_root(); sub check_ndbcluster_support (); sub ndbcluster_install (); sub ndbcluster_start ($); @@ -376,6 +377,7 @@ sub main () { check_ndbcluster_support(); check_ssl_support(); + check_running_as_root(); environment_setup(); signal_setup(); @@ -1337,6 +1339,33 @@ sub kill_and_cleanup () { } +sub check_running_as_root () { + # Check if running as root + # i.e a file can be read regardless what mode we set it to + my $test_file= "test_running_as_root.txt"; + mtr_tofile($test_file, "MySQL"); + chmod(oct("0000"), $test_file); + + my $result=""; + if (open(FILE,"<",$test_file)) + { + $result= join('', ); + close FILE; + } + + chmod(oct("0755"), $test_file); + unlink($test_file); + + $ENV{'MYSQL_TEST_ROOT'}= "NO"; + if ($result eq "MySQL") + { + mtr_warning("running this script as _root_ will cause some " . + "tests to be skipped"); + $ENV{'MYSQL_TEST_ROOT'}= "YES"; + } +} + + sub check_ssl_support () { diff --git a/mysql-test/r/not_as_root.require b/mysql-test/r/not_as_root.require new file mode 100644 index 00000000000..d9ea5244efc --- /dev/null +++ b/mysql-test/r/not_as_root.require @@ -0,0 +1,2 @@ +running_as_root +NO diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 47f262a9d59..90b0fd95eee 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -1,6 +1,9 @@ # This test uses grants, which can't get tested for embedded server -- source include/not_embedded.inc +# This test uses chmod, can't be run with root permissions +-- source include/not_as_root.inc + # Test for information_schema.schemata & # show databases diff --git a/mysql-test/t/rpl_rotate_logs.test b/mysql-test/t/rpl_rotate_logs.test index 77a8fb7d9a4..ee49f92910a 100644 --- a/mysql-test/t/rpl_rotate_logs.test +++ b/mysql-test/t/rpl_rotate_logs.test @@ -1,3 +1,6 @@ +# This test uses chmod, can't be run with root permissions +-- source include/not_as_root.inc + # # Test is run with max_binlog_size=2048 to force automatic rotation of the # binary log