Sha256: 72f3762361751709aca92e784d90c0974f79b58c33a9309d33abcd3cf9e9af91

Contents?: true

Size: 1.93 KB

Versions: 3

Compression:

Stored size: 1.93 KB

Contents

###########################################################
# tc_freebsd.rb
#
# Test suite for sys-cpu on FreeBSD.  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.exist?("sys")

   if File.exist?("cpu.so")
      File.copy("cpu.so","sys")
   else
      puts "No cpu.so 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_FreeBSD < Test::Unit::TestCase
   def test_architecture
      assert_respond_to(CPU, :architecture)
      assert_nothing_raised{ CPU.architecture }
      assert_kind_of(String,CPU.architecture)
      assert_raises(ArgumentError){ CPU.architecture(0) }
   end

   def test_cpu_freq
      assert_respond_to(CPU, :freq)
      assert_nothing_raised{ CPU.freq }
      assert_kind_of(Integer,CPU.freq)
      assert_raises(ArgumentError){ CPU.freq(0) }
   end

   def test_load_avg
      assert_respond_to(CPU, :load_avg)
      assert_nothing_raised{ CPU.load_avg }
      assert_kind_of(Array,CPU.load_avg)
      assert_equal(3,CPU.load_avg.length)
      assert_raises(ArgumentError){ CPU.load_avg(0) }
   end
   
   def test_machine
      assert_respond_to(CPU, :machine)
      assert_nothing_raised{ CPU.machine }
      assert_kind_of(String,CPU.machine)
      assert_raises(ArgumentError){ CPU.machine(0) }
   end

   def test_model
      assert_respond_to(CPU, :model)
      assert_nothing_raised{ CPU.model }
      assert_kind_of(String,CPU.model)
      assert_raises(ArgumentError){ CPU.model(0) }
   end

   def test_num_cpu
      assert_respond_to(CPU, :num_cpu)
      assert_nothing_raised{ CPU.num_cpu }
      assert_kind_of(Integer,CPU.num_cpu)
      assert_raises(ArgumentError){ CPU.num_cpu(0) }
   end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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