| 1 |
set testlist {backtrace args pid num_args symfileline} |
| 2 |
|
| 3 |
if {![installtest_p]} { |
| 4 |
foreach test $testlist { |
| 5 |
untested $test |
| 6 |
} |
| 7 |
return |
| 8 |
} |
| 9 |
|
| 10 |
set build_dir "" |
| 11 |
|
| 12 |
proc cleanup_modules {} { |
| 13 |
global build_dir |
| 14 |
catch { kill -INT -[exp_pid] 2 } |
| 15 |
foreach n {1 2} { |
| 16 |
as_root [list /bin/rm -f /lib/modules/$::uname/kernel/systemtap_test_module$n.ko] |
| 17 |
as_root [list /sbin/rmmod systemtap_test_module$n] |
| 18 |
} |
| 19 |
if {$build_dir != ""} { |
| 20 |
catch { exec rm -rf $build_dir } |
| 21 |
} |
| 22 |
} |
| 23 |
|
| 24 |
proc build_modules {} { |
| 25 |
global build_dir |
| 26 |
global srcdir subdir |
| 27 |
|
| 28 |
# Create the build directory and populate it |
| 29 |
if {[catch {exec mktemp -d staptestXXXXXX} build_dir]} { |
| 30 |
verbose -log "Failed to create temporary directory: $build_dir" |
| 31 |
return 0 |
| 32 |
} |
| 33 |
foreach f [glob $srcdir/$subdir/systemtap_test_module*.c] { |
| 34 |
exec cp $f $build_dir/ |
| 35 |
} |
| 36 |
|
| 37 |
# Build the modules |
| 38 |
# -------------------- |
| 39 |
# Build both modules using a single makefile. This helps module1 |
| 40 |
# to see symbols exported by module2. |
| 41 |
exec cp -p $srcdir/$subdir/makefile1 $build_dir/Makefile |
| 42 |
if {[catch {exec make -C $build_dir clean} res]} { |
| 43 |
verbose -log "$res" |
| 44 |
return 0 |
| 45 |
} |
| 46 |
|
| 47 |
foreach n {2 1} { |
| 48 |
catch {exec make -C $build_dir} res |
| 49 |
if {![file exists $build_dir/systemtap_test_module$n.ko]} { |
| 50 |
verbose -log "$res" |
| 51 |
return 0 |
| 52 |
} |
| 53 |
set res [as_root [list cp $build_dir/systemtap_test_module$n.ko /lib/modules/$::uname/kernel]] |
| 54 |
if { $res != 0 } { |
| 55 |
verbose -log "$res" |
| 56 |
return 0 |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
# Install the modules |
| 61 |
foreach n {2 1} { |
| 62 |
set res [as_root [list /sbin/insmod $build_dir/systemtap_test_module$n.ko]] |
| 63 |
if {$res != 0} { |
| 64 |
verbose -log "$res" |
| 65 |
return 0 |
| 66 |
} |
| 67 |
} |
| 68 |
return 1 |
| 69 |
} |
| 70 |
|
| 71 |
# first build the modules |
| 72 |
|
| 73 |
# NB: We cannot "cd" on behalf the whole dejagnu process, especially |
| 74 |
# without going back to the build tree, and especially not to the |
| 75 |
# source tree expecting to be able to write there. |
| 76 |
# |
| 77 |
# cd $srcdir/$subdir |
| 78 |
|
| 79 |
set uname [exec /bin/uname -r] |
| 80 |
|
| 81 |
if {[build_modules] == 0} { |
| 82 |
verbose -log "BUILD FAILED" |
| 83 |
foreach test $testlist { |
| 84 |
fail "$test - could not build modules" |
| 85 |
} |
| 86 |
return |
| 87 |
} |
| 88 |
|
| 89 |
foreach test $testlist { |
| 90 |
send_log "sourcing: $srcdir/$subdir/$test.tcl\n" |
| 91 |
source $srcdir/$subdir/$test.tcl |
| 92 |
} |
| 93 |
|
| 94 |
cleanup_modules |