5 GC.stress = true if ENV["GC_STRESS"].to_i != 0
7 unless defined?(LISTENER_DEFAULTS)
8 BEFORE_DELAY = ENV['BEFORE_DELAY'] ? ENV['BEFORE_DELAY'].to_f : 0.5
9 AFTER_DELAY = ENV['AFTER_DELAY'] ? ENV['AFTER_DELAY'].to_f : 0.5
11 :address => ENV["LWES_TEST_ADDRESS"] || "127.0.0.1",
12 :iface => ENV["LWES_TEST_IFACE"] || "0.0.0.0",
13 :port => ENV["LWES_TEST_PORT"] ? ENV["LWES_TEST_PORT"].to_i : 12345,
14 :ttl => 60, # nil for no ttl)
18 private_bin = "ext/lwes_ext/.inst/bin"
19 if File.directory? private_bin
20 ENV['PATH'] = "#{private_bin}:#{ENV['PATH']}"
23 def lwes_listener(&block)
24 cmd = "lwes-event-printing-listener" \
25 " -m #{@options[:address]}" \
26 " -i #{@options[:iface]}" \
27 " -p #{@options[:port]}"
28 out = Tempfile.new("out")
29 err = Tempfile.new("err")
33 $stdout.reopen(out.path)
34 $stderr.reopen(err.path)
38 # since everything executes asynchronously and our messaging,
39 # we need to ensure our listener is ready, then ensure our
40 # listener has printed something...
46 Process.kill(:TERM, pid)
48 assert_equal 0, err.size