3 class TestSystemProcessCreation < Test::Unit::TestCase
4 def test_new_should_succeed_for_existing_pid
6 assert_nothing_raised do
7 @process = System::Process.new(pid)
12 class TestSystemProcess < Test::Unit::TestCase
15 @process = System::Process.new(pid)
18 def test_exists_should_return_true_for_running_process
19 assert_equal true, @process.exists?
22 def test_exists_should_return_false_for_non_existant_process
23 assert_equal false, System::Process.new(0).exists?
27 assert_kind_of Integer, @process.memory
28 assert @process.memory > 0
32 assert_kind_of Float, @process.percent_mem
36 assert_kind_of Float, @process.percent_cpu
40 assert_kind_of Integer, @process.cpu_time
43 def test_time_string_to_seconds
44 assert_equal 0, @process.bypass.time_string_to_seconds('0:00:00')
45 assert_equal 0, @process.bypass.time_string_to_seconds('0:00:55')
46 assert_equal 27, @process.bypass.time_string_to_seconds('0:27:32')
47 assert_equal 75, @process.bypass.time_string_to_seconds('1:15:13')
48 assert_equal 735, @process.bypass.time_string_to_seconds('12:15:13')