| 1 |
set TEST_NAME "pr13158" |
| 2 |
if {![installtest_p]} { untested $TEST_NAME; return } |
| 3 |
|
| 4 |
# This is a section of the original rename_module.exp test that caused |
| 5 |
# the problem of a systemtap module sticking around to be found. That |
| 6 |
# test case bug found a real problem - that staprun didn't handle |
| 7 |
# SIGINT. |
| 8 |
|
| 9 |
########## Inserting 2 Identical Modules: Staprun without -R ################# |
| 10 |
# Should give an error when inserting 2 identical modules |
| 11 |
# when calling staprun directly without using -R |
| 12 |
|
| 13 |
set compile { exec stap -e {probe begin{printf("Hello\n");}} -p4 } |
| 14 |
set module_path [eval $compile] |
| 15 |
set module_name [file rootname [file tail $module_path]] |
| 16 |
|
| 17 |
spawn staprun $module_path |
| 18 |
set firstid $spawn_id |
| 19 |
|
| 20 |
# Make sure we get the output from the 1st copy of the module before |
| 21 |
# trying to load the 2nd copy of the module. |
| 22 |
set test "$TEST_NAME: Inserting 1st module" |
| 23 |
set output_seen 0 |
| 24 |
expect { |
| 25 |
-timeout 30 |
| 26 |
"Hello\r\n" { set output_seen 1 } |
| 27 |
timeout { fail "$test (timeout)" } |
| 28 |
} |
| 29 |
if {$output_seen} { |
| 30 |
pass "$test" |
| 31 |
} else { |
| 32 |
fail "$test" |
| 33 |
return |
| 34 |
} |
| 35 |
|
| 36 |
set test "$TEST_NAME: Inserting 2 Identical Modules: Staprun without -R" |
| 37 |
set failed 0 |
| 38 |
|
| 39 |
spawn staprun $module_path |
| 40 |
set secondid $spawn_id |
| 41 |
|
| 42 |
# Make sure it fails |
| 43 |
expect { |
| 44 |
-timeout 30 |
| 45 |
-re {^ERROR: Couldn't insert module .*: File exists\r\n} { |
| 46 |
exp_continue |
| 47 |
} |
| 48 |
-re {^ERROR: Rerun with staprun option '\-R' to rename this module.\r\n} { |
| 49 |
exp_continue |
| 50 |
} |
| 51 |
-re {^[^\r\n]*\r\n} { |
| 52 |
set failed 1 |
| 53 |
} |
| 54 |
timeout { fail "$test (timeout)" } |
| 55 |
} |
| 56 |
|
| 57 |
# Kill both of the hanging processes |
| 58 |
set firstpid [exp_pid -i $firstid] |
| 59 |
set secondpid [exp_pid -i $secondid] |
| 60 |
kill -INT $firstpid |
| 61 |
kill -INT $secondpid |
| 62 |
catch { close -i $firstid }; catch { wait -i $firstid }; |
| 63 |
catch { close -i $secondid }; catch { wait -i $secondid } |
| 64 |
if {$failed} { |
| 65 |
fail "$test" |
| 66 |
} else { |
| 67 |
pass "$test" |
| 68 |
} |
| 69 |
|
| 70 |
# Is the module still loaded? |
| 71 |
if {[catch { exec lsmod | grep -q $module_name }]} { |
| 72 |
pass "$TEST_NAME: module was correctly removed" |
| 73 |
} else { |
| 74 |
fail "$TEST_NAME: module is still loaded!" |
| 75 |
catch {exec staprun -d $module_name} |
| 76 |
} |