fork.tcl 896 B

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