| 1 |
# cache.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 |
if [info exists env(SYSTEMTAP_DIR)] { |
| 9 |
set old_systemtap_dir $env(SYSTEMTAP_DIR) |
| 10 |
} |
| 11 |
set env(SYSTEMTAP_DIR) $local_systemtap_dir |
| 12 |
|
| 13 |
# Set up the scripts we'll use. |
| 14 |
set basic_script1 "\"probe begin { println(1) }\"" |
| 15 |
set basic_script2 "\"probe begin, end { println(2) }\"" |
| 16 |
set error_script "\"probe XbeginX { }\"" |
| 17 |
set var_script1 {{probe kernel.function("schedule_timeout") { println($jiffies) }}} |
| 18 |
|
| 19 |
# Check basic functionality. The 1st compilation of a script won't |
| 20 |
# be cached, the 2nd should be cached. |
| 21 |
cache_compile BASIC1 [F_UNCACHED_COMPILE] $basic_script1 |
| 22 |
cache_compile BASIC2 [F_CACHED_COMPILE] $basic_script1 |
| 23 |
|
| 24 |
# Adding in a macro definition should change the hash |
| 25 |
cache_compile OPTION1 [F_UNCACHED_COMPILE] $basic_script1 -DFOO=1 |
| 26 |
cache_compile OPTION2 [F_CACHED_COMPILE] $basic_script1 -DFOO=1 |
| 27 |
|
| 28 |
# Using '-b' (bulk/relayfs mode) should change the hash |
| 29 |
cache_compile BULK1 [F_UNCACHED_COMPILE] $basic_script1 -b |
| 30 |
cache_compile BULK2 [F_CACHED_COMPILE] $basic_script1 -b |
| 31 |
|
| 32 |
# Using '-t' (benchmark timing) should change the hash |
| 33 |
cache_compile TIMING1 [F_UNCACHED_COMPILE] $basic_script1 -t |
| 34 |
cache_compile TIMING2 [F_CACHED_COMPILE] $basic_script1 -t |
| 35 |
|
| 36 |
# Changing the runtime directory should change the hash |
| 37 |
set new_runtime [exec pwd]/.cache_test_runtime |
| 38 |
exec /bin/rm -f $new_runtime |
| 39 |
exec /bin/ln -s $env(SYSTEMTAP_RUNTIME) $new_runtime |
| 40 |
cache_compile RUNTIME1 [F_UNCACHED_COMPILE] $basic_script1 -R $new_runtime |
| 41 |
cache_compile RUNTIME2 [F_CACHED_COMPILE] $basic_script1 -R $new_runtime |
| 42 |
exec /bin/rm -f $new_runtime |
| 43 |
|
| 44 |
# Disable the cache with SYSTEMTAP_DIR |
| 45 |
set env(SYSTEMTAP_DIR) /dev/null |
| 46 |
cache_compile DISABLED1 [F_UNCACHED_COMPILE] $basic_script1 |
| 47 |
cache_compile DISABLED2 [F_UNCACHED_COMPILE] $basic_script1 |
| 48 |
set env(SYSTEMTAP_DIR) $local_systemtap_dir |
| 49 |
eval [list exec /bin/rm -f] [glob "stap_*.ko"] |
| 50 |
|
| 51 |
# Disable the cache with '-m' |
| 52 |
cache_compile MODNAM1 [F_UNCACHED_COMPILE] $basic_script1 -m modnam |
| 53 |
exec /bin/rm -f modnam.ko |
| 54 |
cache_compile MODNAM2 [F_UNCACHED_COMPILE] $basic_script1 -m modnam |
| 55 |
exec /bin/rm -f modnam.ko |
| 56 |
|
| 57 |
# Make sure scripts that don't actually compile don't get cached |
| 58 |
cache_compile ERROR1 [F_UNCACHED_NO_COMPILE] $error_script |
| 59 |
cache_compile ERROR2 [F_UNCACHED_NO_COMPILE] $error_script |
| 60 |
|
| 61 |
# Make sure basic stuff still works. |
| 62 |
cache_compile BASIC3 [F_UNCACHED_COMPILE] $basic_script2 |
| 63 |
cache_compile BASIC4 [F_CACHED_COMPILE] $basic_script2 |
| 64 |
|
| 65 |
# Make sure vardie_from_symtable caches correctly (PR18936) |
| 66 |
cache_compile VAR1 [F_UNCACHED_COMPILE] $var_script1 |
| 67 |
cache_compile VAR2 [F_CACHED_COMPILE] $var_script1 |
| 68 |
|
| 69 |
# Cleanup. |
| 70 |
exec /bin/rm -rf $local_systemtap_dir |
| 71 |
if [info exists old_systemtap_dir] { |
| 72 |
set env(SYSTEMTAP_DIR) $old_systemtap_dir |
| 73 |
} else { |
| 74 |
unset env(SYSTEMTAP_DIR) |
| 75 |
} |