summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-11-23 20:09:19 -0800
committerTim Smith <tsmith84@gmail.com>2020-11-23 20:09:19 -0800
commit2ae04e544f05e448b283355c865053456f6d242f (patch)
tree848a3a4e03f6857b1cf818e47d8218f1c697d866
parent115f471fb35e058d009cf86cc59f8d49c602b64f (diff)
downloadohai-2ae04e544f05e448b283355c865053456f6d242f.tar.gz
Fix XLC compiler detection to support 3 part version numbersxlc
Add a spec with the newer XLC output from our build systems. Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/ohai/plugins/c.rb6
-rw-r--r--spec/unit/plugins/c_spec.rb12
2 files changed, 15 insertions, 3 deletions
diff --git a/lib/ohai/plugins/c.rb b/lib/ohai/plugins/c.rb
index fb064e81..80cccaca 100644
--- a/lib/ohai/plugins/c.rb
+++ b/lib/ohai/plugins/c.rb
@@ -123,12 +123,12 @@ Ohai.plugin(:C) do
end
def collect_xlc
- # ibm xlc
-
+ # IBM XL C/C++ for AIX, V13.1.3 (5725-C72, 5765-J07)
+ # Version: 13.01.0003.0000
so = shell_out("xlc -qversion")
if so.exitstatus == 0 || (so.exitstatus >> 8) == 249
description = so.stdout.split($/).first
- if description =~ /V(\d+\.\d+)/
+ if description =~ /V(\d+\.\d+(.\d+)?)/
@c[:xlc] = Mash.new
@c[:xlc][:version] = $1
@c[:xlc][:description] = description.strip
diff --git a/spec/unit/plugins/c_spec.rb b/spec/unit/plugins/c_spec.rb
index e295e0ca..0b895291 100644
--- a/spec/unit/plugins/c_spec.rb
+++ b/spec/unit/plugins/c_spec.rb
@@ -65,6 +65,11 @@ C_XLC = <<~EOF.freeze
Version: 09.00.0000.0000
EOF
+C_XLC_NEWER = <<~EOF.freeze
+ IBM XL C/C++ for AIX, V13.1.3 (5725-C72, 5765-J07)
+ Version: 13.01.0003.0000
+EOF
+
C_SUN = <<~EOF.freeze
cc: Sun C 5.8 Patch 121016-06 2007/08/01
EOF
@@ -108,6 +113,13 @@ describe Ohai::System, "plugin c" do
expect(plugin[:languages][:c]).not_to have_key(:xlc)
end
+ it "properly parses 3 part version numbers in newer XLC releases" do
+ expect(plugin).to receive(:shell_out).with("xlc -qversion").and_return(mock_shell_out(0, C_XLC_NEWER, ""))
+ plugin.run
+ expect(plugin.languages[:c][:xlc][:version]).to eql("13.1.3")
+ expect(plugin.languages[:c][:xlc][:description]).to eql("IBM XL C/C++ for AIX, V13.1.3 (5725-C72, 5765-J07)")
+ end
+
it "does not set the languages[:c][:xlc] tree up if xlc command fails" do
allow(plugin).to receive(:shell_out).with("xlc -qversion").and_raise(Ohai::Exceptions::Exec)
plugin.run