ohai 15.3.1 → 15.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -6
  3. data/lib/ohai/mixin/{network_constants.rb → network_helper.rb} +8 -1
  4. data/lib/ohai/plugins/aix/network.rb +3 -8
  5. data/lib/ohai/plugins/darwin/network.rb +6 -4
  6. data/lib/ohai/plugins/filesystem.rb +166 -0
  7. data/lib/ohai/plugins/network.rb +5 -5
  8. data/lib/ohai/plugins/openstack.rb +2 -1
  9. data/lib/ohai/plugins/solaris2/network.rb +6 -4
  10. data/lib/ohai/version.rb +1 -1
  11. data/ohai.gemspec +1 -1
  12. metadata +3 -162
  13. data/Rakefile +0 -42
  14. data/lib/ohai/plugins/windows/filesystem.rb +0 -147
  15. data/spec/data/plugins/dpkg-query.output +0 -4
  16. data/spec/data/plugins/lslpp.output +0 -50
  17. data/spec/data/plugins/pacman.output +0 -51
  18. data/spec/data/plugins/pkg-query.output +0 -58
  19. data/spec/data/plugins/pkginfo.output +0 -50
  20. data/spec/data/plugins/pkglist.output +0 -24
  21. data/spec/data/plugins/rpmquery.output +0 -7
  22. data/spec/functional/application_spec.rb +0 -107
  23. data/spec/functional/loader_spec.rb +0 -53
  24. data/spec/functional/plugins/powershell_spec.rb +0 -88
  25. data/spec/functional/plugins/root_group_spec.rb +0 -41
  26. data/spec/functional/plugins/windows/uptime_spec.rb +0 -51
  27. data/spec/ohai_spec.rb +0 -27
  28. data/spec/rcov.opts +0 -2
  29. data/spec/spec.opts +0 -2
  30. data/spec/spec_helper.rb +0 -124
  31. data/spec/support/integration_helper.rb +0 -61
  32. data/spec/support/platform_helpers.rb +0 -38
  33. data/spec/unit/application_spec.rb +0 -96
  34. data/spec/unit/config_spec.rb +0 -57
  35. data/spec/unit/dsl/plugin_spec.rb +0 -634
  36. data/spec/unit/hints_spec.rb +0 -65
  37. data/spec/unit/loader_spec.rb +0 -195
  38. data/spec/unit/mixin/azure_metadata_spec.rb +0 -72
  39. data/spec/unit/mixin/command_spec.rb +0 -151
  40. data/spec/unit/mixin/dmi_decode.rb +0 -75
  41. data/spec/unit/mixin/ec2_metadata_spec.rb +0 -88
  42. data/spec/unit/mixin/softlayer_metadata_spec.rb +0 -72
  43. data/spec/unit/plugin_config_spec.rb +0 -117
  44. data/spec/unit/plugins/abort_spec.rb +0 -69
  45. data/spec/unit/plugins/aix/cpu_spec.rb +0 -127
  46. data/spec/unit/plugins/aix/filesystem_spec.rb +0 -238
  47. data/spec/unit/plugins/aix/hostname_spec.rb +0 -33
  48. data/spec/unit/plugins/aix/kernel_spec.rb +0 -61
  49. data/spec/unit/plugins/aix/memory_spec.rb +0 -49
  50. data/spec/unit/plugins/aix/network_spec.rb +0 -313
  51. data/spec/unit/plugins/aix/platform_spec.rb +0 -44
  52. data/spec/unit/plugins/aix/uptime_spec.rb +0 -42
  53. data/spec/unit/plugins/aix/virtualization_spec.rb +0 -319
  54. data/spec/unit/plugins/azure_spec.rb +0 -243
  55. data/spec/unit/plugins/bsd/filesystem_spec.rb +0 -138
  56. data/spec/unit/plugins/bsd/virtualization_spec.rb +0 -145
  57. data/spec/unit/plugins/c_spec.rb +0 -341
  58. data/spec/unit/plugins/chef_spec.rb +0 -44
  59. data/spec/unit/plugins/cloud_spec.rb +0 -484
  60. data/spec/unit/plugins/darwin/cpu_spec.rb +0 -124
  61. data/spec/unit/plugins/darwin/filesystem_spec.rb +0 -140
  62. data/spec/unit/plugins/darwin/hardware_spec.rb +0 -105
  63. data/spec/unit/plugins/darwin/hardware_system_profiler_output.rb +0 -1110
  64. data/spec/unit/plugins/darwin/hostname_spec.rb +0 -43
  65. data/spec/unit/plugins/darwin/kernel_spec.rb +0 -65
  66. data/spec/unit/plugins/darwin/memory_spec.rb +0 -64
  67. data/spec/unit/plugins/darwin/network_spec.rb +0 -849
  68. data/spec/unit/plugins/darwin/platform_spec.rb +0 -71
  69. data/spec/unit/plugins/darwin/virtualization_spec.rb +0 -156
  70. data/spec/unit/plugins/digital_ocean_spec.rb +0 -106
  71. data/spec/unit/plugins/dmi_spec.rb +0 -156
  72. data/spec/unit/plugins/docker_spec.rb +0 -100
  73. data/spec/unit/plugins/ec2_spec.rb +0 -452
  74. data/spec/unit/plugins/elixir_spec.rb +0 -55
  75. data/spec/unit/plugins/erlang_spec.rb +0 -71
  76. data/spec/unit/plugins/eucalyptus_spec.rb +0 -109
  77. data/spec/unit/plugins/fail_spec.rb +0 -260
  78. data/spec/unit/plugins/freebsd/cpu_spec.rb +0 -129
  79. data/spec/unit/plugins/freebsd/hostname_spec.rb +0 -35
  80. data/spec/unit/plugins/freebsd/kernel_spec.rb +0 -36
  81. data/spec/unit/plugins/freebsd/platform_spec.rb +0 -38
  82. data/spec/unit/plugins/gce_spec.rb +0 -81
  83. data/spec/unit/plugins/go_spec.rb +0 -48
  84. data/spec/unit/plugins/groovy_spec.rb +0 -66
  85. data/spec/unit/plugins/haskell_spec.rb +0 -231
  86. data/spec/unit/plugins/hostname_spec.rb +0 -162
  87. data/spec/unit/plugins/init_package_spec.rb +0 -60
  88. data/spec/unit/plugins/java_spec.rb +0 -230
  89. data/spec/unit/plugins/joyent_spec.rb +0 -100
  90. data/spec/unit/plugins/kernel_spec.rb +0 -38
  91. data/spec/unit/plugins/linode_spec.rb +0 -135
  92. data/spec/unit/plugins/linux/block_device_spec.rb +0 -75
  93. data/spec/unit/plugins/linux/cpu_spec.rb +0 -441
  94. data/spec/unit/plugins/linux/filesystem_spec.rb +0 -550
  95. data/spec/unit/plugins/linux/fips_spec.rb +0 -60
  96. data/spec/unit/plugins/linux/hostname_spec.rb +0 -52
  97. data/spec/unit/plugins/linux/hostnamectl_spec.rb +0 -59
  98. data/spec/unit/plugins/linux/kernel_spec.rb +0 -71
  99. data/spec/unit/plugins/linux/lsb_spec.rb +0 -147
  100. data/spec/unit/plugins/linux/lspci_spec.rb +0 -133
  101. data/spec/unit/plugins/linux/machineid_spec.rb +0 -46
  102. data/spec/unit/plugins/linux/mdadm_spec.rb +0 -170
  103. data/spec/unit/plugins/linux/memory_spec.rb +0 -256
  104. data/spec/unit/plugins/linux/network_spec.rb +0 -1392
  105. data/spec/unit/plugins/linux/platform_spec.rb +0 -812
  106. data/spec/unit/plugins/linux/sessions_spec.rb +0 -98
  107. data/spec/unit/plugins/linux/sysctl_spec.rb +0 -53
  108. data/spec/unit/plugins/linux/systemd_paths_spec.rb +0 -122
  109. data/spec/unit/plugins/linux/uptime_spec.rb +0 -48
  110. data/spec/unit/plugins/linux/virtualization_spec.rb +0 -650
  111. data/spec/unit/plugins/lua_spec.rb +0 -60
  112. data/spec/unit/plugins/mono_spec.rb +0 -67
  113. data/spec/unit/plugins/netbsd/hostname_spec.rb +0 -43
  114. data/spec/unit/plugins/netbsd/kernel_spec.rb +0 -35
  115. data/spec/unit/plugins/netbsd/platform_spec.rb +0 -38
  116. data/spec/unit/plugins/network_spec.rb +0 -1078
  117. data/spec/unit/plugins/nodejs_spec.rb +0 -55
  118. data/spec/unit/plugins/ohai_spec.rb +0 -32
  119. data/spec/unit/plugins/ohai_time_spec.rb +0 -44
  120. data/spec/unit/plugins/openbsd/hostname_spec.rb +0 -43
  121. data/spec/unit/plugins/openbsd/kernel_spec.rb +0 -36
  122. data/spec/unit/plugins/openbsd/platform_spec.rb +0 -33
  123. data/spec/unit/plugins/openstack_spec.rb +0 -311
  124. data/spec/unit/plugins/os_spec.rb +0 -115
  125. data/spec/unit/plugins/packages_spec.rb +0 -353
  126. data/spec/unit/plugins/passwd_spec.rb +0 -65
  127. data/spec/unit/plugins/perl_spec.rb +0 -62
  128. data/spec/unit/plugins/php_spec.rb +0 -97
  129. data/spec/unit/plugins/platform_spec.rb +0 -65
  130. data/spec/unit/plugins/powershell_spec.rb +0 -71
  131. data/spec/unit/plugins/python_spec.rb +0 -51
  132. data/spec/unit/plugins/rackspace_spec.rb +0 -350
  133. data/spec/unit/plugins/root_group_spec.rb +0 -90
  134. data/spec/unit/plugins/ruby_spec.rb +0 -60
  135. data/spec/unit/plugins/rust_spec.rb +0 -43
  136. data/spec/unit/plugins/scala_spec.rb +0 -58
  137. data/spec/unit/plugins/scaleway_spec.rb +0 -93
  138. data/spec/unit/plugins/scsi_spec.rb +0 -69
  139. data/spec/unit/plugins/shard_spec.rb +0 -121
  140. data/spec/unit/plugins/shells_spec.rb +0 -56
  141. data/spec/unit/plugins/softlayer_spec.rb +0 -60
  142. data/spec/unit/plugins/solaris2/cpu_spec.rb +0 -2926
  143. data/spec/unit/plugins/solaris2/dmi_spec.rb +0 -153
  144. data/spec/unit/plugins/solaris2/filesystem.rb +0 -407
  145. data/spec/unit/plugins/solaris2/hostname_spec.rb +0 -37
  146. data/spec/unit/plugins/solaris2/kernel_spec.rb +0 -183
  147. data/spec/unit/plugins/solaris2/memory_spec.rb +0 -43
  148. data/spec/unit/plugins/solaris2/network_spec.rb +0 -201
  149. data/spec/unit/plugins/solaris2/platform_spec.rb +0 -108
  150. data/spec/unit/plugins/solaris2/virtualization_spec.rb +0 -97
  151. data/spec/unit/plugins/ssh_host_keys_spec.rb +0 -116
  152. data/spec/unit/plugins/sysconf_spec.rb +0 -680
  153. data/spec/unit/plugins/timezone_spec.rb +0 -30
  154. data/spec/unit/plugins/vbox_host_spec.rb +0 -14
  155. data/spec/unit/plugins/virtualbox_spec.rb +0 -375
  156. data/spec/unit/plugins/vmware_spec.rb +0 -81
  157. data/spec/unit/plugins/windows/cpu_spec.rb +0 -118
  158. data/spec/unit/plugins/windows/filesystem_spec.rb +0 -226
  159. data/spec/unit/plugins/windows/fips_spec.rb +0 -60
  160. data/spec/unit/plugins/windows/kernel_spec.rb +0 -79
  161. data/spec/unit/plugins/windows/memory_spec.rb +0 -52
  162. data/spec/unit/plugins/windows/network_spec.rb +0 -137
  163. data/spec/unit/plugins/windows/system_enclosure_spec.rb +0 -45
  164. data/spec/unit/plugins/windows/uptime_spec.rb +0 -38
  165. data/spec/unit/plugins/windows/virtualization_spec.rb +0 -63
  166. data/spec/unit/plugins/zpools_spec.rb +0 -244
  167. data/spec/unit/provides_map_spec.rb +0 -208
  168. data/spec/unit/runner_spec.rb +0 -422
  169. data/spec/unit/system_spec.rb +0 -416
  170. data/spec/unit/util/file_helper_spec.rb +0 -47
  171. data/spec/unit/util/ip_helper_spec.rb +0 -128
