sys-cpu 0.8.1 → 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,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,19 +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.8.1', Sys::CPU::VERSION)
14
- end
15
-
16
- test "version number is frozen" do
17
- assert_true(Sys::CPU::VERSION.frozen?)
18
- end
19
- 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