fork.tcl 811 B

12345678910111213141516171819202122232425262728293031
  1. set testmodule [file normalize tests/modules/fork.so]
  2. proc count_log_message {pattern} {
  3. set result [exec grep -c $pattern < [srv 0 stdout]]
  4. }
  5. start_server {tags {"modules"}} {
  6. r module load $testmodule
  7. test {Module fork} {
  8. # the argument to fork.create is the exitcode on termination
  9. r fork.create 3
  10. wait_for_condition 20 100 {
  11. [r fork.exitcode] != -1
  12. } else {
  13. fail "fork didn't terminate"
  14. }
  15. r fork.exitcode
  16. } {3}
  17. test {Module fork kill} {
  18. r fork.create 3
  19. after 250
  20. r fork.kill
  21. assert {[count_log_message "fork child started"] eq "2"}
  22. assert {[count_log_message "Received SIGUSR1 in child"] eq "1"}
  23. assert {[count_log_message "fork child exiting"] eq "1"}
  24. }
  25. }