test/test_BatchProcessor.rb in taskjuggler-3.0.0 vs test/test_BatchProcessor.rb in taskjuggler-3.1.0
- old
+ new
@@ -1,11 +1,11 @@
#!/usr/bin/env ruby -w
# encoding: UTF-8
#
# = test_BatchProcessor.rb -- The TaskJuggler III Project Management Software
#
-# Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011
+# Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011, 2012
# by Chris Schlaeger <chris@linux.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
@@ -17,10 +17,23 @@
require 'taskjuggler/BatchProcessor'
class TestProject < Test::Unit::TestCase
+ def setup
+ @t = Thread.new do
+ # Timout for the watchdog timer. Even slow hardware should finish each
+ # test in under 30s.
+ sleep(30)
+ assert(false, 'Test timed out')
+ end
+ end
+
+ def teardown
+ @t.kill
+ end
+
def test_simple
doRun(1, 1) { sleep 0.1 }
doRun(1, 2) { sleep 0.1 }
doRun(1, 7) { sleep 0.1 }
doRun(2, 1) { sleep 0.1 }
@@ -30,18 +43,18 @@
doRun(3, 3) { sleep 0.1 }
doRun(3, 67) { sleep 0.1 }
end
# This test case triggers a Ruby 1.9.x mutex bug
- #def test_fileIO
- # doRun(3, 200) do
- # fname = "test#{$$}.txt"
- # f = File.new(fname, 'w')
- # 0.upto(10000) { |i| f.puts "#{i} Hello, world!" }
- # f.close
- # File.delete(fname)
- # end
- #end
+ def test_fileIO
+ doRun(3, 80) do
+ fname = "test#{$$}.txt"
+ f = File.new(fname, 'w')
+ 0.upto(10000) { |i| f.puts "#{i} Hello, world!" }
+ f.close
+ File.delete(fname)
+ end
+ end
def doRun(maxCPUs, jobs, &block)
bp = TaskJuggler::BatchProcessor.new(maxCPUs)
jobs.times do |i|
bp.queue("job #{i}") { runJob(i, &block) }