sys-cpu 0.6.1-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +131 -0
- data/MANIFEST +28 -0
- data/README +79 -0
- data/doc/bsd.txt +67 -0
- data/doc/hpux.txt +75 -0
- data/doc/linux.txt +41 -0
- data/doc/sunos.txt +78 -0
- data/doc/windows.txt +152 -0
- data/lib/sys/cpu.rb +784 -0
- data/test/tc_bsd.rb +56 -0
- data/test/tc_cpu.rb +17 -0
- data/test/tc_hpux.rb +49 -0
- data/test/tc_linux.rb +34 -0
- data/test/tc_sunos.rb +65 -0
- data/test/tc_version.rb +15 -0
- data/test/tc_windows.rb +69 -0
- metadata +71 -0
data/test/tc_bsd.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
#############################################################
|
2
|
+
# tc_bsd.rb
|
3
|
+
#
|
4
|
+
# The test case for sys-cpu on BSD flavors, including OS X.
|
5
|
+
#############################################################
|
6
|
+
require "sys/cpu"
|
7
|
+
require "test/unit"
|
8
|
+
require "tc_version"
|
9
|
+
include Sys
|
10
|
+
|
11
|
+
class TC_BSD < Test::Unit::TestCase
|
12
|
+
def test_architecture
|
13
|
+
assert_respond_to(CPU, :architecture)
|
14
|
+
assert_nothing_raised{ CPU.architecture }
|
15
|
+
assert_kind_of(String, CPU.architecture)
|
16
|
+
assert_raises(ArgumentError){ CPU.architecture(0) }
|
17
|
+
end
|
18
|
+
|
19
|
+
unless RUBY_PLATFORM.match('darwin')
|
20
|
+
def test_cpu_freq
|
21
|
+
assert_respond_to(CPU, :freq)
|
22
|
+
assert_nothing_raised{ CPU.freq }
|
23
|
+
assert_kind_of(Integer, CPU.freq)
|
24
|
+
assert_raises(ArgumentError){ CPU.freq(0) }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_load_avg
|
29
|
+
assert_respond_to(CPU, :load_avg)
|
30
|
+
assert_nothing_raised{ CPU.load_avg }
|
31
|
+
assert_kind_of(Array, CPU.load_avg)
|
32
|
+
assert_equal(3,CPU.load_avg.length)
|
33
|
+
assert_raises(ArgumentError){ CPU.load_avg(0) }
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_machine
|
37
|
+
assert_respond_to(CPU, :machine)
|
38
|
+
assert_nothing_raised{ CPU.machine }
|
39
|
+
assert_kind_of(String, CPU.machine)
|
40
|
+
assert_raises(ArgumentError){ CPU.machine(0) }
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_model
|
44
|
+
assert_respond_to(CPU, :model)
|
45
|
+
assert_nothing_raised{ CPU.model }
|
46
|
+
assert_kind_of(String, CPU.model)
|
47
|
+
assert_raises(ArgumentError){ CPU.model(0) }
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_num_cpu
|
51
|
+
assert_respond_to(CPU, :num_cpu)
|
52
|
+
assert_nothing_raised{ CPU.num_cpu }
|
53
|
+
assert_kind_of(Integer, CPU.num_cpu)
|
54
|
+
assert_raises(ArgumentError){ CPU.num_cpu(0) }
|
55
|
+
end
|
56
|
+
end
|
data/test/tc_cpu.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__))
|
2
|
+
require 'tc_version'
|
3
|
+
|
4
|
+
case RUBY_PLATFORM
|
5
|
+
when /bsd|darwin|mach|osx/i
|
6
|
+
require 'tc_bsd'
|
7
|
+
when /hpux/i
|
8
|
+
require 'tc_hpux'
|
9
|
+
when /linux/i
|
10
|
+
require 'tc_linux'
|
11
|
+
when /sunos|solaris/i
|
12
|
+
require 'tc_sunos'
|
13
|
+
when /mswin|win32|dos|mingw|cygwin/i
|
14
|
+
require 'tc_windows'
|
15
|
+
else
|
16
|
+
raise "Platform not supported"
|
17
|
+
end
|
data/test/tc_hpux.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
#####################################################################
|
2
|
+
# tc_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 "tc_version"
|
10
|
+
include Sys
|
11
|
+
|
12
|
+
class TC_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
|
data/test/tc_linux.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
###########################################################
|
2
|
+
# tc_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 "tc_version"
|
10
|
+
include Sys
|
11
|
+
|
12
|
+
class TC_Linux < Test::Unit::TestCase
|
13
|
+
def test_all_dynamic_methods
|
14
|
+
assert_nothing_raised{
|
15
|
+
CPU.processors{ |cs|
|
16
|
+
cs.members.each{ |m|
|
17
|
+
puts "#{m}: " + cs[m].to_s
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_load_avg
|
24
|
+
assert_nothing_raised{ CPU.load_avg }
|
25
|
+
assert_equal(3, CPU.load_avg.length)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_cpu_stats
|
29
|
+
assert_nothing_raised{ CPU.cpu_stats }
|
30
|
+
assert_kind_of(Hash, CPU.cpu_stats)
|
31
|
+
assert_equal(true, CPU.cpu_stats["cpu0"].length >= 4)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
data/test/tc_sunos.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
###########################################################
|
2
|
+
# tc_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
|
+
require "tc_version"
|
10
|
+
include Sys
|
11
|
+
|
12
|
+
class TC_SunOS < 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(0))
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_cpu_type
|
21
|
+
assert_respond_to(CPU, :cpu_type)
|
22
|
+
assert_nothing_raised{ CPU.cpu_type }
|
23
|
+
assert_kind_of(String, CPU.cpu_type)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_fpu_type
|
27
|
+
assert_respond_to(CPU, :fpu_type)
|
28
|
+
assert_nothing_raised{ CPU.fpu_type }
|
29
|
+
assert_kind_of(String, CPU.fpu_type)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_load_avg
|
33
|
+
assert_respond_to(CPU, :load_avg)
|
34
|
+
assert_nothing_raised{ CPU.load_avg }
|
35
|
+
assert_kind_of(Array, CPU.load_avg)
|
36
|
+
assert_equal(3, CPU.load_avg.length)
|
37
|
+
assert_kind_of(Float, CPU.load_avg.first)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_cpu_model
|
41
|
+
assert_respond_to(CPU, :model)
|
42
|
+
assert_nothing_raised{ CPU.model }
|
43
|
+
assert_kind_of(String, CPU.model)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_num_cpu
|
47
|
+
assert_respond_to(CPU, :num_cpu)
|
48
|
+
assert_nothing_raised{ CPU.num_cpu }
|
49
|
+
assert_kind_of(Integer, CPU.num_cpu)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_state
|
53
|
+
assert_respond_to(CPU, :state)
|
54
|
+
assert_nothing_raised{ CPU.state }
|
55
|
+
assert_nothing_raised{ CPU.state(0) }
|
56
|
+
assert_kind_of(String, CPU.state(0))
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_exceptions
|
60
|
+
assert_raises(Sys::CPU::Error){ CPU.state(55) }
|
61
|
+
assert_raises(TypeError){ CPU.state("yo") }
|
62
|
+
assert_raises(Sys::CPU::Error){ CPU.freq(999) }
|
63
|
+
assert_raises(TypeError){ CPU.freq("yo") }
|
64
|
+
end
|
65
|
+
end
|
data/test/tc_version.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#######################################################################
|
2
|
+
# tc_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
|
+
def test_version
|
13
|
+
assert_equal('0.6.1', Sys::CPU::VERSION)
|
14
|
+
end
|
15
|
+
end
|
data/test/tc_windows.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
######################################################################
|
2
|
+
# tc_windows.rb
|
3
|
+
#
|
4
|
+
# Test suite for MS Windows systems. This should be run via the
|
5
|
+
# 'rake test' task.
|
6
|
+
######################################################################
|
7
|
+
require "test/unit"
|
8
|
+
require "sys/cpu"
|
9
|
+
require "tc_version"
|
10
|
+
require "socket"
|
11
|
+
include Sys
|
12
|
+
|
13
|
+
class TC_Windows_CPU < Test::Unit::TestCase
|
14
|
+
def setup
|
15
|
+
@host = Socket.gethostname
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_architecture
|
19
|
+
assert_respond_to(CPU, :architecture)
|
20
|
+
assert_nothing_raised{ CPU.architecture }
|
21
|
+
assert_nothing_raised{ CPU.architecture(@host) }
|
22
|
+
assert_kind_of(String, CPU.architecture, "Invalid Type")
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_freq
|
26
|
+
assert_respond_to(CPU, :freq)
|
27
|
+
assert_nothing_raised{ CPU.freq }
|
28
|
+
assert_nothing_raised{ CPU.freq(0) }
|
29
|
+
assert_nothing_raised{ CPU.freq(0, @host) }
|
30
|
+
assert_kind_of(Integer, CPU.freq, "Invalid Type")
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_model
|
34
|
+
assert_respond_to(CPU, :model)
|
35
|
+
assert_nothing_raised{ CPU.model }
|
36
|
+
assert_nothing_raised{ CPU.model(@host) }
|
37
|
+
assert_kind_of(String, CPU.model, "Invalid Type")
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_num_cpu
|
41
|
+
assert_respond_to(CPU, :num_cpu)
|
42
|
+
assert_nothing_raised{ CPU.num_cpu }
|
43
|
+
assert_nothing_raised{ CPU.num_cpu(@host) }
|
44
|
+
assert_kind_of(Integer, CPU.num_cpu, "Invalid Type")
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_type
|
48
|
+
assert_respond_to(CPU, :type)
|
49
|
+
assert_nothing_raised{ CPU.type }
|
50
|
+
assert_nothing_raised{ CPU.type(@host) }
|
51
|
+
assert_kind_of(String, CPU.type, "Invalid Type")
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_load_avg
|
55
|
+
assert_respond_to(CPU, :load_avg)
|
56
|
+
assert_nothing_raised{ CPU.load_avg }
|
57
|
+
assert_nothing_raised{ CPU.load_avg(0, @host) }
|
58
|
+
assert_kind_of(Integer, CPU.load_avg, "Invalid Type")
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_processors
|
62
|
+
assert_respond_to(CPU, :processors)
|
63
|
+
assert_nothing_raised{ CPU.processors{} }
|
64
|
+
end
|
65
|
+
|
66
|
+
def teardown
|
67
|
+
@host = nil
|
68
|
+
end
|
69
|
+
end
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sys-cpu
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.6.1
|
5
|
+
platform: x86-mswin32-60
|
6
|
+
authors:
|
7
|
+
- Daniel J. Berger
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-01-04 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: A Ruby interface for providing CPU information
|
17
|
+
email: djberg96 at nospam at gmail dot com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- CHANGES
|
24
|
+
- README
|
25
|
+
- MANIFEST
|
26
|
+
- lib/sys/cpu.rb
|
27
|
+
files:
|
28
|
+
- doc/bsd.txt
|
29
|
+
- doc/hpux.txt
|
30
|
+
- doc/linux.txt
|
31
|
+
- doc/sunos.txt
|
32
|
+
- doc/windows.txt
|
33
|
+
- test/tc_bsd.rb
|
34
|
+
- test/tc_cpu.rb
|
35
|
+
- test/tc_hpux.rb
|
36
|
+
- test/tc_linux.rb
|
37
|
+
- test/tc_sunos.rb
|
38
|
+
- test/tc_version.rb
|
39
|
+
- test/tc_windows.rb
|
40
|
+
- CHANGES
|
41
|
+
- README
|
42
|
+
- MANIFEST
|
43
|
+
- lib/sys/cpu.rb
|
44
|
+
has_rdoc: true
|
45
|
+
homepage: http://www.rubyforge.org/projects/sysutils
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 1.8.2
|
56
|
+
version:
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: "0"
|
62
|
+
version:
|
63
|
+
requirements: []
|
64
|
+
|
65
|
+
rubyforge_project: sysutils
|
66
|
+
rubygems_version: 1.3.1
|
67
|
+
signing_key:
|
68
|
+
specification_version: 2
|
69
|
+
summary: A Ruby interface for providing CPU information
|
70
|
+
test_files:
|
71
|
+
- test/tc_windows.rb
|