about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/detach.ru11
-rwxr-xr-xt/t0021-process_detach.sh29
2 files changed, 40 insertions, 0 deletions
diff --git a/t/detach.ru b/t/detach.ru
new file mode 100644
index 0000000..bbd998e
--- /dev/null
+++ b/t/detach.ru
@@ -0,0 +1,11 @@
+use Rack::ContentType, "text/plain"
+fifo_path = ENV["TEST_FIFO"] or abort "TEST_FIFO not set"
+run lambda { |env|
+  pid = fork do
+    File.open(fifo_path, "wb") do |fp|
+      fp.write "HIHI"
+    end
+  end
+  Process.detach(pid)
+  [ 200, {}, [ pid.to_s ] ]
+}
diff --git a/t/t0021-process_detach.sh b/t/t0021-process_detach.sh
new file mode 100755
index 0000000..f03c497
--- /dev/null
+++ b/t/t0021-process_detach.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+. ./test-lib.sh
+
+t_plan 5 "Process.detach on forked background process works"
+
+t_begin "setup and startup" && {
+        t_fifos process_detach
+        unicorn_setup
+        TEST_FIFO=$process_detach \
+          unicorn -E none -D detach.ru -c $unicorn_config
+        unicorn_wait_start
+}
+
+t_begin "read detached PID with HTTP/1.0" && {
+        detached_pid=$(curl -0 -sSf http://$listen/)
+        t_info "detached_pid=$detached_pid"
+}
+
+t_begin "read background FIFO" && {
+        test xHIHI = x"$(cat $process_detach)"
+}
+
+t_begin "killing succeeds" && {
+        kill $unicorn_pid
+}
+
+t_begin "check stderr" && check_stderr
+
+t_done