tests: add check_skip_kernel_test to check root user and lttng kernel modules
[lttng-tools.git] / tests / destructive / metadata-regeneration
index a8b57633f7b73b4b9198fc8568dcdd9c246b805c..dcae6bce0dfb901f318bd26bdc8012f0e7d51cc3 100755 (executable)
@@ -18,7 +18,7 @@ TESTDIR=$CURDIR/..
 NUM_TESTS=44
 SESSION_NAME="regen"
 KERNEL_EVENT_NAME="lttng_test_filter_event"
-TRACE_PATH=$(mktemp --tmpdir -d -t tmp.metadata_regen_after_data_change.XXXXXX)
+TRACE_PATH=$(mktemp -d -t tmp.metadata_regen_after_data_change.XXXXXX)
 
 TESTAPP_PATH="$TESTDIR/utils/testapp"
 TESTAPP_NAME="gen-ust-events"
@@ -110,8 +110,8 @@ function test_ust_local ()
        local file_sync_after_first
        local file_sync_before_last
 
-       file_sync_after_first=$(mktemp --tmpdir -u -t "tmp.${FUNCNAME[0]}_sync_after_first.XXXXXX")
-       file_sync_before_last=$(mktemp --tmpdir -u -t "tmp.${FUNCNAME[0]}_sync_before_last.XXXXXX")
+       file_sync_after_first=$(mktemp -u -t "tmp.${FUNCNAME[0]}_sync_after_first.XXXXXX")
+       file_sync_before_last=$(mktemp -u -t "tmp.${FUNCNAME[0]}_sync_before_last.XXXXXX")
 
        diag "Test UST local with metadata regeneration"
        date "+%Y-%m-%d %H:%M" -s "$DATE1 $HOUR" >/dev/null
@@ -151,8 +151,8 @@ function test_ust_streaming ()
        local file_sync_after_first
        local file_sync_before_last
 
-       file_sync_after_first=$(mktemp --tmpdir -u -t "tmp.${FUNCNAME[0]}_sync_after_first.XXXXXX")
-       file_sync_before_last=$(mktemp --tmpdir -u -t "tmp.${FUNCNAME[0]}_sync_before_last.XXXXXX")
+       file_sync_after_first=$(mktemp -u -t "tmp.${FUNCNAME[0]}_sync_after_first.XXXXXX")
+       file_sync_before_last=$(mktemp -u -t "tmp.${FUNCNAME[0]}_sync_before_last.XXXXXX")
 
        diag "Test UST streaming with metadata regeneration"
        date "+%Y-%m-%d %H:%M" -s "$DATE1 $HOUR" >/dev/null
@@ -189,12 +189,6 @@ function test_ust_streaming ()
        rm -f "${file_sync_before_last}"
 }
 
-if [ "$(id -u)" == "0" ]; then
-       isroot=1
-else
-       isroot=0
-fi
-
 if ! destructive_tests_enabled ; then
        echo 'Please make sure that ntp is not running while executing this test'
        skip 0 "You need to set the LTTNG_ENABLE_DESTRUCTIVE_TESTS environment variable to \"will-break-my-system\" to run this test" $NUM_TESTS
@@ -202,8 +196,9 @@ if ! destructive_tests_enabled ; then
        exit 0
 fi
 
-skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
+check_skip_kernel_test $NUM_TESTS "Skipping all tests." ||
 {
+       original_date=$(date)
        start_lttng_relayd "-o $TRACE_PATH"
        start_lttng_sessiond
 
@@ -217,4 +212,11 @@ skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
 
        stop_lttng_sessiond
        stop_lttng_relayd
+
+       # This set of test sets the date in the past which causes
+       # `make` to panic when it sees files created in the "future"
+       # while running the "check" target. Obviously this doesn't set
+       # the correct date, but at least its close enough to allow the
+       # test suite to continue.
+       date --set "$original_date"
 }
This page took 0.023983 seconds and 4 git commands to generate.