1 require File.dirname(__FILE__) + '/helper'
3 class TestSystemProcess < Test::Unit::TestCase
6 @process = System::Process.new(pid)
9 def test_exists_should_return_true_for_running_process
10 assert_equal true, @process.exists?
13 def test_exists_should_return_false_for_non_existant_process
14 assert_equal false, System::Process.new(9999999).exists?
18 assert_kind_of Integer, @process.memory
19 assert @process.memory > 0
22 def test_percent_memory
23 assert_kind_of Float, @process.percent_memory
27 assert_kind_of Float, @process.percent_cpu
31 assert_kind_of Integer, @process.cpu_time
34 def test_time_string_to_seconds
35 assert_equal 0, @process.bypass.time_string_to_seconds('0:00:00')
36 assert_equal 0, @process.bypass.time_string_to_seconds('0:00:55')
37 assert_equal 27, @process.bypass.time_string_to_seconds('0:27:32')
38 assert_equal 75, @process.bypass.time_string_to_seconds('1:15:13')
39 assert_equal 735, @process.bypass.time_string_to_seconds('12:15:13')