| 1 |
# cache_clean.exp |
| 2 |
|
| 3 |
# Since we need a clean cache directory, we'll use a temporary |
| 4 |
# systemtap directory and cache (add user name so make check and |
| 5 |
# sudo make installcheck don't clobber each others) |
| 6 |
set local_systemtap_dir [exec pwd]/.cache_test-[exec whoami] |
| 7 |
exec /bin/rm -rf $local_systemtap_dir |
| 8 |
exec /bin/mkdir $local_systemtap_dir |
| 9 |
exec /bin/mkdir $local_systemtap_dir/cache |
| 10 |
|
| 11 |
if [info exists env(SYSTEMTAP_DIR)] { |
| 12 |
set old_systemtap_dir $env(SYSTEMTAP_DIR) |
| 13 |
} |
| 14 |
set env(SYSTEMTAP_DIR) $local_systemtap_dir |
| 15 |
|
| 16 |
# Set up the scripts we'll use. |
| 17 |
set script1 "\"probe begin {println(1)}\"" |
| 18 |
set script2 "\"probe begin {println(2)}\"" |
| 19 |
|
| 20 |
#Set a high interval, so we can make sure that the cache isn't cleaned |
| 21 |
exec /bin/echo 100000 > $local_systemtap_dir/cache/cache_clean_interval_s |
| 22 |
|
| 23 |
# Make sure the cache isn't cleaned when it hasn't passed the interval |
| 24 |
set test "cache_clean" |
| 25 |
set cmd [concat {stap -vv -p4 -e} $script1] |
| 26 |
eval spawn $cmd |
| 27 |
set cleaned -1 |
| 28 |
expect { |
| 29 |
-timeout 180 |
| 30 |
-re {^Cleaning cache, interval reached [^\r\n]*\r\n} {fail "$test premature cleaning"} |
| 31 |
-re {^Cache cleaning skipped, interval not reached [^\r\n]*\r\n} {pass "$test premature cleaning"} |
| 32 |
-re {^[^\r\n]*\r\n} {exp_continue} |
| 33 |
|
| 34 |
timeout { fail "$test (timeout)" } |
| 35 |
} |
| 36 |
catch { close }; catch { wait } |
| 37 |
|
| 38 |
# Set a small interval to insure the next stap call cleans the cache |
| 39 |
exec /bin/echo 1 > $local_systemtap_dir/cache/cache_clean_interval_s |
| 40 |
sleep 1 |
| 41 |
|
| 42 |
# Make sure the cache is cleaned when it has passed the interval |
| 43 |
set cmd [concat {stap -vv -p4 -e} $script2] |
| 44 |
eval spawn $cmd |
| 45 |
set cleaned -1 |
| 46 |
expect { |
| 47 |
-timeout 180 |
| 48 |
-re {^Cleaning cache, interval reached [^\r\n]*\r\n} {pass "$test timed cleaning"} |
| 49 |
-re {^Cache cleaning skipped, interval not reached [^\r\n]*\r\n} {fail "$test timed cleaning"} |
| 50 |
-re {^[^\r\n]*\r\n} {exp_continue} |
| 51 |
|
| 52 |
timeout { fail "$test (timeout)" } |
| 53 |
} |
| 54 |
catch { close }; catch { wait } |
| 55 |
|
| 56 |
# Cleanup. |
| 57 |
exec /bin/rm -rf $local_systemtap_dir |
| 58 |
if [info exists old_systemtap_dir] { |
| 59 |
set env(SYSTEMTAP_DIR) $old_systemtap_dir |
| 60 |
} else { |
| 61 |
unset env(SYSTEMTAP_DIR) |
| 62 |
} |
| 63 |
|