######################################## # tc_linux.rb # # Test Suite for sys-cpu for Linux ######################################## base = File.basename(Dir.pwd) if base == "test" || base =~ /sys-cpu/ require "ftools" Dir.chdir ".." if base == "test" Dir.mkdir("sys") unless File.exists?("sys") File.copy("lib/sys/linux.rb","sys/cpu.rb") $LOAD_PATH.unshift Dir.pwd end require "sys/cpu" require "test/unit" include Sys class TC_Linux < Test::Unit::TestCase def test_all_dynamic_methods assert_nothing_raised{ CPU.processors{ |cs| cs.members.each{ |m| puts "#{m}: " + cs[m].to_s } } } end def test_load_avg assert_nothing_raised{ CPU.load_avg } assert_equal(3, CPU.load_avg.length) end def test_cpu_stats assert_nothing_raised{ CPU.cpu_stats } assert_kind_of(Hash, CPU.cpu_stats) assert_equal(true, CPU.cpu_stats["cpu0"].length >= 4) end end