File: cache_clean.exp

package info (click to toggle)
systemtap 5.1-5
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 47,964 kB
  • sloc: cpp: 80,838; ansic: 54,757; xml: 49,725; exp: 43,665; sh: 11,527; python: 5,003; perl: 2,252; tcl: 1,312; makefile: 1,006; javascript: 149; lisp: 105; awk: 101; asm: 91; java: 70; sed: 16
file content (63 lines) | stat: -rw-r--r-- 2,044 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# cache_clean.exp

# Since we need a clean cache directory, we'll use a temporary
# systemtap directory and cache (add user name so make check and
# sudo make installcheck don't clobber each others)
set local_systemtap_dir [exec pwd]/.cache_test-[exec whoami]
exec /bin/rm -rf $local_systemtap_dir
exec /bin/mkdir $local_systemtap_dir
exec /bin/mkdir $local_systemtap_dir/cache

if [info exists env(SYSTEMTAP_DIR)] {
    set old_systemtap_dir $env(SYSTEMTAP_DIR)
}
set env(SYSTEMTAP_DIR) $local_systemtap_dir

# Set up the scripts we'll use.
set script1 "\"probe begin {println(1)}\""
set script2 "\"probe begin {println(2)}\""

#Set a high interval, so we can make sure that the cache isn't cleaned
exec /bin/echo 100000 > $local_systemtap_dir/cache/cache_clean_interval_s

# Make sure the cache isn't cleaned when it hasn't passed the interval
set test "cache_clean"
set cmd [concat {stap -vv -p4 -e} $script1]
eval spawn $cmd
set cleaned -1
expect {
  -timeout 180
  -re {^Cleaning cache, interval reached [^\r\n]*\r\n} {fail "$test premature cleaning"}
  -re {^Cache cleaning skipped, interval not reached [^\r\n]*\r\n} {pass "$test premature cleaning"}
  -re {^[^\r\n]*\r\n} {exp_continue}

  timeout { fail "$test (timeout)" }
}
catch { close }; catch { wait }

# Set a small interval to insure the next stap call cleans the cache
exec /bin/echo 1 > $local_systemtap_dir/cache/cache_clean_interval_s
sleep 1

# Make sure the cache is cleaned when it has passed the interval
set cmd [concat {stap -vv -p4 -e} $script2]
eval spawn $cmd
set cleaned -1
expect {
  -timeout 180
  -re {^Cleaning cache, interval reached [^\r\n]*\r\n} {pass "$test timed cleaning"}
  -re {^Cache cleaning skipped, interval not reached [^\r\n]*\r\n} {fail "$test timed cleaning"}
  -re {^[^\r\n]*\r\n} {exp_continue}

  timeout { fail "$test (timeout)" }
}
catch { close }; catch { wait }

# Cleanup.
exec /bin/rm -rf $local_systemtap_dir
if [info exists old_systemtap_dir] {
    set env(SYSTEMTAP_DIR) $old_systemtap_dir
} else {
    unset env(SYSTEMTAP_DIR)
}