sys-cpu 0.5.4-mswin32

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,71 @@
1
+ ###########################################################
2
+ # tc_freebsd.rb
3
+ #
4
+ # Test suite for sys-cpu on FreeBSD. This should only be
5
+ # run *after* the make process.
6
+ ###########################################################
7
+ base = File.basename(Dir.pwd)
8
+ if base == "test" || base =~ /sys-cpu/
9
+ require "ftools"
10
+ Dir.chdir ".." if base == "test"
11
+
12
+ Dir.mkdir("sys") unless File.exist?("sys")
13
+
14
+ if File.exist?("cpu.so")
15
+ File.copy("cpu.so","sys")
16
+ else
17
+ puts "No cpu.so file found. Please run extconf.rb and make first"
18
+ exit
19
+ end
20
+
21
+ $LOAD_PATH.unshift Dir.pwd
22
+ end
23
+
24
+ require "sys/cpu"
25
+ require "test/unit"
26
+ include Sys
27
+
28
+ class TC_FreeBSD < Test::Unit::TestCase
29
+ def test_architecture
30
+ assert_respond_to(CPU, :architecture)
31
+ assert_nothing_raised{ CPU.architecture }
32
+ assert_kind_of(String,CPU.architecture)
33
+ assert_raises(ArgumentError){ CPU.architecture(0) }
34
+ end
35
+
36
+ def test_cpu_freq
37
+ assert_respond_to(CPU, :freq)
38
+ assert_nothing_raised{ CPU.freq }
39
+ assert_kind_of(Integer,CPU.freq)
40
+ assert_raises(ArgumentError){ CPU.freq(0) }
41
+ end
42
+
43
+ def test_load_avg
44
+ assert_respond_to(CPU, :load_avg)
45
+ assert_nothing_raised{ CPU.load_avg }
46
+ assert_kind_of(Array,CPU.load_avg)
47
+ assert_equal(3,CPU.load_avg.length)
48
+ assert_raises(ArgumentError){ CPU.load_avg(0) }
49
+ end
50
+
51
+ def test_machine
52
+ assert_respond_to(CPU, :machine)
53
+ assert_nothing_raised{ CPU.machine }
54
+ assert_kind_of(String,CPU.machine)
55
+ assert_raises(ArgumentError){ CPU.machine(0) }
56
+ end
57
+
58
+ def test_model
59
+ assert_respond_to(CPU, :model)
60
+ assert_nothing_raised{ CPU.model }
61
+ assert_kind_of(String,CPU.model)
62
+ assert_raises(ArgumentError){ CPU.model(0) }
63
+ end
64
+
65
+ def test_num_cpu
66
+ assert_respond_to(CPU, :num_cpu)
67
+ assert_nothing_raised{ CPU.num_cpu }
68
+ assert_kind_of(Integer,CPU.num_cpu)
69
+ assert_raises(ArgumentError){ CPU.num_cpu(0) }
70
+ end
71
+ end
data/test/tc_hpux.rb ADDED
@@ -0,0 +1,63 @@
1
+ ####################################################
2
+ # tc_hpux.rb
3
+ #
4
+ # Test suite for the HP-UX platform. Note that this should only
5
+ # be run *after* the make process.
6
+ ####################################################
7
+ base = File.basename(Dir.pwd)
8
+ if base == "test" || base =~ /sys-cpu/
9
+ require "ftools"
10
+ Dir.chdir ".." if base == "test"
11
+
12
+ Dir.mkdir("sys") unless File.exists?("sys")
13
+ if File.exist?("cpu.sl")
14
+ File.copy("cpu.sl","sys")
15
+ else
16
+ puts "No cpu.sl file found. Please run extconf.rb and make first"
17
+ exit
18
+ end
19
+ $LOAD_PATH.unshift Dir.pwd
20
+ end
21
+
22
+ require "sys/cpu"
23
+ require "test/unit"
24
+ include Sys
25
+
26
+ class TC_HPUX < Test::Unit::TestCase
27
+ def test_cpu_freq
28
+ assert_respond_to(CPU, :freq)
29
+ assert_nothing_raised{ CPU.freq }
30
+ assert_nothing_raised{ CPU.freq(0) }
31
+ assert_kind_of(Integer,CPU.freq,"Invalid Type")
32
+ end
33
+
34
+ def test_num_cpu
35
+ assert_respond_to(CPU, :num_cpu)
36
+ assert_nothing_raised{ CPU.num_cpu }
37
+ assert_kind_of(Integer,CPU.num_cpu,"Invalid Type")
38
+ end
39
+
40
+ def test_num_active_cpu
41
+ assert_respond_to(CPU, :num_active_cpu)
42
+ assert_nothing_raised{ CPU.num_active_cpu }
43
+ assert_kind_of(Integer,CPU.num_active_cpu,"Invalid Type")
44
+ end
45
+
46
+ def test_cpu_architecture
47
+ assert_respond_to(CPU, :architecture)
48
+ assert_nothing_raised{ CPU.architecture }
49
+ assert_kind_of(String,CPU.architecture,"Invalid Type")
50
+ end
51
+
52
+ def test_load_avg
53
+ assert_respond_to(CPU, :load_avg)
54
+ assert_nothing_raised{ CPU.load_avg }
55
+ assert_nothing_raised{ CPU.load_avg(0) }
56
+ assert_nothing_raised{ CPU.load_avg{ |e| } }
57
+ assert_raises(ArgumentError){ CPU.load_avg(0){ } }
58
+ assert_kind_of(Array,CPU.load_avg,"Invalid Type")
59
+ assert_kind_of(Array,CPU.load_avg(0),"Invalid Type")
60
+ assert_equal(3,CPU.load_avg.length,"Bad number of elements")
61
+ assert_equal(3,CPU.load_avg(0).length,"Bad number of elements")
62
+ end
63
+ end
data/test/tc_linux.rb ADDED
@@ -0,0 +1,41 @@
1
+ ########################################
2
+ # tc_linux.rb
3
+ #
4
+ # Test Suite for sys-cpu for Linux
5
+ ########################################
6
+ base = File.basename(Dir.pwd)
7
+ if base == "test" || base =~ /sys-cpu/
8
+ require "ftools"
9
+ Dir.chdir ".." if base == "test"
10
+ Dir.mkdir("sys") unless File.exists?("sys")
11
+ File.copy("lib/os/linux.rb","sys/cpu.rb")
12
+ $LOAD_PATH.unshift Dir.pwd
13
+ end
14
+
15
+ require "sys/cpu"
16
+ require "test/unit"
17
+ include Sys
18
+
19
+ class TC_Linux < Test::Unit::TestCase
20
+ def test_all_dynamic_methods
21
+ assert_nothing_raised{
22
+ CPU.processors{ |cs|
23
+ cs.members.each{ |m|
24
+ puts "#{m}: " + cs[m].to_s
25
+ }
26
+ }
27
+ }
28
+ end
29
+
30
+ def test_load_avg
31
+ assert_nothing_raised{ CPU.load_avg }
32
+ assert_equal(3, CPU.load_avg.length)
33
+ end
34
+
35
+ def test_cpu_stats
36
+ assert_nothing_raised{ CPU.cpu_stats }
37
+ assert_kind_of(Hash, CPU.cpu_stats)
38
+ assert_equal(true, CPU.cpu_stats["cpu0"].length >= 4)
39
+ end
40
+ end
41
+
data/test/tc_sunos.rb ADDED
@@ -0,0 +1,82 @@
1
+ ###########################################################
2
+ # tc_sunos.rb
3
+ #
4
+ # Test suite for sys-cpu on Solaris. This should only be
5
+ # run *after* the make process.
6
+ ###########################################################
7
+ base = File.basename(Dir.pwd)
8
+ if base == "test" || base =~ /sys-cpu/
9
+ require "ftools"
10
+ Dir.chdir ".." if base == "test"
11
+
12
+ Dir.mkdir("sys") unless File.exist?("sys")
13
+
14
+ if File.exist?("cpu.so")
15
+ File.copy("cpu.so","sys")
16
+ else
17
+ puts "No cpu.so file found. Please run extconf.rb and make first"
18
+ exit
19
+ end
20
+
21
+ $LOAD_PATH.unshift Dir.pwd
22
+ end
23
+
24
+ require "sys/cpu"
25
+ require "test/unit"
26
+ include Sys
27
+
28
+ # I could really use a mock object here
29
+ class TC_SunOS < Test::Unit::TestCase
30
+ def test_cpu_freq
31
+ assert_respond_to(CPU, :freq)
32
+ assert_nothing_raised{ CPU.freq }
33
+ assert_nothing_raised{ CPU.freq(0) }
34
+ assert_kind_of(Integer, CPU.freq(0))
35
+ end
36
+
37
+ def test_cpu_type
38
+ assert_respond_to(CPU, :type)
39
+ assert_nothing_raised{ CPU.type }
40
+ assert_kind_of(String, CPU.type)
41
+ end
42
+
43
+ def test_fpu_type
44
+ assert_respond_to(CPU, :fpu_type)
45
+ assert_nothing_raised{ CPU.fpu_type }
46
+ assert_kind_of(String, CPU.fpu_type)
47
+ end
48
+
49
+ def test_load_avg
50
+ assert_respond_to(CPU, :load_avg)
51
+ assert_nothing_raised{ CPU.load_avg }
52
+ assert_kind_of(Array, CPU.load_avg)
53
+ assert_equal(3, CPU.load_avg.length)
54
+ assert_kind_of(Float, CPU.load_avg.first)
55
+ end
56
+
57
+ def test_cpu_model
58
+ assert_respond_to(CPU, :model)
59
+ assert_nothing_raised{ CPU.model }
60
+ assert_kind_of(String, CPU.model)
61
+ end
62
+
63
+ def test_num_cpu
64
+ assert_respond_to(CPU, :num_cpu)
65
+ assert_nothing_raised{ CPU.num_cpu }
66
+ assert_kind_of(Integer, CPU.num_cpu)
67
+ end
68
+
69
+ def test_state
70
+ assert_respond_to(CPU, :state)
71
+ assert_nothing_raised{ CPU.state }
72
+ assert_nothing_raised{ CPU.state(0) }
73
+ assert_kind_of(String, CPU.state(0))
74
+ end
75
+
76
+ def test_exceptions
77
+ assert_raises(Sys::CPUError){ CPU.state(55) }
78
+ assert_raises(TypeError){ CPU.state("yo") }
79
+ assert_raises(Sys::CPUError){ CPU.freq(999) }
80
+ assert_raises(TypeError){ CPU.freq("yo") }
81
+ end
82
+ end
@@ -0,0 +1,33 @@
1
+ ###########################################################
2
+ # tc_version.rb
3
+ #
4
+ # The sole purpose of this test case is to verify the
5
+ # version. This reduces the pain of having separate tests
6
+ # for the VERSION constant in every single test case.
7
+ ###########################################################
8
+ base = File.basename(Dir.pwd)
9
+ if base == "test" || base =~ /sys-cpu/
10
+ require "ftools"
11
+ Dir.chdir ".." if base == "test"
12
+
13
+ Dir.mkdir("sys") unless File.exist?("sys")
14
+
15
+ if File.exist?("cpu.so")
16
+ File.copy("cpu.so","sys")
17
+ else
18
+ puts "No cpu.so file found. Please run extconf.rb and make first"
19
+ exit
20
+ end
21
+
22
+ $LOAD_PATH.unshift Dir.pwd
23
+ end
24
+
25
+ require "sys/cpu"
26
+ require "test/unit"
27
+ include Sys
28
+
29
+ class TC_Sys_CPU_VERSION < Test::Unit::TestCase
30
+ def test_version
31
+ assert_equal('0.5.4', CPU::VERSION)
32
+ end
33
+ end
@@ -0,0 +1,76 @@
1
+ ######################################################################
2
+ # tc_windows.rb
3
+ #
4
+ # Test suite for Win32 systems.
5
+ ######################################################################
6
+ base = File.basename(Dir.pwd)
7
+ if base == "test" || base =~ /sys-cpu/
8
+ require "ftools" if base == "test"
9
+ Dir.chdir '..'
10
+ Dir.mkdir("sys") unless File.exists?("sys")
11
+ File.copy("lib/os/windows.rb","sys/cpu.rb")
12
+ $LOAD_PATH.unshift Dir.pwd
13
+ end
14
+
15
+ require "test/unit"
16
+ require "sys/cpu"
17
+ require "socket"
18
+ include Sys
19
+
20
+ class TC_Windows_CPU < Test::Unit::TestCase
21
+ def setup
22
+ @host = Socket.gethostname
23
+ end
24
+
25
+ def test_architecture
26
+ assert_respond_to(CPU, :architecture)
27
+ assert_nothing_raised{ CPU.architecture }
28
+ assert_nothing_raised{ CPU.architecture(@host) }
29
+ assert_kind_of(String,CPU.architecture,"Invalid Type")
30
+ end
31
+
32
+ def test_freq
33
+ assert_respond_to(CPU, :freq)
34
+ assert_nothing_raised{ CPU.freq }
35
+ assert_nothing_raised{ CPU.freq(0) }
36
+ assert_nothing_raised{ CPU.freq(0,@host) }
37
+ assert_kind_of(Integer,CPU.freq,"Invalid Type")
38
+ end
39
+
40
+ def test_model
41
+ assert_respond_to(CPU, :model)
42
+ assert_nothing_raised{ CPU.model }
43
+ assert_nothing_raised{ CPU.model(@host) }
44
+ assert_kind_of(String,CPU.model,"Invalid Type")
45
+ end
46
+
47
+ def test_num_cpu
48
+ assert_respond_to(CPU, :num_cpu)
49
+ assert_nothing_raised{ CPU.num_cpu }
50
+ assert_nothing_raised{ CPU.num_cpu(@host) }
51
+ assert_kind_of(Integer,CPU.num_cpu,"Invalid Type")
52
+ end
53
+
54
+ def test_type
55
+ assert_respond_to(CPU, :type)
56
+ assert_nothing_raised{ CPU.type }
57
+ assert_nothing_raised{ CPU.type(@host) }
58
+ assert_kind_of(String,CPU.type,"Invalid Type")
59
+ end
60
+
61
+ def test_load_avg
62
+ assert_respond_to(CPU, :load_avg)
63
+ assert_nothing_raised{ CPU.load_avg }
64
+ assert_nothing_raised{ CPU.load_avg(0,@host) }
65
+ assert_kind_of(Integer,CPU.load_avg,"Invalid Type")
66
+ end
67
+
68
+ def test_processors
69
+ assert_respond_to(CPU, :processors)
70
+ assert_nothing_raised{ CPU.processors{} }
71
+ end
72
+
73
+ def teardown
74
+ @host = nil
75
+ end
76
+ end
data/test/ts_all.rb ADDED
@@ -0,0 +1,17 @@
1
+ $LOAD_PATH.unshift Dir.pwd
2
+ $LOAD_PATH.unshift Dir.pwd + '/test'
3
+
4
+ require 'tc_version'
5
+
6
+ case RUBY_PLATFORM
7
+ when /sunos|solaris/i
8
+ require 'tc_sunos'
9
+ when /linux/i
10
+ require 'tc_linux'
11
+ when /mswin|cygwin|mingw/i
12
+ require 'tc_windows'
13
+ when /hpux/i
14
+ require 'tc_hpux'
15
+ when /bsd/i
16
+ require 'tc_freebsd'
17
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.0
3
+ specification_version: 1
4
+ name: sys-cpu
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.5.4
7
+ date: 2006-11-17 00:00:00 -07:00
8
+ summary: A Ruby interface for providing CPU information
9
+ require_paths:
10
+ - lib
11
+ email: djberg96@gmail.com
12
+ homepage: http://www.rubyforge.org/projects/sysutils
13
+ rubyforge_project: sysutils
14
+ description: A Ruby interface for providing CPU information
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.8.2
24
+ version:
25
+ platform: mswin32
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Daniel J. Berger
31
+ files:
32
+ - doc/freebsd.txt
33
+ - doc/hpux.txt
34
+ - doc/linux.txt
35
+ - doc/sunos.txt
36
+ - doc/windows.txt
37
+ - test/tc_freebsd.rb
38
+ - test/tc_hpux.rb
39
+ - test/tc_linux.rb
40
+ - test/tc_sunos.rb
41
+ - test/tc_version.rb
42
+ - test/tc_windows.rb
43
+ - test/ts_all.rb
44
+ - CHANGES
45
+ - README
46
+ - lib/sys/cpu.rb
47
+ test_files:
48
+ - test/ts_all.rb
49
+ rdoc_options: []
50
+
51
+ extra_rdoc_files:
52
+ - CHANGES
53
+ - README
54
+ executables: []
55
+
56
+ extensions: []
57
+
58
+ requirements: []
59
+
60
+ dependencies: []
61
+