File: signals.rb

package info (click to toggle)
ruby-curb 0.8.6-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 604 kB
  • ctags: 880
  • sloc: ansic: 4,242; ruby: 2,768; makefile: 3
file content (33 lines) | stat: -rw-r--r-- 776 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))

# This test suite requires the timeout server to be running
# See tests/timeout.rb for more info about the timeout server
class TestCurbSignals < Test::Unit::TestCase

  # Testcase for https://github.com/taf2/curb/issues/117
  def test_continue_after_signal
    trap("SIGUSR1") { }

    curl = Curl::Easy.new(wait_url(2))
    pid = $$
    Thread.new do
      sleep 1
      Process.kill("SIGUSR1", pid)
    end
    assert_equal true, curl.http_get
  end

  private
  
  def wait_url(time)
    "#{server_base}/wait/#{time}"
  end
  
  def serve_url(chunk_size, time, count)
    "#{server_base}/serve/#{chunk_size}/every/#{time}/for/#{count}"
  end
  
  def server_base
    'http://127.0.0.1:9128'
  end
end