ohai 6.24.2 → 7.0.0.rc.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ohai.rb +1 -1
- data/lib/ohai/application.rb +5 -12
- data/lib/ohai/common/dmi.rb +126 -0
- data/lib/ohai/config.rb +9 -9
- data/lib/ohai/{plugins/darwin/hostname.rb → dsl.rb} +7 -7
- data/lib/ohai/dsl/plugin.rb +186 -0
- data/lib/ohai/dsl/plugin/versionvi.rb +62 -0
- data/lib/ohai/dsl/plugin/versionvii.rb +106 -0
- data/lib/ohai/exception.rb +11 -2
- data/lib/ohai/hints.rb +48 -0
- data/lib/ohai/loader.rb +205 -0
- data/lib/ohai/mixin/command.rb +14 -18
- data/lib/ohai/mixin/constant_helper.rb +53 -0
- data/lib/ohai/mixin/gce_metadata.rb +0 -2
- data/lib/ohai/{plugins/freebsd/uptime.rb → mixin/network_constants.rb} +15 -13
- data/lib/ohai/mixin/os.rb +59 -0
- data/lib/ohai/mixin/seconds_to_human.rb +48 -0
- data/lib/ohai/plugins/aix/cpu.rb +26 -22
- data/lib/ohai/plugins/aix/filesystem.rb +47 -48
- data/lib/ohai/plugins/aix/kernel.rb +11 -7
- data/lib/ohai/plugins/aix/memory.rb +8 -4
- data/lib/ohai/plugins/aix/network.rb +73 -82
- data/lib/ohai/plugins/aix/platform.rb +9 -6
- data/lib/ohai/plugins/aix/uptime.rb +14 -12
- data/lib/ohai/plugins/azure.rb +33 -11
- data/lib/ohai/plugins/c.rb +103 -78
- data/lib/ohai/plugins/chef.rb +20 -8
- data/lib/ohai/plugins/cloud.rb +234 -230
- data/lib/ohai/plugins/command.rb +6 -2
- data/lib/ohai/plugins/darwin/cpu.rb +10 -4
- data/lib/ohai/plugins/darwin/filesystem.rb +32 -32
- data/lib/ohai/plugins/darwin/network.rb +157 -154
- data/lib/ohai/plugins/darwin/platform.rb +18 -16
- data/lib/ohai/plugins/darwin/system_profiler.rb +49 -46
- data/lib/ohai/plugins/dmi.rb +102 -102
- data/lib/ohai/plugins/ec2.rb +30 -28
- data/lib/ohai/plugins/erlang.rb +19 -16
- data/lib/ohai/plugins/eucalyptus.rb +37 -36
- data/lib/ohai/plugins/freebsd/cpu.rb +34 -29
- data/lib/ohai/plugins/freebsd/filesystem.rb +32 -32
- data/lib/ohai/plugins/freebsd/memory.rb +35 -25
- data/lib/ohai/plugins/freebsd/network.rb +94 -89
- data/lib/ohai/plugins/freebsd/platform.rb +10 -4
- data/lib/ohai/plugins/freebsd/virtualization.rb +62 -61
- data/lib/ohai/plugins/gce.rb +30 -36
- data/lib/ohai/plugins/groovy.rb +14 -11
- data/lib/ohai/plugins/hostname.rb +132 -10
- data/lib/ohai/plugins/ip_scopes.rb +31 -16
- data/lib/ohai/plugins/java.rb +45 -21
- data/lib/ohai/plugins/kernel.rb +186 -19
- data/lib/ohai/plugins/keys.rb +6 -2
- data/lib/ohai/plugins/languages.rb +6 -2
- data/lib/ohai/plugins/linode.rb +38 -30
- data/lib/ohai/plugins/linux/block_device.rb +19 -15
- data/lib/ohai/plugins/linux/cpu.rb +42 -38
- data/lib/ohai/plugins/linux/filesystem.rb +70 -130
- data/lib/ohai/plugins/linux/lsb.rb +35 -35
- data/lib/ohai/plugins/linux/memory.rb +65 -61
- data/lib/ohai/plugins/linux/network.rb +343 -362
- data/lib/ohai/plugins/linux/platform.rb +90 -88
- data/lib/ohai/plugins/linux/virtualization.rb +95 -90
- data/lib/ohai/plugins/lua.rb +14 -10
- data/lib/ohai/plugins/mono.rb +17 -13
- data/lib/ohai/plugins/netbsd/cpu.rb +25 -23
- data/lib/ohai/plugins/netbsd/filesystem.rb +32 -32
- data/lib/ohai/plugins/netbsd/memory.rb +59 -59
- data/lib/ohai/plugins/netbsd/network.rb +92 -88
- data/lib/ohai/plugins/netbsd/platform.rb +10 -3
- data/lib/ohai/plugins/netbsd/virtualization.rb +41 -38
- data/lib/ohai/plugins/network.rb +131 -130
- data/lib/ohai/plugins/network_listeners.rb +26 -22
- data/lib/ohai/plugins/nodejs.rb +14 -10
- data/lib/ohai/plugins/ohai.rb +11 -6
- data/lib/ohai/plugins/ohai_time.rb +6 -2
- data/lib/ohai/plugins/openbsd/cpu.rb +20 -15
- data/lib/ohai/plugins/openbsd/filesystem.rb +32 -32
- data/lib/ohai/plugins/openbsd/memory.rb +59 -59
- data/lib/ohai/plugins/openbsd/network.rb +92 -88
- data/lib/ohai/plugins/openbsd/platform.rb +10 -4
- data/lib/ohai/plugins/openbsd/virtualization.rb +41 -39
- data/lib/ohai/plugins/openstack.rb +23 -21
- data/lib/ohai/plugins/os.rb +8 -32
- data/lib/ohai/plugins/passwd.rb +27 -22
- data/lib/ohai/plugins/perl.rb +21 -16
- data/lib/ohai/plugins/php.rb +15 -12
- data/lib/ohai/plugins/platform.rb +9 -9
- data/lib/ohai/plugins/{linux/kernel.rb → ps.rb} +13 -12
- data/lib/ohai/plugins/python.rb +16 -12
- data/lib/ohai/plugins/rackspace.rb +82 -77
- data/lib/ohai/plugins/root_group.rb +13 -9
- data/lib/ohai/plugins/ruby.rb +50 -48
- data/lib/ohai/plugins/sigar/cpu.rb +21 -17
- data/lib/ohai/plugins/sigar/filesystem.rb +26 -23
- data/lib/ohai/plugins/sigar/memory.rb +17 -14
- data/lib/ohai/plugins/sigar/network.rb +133 -67
- data/lib/ohai/plugins/sigar/network_route.rb +33 -28
- data/lib/ohai/plugins/sigar/platform.rb +10 -6
- data/lib/ohai/plugins/solaris2/cpu.rb +41 -33
- data/lib/ohai/plugins/solaris2/dmi.rb +146 -146
- data/lib/ohai/plugins/solaris2/filesystem.rb +74 -77
- data/lib/ohai/plugins/{aix/hostname.rb → solaris2/memory.rb} +7 -4
- data/lib/ohai/plugins/solaris2/network.rb +91 -86
- data/lib/ohai/plugins/solaris2/platform.rb +40 -36
- data/lib/ohai/plugins/solaris2/virtualization.rb +54 -59
- data/lib/ohai/plugins/solaris2/zpools.rb +38 -38
- data/lib/ohai/plugins/ssh_host_key.rb +49 -45
- data/lib/ohai/plugins/uptime.rb +87 -25
- data/lib/ohai/plugins/virtualization.rb +59 -55
- data/lib/ohai/plugins/windows/cpu.rb +44 -40
- data/lib/ohai/plugins/windows/filesystem.rb +28 -22
- data/lib/ohai/plugins/windows/network.rb +88 -79
- data/lib/ohai/plugins/windows/platform.rb +10 -3
- data/lib/ohai/provides_map.rb +184 -0
- data/lib/ohai/runner.rb +109 -0
- data/lib/ohai/system.rb +103 -184
- data/lib/ohai/version.rb +4 -3
- data/spec/data/plugins/___lib64___libc.so.6.output +135 -0
- data/spec/data/plugins/___lib___libc.so.6.output +135 -0
- data/spec/data/plugins/cc.output +135 -0
- data/spec/data/plugins/cl.output +135 -0
- data/spec/data/plugins/devenv.com.output +135 -0
- data/spec/data/plugins/env.output +71 -0
- data/spec/data/plugins/erl.output +144 -0
- data/spec/data/plugins/gcc.output +135 -0
- data/spec/data/plugins/groovy.output +159 -0
- data/spec/data/plugins/java.output +143 -0
- data/spec/data/plugins/lua.output +143 -0
- data/spec/data/plugins/messages.rb +8 -0
- data/spec/data/plugins/node.output +143 -0
- data/spec/data/plugins/perl.output +143 -0
- data/spec/data/plugins/php.output +143 -0
- data/spec/data/plugins/python.output +143 -0
- data/spec/data/plugins/uname.output +71 -0
- data/spec/data/plugins/v6message.rb +2 -0
- data/spec/data/plugins/v7message.rb +7 -0
- data/spec/data/plugins/what.output +135 -0
- data/spec/data/plugins/xlc.output +135 -0
- data/spec/spec_helper.rb +52 -18
- data/spec/support/integration_helper.rb +44 -0
- data/spec/unit/dsl/plugin_spec.rb +298 -0
- data/spec/unit/hints_spec.rb +65 -0
- data/spec/unit/loader_spec.rb +226 -0
- data/spec/unit/mixin/ec2_metadata_spec.rb +9 -9
- data/spec/unit/plugins/aix/cpu_spec.rb +17 -18
- data/spec/unit/plugins/aix/filesystem_spec.rb +20 -18
- data/spec/unit/plugins/aix/hostname_spec.rb +8 -4
- data/spec/unit/plugins/aix/kernel_spec.rb +13 -12
- data/spec/unit/plugins/aix/network_spec.rb +66 -45
- data/spec/unit/plugins/aix/platform_spec.rb +11 -10
- data/spec/unit/plugins/aix/uptime_spec.rb +7 -8
- data/spec/unit/plugins/azure_spec.rb +20 -21
- data/spec/unit/plugins/c_spec.rb +88 -87
- data/spec/unit/plugins/chef_spec.rb +5 -6
- data/spec/unit/plugins/cloud_spec.rb +81 -82
- data/spec/unit/plugins/darwin/cpu_spec.rb +8 -9
- data/spec/unit/plugins/darwin/hostname_spec.rb +23 -11
- data/spec/unit/plugins/darwin/kernel_spec.rb +39 -16
- data/spec/unit/plugins/darwin/network_spec.rb +375 -378
- data/spec/unit/plugins/darwin/platform_spec.rb +23 -50
- data/spec/unit/plugins/darwin/system_profiler_spec.rb +7 -8
- data/spec/unit/plugins/dmi_spec.rb +7 -12
- data/spec/unit/plugins/ec2_spec.rb +70 -59
- data/spec/unit/plugins/erlang_spec.rb +18 -20
- data/spec/unit/plugins/eucalyptus_spec.rb +37 -33
- data/spec/unit/plugins/fail_spec.rb +276 -23
- data/spec/unit/plugins/freebsd/hostname_spec.rb +11 -9
- data/spec/unit/plugins/freebsd/kernel_spec.rb +8 -8
- data/spec/unit/plugins/freebsd/platform_spec.rb +9 -10
- data/spec/unit/plugins/freebsd/virtualization_spec.rb +32 -32
- data/spec/unit/plugins/gce_spec.rb +19 -25
- data/spec/unit/plugins/groovy_spec.rb +10 -16
- data/spec/unit/plugins/hostname_spec.rb +45 -20
- data/spec/unit/plugins/ip_scopes_spec.rb +97 -0
- data/spec/unit/plugins/java_spec.rb +145 -99
- data/spec/unit/plugins/kernel_spec.rb +51 -15
- data/spec/unit/plugins/linode_spec.rb +31 -29
- data/spec/unit/plugins/linux/cpu_spec.rb +42 -43
- data/spec/unit/plugins/linux/filesystem_spec.rb +143 -324
- data/spec/unit/plugins/linux/hostname_spec.rb +16 -23
- data/spec/unit/plugins/linux/kernel_spec.rb +22 -8
- data/spec/unit/plugins/linux/lsb_spec.rb +54 -56
- data/spec/unit/plugins/linux/network_spec.rb +196 -238
- data/spec/unit/plugins/linux/platform_spec.rb +186 -205
- data/spec/unit/plugins/linux/uptime_spec.rb +13 -25
- data/spec/unit/plugins/linux/virtualization_spec.rb +149 -129
- data/spec/unit/plugins/lua_spec.rb +12 -15
- data/spec/unit/plugins/mono_spec.rb +10 -15
- data/spec/unit/plugins/netbsd/hostname_spec.rb +17 -7
- data/spec/unit/plugins/netbsd/kernel_spec.rb +8 -8
- data/spec/unit/plugins/netbsd/platform_spec.rb +8 -10
- data/spec/unit/plugins/network_spec.rb +358 -235
- data/spec/unit/plugins/nodejs_spec.rb +13 -15
- data/spec/unit/plugins/ohai_spec.rb +3 -4
- data/spec/unit/plugins/ohai_time_spec.rb +8 -9
- data/spec/unit/plugins/openbsd/hostname_spec.rb +21 -11
- data/spec/unit/plugins/openbsd/kernel_spec.rb +8 -8
- data/spec/unit/plugins/openbsd/platform_spec.rb +6 -12
- data/spec/unit/plugins/openstack_spec.rb +214 -0
- data/spec/unit/plugins/os_spec.rb +13 -16
- data/spec/unit/plugins/passwd_spec.rb +12 -13
- data/spec/unit/plugins/perl_spec.rb +20 -44
- data/spec/unit/plugins/php_spec.rb +20 -15
- data/spec/unit/plugins/platform_spec.rb +24 -29
- data/spec/unit/plugins/python_spec.rb +13 -17
- data/spec/unit/plugins/rackspace_spec.rb +90 -57
- data/spec/unit/plugins/root_group_spec.rb +17 -19
- data/spec/unit/plugins/ruby_spec.rb +15 -16
- data/spec/unit/plugins/sigar/network_route_spec.rb +12 -13
- data/spec/unit/plugins/solaris2/cpu_spec.rb +82 -0
- data/spec/unit/plugins/solaris2/hostname_spec.rb +12 -13
- data/spec/unit/plugins/solaris2/kernel_spec.rb +11 -15
- data/{lib/ohai/plugins/openbsd/uptime.rb → spec/unit/plugins/solaris2/memory_spec.rb} +10 -12
- data/spec/unit/plugins/solaris2/network_spec.rb +44 -20
- data/spec/unit/plugins/solaris2/platform_spec.rb +13 -22
- data/spec/unit/plugins/solaris2/virtualization_spec.rb +37 -45
- data/spec/unit/plugins/ssh_host_keys_spec.rb +11 -15
- data/spec/unit/provides_map_spec.rb +208 -0
- data/spec/unit/runner_spec.rb +488 -0
- data/spec/unit/system_spec.rb +639 -104
- metadata +151 -87
- checksums.yaml +0 -7
- data/lib/ohai/mixin/from_file.rb +0 -36
- data/lib/ohai/plugins/aix/ps.rb +0 -23
- data/lib/ohai/plugins/darwin/kernel.rb +0 -37
- data/lib/ohai/plugins/darwin/ps.rb +0 -23
- data/lib/ohai/plugins/darwin/uptime.rb +0 -32
- data/lib/ohai/plugins/dmi_common.rb +0 -121
- data/lib/ohai/plugins/freebsd/hostname.rb +0 -22
- data/lib/ohai/plugins/freebsd/kernel.rb +0 -37
- data/lib/ohai/plugins/freebsd/ps.rb +0 -24
- data/lib/ohai/plugins/hpux/cpu.rb +0 -19
- data/lib/ohai/plugins/hpux/filesystem.rb +0 -19
- data/lib/ohai/plugins/hpux/hostname.rb +0 -19
- data/lib/ohai/plugins/hpux/memory.rb +0 -19
- data/lib/ohai/plugins/hpux/network.rb +0 -19
- data/lib/ohai/plugins/hpux/platform.rb +0 -19
- data/lib/ohai/plugins/hpux/ps.rb +0 -23
- data/lib/ohai/plugins/hpux/uptime.rb +0 -19
- data/lib/ohai/plugins/linux/hostname.rb +0 -40
- data/lib/ohai/plugins/linux/ps.rb +0 -23
- data/lib/ohai/plugins/linux/uptime.rb +0 -28
- data/lib/ohai/plugins/netbsd/hostname.rb +0 -22
- data/lib/ohai/plugins/netbsd/kernel.rb +0 -35
- data/lib/ohai/plugins/netbsd/ps.rb +0 -24
- data/lib/ohai/plugins/netbsd/uptime.rb +0 -31
- data/lib/ohai/plugins/openbsd/hostname.rb +0 -22
- data/lib/ohai/plugins/openbsd/kernel.rb +0 -35
- data/lib/ohai/plugins/openbsd/ps.rb +0 -24
- data/lib/ohai/plugins/sigar/hostname.rb +0 -28
- data/lib/ohai/plugins/sigar/uptime.rb +0 -27
- data/lib/ohai/plugins/solaris2/hostname.rb +0 -34
- data/lib/ohai/plugins/solaris2/kernel.rb +0 -40
- data/lib/ohai/plugins/solaris2/ps.rb +0 -23
- data/lib/ohai/plugins/solaris2/uptime.rb +0 -36
- data/lib/ohai/plugins/windows/hostname.rb +0 -33
- data/lib/ohai/plugins/windows/kernel.rb +0 -58
- data/lib/ohai/plugins/windows/kernel_devices.rb +0 -39
- data/lib/ohai/plugins/windows/uptime.rb +0 -23
- data/spec/unit/mixin/from_file_spec.rb +0 -53
@@ -19,24 +19,25 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
19
19
|
|
20
20
|
describe Ohai::System, "Aix plugin platform" do
|
21
21
|
before(:each) do
|
22
|
-
@
|
23
|
-
@
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
@
|
22
|
+
@plugin = get_plugin("aix/platform")
|
23
|
+
@plugin.stub(:collect_os).and_return(:aix)
|
24
|
+
kernel = Mash.new
|
25
|
+
kernel[:name] = "aix"
|
26
|
+
kernel[:version] = "1"
|
27
|
+
kernel[:release] = "0"
|
28
|
+
@plugin.stub(:kernel).and_return(kernel)
|
29
|
+
@plugin.run
|
29
30
|
end
|
30
31
|
|
31
32
|
it "should set platform to aix" do
|
32
|
-
@
|
33
|
+
@plugin[:platform].should == "aix"
|
33
34
|
end
|
34
35
|
|
35
36
|
it "should set the platform_version" do
|
36
|
-
@
|
37
|
+
@plugin[:platform_version].should == "1.0"
|
37
38
|
end
|
38
39
|
|
39
40
|
it "should set platform_family" do
|
40
|
-
@
|
41
|
+
@plugin[:platform_family].should == @plugin[:platform]
|
41
42
|
end
|
42
43
|
end
|
@@ -20,21 +20,20 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
20
20
|
describe Ohai::System, "Aix plugin uptime" do
|
21
21
|
|
22
22
|
before(:each) do
|
23
|
-
@
|
24
|
-
@
|
25
|
-
@ohai._require_plugin("uptime")
|
26
|
-
@ohai.stub(:popen4).with("who -b").and_yield(nil, StringIO.new, StringIO.new(" . system boot Jul 9 17:51"), nil)
|
27
|
-
|
23
|
+
@plugin = get_plugin("aix/uptime")
|
24
|
+
@plugin.stub(:collect_os).and_return(:aix)
|
28
25
|
Time.stub_chain(:now, :to_i).and_return(1374258600)
|
29
26
|
DateTime.stub_chain(:parse, :strftime, :to_i).and_return(1373392260)
|
30
|
-
@
|
27
|
+
@plugin.stub(:shell_out).with("who -b").and_return(mock_shell_out(0, " . system boot Jul 9 17:51", nil))
|
28
|
+
|
29
|
+
@plugin.run
|
31
30
|
end
|
32
31
|
|
33
32
|
it "should set uptime_seconds to uptime" do
|
34
|
-
@
|
33
|
+
@plugin[:uptime_seconds].should == 866340
|
35
34
|
end
|
36
35
|
|
37
36
|
it "should set uptime to a human readable date" do
|
38
|
-
@
|
37
|
+
@plugin[:uptime].should == "10 days 00 hours 39 minutes 00 seconds"
|
39
38
|
end
|
40
39
|
end
|
@@ -22,51 +22,50 @@ require 'open-uri'
|
|
22
22
|
|
23
23
|
describe Ohai::System, "plugin azure" do
|
24
24
|
before(:each) do
|
25
|
-
@
|
26
|
-
@ohai.stub!(:require_plugin).and_return(true)
|
25
|
+
@plugin = get_plugin("azure")
|
27
26
|
end
|
28
27
|
|
29
28
|
describe "with azure cloud file" do
|
30
29
|
before(:each) do
|
31
|
-
File.stub
|
32
|
-
File.stub
|
33
|
-
File.stub
|
34
|
-
File.stub
|
35
|
-
@
|
30
|
+
File.stub(:exist?).with('/etc/chef/ohai/hints/azure.json').and_return(true)
|
31
|
+
File.stub(:read).with('/etc/chef/ohai/hints/azure.json').and_return('{"public_ip":"137.135.46.202","vm_name":"test-vm","public_fqdn":"service.cloudapp.net","public_ssh_port":"22", "public_winrm_port":"5985"}')
|
32
|
+
File.stub(:exist?).with('C:\chef\ohai\hints/azure.json').and_return(true)
|
33
|
+
File.stub(:read).with('C:\chef\ohai\hints/azure.json').and_return('{"public_ip":"137.135.46.202","vm_name":"test-vm","public_fqdn":"service.cloudapp.net","public_ssh_port":"22", "public_winrm_port":"5985"}')
|
34
|
+
@plugin.run
|
36
35
|
end
|
37
36
|
|
38
37
|
it 'should set the azure cloud attributes' do
|
39
|
-
@
|
40
|
-
@
|
41
|
-
@
|
42
|
-
@
|
43
|
-
@
|
44
|
-
@
|
38
|
+
@plugin[:azure].should_not be_nil
|
39
|
+
@plugin[:azure]['public_ip'].should == "137.135.46.202"
|
40
|
+
@plugin[:azure]['vm_name'].should == "test-vm"
|
41
|
+
@plugin[:azure]['public_fqdn'].should == "service.cloudapp.net"
|
42
|
+
@plugin[:azure]['public_ssh_port'].should == "22"
|
43
|
+
@plugin[:azure]['public_winrm_port'].should == "5985"
|
45
44
|
end
|
46
45
|
|
47
46
|
end
|
48
47
|
|
49
48
|
describe "without azure cloud file" do
|
50
49
|
before(:each) do
|
51
|
-
File.stub
|
52
|
-
File.stub
|
50
|
+
File.stub(:exist?).with('/etc/chef/ohai/hints/azure.json').and_return(false)
|
51
|
+
File.stub(:exist?).with('C:\chef\ohai\hints/azure.json').and_return(false)
|
53
52
|
end
|
54
53
|
|
55
54
|
it 'should not behave like azure' do
|
56
|
-
@
|
55
|
+
@plugin[:azure].should be_nil
|
57
56
|
end
|
58
57
|
end
|
59
58
|
|
60
59
|
describe "with rackspace cloud file" do
|
61
60
|
before(:each) do
|
62
|
-
File.stub
|
63
|
-
File.stub
|
64
|
-
File.stub
|
65
|
-
File.stub
|
61
|
+
File.stub(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true)
|
62
|
+
File.stub(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('')
|
63
|
+
File.stub(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true)
|
64
|
+
File.stub(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('')
|
66
65
|
end
|
67
66
|
|
68
67
|
it 'should not behave like azure' do
|
69
|
-
@
|
68
|
+
@plugin[:azure].should be_nil
|
70
69
|
end
|
71
70
|
end
|
72
71
|
|
data/spec/unit/plugins/c_spec.rb
CHANGED
@@ -103,205 +103,206 @@ EOF
|
|
103
103
|
describe Ohai::System, "plugin c" do
|
104
104
|
|
105
105
|
before(:each) do
|
106
|
-
@
|
107
|
-
|
108
|
-
@
|
106
|
+
@plugin = get_plugin("c")
|
107
|
+
|
108
|
+
@plugin[:languages] = Mash.new
|
109
109
|
#gcc
|
110
|
-
@
|
110
|
+
@plugin.stub(:shell_out).with("gcc -v").and_return(mock_shell_out(0, "", C_GCC))
|
111
111
|
#glibc
|
112
|
-
@
|
112
|
+
@plugin.stub(:shell_out).with("/lib/libc.so.6").and_return(mock_shell_out(0, C_GLIBC_2_3_4, ""))
|
113
113
|
#ms cl
|
114
|
-
@
|
114
|
+
@plugin.stub(:shell_out).with("cl /\?").and_return(mock_shell_out(0, "", C_CL))
|
115
115
|
#ms vs
|
116
|
-
@
|
116
|
+
@plugin.stub(:shell_out).with("devenv.com /\?").and_return(mock_shell_out(0, C_VS, ""))
|
117
117
|
#ibm xlc
|
118
|
-
@
|
118
|
+
@plugin.stub(:shell_out).with("xlc -qversion").and_return(mock_shell_out(0, C_XLC, ""))
|
119
119
|
#sun pro
|
120
|
-
@
|
120
|
+
@plugin.stub(:shell_out).with("cc -V -flags").and_return(mock_shell_out(0, "", C_SUN))
|
121
121
|
#hpux cc
|
122
|
-
@
|
122
|
+
@plugin.stub(:shell_out).with("what /opt/ansic/bin/cc").and_return(mock_shell_out(0, C_HPUX, ""))
|
123
123
|
end
|
124
124
|
|
125
125
|
#gcc
|
126
126
|
it "should get the gcc version from running gcc -v" do
|
127
|
-
@
|
128
|
-
@
|
127
|
+
@plugin.should_receive(:shell_out).with("gcc -v").and_return(mock_shell_out(0, "", C_GCC))
|
128
|
+
@plugin.run
|
129
129
|
end
|
130
130
|
|
131
131
|
it "should set languages[:c][:gcc][:version]" do
|
132
|
-
@
|
133
|
-
@
|
132
|
+
@plugin.run
|
133
|
+
@plugin.languages[:c][:gcc][:version].should eql("3.4.6")
|
134
134
|
end
|
135
135
|
|
136
136
|
it "should set languages[:c][:gcc][:description]" do
|
137
|
-
@
|
138
|
-
@
|
137
|
+
@plugin.run
|
138
|
+
@plugin.languages[:c][:gcc][:description].should eql(C_GCC.split($/).last)
|
139
139
|
end
|
140
140
|
|
141
141
|
it "should not set the languages[:c][:gcc] tree up if gcc command fails" do
|
142
|
-
@
|
143
|
-
@
|
144
|
-
@
|
142
|
+
@plugin.stub(:shell_out).with("gcc -v").and_return(mock_shell_out(1, "", ""))
|
143
|
+
@plugin.run
|
144
|
+
@plugin[:languages][:c].should_not have_key(:gcc) if @plugin[:languages][:c]
|
145
145
|
end
|
146
146
|
|
147
147
|
#glibc
|
148
148
|
it "should get the glibc x.x.x version from running /lib/libc.so.6" do
|
149
|
-
@
|
150
|
-
@
|
149
|
+
@plugin.should_receive(:shell_out).with("/lib/libc.so.6").and_return(mock_shell_out(0, C_GLIBC_2_3_4, ""))
|
150
|
+
@plugin.run
|
151
151
|
end
|
152
152
|
|
153
153
|
it "should set languages[:c][:glibc][:version]" do
|
154
|
-
@
|
155
|
-
@
|
154
|
+
@plugin.run
|
155
|
+
@plugin.languages[:c][:glibc][:version].should eql("2.3.4")
|
156
156
|
end
|
157
157
|
|
158
158
|
it "should set languages[:c][:glibc][:description]" do
|
159
|
-
@
|
160
|
-
@
|
159
|
+
@plugin.run
|
160
|
+
@plugin.languages[:c][:glibc][:description].should eql(C_GLIBC_2_3_4.split($/).first)
|
161
161
|
end
|
162
162
|
|
163
163
|
it "should not set the languages[:c][:glibc] tree up if glibc command fails" do
|
164
|
-
@
|
165
|
-
@
|
166
|
-
@
|
164
|
+
@plugin.stub(:shell_out).with("/lib/libc.so.6").and_return(mock_shell_out(1, "", ""))
|
165
|
+
@plugin.stub(:shell_out).with("/lib64/libc.so.6").and_return(mock_shell_out(1, "", ""))
|
166
|
+
@plugin.run
|
167
|
+
@plugin[:languages][:c].should_not have_key(:glibc) if @plugin[:languages][:c]
|
167
168
|
end
|
168
169
|
|
169
170
|
it "should get the glibc x.x version from running /lib/libc.so.6" do
|
170
|
-
@
|
171
|
-
@
|
172
|
-
@
|
173
|
-
@
|
171
|
+
@plugin.stub(:shell_out).with("/lib/libc.so.6").and_return(mock_shell_out(0, C_GLIBC_2_5, ""))
|
172
|
+
@plugin.should_receive(:shell_out).with("/lib/libc.so.6").and_return(mock_shell_out(0, C_GLIBC_2_5, ""))
|
173
|
+
@plugin.run
|
174
|
+
@plugin.languages[:c][:glibc][:version].should eql("2.5")
|
174
175
|
end
|
175
176
|
|
176
177
|
#ms cl
|
177
178
|
it "should get the cl version from running cl /?" do
|
178
|
-
@
|
179
|
-
@
|
179
|
+
@plugin.should_receive(:shell_out).with("cl /\?").and_return(mock_shell_out(0, "", C_CL))
|
180
|
+
@plugin.run
|
180
181
|
end
|
181
182
|
|
182
183
|
it "should set languages[:c][:cl][:version]" do
|
183
|
-
@
|
184
|
-
@
|
184
|
+
@plugin.run
|
185
|
+
@plugin.languages[:c][:cl][:version].should eql("14.00.50727.762")
|
185
186
|
end
|
186
187
|
|
187
188
|
it "should set languages[:c][:cl][:description]" do
|
188
|
-
@
|
189
|
-
@
|
189
|
+
@plugin.run
|
190
|
+
@plugin.languages[:c][:cl][:description].should eql(C_CL.split($/).first)
|
190
191
|
end
|
191
192
|
|
192
193
|
it "should not set the languages[:c][:cl] tree up if cl command fails" do
|
193
|
-
@
|
194
|
-
@
|
195
|
-
@
|
194
|
+
@plugin.stub(:shell_out).with("cl /\?").and_return(mock_shell_out(1, "", ""))
|
195
|
+
@plugin.run
|
196
|
+
@plugin[:languages][:c].should_not have_key(:cl) if @plugin[:languages][:c]
|
196
197
|
end
|
197
198
|
|
198
199
|
#ms vs
|
199
200
|
it "should get the vs version from running devenv.com /?" do
|
200
|
-
@
|
201
|
-
@
|
201
|
+
@plugin.should_receive(:shell_out).with("devenv.com /\?").and_return(mock_shell_out(0, C_VS, ""))
|
202
|
+
@plugin.run
|
202
203
|
end
|
203
204
|
|
204
205
|
it "should set languages[:c][:vs][:version]" do
|
205
|
-
@
|
206
|
-
@
|
206
|
+
@plugin.run
|
207
|
+
@plugin.languages[:c][:vs][:version].should eql("8.0.50727.762")
|
207
208
|
end
|
208
209
|
|
209
210
|
it "should set languages[:c][:vs][:description]" do
|
210
|
-
@
|
211
|
-
@
|
211
|
+
@plugin.run
|
212
|
+
@plugin.languages[:c][:vs][:description].should eql(C_VS.split($/)[1])
|
212
213
|
end
|
213
214
|
|
214
215
|
it "should not set the languages[:c][:vs] tree up if devenv command fails" do
|
215
|
-
@
|
216
|
-
@
|
217
|
-
@
|
216
|
+
@plugin.stub(:shell_out).with("devenv.com /\?").and_return(mock_shell_out(1, "", ""))
|
217
|
+
@plugin.run
|
218
|
+
@plugin[:languages][:c].should_not have_key(:vs) if @plugin[:languages][:c]
|
218
219
|
end
|
219
220
|
|
220
221
|
#ibm xlc
|
221
222
|
it "should get the xlc version from running xlc -qversion" do
|
222
|
-
@
|
223
|
-
@
|
223
|
+
@plugin.should_receive(:shell_out).with("xlc -qversion").and_return(mock_shell_out(0, C_XLC, ""))
|
224
|
+
@plugin.run
|
224
225
|
end
|
225
226
|
|
226
227
|
it "should set languages[:c][:xlc][:version]" do
|
227
|
-
@
|
228
|
-
@
|
228
|
+
@plugin.run
|
229
|
+
@plugin.languages[:c][:xlc][:version].should eql("9.0")
|
229
230
|
end
|
230
231
|
|
231
232
|
it "should set languages[:c][:xlc][:description]" do
|
232
|
-
@
|
233
|
-
@
|
233
|
+
@plugin.run
|
234
|
+
@plugin.languages[:c][:xlc][:description].should eql(C_XLC.split($/).first)
|
234
235
|
end
|
235
236
|
|
236
237
|
it "should not set the languages[:c][:xlc] tree up if xlc command fails" do
|
237
|
-
@
|
238
|
-
@
|
239
|
-
@
|
238
|
+
@plugin.stub(:shell_out).with("xlc -qversion").and_return(mock_shell_out(1, "", ""))
|
239
|
+
@plugin.run
|
240
|
+
@plugin[:languages][:c].should_not have_key(:xlc) if @plugin[:languages][:c]
|
240
241
|
end
|
241
242
|
|
242
243
|
it "should set the languages[:c][:xlc] tree up if xlc exit status is 249" do
|
243
|
-
@
|
244
|
-
@
|
245
|
-
@
|
244
|
+
@plugin.stub(:shell_out).with("xlc -qversion").and_return(mock_shell_out(63744, "", ""))
|
245
|
+
@plugin.run
|
246
|
+
@plugin[:languages][:c].should_not have_key(:xlc) if @plugin[:languages][:c]
|
246
247
|
end
|
247
248
|
|
248
249
|
#sun pro
|
249
250
|
it "should get the cc version from running cc -V -flags" do
|
250
|
-
@
|
251
|
-
@
|
251
|
+
@plugin.should_receive(:shell_out).with("cc -V -flags").and_return(mock_shell_out(0, "", C_SUN))
|
252
|
+
@plugin.run
|
252
253
|
end
|
253
254
|
|
254
255
|
it "should set languages[:c][:sunpro][:version]" do
|
255
|
-
@
|
256
|
-
@
|
256
|
+
@plugin.run
|
257
|
+
@plugin.languages[:c][:sunpro][:version].should eql("5.8")
|
257
258
|
end
|
258
259
|
|
259
260
|
it "should set languages[:c][:sunpro][:description]" do
|
260
|
-
@
|
261
|
-
@
|
261
|
+
@plugin.run
|
262
|
+
@plugin.languages[:c][:sunpro][:description].should eql(C_SUN.chomp)
|
262
263
|
end
|
263
264
|
|
264
265
|
it "should not set the languages[:c][:sunpro] tree up if cc command fails" do
|
265
|
-
@
|
266
|
-
@
|
267
|
-
@
|
266
|
+
@plugin.stub(:shell_out).with("cc -V -flags").and_return(mock_shell_out(1, "", ""))
|
267
|
+
@plugin.run
|
268
|
+
@plugin[:languages][:c].should_not have_key(:sunpro) if @plugin[:languages][:c]
|
268
269
|
end
|
269
270
|
|
270
|
-
|
271
271
|
it "should not set the languages[:c][:sunpro] tree if the corresponding cc command fails on linux" do
|
272
272
|
fedora_error_message = "cc: error trying to exec 'i686-redhat-linux-gcc--flags': execvp: No such file or directory"
|
273
273
|
|
274
|
-
@
|
275
|
-
@
|
276
|
-
@
|
274
|
+
@plugin.stub(:shell_out).with("cc -V -flags").and_return(mock_shell_out(0, "", fedora_error_message))
|
275
|
+
@plugin.run
|
276
|
+
@plugin[:languages][:c].should_not have_key(:sunpro) if @plugin[:languages][:c]
|
277
277
|
end
|
278
278
|
|
279
279
|
it "should not set the languages[:c][:sunpro] tree if the corresponding cc command fails on hpux" do
|
280
280
|
hpux_error_message = "cc: warning 901: unknown option: `-flags': use +help for online documentation.\ncc: HP C/aC++ B3910B A.06.25 [Nov 30 2009]"
|
281
|
-
@
|
282
|
-
@
|
283
|
-
@
|
281
|
+
@plugin.stub(:shell_out).with("cc -V -flags").and_return(mock_shell_out(0, "", hpux_error_message))
|
282
|
+
@plugin.run
|
283
|
+
@plugin[:languages][:c].should_not have_key(:sunpro) if @plugin[:languages][:c]
|
284
284
|
end
|
285
285
|
|
286
286
|
#hpux cc
|
287
287
|
it "should get the cc version from running what cc" do
|
288
|
-
@
|
289
|
-
@
|
288
|
+
@plugin.should_receive(:shell_out).with("what /opt/ansic/bin/cc").and_return(mock_shell_out(0, C_HPUX, ""))
|
289
|
+
@plugin.run
|
290
290
|
end
|
291
291
|
|
292
292
|
it "should set languages[:c][:hpcc][:version]" do
|
293
|
-
@
|
294
|
-
@
|
293
|
+
@plugin.run
|
294
|
+
@plugin.languages[:c][:hpcc][:version].should eql("B.11.11.16")
|
295
295
|
end
|
296
296
|
|
297
297
|
it "should set languages[:c][:hpcc][:description]" do
|
298
|
-
@
|
299
|
-
@
|
298
|
+
@plugin.run
|
299
|
+
@plugin.languages[:c][:hpcc][:description].should eql(C_HPUX.split($/)[3].strip)
|
300
300
|
end
|
301
301
|
|
302
302
|
it "should not set the languages[:c][:hpcc] tree up if cc command fails" do
|
303
|
-
@
|
304
|
-
@
|
305
|
-
@
|
303
|
+
@plugin.stub(:shell_out).with("what /opt/ansic/bin/cc").and_return(mock_shell_out(1, "", ""))
|
304
|
+
@plugin.run
|
305
|
+
@plugin[:languages][:c].should_not have_key(:hpcc) if @plugin[:languages][:c]
|
306
306
|
end
|
307
|
+
|
307
308
|
end
|
@@ -25,18 +25,17 @@ begin
|
|
25
25
|
|
26
26
|
describe Ohai::System, "plugin chef" do
|
27
27
|
before(:each) do
|
28
|
-
@
|
29
|
-
@ohai.stub!(:require_plugin).and_return(true)
|
28
|
+
@plugin = get_plugin("chef")
|
30
29
|
end
|
31
|
-
|
30
|
+
|
32
31
|
it "should set [:chef_packages][:chef][:version] to the current chef version", :if => defined?(Chef) do
|
33
|
-
@
|
34
|
-
@
|
32
|
+
@plugin.run
|
33
|
+
@plugin[:chef_packages][:chef][:version].should == Chef::VERSION
|
35
34
|
end
|
36
35
|
|
37
36
|
pending "would set [:chef_packages][:chef][:version] if chef was available", :unless => defined?(Chef)
|
38
|
-
|
39
37
|
end
|
38
|
+
|
40
39
|
rescue LoadError
|
41
40
|
# the chef module is not available, ignoring.
|
42
41
|
|