Sha256: 2ff64f65d9bf3088d5f570b2d0dc0b909c81fc6e70b1155403bb6f5a351c4ee1

Contents?: true

Size: 1.91 KB

Versions: 3

Compression:

Stored size: 1.91 KB

Contents

####################################################
# tc_hpux.rb
#
# Test suite for the HP-UX platform.  Note that this should only
# be run *after* the make process.
####################################################
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")
   if File.exist?("cpu.sl")
      File.copy("cpu.sl","sys")
   else
      puts "No cpu.sl file found.  Please run extconf.rb and make first"
      exit
   end
   $LOAD_PATH.unshift Dir.pwd
end

require "sys/cpu"
require "test/unit"
include Sys

class TC_HPUX < Test::Unit::TestCase
   def test_cpu_freq
      assert_respond_to(CPU, :freq)
      assert_nothing_raised{ CPU.freq }
      assert_nothing_raised{ CPU.freq(0) }
      assert_kind_of(Integer,CPU.freq,"Invalid Type")
   end

   def test_num_cpu
      assert_respond_to(CPU, :num_cpu)
      assert_nothing_raised{ CPU.num_cpu }
      assert_kind_of(Integer,CPU.num_cpu,"Invalid Type")
   end

   def test_num_active_cpu
      assert_respond_to(CPU, :num_active_cpu)
      assert_nothing_raised{ CPU.num_active_cpu }
      assert_kind_of(Integer,CPU.num_active_cpu,"Invalid Type")
   end

   def test_cpu_architecture
      assert_respond_to(CPU, :architecture)
      assert_nothing_raised{ CPU.architecture }
      assert_kind_of(String,CPU.architecture,"Invalid Type")
   end

   def test_load_avg
      assert_respond_to(CPU, :load_avg)
      assert_nothing_raised{ CPU.load_avg }
      assert_nothing_raised{ CPU.load_avg(0) }
      assert_nothing_raised{ CPU.load_avg{ |e| } }
      assert_raises(ArgumentError){ CPU.load_avg(0){ } }
      assert_kind_of(Array,CPU.load_avg,"Invalid Type")
      assert_kind_of(Array,CPU.load_avg(0),"Invalid Type")
      assert_equal(3,CPU.load_avg.length,"Bad number of elements") 
      assert_equal(3,CPU.load_avg(0).length,"Bad number of elements")
   end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sys-cpu-0.5.5-i586-linux test/tc_hpux.rb
sys-cpu-0.5.5 test/tc_hpux.rb
sys-cpu-0.5.4 test/tc_hpux.rb