Skip to content

Commit

Permalink
Merge pull request #1574 from chef/aix_kernel
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Smith <[email protected]>
  • Loading branch information
tas50 authored Nov 18, 2020
2 parents 3938730 + c8fc500 commit a65dafa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
10 changes: 6 additions & 4 deletions lib/ohai/plugins/aix/kernel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
collect_data(:aix) do
kernel Mash.new

kernel[:name] = shell_out("uname -s").stdout.split($/)[0].downcase
kernel[:release] = shell_out("uname -r").stdout.split($/)[0]
kernel[:version] = shell_out("uname -v").stdout.split($/)[0]
kernel[:machine] = shell_out("uname -p").stdout.split($/)[0]
uname_so = shell_out("uname -srvp").stdout.split

kernel[:name] = uname_so[0].downcase
kernel[:release] = uname_so[1]
kernel[:version] = uname_so[2]
kernel[:machine] = uname_so[3]
kernel[:bits] = shell_out("getconf KERNEL_BITMODE").stdout.strip

modules = Mash.new
Expand Down
9 changes: 3 additions & 6 deletions spec/unit/plugins/aix/kernel_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@
before do
@plugin = get_plugin("aix/kernel")
allow(@plugin).to receive(:collect_os).and_return(:aix)
allow(@plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "AIX", nil))
allow(@plugin).to receive(:shell_out).with("uname -r").and_return(mock_shell_out(0, "1", nil))
allow(@plugin).to receive(:shell_out).with("uname -v").and_return(mock_shell_out(0, "6", nil))
allow(@plugin).to receive(:shell_out).with("uname -p").and_return(mock_shell_out(0, "powerpc", nil))
allow(@plugin).to receive(:shell_out).with("uname -srvp").and_return(mock_shell_out(0, "AIX 2 7 powerpc", nil))
allow(@plugin).to receive(:shell_out).with("genkex -d").and_return(mock_shell_out(0, " Text address Size Data address Size File\nf1000000c0338000 77000 f1000000c0390000 1ec8c /usr/lib/drivers/cluster\n 6390000 20000 63a0000 ba8 /usr/lib/drivers/if_en", nil))
allow(@plugin).to receive(:shell_out).with("getconf KERNEL_BITMODE").and_return(mock_shell_out(0, "64", nil))
@plugin.run
Expand All @@ -36,11 +33,11 @@
end

it "uname -r detects the release" do
expect(@plugin[:kernel][:release]).to eq("1")
expect(@plugin[:kernel][:release]).to eq("2")
end

it "uname -v detects the version" do
expect(@plugin[:kernel][:version]).to eq("6")
expect(@plugin[:kernel][:version]).to eq("7")
end

it "uname -p detects the machine" do
Expand Down

0 comments on commit a65dafa

Please sign in to comment.