cpuinfo 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- require_relative 'sys/cpu'
@@ -1,97 +0,0 @@
1
- #############################################################
2
- # test_sys_cpu_bsd.rb
3
- #
4
- # The test case for sys-cpu on BSD flavors, including OS X.
5
- #############################################################
6
- require 'sys/cpu'
7
- require 'rbconfig'
8
- require 'test-unit'
9
- require 'test_sys_cpu_version'
10
- include Sys
11
-
12
- class TC_Sys_CPU_BSD < Test::Unit::TestCase
13
- test "architecture method basic functionality" do
14
- assert_respond_to(CPU, :architecture)
15
- assert_nothing_raised{ CPU.architecture }
16
- end
17
-
18
- test "architecture method returns a sane value" do
19
- assert_kind_of(String, CPU.architecture)
20
- assert_true(CPU.architecture.size > 0)
21
- end
22
-
23
- test "architecture method does not accept any arguments" do
24
- assert_raises(ArgumentError){ CPU.architecture(0) }
25
- end
26
-
27
- test "freq method basic functionality" do
28
- assert_respond_to(CPU, :freq)
29
- assert_nothing_raised{ CPU.freq }
30
- end
31
-
32
- test "freq method returns expected value" do
33
- assert_kind_of(Integer, CPU.freq)
34
- assert_true(CPU.freq > 0)
35
- end
36
-
37
- test "freq method does not accept any arguments" do
38
- assert_raises(ArgumentError){ CPU.freq(0) }
39
- end
40
-
41
- test "load_avg method basic functionality" do
42
- assert_respond_to(CPU, :load_avg)
43
- assert_nothing_raised{ CPU.load_avg }
44
- end
45
-
46
- test "load_avg returns the expected results" do
47
- assert_kind_of(Array, CPU.load_avg)
48
- assert_equal(3, CPU.load_avg.length)
49
- assert_kind_of(Float, CPU.load_avg[0])
50
- end
51
-
52
- test "load_avg does not accept any arguments" do
53
- assert_raises(ArgumentError){ CPU.load_avg(0) }
54
- end
55
-
56
- test "machine method basic functionality" do
57
- assert_respond_to(CPU, :machine)
58
- assert_nothing_raised{ CPU.machine }
59
- end
60
-
61
- test "machine method returns sane value" do
62
- assert_kind_of(String, CPU.machine)
63
- assert_true(CPU.machine.size > 0)
64
- end
65
-
66
- test "machine method does not accept any arguments" do
67
- assert_raises(ArgumentError){ CPU.machine(0) }
68
- end
69
-
70
- test "model method basic functionality" do
71
- assert_respond_to(CPU, :model)
72
- assert_nothing_raised{ CPU.model }
73
- end
74
-
75
- test "model method returns sane value" do
76
- assert_kind_of(String, CPU.model)
77
- assert_true(CPU.model.length > 0)
78
- end
79
-
80
- test "model method does not accept any arguments" do
81
- assert_raises(ArgumentError){ CPU.model(0) }
82
- end
83
-
84
- test "num_cpu method basic functionality" do
85
- assert_respond_to(CPU, :num_cpu)
86
- assert_nothing_raised{ CPU.num_cpu }
87
- end
88
-
89
- test "num_cpu method returns expected value" do
90
- assert_kind_of(Integer, CPU.num_cpu)
91
- assert_true(CPU.num_cpu > 0)
92
- end
93
-
94
- test "num_cpu method does not accept any arguments" do
95
- assert_raises(ArgumentError){ CPU.num_cpu(0) }
96
- end
97
- end
@@ -1,49 +0,0 @@
1
- #####################################################################
2
- # test_sys_cpu_hpux.rb
3
- #
4
- # Test suite for the HP-UX platform. This should be run via the
5
- # 'rake test' task.
6
- #####################################################################
7
- require 'sys/cpu'
8
- require 'test-unit'
9
- require 'test_sys_cpu_version'
10
- include Sys
11
-
12
- class TC_Sys_CPU_HPUX < Test::Unit::TestCase
13
- def test_cpu_freq
14
- assert_respond_to(CPU, :freq)
15
- assert_nothing_raised{ CPU.freq }
16
- assert_nothing_raised{ CPU.freq(0) }
17
- assert_kind_of(Integer, CPU.freq, 'Invalid Type')
18
- end
19
-
20
- def test_num_cpu
21
- assert_respond_to(CPU, :num_cpu)
22
- assert_nothing_raised{ CPU.num_cpu }
23
- assert_kind_of(Integer, CPU.num_cpu, 'Invalid Type')
24
- end
25
-
26
- def test_num_active_cpu
27
- assert_respond_to(CPU, :num_active_cpu)
28
- assert_nothing_raised{ CPU.num_active_cpu }
29
- assert_kind_of(Integer, CPU.num_active_cpu, 'Invalid Type')
30
- end
31
-
32
- def test_cpu_architecture
33
- assert_respond_to(CPU, :architecture)
34
- assert_nothing_raised{ CPU.architecture }
35
- assert_kind_of(String, CPU.architecture, 'Invalid Type')
36
- end
37
-
38
- def test_load_avg
39
- assert_respond_to(CPU, :load_avg)
40
- assert_nothing_raised{ CPU.load_avg }
41
- assert_nothing_raised{ CPU.load_avg(0) }
42
- assert_nothing_raised{ CPU.load_avg{ |e| } }
43
- assert_raises(ArgumentError){ CPU.load_avg(0){ } }
44
- assert_kind_of(Array, CPU.load_avg, 'Invalid Type')
45
- assert_kind_of(Array, CPU.load_avg(0), 'Invalid Type')
46
- assert_equal(3, CPU.load_avg.length, 'Bad number of elements')
47
- assert_equal(3, CPU.load_avg(0).length, 'Bad number of elements')
48
- end
49
- end
@@ -1,31 +0,0 @@
1
- ###########################################################
2
- # test_sys_cpu_linux.rb
3
- #
4
- # Test Suite for sys-cpu for Linux. This should be run via
5
- # the 'rake test' task.
6
- ###########################################################
7
- require 'sys/cpu'
8
- require 'test-unit'
9
- require 'test_sys_cpu_version'
10
- include Sys
11
-
12
- class TC_Sys_CPU_Linux < Test::Unit::TestCase
13
- def test_all_dynamic_methods
14
- assert_nothing_raised{
15
- CPU.processors{ |cs|
16
- cs.members.each{ |m| cs[m].to_s }
17
- }
18
- }
19
- end
20
-
21
- def test_load_avg
22
- assert_nothing_raised{ CPU.load_avg }
23
- assert_equal(3, CPU.load_avg.length)
24
- end
25
-
26
- def test_cpu_stats
27
- assert_nothing_raised{ CPU.cpu_stats }
28
- assert_kind_of(Hash, CPU.cpu_stats)
29
- assert_equal(true, CPU.cpu_stats['cpu0'].length >= 4)
30
- end
31
- end
@@ -1,81 +0,0 @@
1
- ###########################################################
2
- # test_sys_cpu_sunos.rb
3
- #
4
- # Test suite for sys-cpu on Solaris. This should be run
5
- # via the 'rake test' task.
6
- ###########################################################
7
- require 'sys/cpu'
8
- require 'test-unit'
9
- include Sys
10
-
11
- class TC_Sys_CPU_SunOS < Test::Unit::TestCase
12
- test "freq method basic functionality" do
13
- assert_respond_to(CPU, :freq)
14
- assert_nothing_raised{ CPU.freq }
15
- end
16
-
17
- test "freq method does not accept any arguments" do
18
- assert_raise(ArgumentError){ CPU.freq(0) }
19
- end
20
-
21
- test "freq method returns a sane value" do
22
- assert_kind_of(Integer, CPU.freq)
23
- assert_true(CPU.freq > 100)
24
- end
25
-
26
- test "fpu_type basic functionality" do
27
- assert_respond_to(CPU, :fpu_type)
28
- assert_nothing_raised{ CPU.fpu_type }
29
- end
30
-
31
- test "fpu_type returns a sane value" do
32
- assert_kind_of(String, CPU.fpu_type)
33
- assert_false(CPU.fpu_type.empty?)
34
- end
35
-
36
- test "load_avg basic functionality" do
37
- assert_respond_to(CPU, :load_avg)
38
- assert_nothing_raised{ CPU.load_avg }
39
- end
40
-
41
- test "load_avg method returns the expected values" do
42
- assert_kind_of(Array, CPU.load_avg)
43
- assert_equal(3, CPU.load_avg.length)
44
- assert_kind_of(Float, CPU.load_avg.first)
45
- end
46
-
47
- test "model method basic functionality" do
48
- assert_respond_to(CPU, :model)
49
- assert_nothing_raised{ CPU.model }
50
- end
51
-
52
- test "model method returns a sane value" do
53
- assert_kind_of(String, CPU.model)
54
- assert_false(CPU.model.empty?)
55
- end
56
-
57
- test "num_cpu method basic functionalty" do
58
- assert_respond_to(CPU, :num_cpu)
59
- assert_nothing_raised{ CPU.num_cpu }
60
- end
61
-
62
- test "num_cpu method returns a sane value" do
63
- assert_kind_of(Integer, CPU.num_cpu)
64
- assert_true(CPU.num_cpu > 0)
65
- end
66
-
67
- test "state basic functionality" do
68
- assert_respond_to(CPU, :state)
69
- assert_nothing_raised{ CPU.state }
70
- end
71
-
72
- test "state method accepts one optional argument" do
73
- assert_nothing_raised{ CPU.state(0) }
74
- assert_raise(ArgumentError){ CPU.state(0,0) }
75
- end
76
-
77
- test "state method returns a sane value" do
78
- assert_kind_of(String, CPU.state(0))
79
- assert_false(CPU.state.empty?)
80
- end
81
- end
@@ -1,15 +0,0 @@
1
- #######################################################################
2
- # test_sys_cpu_version.rb
3
- #
4
- # The sole purpose of this test case is to verify the version number.
5
- # This reduces the pain of having separate tests for the VERSION
6
- # constant in every single test case.
7
- #######################################################################
8
- require 'sys/cpu'
9
- require 'test-unit'
10
-
11
- class TC_Sys_CPU_VERSION < Test::Unit::TestCase
12
- test "version number is set to the expected value" do
13
- assert_equal('0.7.2', Sys::CPU::VERSION)
14
- end
15
- end
@@ -1,72 +0,0 @@
1
- ######################################################################
2
- # test_sys_cpu_windows.rb
3
- #
4
- # Test suite for MS Windows systems. This should be run via the
5
- # 'rake test' task.
6
- ######################################################################
7
- require 'rubygems'
8
- gem 'test-unit'
9
-
10
- require 'test/unit'
11
- require 'sys/cpu'
12
- require 'test_sys_cpu_version'
13
- require 'socket'
14
- include Sys
15
-
16
- class TC_Sys_CPU_Windows < Test::Unit::TestCase
17
- def self.startup
18
- @@host = Socket.gethostname
19
- end
20
-
21
- def test_architecture
22
- assert_respond_to(CPU, :architecture)
23
- assert_nothing_raised{ CPU.architecture }
24
- assert_nothing_raised{ CPU.architecture(@@host) }
25
- assert_kind_of(String, CPU.architecture, 'Invalid Type')
26
- end
27
-
28
- def test_freq
29
- assert_respond_to(CPU, :freq)
30
- assert_nothing_raised{ CPU.freq }
31
- assert_nothing_raised{ CPU.freq(0) }
32
- assert_nothing_raised{ CPU.freq(0, @@host) }
33
- assert_kind_of(Integer, CPU.freq, 'Invalid Type')
34
- end
35
-
36
- def test_model
37
- assert_respond_to(CPU, :model)
38
- assert_nothing_raised{ CPU.model }
39
- assert_nothing_raised{ CPU.model(@@host) }
40
- assert_kind_of(String, CPU.model, 'Invalid Type')
41
- end
42
-
43
- def test_num_cpu
44
- assert_respond_to(CPU, :num_cpu)
45
- assert_nothing_raised{ CPU.num_cpu }
46
- assert_nothing_raised{ CPU.num_cpu(@@host) }
47
- assert_kind_of(Integer, CPU.num_cpu, 'Invalid Type')
48
- end
49
-
50
- def test_cpu_type
51
- assert_respond_to(CPU, :cpu_type)
52
- assert_nothing_raised{ CPU.cpu_type }
53
- assert_nothing_raised{ CPU.cpu_type(@@host) }
54
- assert_kind_of(String, CPU.cpu_type, 'Invalid Type')
55
- end
56
-
57
- def test_load_avg
58
- assert_respond_to(CPU, :load_avg)
59
- assert_nothing_raised{ CPU.load_avg }
60
- assert_nothing_raised{ CPU.load_avg(0, @@host) }
61
- assert_kind_of(Integer, CPU.load_avg, 'Invalid Type')
62
- end
63
-
64
- def test_processors
65
- assert_respond_to(CPU, :processors)
66
- assert_nothing_raised{ CPU.processors{} }
67
- end
68
-
69
- def self.shutdown
70
- @@host = nil
71
- end
72
- end