Debian Codegraph @

testsuite/systemtap.printf/memory1.exp

raw
1 set test "memory1"
2 set ::result_string {Test passed\r\n}
3
4 if {![installtest_p]} {
5 untested $test
6 return
7 }
8
9 set build_dir ""
10 set uname [exec /bin/uname -r]
11
12 proc build_and_install_module {} {
13 global build_dir
14 global srcdir subdir
15
16 # Create the build directory and populate it
17 if {[catch {exec mktemp -d staptestXXXXXX} build_dir]} {
18 verbose -log "Failed to create temporary directory: $build_dir"
19 return 0
20 }
21 exec cp $srcdir/$subdir/memory1_module.c $build_dir/
22 exec cp -p $srcdir/$subdir/memory1_module.Makefile $build_dir/Makefile
23
24 # Build the module
25 if {[catch {exec make -C $build_dir clean} res]} {
26 verbose -log "$res"
27 return 0
28 }
29 catch {exec make -C $build_dir} res
30 verbose -log "$res"
31 if {![file exists $build_dir/memory1_module.ko]} {
32 return 0
33 }
34 set res [as_root [list cp $build_dir/memory1_module.ko /lib/modules/$::uname/kernel/]]
35 if { $res != 0 } {
36 verbose -log "$res"
37 return 0
38 }
39
40 # Install the module
41 set res [as_root [list /sbin/insmod $build_dir/memory1_module.ko]]
42 if {$res != 0} {
43 verbose -log "$res"
44 return 0
45 }
46 return 1
47 }
48
49 proc cleanup_module {} {
50 global build_dir
51 as_root [list /bin/rm -f /lib/modules/$::uname/kernel/memory1_module.ko]
52 as_root [list /sbin/rmmod memory1_module]
53 if {$build_dir != ""} {
54 catch { exec rm -rf $build_dir }
55 }
56 }
57
58 proc memory1_load {} {
59 # Trigger the test module
60 if {[file exists /proc/stap_memory1_test]} {
61 exec echo Memory1Test > /proc/stap_memory1_test
62 return 0
63 } else {
64 return 1
65 }
66 }
67
68 if {[build_and_install_module] == 0} {
69 verbose -log "BUILD FAILED"
70 fail "$test (could not build/install module)"
71 return
72 } else {
73 pass "$test (built and installed module)"
74 }
75
76
77 # Note that we don't test other runtimes here since the script uses a
78 # kernel module
79 stap_run $test memory1_load $result_string $srcdir/$subdir/$test.stp
80 stap_run $test memory1_load $result_string -DSTP_LEGACY_PRINT $srcdir/$subdir/$test.stp
81
82 cleanup_module