@@ -1,138 +0,0 @@
1
- #
2
- # Author:: Matthew Kent (<mkent@magoazul.com>)
3
- # Author:: Tim Smith (<tsmith@chef.io>)
4
- # Copyright:: Copyright (c) 2011-2018, Chef Software Inc.
5
- # License:: Apache License, Version 2.0
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
- #
19
-
20
- require "spec_helper"
21
-
22
- describe Ohai::System, "BSD filesystem plugin" do
23
- let(:plugin) { get_plugin("filesystem") }
24
-
25
- before do
26
- allow(plugin).to receive(:collect_os).and_return(:freebsd)
27
-
28
- allow(plugin).to receive(:shell_out).with("df").and_return(mock_shell_out(0, "", ""))
29
- allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, "", ""))
30
- allow(plugin).to receive(:shell_out).with("mount -l").and_return(mock_shell_out(0, "", ""))
31
- end
32
-
33
- describe "when gathering filesystem usage data from df" do
34
- before do
35
- @stdout = <<~DF
36
- Filesystem 1K-blocks Used Avail Capacity Mounted on
37
- /dev/ada0p2 9637788 3313504 5553264 37% /
38
- devfs 1 1 0 100% /dev
39
- DF
40
- allow(plugin).to receive(:shell_out).with("df").and_return(mock_shell_out(0, @stdout, ""))
41
-
42
- @inode_stdout = <<~DFI
43
- Filesystem 512-blocks Used Avail Capacity iused ifree %iused Mounted on
44
- /dev/ada0p2 15411832 5109256 9069632 36% 252576 790750 24% /
45
- devfs 2 2 0 100% 0 0 100% /dev
46
- DFI
47
- allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
48
- end
49
-
50
- it "runs df and df -iP" do
51
- expect(plugin).to receive(:shell_out).ordered.with("df").and_return(mock_shell_out(0, @stdout, ""))
52
- expect(plugin).to receive(:shell_out).ordered.with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
53
- plugin.run
54
- end
55
-
56
- it "sets kb_size to value from df" do
57
- plugin.run
58
- expect(plugin[:filesystem]["/dev/ada0p2"][:kb_size]).to eq("9637788")
59
- expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:kb_size]).to eq("9637788")
60
- end
61
-
62
- it "sets kb_used to value from df" do
63
- plugin.run
64
- expect(plugin[:filesystem]["/dev/ada0p2"][:kb_used]).to eq("3313504")
65
- expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:kb_used]).to eq("3313504")
66
- end
67
-
68
- it "sets kb_available to value from df" do
69
- plugin.run
70
- expect(plugin[:filesystem]["/dev/ada0p2"][:kb_available]).to eq("5553264")
71
- expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:kb_available]).to eq("5553264")
72
- end
73
-
74
- it "sets percent_used to value from df" do
75
- plugin.run
76
- expect(plugin[:filesystem]["/dev/ada0p2"][:percent_used]).to eq("37%")
77
- expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:percent_used]).to eq("37%")
78
- end
79
-
80
- it "sets mount to value from df" do
81
- plugin.run
82
- expect(plugin[:filesystem]["/dev/ada0p2"][:mount]).to eq("/")
83
- expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:mount]).to eq("/")
84
- end
85
-
86
- it "sets total_inodes to value from df -iP" do
87
- plugin.run
88
- expect(plugin[:filesystem]["/dev/ada0p2"][:total_inodes]).to eq("1043326")
89
- expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:total_inodes]).to eq("1043326")
90
- end
91
-
92
- it "sets inodes_used to value from df -iP" do
93
- plugin.run
94
- expect(plugin[:filesystem]["/dev/ada0p2"][:inodes_used]).to eq("252576")
95
- expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:inodes_used]).to eq("252576")
96
- end
97
-
98
- it "sets inodes_available to value from df -iP" do
99
- plugin.run
100
- expect(plugin[:filesystem]["/dev/ada0p2"][:inodes_available]).to eq("790750")
101
- expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:inodes_available]).to eq("790750")
102
- end
103
- end
104
-
105
- describe "when gathering mounted filesystem data from mount" do
106
- before do
107
- @stdout = <<~MOUNT
108
- /dev/ada0p2 on / (ufs, local, journaled soft-updates)
109
- devfs on /dev (devfs, local, multilabel)
110
- MOUNT
111
- allow(plugin).to receive(:shell_out).with("mount -l").and_return(mock_shell_out(0, @stdout, ""))
112
- end
113
-
114
- it "runs mount" do
115
- expect(plugin).to receive(:shell_out).with("mount -l").and_return(mock_shell_out(0, @stdout, ""))
116
- plugin.run
117
- end
118
-
119
- it "sets mount to value from mount" do
120
- plugin.run
121
- expect(plugin[:filesystem]["/dev/ada0p2"][:mount]).to eq("/")
122
- expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:mount]).to eq("/")
123
- end
124
-
125
- it "sets fs_type to value from mount" do
126
- plugin.run
127
- expect(plugin[:filesystem]["/dev/ada0p2"][:fs_type]).to eq("ufs")
128
- expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:fs_type]).to eq("ufs")
129
- end
130
-
131
- it "sets mount_options to an array of values from mount" do
132
- plugin.run
133
- expect(plugin[:filesystem]["/dev/ada0p2"][:mount_options]).to eq(["local", "journaled soft-updates"])
134
- expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:mount_options]).to eq(["local", "journaled soft-updates"])
135
- end
136
- end
137
-
138
- end
@@ -1,145 +0,0 @@
1
- #
2
- # Author:: Bryan McLellan <btm@chef.io>
3
- # Copyright:: Copyright (c) 2012-2018 Chef Software, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require "spec_helper"
20
-
21
- describe Ohai::System, "BSD virtualization plugin" do
22
- let(:plugin) { get_plugin("bsd/virtualization") }
23
-
24
- before do
25
- allow(plugin).to receive(:collect_os).and_return(:freebsd)
26
- allow(plugin).to receive(:shell_out).with("sysctl -n security.jail.jailed").and_return(mock_shell_out(0, "0", ""))
27
- allow(plugin).to receive(:shell_out).with((Ohai.abs_path( "/sbin/kldstat" )).to_s).and_return(mock_shell_out(0, "", ""))
28
- allow(plugin).to receive(:shell_out).with("jls -nd").and_return(mock_shell_out(0, "", ""))
29
- allow(plugin).to receive(:shell_out).with("sysctl -n hw.model").and_return(mock_shell_out(0, "", ""))
30
- allow(plugin).to receive(:shell_out).with("sysctl -n kern.vm_guest").and_return(mock_shell_out(0, "", ""))
31
- allow(plugin).to receive(:shell_out).with("sysctl -n kern.hostuuid").and_return(mock_shell_out(0, "", ""))
32
- allow(File).to receive(:exist?).and_return false
33
- end
34
-
35
- context "when on a bhyve host" do
36
- it "detects we are a host" do
37
- allow(File).to receive(:exist?).with("/dev/vmm").and_return true
38
- plugin.run
39
- expect(plugin[:virtualization][:system]).to eq("bhyve")
40
- expect(plugin[:virtualization][:role]).to eq("host")
41
- expect(plugin[:virtualization][:systems][:bhyve]).to eq("host")
42
- end
43
- end
44
-
45
- context "when on a bhyve guest" do
46
- it "detects we are a guest" do
47
- allow(plugin).to receive(:shell_out).with("sysctl -n kern.vm_guest").and_return(mock_shell_out(0, "bhyve", ""))
48
- plugin.run
49
- expect(plugin[:virtualization][:system]).to eq("bhyve")
50
- expect(plugin[:virtualization][:role]).to eq("guest")
51
- expect(plugin[:virtualization][:systems][:bhyve]).to eq("guest")
52
- end
53
- end
54
-
55
- context "jails" do
56
- it "detects we are in a jail" do
57
- allow(plugin).to receive(:shell_out).with("sysctl -n security.jail.jailed").and_return(mock_shell_out(0, "1", ""))
58
- plugin.run
59
- expect(plugin[:virtualization][:system]).to eq("jail")
60
- expect(plugin[:virtualization][:role]).to eq("guest")
61
- expect(plugin[:virtualization][:systems][:jail]).to eq("guest")
62
- end
63
-
64
- it "detects we are hosting jails" do
65
- # from http://www.freebsd.org/doc/handbook/jails-application.html
66
- @jails = "JID IP Address Hostname Path\n 3 192.168.3.17 ns.example.org /home/j/ns\n 2 192.168.3.18 mail.example.org /home/j/mail\n 1 62.123.43.14 www.example.org /home/j/www"
67
- allow(plugin).to receive(:shell_out).with("jls -nd").and_return(mock_shell_out(0, @jails, ""))
68
- plugin.run
69
- expect(plugin[:virtualization][:system]).to eq("jail")
70
- expect(plugin[:virtualization][:role]).to eq("host")
71
- expect(plugin[:virtualization][:systems][:jail]).to eq("host")
72
- end
73
- end
74
-
75
- context "when on a virtualbox guest" do
76
- before do
77
- @vbox_guest = <<~OUT
78
- Id Refs Address Size Name
79
- 1 40 0xffffffff80100000 d20428 kernel
80
- 7 3 0xffffffff81055000 41e88 vboxguest.ko
81
- OUT
82
- allow(plugin).to receive(:shell_out).with((Ohai.abs_path("/sbin/kldstat")).to_s).and_return(mock_shell_out(0, @vbox_guest, ""))
83
- end
84
-
85
- it "detects we are a guest" do
86
- plugin.run
87
- expect(plugin[:virtualization][:system]).to eq("vbox")
88
- expect(plugin[:virtualization][:role]).to eq("guest")
89
- expect(plugin[:virtualization][:systems][:vbox]).to eq("guest")
90
- end
91
- end
92
-
93
- context "when on a virtualbox host" do
94
- before do
95
- @stdout = <<~OUT
96
- Id Refs Address Size Name
97
- 1 40 0xffffffff80100000 d20428 kernel
98
- 7 3 0xffffffff81055000 41e88 vboxdrv.ko
99
- OUT
100
- allow(plugin).to receive(:shell_out).with("/sbin/kldstat").and_return(mock_shell_out(0, @stdout, ""))
101
- end
102
-
103
- it "detects we are a host" do
104
- plugin.run
105
- expect(plugin[:virtualization][:system]).to eq("vbox")
106
- expect(plugin[:virtualization][:role]).to eq("host")
107
- expect(plugin[:virtualization][:systems][:vbox]).to eq("host")
108
- end
109
- end
110
-
111
- context "when on a QEMU guest" do
112
- it "detects we are a guest" do
113
- [ "Common KVM processor", 'QEMU Virtual CPU version (cpu64-rhel6) ("GenuineIntel" 686-class)', "Common 32-bit KVM processor"].each do |kvm_string|
114
- allow(plugin).to receive(:shell_out).with("sysctl -n hw.model").and_return(mock_shell_out(0, kvm_string, ""))
115
- plugin.run
116
- expect(plugin[:virtualization][:system]).to eq("kvm")
117
- expect(plugin[:virtualization][:role]).to eq("guest")
118
- expect(plugin[:virtualization][:systems][:kvm]).to eq("guest")
119
- end
120
- end
121
- end
122
-
123
- { xen: "xen", vmware: "vmware", hyperv: "hv", kvm: "kvm", bhyve: "bhyve" }.each_pair do |hypervisor, val|
124
- context "when on a #{hypervisor} guest" do
125
- it "detects we are a guest" do
126
- allow(plugin).to receive(:shell_out).with("sysctl -n kern.vm_guest").and_return(mock_shell_out(0, val, ""))
127
- plugin.run
128
- expect(plugin[:virtualization][:system]).to eq(hypervisor.to_s)
129
- expect(plugin[:virtualization][:role]).to eq("guest")
130
- expect(plugin[:virtualization][:systems][hypervisor]).to eq("guest")
131
- end
132
- end
133
- end
134
-
135
- context "when on an amazonec2 guest" do
136
- it "detects we are a guest" do
137
- allow(plugin).to receive(:shell_out).with("sysctl -n kern.vm_guest").and_return(mock_shell_out(0, "kvm", ""))
138
- allow(plugin).to receive(:shell_out).with("sysctl -n kern.hostuuid").and_return(mock_shell_out(0, "ec2fb75c-7a36-7938-4efa-8e40b4ac634b", ""))
139
- plugin.run
140
- expect(plugin[:virtualization][:system]).to eq("amazonec2")
141
- expect(plugin[:virtualization][:role]).to eq("guest")
142
- expect(plugin[:virtualization][:systems][:amazonec2]).to eq("guest")
143
- end
144
- end
145
- end
@@ -1,341 +0,0 @@
1
-
2
- # Author:: Doug MacEachern <dougm@vmware.com>
3
- # Copyright:: Copyright (c) 2010 VMware, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require "spec_helper"
20
-
21
- C_GCC = <<~EOF.freeze
22
- Using built-in specs.
23
- COLLECT_GCC=gcc
24
- COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
25
- Target: x86_64-linux-gnu
26
- Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.4' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
27
- Thread model: posix
28
- gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)
29
- EOF
30
-
31
- C_GLIBC = <<~EOF.freeze
32
- GNU C Library stable release version 2.5, by Roland McGrath et al.
33
- Copyright (C) 2006 Free Software Foundation, Inc.
34
- This is free software; see the source for copying conditions.
35
- There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
36
- PARTICULAR PURPOSE.
37
- Compiled by GNU CC version 4.1.2 20080704 (Red Hat 4.1.2-44).
38
- Compiled on a Linux 2.6.9 system on 2009-09-02.
39
- Available extensions:
40
- The C stubs add-on version 2.1.2.
41
- crypt add-on version 2.1 by Michael Glad and others
42
- GNU Libidn by Simon Josefsson
43
- GNU libio by Per Bothner
44
- NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk
45
- Native POSIX Threads Library by Ulrich Drepper et al
46
- BIND-8.2.3-T5B
47
- RT using linux kernel aio
48
- Thread-local storage support included.
49
- For bug reporting instructions, please see:
50
- <http://www.gnu.org/software/libc/bugs.html>.
51
- EOF
52
-
53
- C_CL = <<~EOF.freeze
54
- Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86
55
- Copyright (C) Microsoft Corporation. All rights reserved.
56
- EOF
57
-
58
- C_VS = <<~EOF.freeze
59
-
60
- Microsoft (R) Visual Studio Version 8.0.50727.762.
61
- Copyright (C) Microsoft Corp 1984-2005. All rights reserved.
62
- EOF
63
-
64
- C_XLC = <<~EOF.freeze
65
- IBM XL C/C++ Enterprise Edition for AIX, V9.0
66
- Version: 09.00.0000.0000
67
- EOF
68
-
69
- C_SUN = <<~EOF.freeze
70
- cc: Sun C 5.8 Patch 121016-06 2007/08/01
71
- EOF
72
-
73
- describe Ohai::System, "plugin c" do
74
-
75
- let(:plugin) { get_plugin("c") }
76
-
77
- before do
78
-
79
- plugin[:languages] = Mash.new
80
- # gcc
81
- allow(plugin).to receive(:shell_out).with("gcc -v").and_return(mock_shell_out(0, "", C_GCC))
82
- end
83
-
84
- context "on AIX" do
85
- before do
86
- allow(plugin).to receive(:collect_os).and_return(:aix)
87
- allow(plugin).to receive(:shell_out).with("xlc -qversion").and_return(mock_shell_out(0, C_XLC, ""))
88
- end
89
-
90
- # ibm xlc
91
- it "gets the xlc version from running xlc -qversion" do
92
- expect(plugin).to receive(:shell_out).with("xlc -qversion").and_return(mock_shell_out(0, C_XLC, ""))
93
- plugin.run
94
- end
95
-
96
- it "sets languages[:c][:xlc][:version]" do
97
- plugin.run
98
- expect(plugin.languages[:c][:xlc][:version]).to eql("9.0")
99
- end
100
-
101
- it "sets languages[:c][:xlc][:description]" do
102
- plugin.run
103
- expect(plugin.languages[:c][:xlc][:description]).to eql("IBM XL C/C++ Enterprise Edition for AIX, V9.0")
104
- end
105
-
106
- it "does not set the languages[:c][:xlc] tree up if xlc command exits nonzero" do
107
- allow(plugin).to receive(:shell_out).with("xlc -qversion").and_return(mock_shell_out(1, "", ""))
108
- plugin.run
109
- expect(plugin[:languages][:c]).not_to have_key(:xlc)
110
- end
111
-
112
- it "does not set the languages[:c][:xlc] tree up if xlc command fails" do
113
- allow(plugin).to receive(:shell_out).with("xlc -qversion").and_raise(Ohai::Exceptions::Exec)
114
- plugin.run
115
- expect(plugin[:languages][:c]).not_to have_key(:xlc)
116
- expect(plugin[:languages][:c]).not_to be_empty # expect other attributes
117
- end
118
-
119
- it "sets the languages[:c][:xlc] tree up if xlc exit status is 249" do
120
- allow(plugin).to receive(:shell_out).with("xlc -qversion").and_return(mock_shell_out(63744, "", ""))
121
- plugin.run
122
- expect(plugin[:languages][:c]).not_to have_key(:xlc)
123
- end
124
-
125
- end
126
-
127
- context "on Darwin" do
128
- before do
129
- allow(plugin).to receive(:shell_out).with("/usr/bin/xcode-select -p").and_return(mock_shell_out(0, "", ""))
130
- allow(plugin).to receive(:collect_os).and_return(:darwin)
131
- end
132
-
133
- it "shells out to see if xcode is installed" do
134
- expect(plugin).to receive(:shell_out).with("/usr/bin/xcode-select -p")
135
- plugin.run
136
- end
137
-
138
- it "doesnt shellout to gcc if xcode isn't installed" do
139
- allow(plugin).to receive(:shell_out).with("/usr/bin/xcode-select -p").and_return(mock_shell_out(1, "", ""))
140
- expect(plugin).not_to receive(:shell_out).with("gcc -v")
141
- plugin.run
142
- end
143
-
144
- end
145
-
146
- context "on Windows" do
147
- before do
148
- allow(plugin).to receive(:collect_os).and_return(:windows)
149
- allow(plugin).to receive(:shell_out).with("cl /\?").and_return(mock_shell_out(0, "", C_CL))
150
- allow(plugin).to receive(:shell_out).with("devenv.com /\?").and_return(mock_shell_out(0, C_VS, ""))
151
- end
152
-
153
- # ms cl
154
- it "gets the cl version from running cl /?" do
155
- expect(plugin).to receive(:shell_out).with("cl /\?")
156
- plugin.run
157
- end
158
-
159
- it "sets languages[:c][:cl][:version]" do
160
- plugin.run
161
- expect(plugin.languages[:c][:cl][:version]).to eql("14.00.50727.762")
162
- end
163
-
164
- it "sets languages[:c][:cl][:description]" do
165
- plugin.run
166
- expect(plugin.languages[:c][:cl][:description]).to eql("Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86")
167
- end
168
-
169
- it "does not set the languages[:c][:cl] tree up if cl command exits nonzero" do
170
- allow(plugin).to receive(:shell_out).with("cl /\?").and_return(mock_shell_out(1, "", ""))
171
- plugin.run
172
- expect(plugin[:languages][:c]).not_to have_key(:cl)
173
- end
174
-
175
- it "does not set the languages[:c][:cl] tree up if cl command fails" do
176
- allow(plugin).to receive(:shell_out).with("cl /\?").and_raise(Ohai::Exceptions::Exec)
177
- plugin.run
178
- expect(plugin[:languages][:c]).not_to have_key(:cl)
179
- expect(plugin[:languages][:c]).not_to be_empty # expect other attributes
180
- end
181
-
182
- # ms vs
183
- it "gets the vs version from running devenv.com /?" do
184
- expect(plugin).to receive(:shell_out).with("devenv.com /\?").and_return(mock_shell_out(0, C_VS, ""))
185
- plugin.run
186
- end
187
-
188
- it "sets languages[:c][:vs][:version]" do
189
- plugin.run
190
- expect(plugin.languages[:c][:vs][:version]).to eql("8.0.50727.762")
191
- end
192
-
193
- it "sets languages[:c][:vs][:description]" do
194
- plugin.run
195
- expect(plugin.languages[:c][:vs][:description]).to eql("Microsoft (R) Visual Studio Version 8.0.50727.762.")
196
- end
197
-
198
- it "does not set the languages[:c][:vs] tree up if devenv command exits nonzero" do
199
- allow(plugin).to receive(:shell_out).with("devenv.com /\?").and_return(mock_shell_out(1, "", ""))
200
- plugin.run
201
- expect(plugin[:languages][:c]).not_to have_key(:vs)
202
- end
203
-
204
- it "does not set the languages[:c][:vs] tree up if devenv command fails" do
205
- allow(plugin).to receive(:shell_out).with("devenv.com /\?").and_raise(Ohai::Exceptions::Exec)
206
- plugin.run
207
- expect(plugin[:languages][:c]).not_to have_key(:vs)
208
- expect(plugin[:languages][:c]).not_to be_empty # expect other attributes
209
- end
210
- end
211
-
212
- context "on Linux" do
213
- before do
214
- allow(plugin).to receive(:collect_os).and_return(:linux)
215
- # glibc
216
- allow(plugin).to receive(:shell_out).with("/lib/libc.so.6").and_return(mock_shell_out(0, C_GLIBC, ""))
217
- allow(plugin).to receive(:shell_out).with("/lib64/libc.so.6").and_return(mock_shell_out(0, C_GLIBC, ""))
218
- # sun pro
219
- allow(plugin).to receive(:shell_out).with("cc -V -flags").and_return(mock_shell_out(0, "", C_SUN))
220
- end
221
-
222
- # gcc
223
- it "gets the gcc version from running gcc -v" do
224
- expect(plugin).to receive(:shell_out).with("gcc -v")
225
- plugin.run
226
- end
227
-
228
- it "sets languages[:c][:gcc][:version]" do
229
- plugin.run
230
- expect(plugin.languages[:c][:gcc][:version]).to eql("5.4.0")
231
- end
232
-
233
- it "sets languages[:c][:gcc][:description]" do
234
- plugin.run
235
- expect(plugin.languages[:c][:gcc][:description]).to eql("gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)")
236
- end
237
-
238
- it "sets languages[:c][:gcc][:configured_with]" do
239
- plugin.run
240
- expect(plugin.languages[:c][:gcc][:configured_with]).to eql("../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.4' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu")
241
- end
242
-
243
- it "sets languages[:c][:gcc][:target]" do
244
- plugin.run
245
- expect(plugin.languages[:c][:gcc][:target]).to eql("x86_64-linux-gnu")
246
- end
247
-
248
- it "sets languages[:c][:gcc][:thread_model]" do
249
- plugin.run
250
- expect(plugin.languages[:c][:gcc][:thread_model]).to eql("posix")
251
- end
252
-
253
- it "does not set the languages[:c][:gcc] tree up if gcc command exits nonzero" do
254
- allow(plugin).to receive(:shell_out).with("gcc -v").and_return(mock_shell_out(1, "", ""))
255
- plugin.run
256
- expect(plugin[:languages][:c]).not_to have_key(:gcc)
257
- end
258
-
259
- it "does not set the languages[:c][:gcc] tree up if gcc command fails" do
260
- allow(plugin).to receive(:shell_out).with("gcc -v").and_raise(Ohai::Exceptions::Exec)
261
- plugin.run
262
- expect(plugin[:languages][:c]).not_to have_key(:gcc)
263
- expect(plugin[:languages][:c]).not_to be_empty # expect other attributes
264
- end
265
-
266
- # glibc
267
- it "gets the glibc x.x.x version from running /lib/libc.so.6" do
268
- expect(plugin).to receive(:shell_out).with("/lib/libc.so.6")
269
- plugin.run
270
- end
271
-
272
- it "sets languages[:c][:glibc][:version]", :unix_only do
273
- plugin.run
274
- expect(plugin.languages[:c][:glibc][:version]).to eql("2.5")
275
- end
276
-
277
- it "sets languages[:c][:glibc][:description]" do
278
- plugin.run
279
- expect(plugin.languages[:c][:glibc][:description]).to eql("GNU C Library stable release version 2.5, by Roland McGrath et al.")
280
- end
281
-
282
- it "does not set the languages[:c][:glibc] tree up if glibc exits nonzero" do
283
- allow(plugin).to receive(:shell_out).with("/lib/libc.so.6").and_return(mock_shell_out(1, "", ""))
284
- allow(plugin).to receive(:shell_out).with("/lib64/libc.so.6").and_return(mock_shell_out(1, "", ""))
285
- plugin.run
286
- expect(plugin[:languages][:c]).not_to have_key(:glibc)
287
- end
288
-
289
- it "does not set the languages[:c][:glibc] tree up if glibc fails" do
290
- allow(plugin).to receive(:shell_out).with("/lib/libc.so.6").and_raise(Ohai::Exceptions::Exec)
291
- allow(plugin).to receive(:shell_out).with("/lib64/libc.so.6").and_raise(Ohai::Exceptions::Exec)
292
- plugin.run
293
- expect(plugin[:languages][:c]).not_to have_key(:glibc)
294
- expect(plugin[:languages][:c]).not_to be_empty # expect other attributes
295
- end
296
-
297
- it "gets the glibc x.x version from running /lib/libc.so.6" do
298
- allow(plugin).to receive(:shell_out).with("/lib/libc.so.6").and_return(mock_shell_out(0, C_GLIBC, ""))
299
- expect(plugin).to receive(:shell_out).with("/lib/libc.so.6")
300
- plugin.run
301
- expect(plugin.languages[:c][:glibc][:version]).to eql("2.5")
302
- end
303
-
304
- # sun pro
305
- it "gets the cc version from running cc -V -flags" do
306
- expect(plugin).to receive(:shell_out).with("cc -V -flags").and_return(mock_shell_out(0, "", C_SUN))
307
- plugin.run
308
- end
309
-
310
- it "sets languages[:c][:sunpro][:version]" do
311
- plugin.run
312
- expect(plugin.languages[:c][:sunpro][:version]).to eql("5.8")
313
- end
314
-
315
- it "sets languages[:c][:sunpro][:description]" do
316
- plugin.run
317
- expect(plugin.languages[:c][:sunpro][:description]).to eql("cc: Sun C 5.8 Patch 121016-06 2007/08/01")
318
- end
319
-
320
- it "does not set the languages[:c][:sunpro] tree up if cc command exits nonzero" do
321
- allow(plugin).to receive(:shell_out).with("cc -V -flags").and_return(mock_shell_out(1, "", ""))
322
- plugin.run
323
- expect(plugin[:languages][:c]).not_to have_key(:sunpro)
324
- end
325
-
326
- it "does not set the languages[:c][:sunpro] tree up if cc command fails" do
327
- allow(plugin).to receive(:shell_out).with("cc -V -flags").and_raise(Ohai::Exceptions::Exec)
328
- plugin.run
329
- expect(plugin[:languages][:c]).not_to have_key(:sunpro)
330
- expect(plugin[:languages][:c]).not_to be_empty # expect other attributes
331
- end
332
-
333
- it "does not set the languages[:c][:sunpro] tree if the corresponding cc command fails on linux" do
334
- fedora_error_message = "cc: error trying to exec 'i686-redhat-linux-gcc--flags': execvp: No such file or directory"
335
-
336
- allow(plugin).to receive(:shell_out).with("cc -V -flags").and_return(mock_shell_out(0, "", fedora_error_message))
337
- plugin.run
338
- expect(plugin[:languages][:c]).not_to have_key(:sunpro)
339
- end
340
- end
341
- end