diff -Nru facter-1.6.4/CHANGELOG facter-1.6.5/CHANGELOG --- facter-1.6.4/CHANGELOG 2011-12-07 21:05:35.000000000 +0000 +++ facter-1.6.5/CHANGELOG 2012-01-25 19:37:57.000000000 +0000 @@ -1,6 +1,38 @@ +1.6.5 +=== +71d3d3d (#12077) Add pciutils RPM dependency +1df5b46 (#11566) Add windows support for ec2 facts +d1a33e5 (#11848) Don't hard code ruby install paths in Windows batch files +14cad7e Build a Rake task for building Apple Packages +5a60ca6 (#11559) Switch to RbConfig & Provide alias for RbConfig for pre-1.8.5 +88c9429 (#10271) Identifying 'Amazon' using '/etc/system-release' +2de7b84 (#11661) EC2 rspec tests were using throw not raise to simulate a timeout +b51ccf0 (#11583) Add basic coverage to the ec2 fact +82692ba (#9599) Generalize zone detection +e6cebd3 (#9599) Add nexenta facts +9401b78 (#11583) Switch request method to open-uri monkey patch 'open' +3ccac87 (#9708) Amend requires in specs to use simple requires +b0b5282 (#9708) Confine facts by kernel not operating system and remove confine for hardwareisa +c473e3f (#10309) Remove the with_verbose_disabled method +a99d87c (#10309) Rename tmpfile to tmpfilename to make function clear +d50fc48 (#10309) Move all fixture data in spec/unit/data to spec/fixtures +d6e8523 (#10309) Integrate new PuppetlabsSpec helpers into our existing facter spec code and general spec cleanup +c1604c7 (#10309) Add puppetlabs_spec helper library based on Puppets own puppet_spec helpers +d141e7e (maint) Fix requirement for FileUtils as operatingsystem_spec needs it now +9c224d3 (#11436) Unify memorysize and memorytotal facts +5c6322a (maint) Joined conditional statements for domain +a1dba38 (#11196) Scan all arp entries for an ec2 mac +5cd30eb (#8279) Join ec2 fact output with commas +4633996 (#9789) Extend coverage of operatingsystem specs +6d21f90 Move Linux specific virtual tests to correct block. +cb4e294 (#7753) Added error checking when adding resolves +6201820 (maint) remove redundant arch detection +4f9da1c (#11328) Fix uptime detection on OpenBSD +3f99f16 (#11328) Add virtualisation detection for OpenBSD + 1.6.4 === -6406c8f (##11041) Add dmidecode as a requirement for rpm +6406c8f (#11041) Add dmidecode as a requirement for rpm ed81492 (#10444) Add identification of system boards to Facter bdbb2da (#10885) Malformed facter.bat when ruby dir contains backreferences 0bad18b (#10490) Handle case where no macaddress can be found diff -Nru facter-1.6.4/conf/redhat/facter.spec facter-1.6.5/conf/redhat/facter.spec --- facter-1.6.4/conf/redhat/facter.spec 2011-12-01 01:56:14.000000000 +0000 +++ facter-1.6.5/conf/redhat/facter.spec 2012-01-25 19:37:57.000000000 +0000 @@ -1,4 +1,4 @@ -%{!?ruby_sitelibdir: %define ruby_sitelibdir %(ruby -rrbconfig -e 'puts Config::CONFIG["sitelibdir"]')} +%{!?ruby_sitelibdir: %define ruby_sitelibdir %(ruby -rrbconfig -e 'puts Object.const_get(defined?(RbConfig) ? :RbConfig : :Config)::CONFIG["sitelibdir"]' %define has_ruby_abi 0%{?fedora} || 0%{?rhel} >= 5 %define has_ruby_noarch %has_ruby_abi @@ -22,6 +22,7 @@ Requires: ruby >= 1.8.1 Requires: which Requires: dmidecode +Requires: pciutils %if %has_ruby_abi Requires: ruby(abi) = 1.8 %endif diff -Nru facter-1.6.4/debian/changelog facter-1.6.5/debian/changelog --- facter-1.6.4/debian/changelog 2012-01-30 21:07:03.000000000 +0000 +++ facter-1.6.5/debian/changelog 2012-02-13 01:40:28.000000000 +0000 @@ -1,3 +1,23 @@ +facter (1.6.5-1ubuntu1) precise; urgency=low + + * Merge from Debian testing. Remaining changes: + - debian/rules: use what we had in natty; we don't want ruby-pkg-tools + in main. (LP: #408402) + - debian/control: Continue using ruby + libopenssl-ruby as Build-Depends + even tho Debian has moved to gem2deb (not in main). Move ruby-json to + Suggests. + - debian/rules: Use dh_prep instead of dh_clean, add build-arch + + build-indep targets + - debian/control: Make binary package depend on ruby1.8 explicitly + + -- Chuck Short Sun, 12 Feb 2012 20:40:24 -0500 + +facter (1.6.5-1) unstable; urgency=low + + * New upstream release + + -- Stig Sandbeck Mathisen Thu, 26 Jan 2012 11:11:13 +0100 + facter (1.6.4-2ubuntu1) precise; urgency=low * Merge from Debian testing (LP: #922788). Remaining changes: diff -Nru facter-1.6.4/install.rb facter-1.6.5/install.rb --- facter-1.6.4/install.rb 2011-12-01 01:44:50.000000000 +0000 +++ facter-1.6.5/install.rb 2012-01-18 18:11:40.000000000 +0000 @@ -46,6 +46,12 @@ $haverdoc = false end +# Monkey patch RbConfig->Config for Rubies older then 1.8.5. +unless defined? ::RbConfig + require 'rbconfig' + ::RbConfig = ::Config +end + begin if $haverdoc rst2man = %x{which rst2man.py} @@ -180,16 +186,16 @@ opts.on('--destdir[=OPTIONAL]', 'Installation prefix for all targets', 'Default essentially /') do |destdir| InstallOptions.destdir = destdir end - opts.on('--bindir[=OPTIONAL]', 'Installation directory for binaries', 'overrides Config::CONFIG["bindir"]') do |bindir| + opts.on('--bindir[=OPTIONAL]', 'Installation directory for binaries', 'overrides RbConfig::CONFIG["bindir"]') do |bindir| InstallOptions.bindir = bindir end - opts.on('--sbindir[=OPTIONAL]', 'Installation directory for system binaries', 'overrides Config::CONFIG["sbindir"]') do |sbindir| + opts.on('--sbindir[=OPTIONAL]', 'Installation directory for system binaries', 'overrides RbConfig::CONFIG["sbindir"]') do |sbindir| InstallOptions.sbindir = sbindir end - opts.on('--sitelibdir[=OPTIONAL]', 'Installation directory for libraries', 'overrides Config::CONFIG["sitelibdir"]') do |sitelibdir| + opts.on('--sitelibdir[=OPTIONAL]', 'Installation directory for libraries', 'overrides RbConfig::CONFIG["sitelibdir"]') do |sitelibdir| InstallOptions.sitelibdir = sitelibdir end - opts.on('--mandir[=OPTIONAL]', 'Installation directory for man pages', 'overrides Config::CONFIG["mandir"]') do |mandir| + opts.on('--mandir[=OPTIONAL]', 'Installation directory for man pages', 'overrides RbConfig::CONFIG["mandir"]') do |mandir| InstallOptions.mandir = mandir end opts.on('--quick', 'Performs a quick installation. Only the', 'installation is done.') do |quick| @@ -213,8 +219,8 @@ tmpdirs = [ENV['TMP'], ENV['TEMP'], "/tmp", "/var/tmp", "."] - version = [Config::CONFIG["MAJOR"], Config::CONFIG["MINOR"]].join(".") - libdir = File.join(Config::CONFIG["libdir"], "ruby", version) + version = [RbConfig::CONFIG["MAJOR"], RbConfig::CONFIG["MINOR"]].join(".") + libdir = File.join(RbConfig::CONFIG["libdir"], "ruby", version) # Mac OS X 10.5 and higher declare bindir and sbindir as # /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin @@ -222,26 +228,26 @@ # which is not generally where people expect executables to be installed # These settings are appropriate defaults for all OS X versions. if RUBY_PLATFORM =~ /^universal-darwin[\d\.]+$/ - Config::CONFIG['bindir'] = "/usr/bin" - Config::CONFIG['sbindir'] = "/usr/sbin" + RbConfig::CONFIG['bindir'] = "/usr/bin" + RbConfig::CONFIG['sbindir'] = "/usr/sbin" end if not InstallOptions.bindir.nil? bindir = InstallOptions.bindir else - bindir = Config::CONFIG['bindir'] + bindir = RbConfig::CONFIG['bindir'] end if not InstallOptions.sbindir.nil? sbindir = InstallOptions.sbindir else - sbindir = Config::CONFIG['sbindir'] + sbindir = RbConfig::CONFIG['sbindir'] end if not InstallOptions.sitelibdir.nil? sitelibdir = InstallOptions.sitelibdir else - sitelibdir = Config::CONFIG["sitelibdir"] + sitelibdir = RbConfig::CONFIG["sitelibdir"] if sitelibdir.nil? sitelibdir = $:.find { |x| x =~ /site_ruby/ } if sitelibdir.nil? @@ -255,7 +261,7 @@ if not InstallOptions.mandir.nil? mandir = InstallOptions.mandir else - mandir = Config::CONFIG['mandir'] + mandir = RbConfig::CONFIG['mandir'] end # To be deprecated once people move over to using --destdir option @@ -373,7 +379,7 @@ end ## -# Install file(s) from ./bin to Config::CONFIG['bindir']. Patch it on the way +# Install file(s) from ./bin to RbConfig::CONFIG['bindir']. Patch it on the way # to insert a #! line; on a Unix install, the command is named as expected # (e.g., bin/rdoc becomes rdoc); the shebang line handles running it. Under # windows, we add an '.rb' extension and let file associations do their stuff. @@ -388,11 +394,11 @@ fail "Cannot find a temporary directory" unless tmp_dir tmp_file = File.join(tmp_dir, '_tmp') - ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']) + ruby = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) File.open(from) do |ip| File.open(tmp_file, "w") do |op| - ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']) + ruby = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) op.puts "#!#{ruby}" contents = ip.readlines if contents[0] =~ /^#!/ @@ -417,16 +423,12 @@ if not installed_wrapper tmp_file2 = File.join(tmp_dir, '_tmp_wrapper') - cwn = File.join(Config::CONFIG['bindir'], op_file) cwv = <<-EOS @echo off -if "%OS%"=="Windows_NT" goto WinNT -#{ruby} -x "#{cwn}" %1 %2 %3 %4 %5 %6 %7 %8 %9 -goto done -:WinNT -#{ruby} -x "#{cwn}" %* -goto done -:done +setlocal +set RUBY_BIN=%~dp0 +set RUBY_BIN=%RUBY_BIN:\\=/% +"%RUBY_BIN%ruby.exe" -x "%RUBY_BIN%facter" %* EOS File.open(tmp_file2, "w") { |cw| cw.puts cwv } FileUtils.install(tmp_file2, File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true) diff -Nru facter-1.6.4/lib/facter/domain.rb facter-1.6.5/lib/facter/domain.rb --- facter-1.6.4/lib/facter/domain.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/lib/facter/domain.rb 2012-01-18 18:11:40.000000000 +0000 @@ -23,12 +23,12 @@ # Get the domain from various sources; the order of these # steps is important - if name = Facter::Util::Resolution.exec('hostname') and - name =~ /.*?\.(.+$)/ + if name = Facter::Util::Resolution.exec('hostname') \ + and name =~ /.*?\.(.+$)/ $1 - elsif domain = Facter::Util::Resolution.exec('dnsdomainname') and - domain =~ /.+\..+/ + elsif domain = Facter::Util::Resolution.exec('dnsdomainname') \ + and domain =~ /.+\..+/ domain elsif FileTest.exists?("/etc/resolv.conf") diff -Nru facter-1.6.4/lib/facter/ec2.rb facter-1.6.5/lib/facter/ec2.rb --- facter-1.6.4/lib/facter/ec2.rb 2011-09-13 23:19:13.000000000 +0000 +++ facter-1.6.5/lib/facter/ec2.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,20 +1,5 @@ -# Original fact Tim Dysinger -# Additional work from KurtBe -# Additional work for Paul Nasrat -# Additional work modelled on Ohai EC2 fact - +require 'facter/util/ec2' require 'open-uri' -require 'timeout' - -def can_connect?(wait_sec=2) - url = "http://169.254.169.254:80/" - Timeout::timeout(wait_sec) {open(url)} - return true - rescue Timeout::Error - return false - rescue - return false -end def metadata(id = "") open("http://169.254.169.254/2008-02-01/meta-data/#{id||=''}").read. @@ -23,9 +8,8 @@ if key[-1..-1] != '/' value = open("http://169.254.169.254/2008-02-01/meta-data/#{key}").read. split("\n") - value = value.size>1 ? value : value.first symbol = "ec2_#{key.gsub(/\-|\//, '_')}".to_sym - Facter.add(symbol) { setcode { value } } + Facter.add(symbol) { setcode { value.join(',') } } else metadata(key) end @@ -34,21 +18,15 @@ def userdata() begin - value = OpenURI.open_uri("http://169.254.169.254/2008-02-01/user-data/").read.split - Facter.add(:ec2_userdata) { setcode { value } } + value = open("http://169.254.169.254/2008-02-01/user-data/").read.split + Facter.add(:ec2_userdata) { setcode { value } } rescue OpenURI::HTTPError end end -def has_euca_mac? - !!(Facter.value(:macaddress) =~ %r{^[dD]0:0[dD]:}) -end - -def has_ec2_arp? - !!(Facter.value(:arp) == "fe:ff:ff:ff:ff:ff") -end +if (Facter::Util::EC2.has_euca_mac? || Facter::Util::EC2.has_ec2_arp?) && + Facter::Util::EC2.can_connect? -if (has_euca_mac? || has_ec2_arp?) && can_connect? metadata userdata else diff -Nru facter-1.6.4/lib/facter/hardwareisa.rb facter-1.6.5/lib/facter/hardwareisa.rb --- facter-1.6.4/lib/facter/hardwareisa.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/lib/facter/hardwareisa.rb 2012-01-18 18:11:40.000000000 +0000 @@ -12,5 +12,4 @@ Facter.add(:hardwareisa) do setcode 'uname -p' - confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS Scientific PSBM SLC Ascendos SuSE SLES Debian Ubuntu Gentoo FreeBSD OpenBSD NetBSD DragonFly OEL OracleLinux OVS GNU/kFreeBSD} end diff -Nru facter-1.6.4/lib/facter/hardwaremodel.rb facter-1.6.5/lib/facter/hardwaremodel.rb --- facter-1.6.4/lib/facter/hardwaremodel.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/lib/facter/hardwaremodel.rb 2012-01-18 18:11:40.000000000 +0000 @@ -29,6 +29,6 @@ confine :operatingsystem => :windows setcode do require 'rbconfig' - Config::CONFIG['host_cpu'] + RbConfig::CONFIG['host_cpu'] end end diff -Nru facter-1.6.4/lib/facter/lsbmajdistrelease.rb facter-1.6.5/lib/facter/lsbmajdistrelease.rb --- facter-1.6.4/lib/facter/lsbmajdistrelease.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/lib/facter/lsbmajdistrelease.rb 2012-01-18 18:11:40.000000000 +0000 @@ -15,7 +15,7 @@ require 'facter' Facter.add("lsbmajdistrelease") do - confine :operatingsystem => %w{Linux Fedora RedHat CentOS Scientific PSBM SLC Ascendos SuSE SLES Debian Ubuntu Gentoo OEL OracleLinux OVS GNU/kFreeBSD} + confine :kernel => %w{Linux GNU/kFreeBSD} setcode do if /(\d*)\./i =~ Facter.value(:lsbdistrelease) result=$1 diff -Nru facter-1.6.4/lib/facter/macaddress.rb facter-1.6.5/lib/facter/macaddress.rb --- facter-1.6.4/lib/facter/macaddress.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/lib/facter/macaddress.rb 2012-01-18 18:11:40.000000000 +0000 @@ -10,7 +10,7 @@ require 'facter/util/macaddress' Facter.add(:macaddress) do - confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS Scientific PSBM SLC Ascendos SuSE SLES Debian Gentoo Ubuntu OEL OracleLinux OVS GNU/kFreeBSD} + confine :kernel => %w{SunOS Linux GNU/kFreeBSD} setcode do ether = [] output = Facter::Util::Resolution.exec("/sbin/ifconfig -a") diff -Nru facter-1.6.4/lib/facter/memory.rb facter-1.6.5/lib/facter/memory.rb --- facter-1.6.4/lib/facter/memory.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/lib/facter/memory.rb 2012-01-18 18:11:40.000000000 +0000 @@ -116,7 +116,7 @@ Facter::Memory.vmstat_find_free_memory() - Facter.add("MemoryTotal") do + Facter.add("memorysize") do confine :kernel => :openbsd memtotal = Facter::Util::Resolution.exec("sysctl hw.physmem | cut -d'=' -f2") setcode do @@ -153,7 +153,7 @@ Facter::Memory.vmstat_darwin_find_free_memory() - Facter.add("MemoryTotal") do + Facter.add("memorysize") do confine :kernel => :Darwin memtotal = Facter::Util::Resolution.exec("sysctl hw.memsize | cut -d':' -f2") setcode do @@ -220,7 +220,7 @@ end end - Facter.add("MemoryTotal") do + Facter.add("memorysize") do confine :kernel => :windows setcode do mem = 0 @@ -254,7 +254,7 @@ end end -Facter.add("MemoryTotal") do +Facter.add("memorysize") do confine :kernel => :dragonfly setcode do Facter::Memory.vmstat_find_free_memory() @@ -262,3 +262,14 @@ Facter::Memory.scale_number(memtotal.to_f,"") end end + +# http://projects.puppetlabs.com/issues/11436 +# +# Unifying naming for the amount of physical memory in a given host. +# This fact is DEPRECATED and will be removed in Facter 2.0 per +# http://projects.puppetlabs.com/issues/11466 +Facter.add("MemoryTotal") do + setcode do + Facter.value("memorysize") + end +end diff -Nru facter-1.6.4/lib/facter/operatingsystem.rb facter-1.6.5/lib/facter/operatingsystem.rb --- facter-1.6.4/lib/facter/operatingsystem.rb 2011-11-09 19:10:25.000000000 +0000 +++ facter-1.6.5/lib/facter/operatingsystem.rb 2012-01-18 18:11:40.000000000 +0000 @@ -14,7 +14,13 @@ Facter.add(:operatingsystem) do confine :kernel => :sunos - setcode do "Solaris" end + setcode do + if FileTest.exists?("/etc/debian_version") + "Nexenta" + else + "Solaris" + end + end end Facter.add(:operatingsystem) do @@ -44,8 +50,6 @@ else "OEL" end - elsif FileTest.exists?("/etc/arch-release") - "Arch" elsif FileTest.exists?("/etc/vmware-release") "VMWareESX" elsif FileTest.exists?("/etc/redhat-release") @@ -84,7 +88,7 @@ "Slackware" elsif FileTest.exists?("/etc/alpine-release") "Alpine" - elsif Facter.value(:lsbdistdescription) =~ /Amazon Linux/ + elsif FileTest.exists?("/etc/system-release") "Amazon" end end diff -Nru facter-1.6.4/lib/facter/osfamily.rb facter-1.6.5/lib/facter/osfamily.rb --- facter-1.6.4/lib/facter/osfamily.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/lib/facter/osfamily.rb 2012-01-18 18:11:40.000000000 +0000 @@ -22,7 +22,7 @@ "Debian" when "SLES", "SLED", "OpenSuSE", "SuSE" "Suse" - when "Solaris" + when "Solaris", "Nexenta" "Solaris" else Facter.value("kernel") diff -Nru facter-1.6.4/lib/facter/uniqueid.rb facter-1.6.5/lib/facter/uniqueid.rb --- facter-1.6.4/lib/facter/uniqueid.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/lib/facter/uniqueid.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,4 +1,4 @@ Facter.add(:uniqueid) do setcode 'hostid' - confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS Scientific PSBM SLC Ascendos SuSE SLES Debian Ubuntu Gentoo AIX OEL OracleLinux OVS GNU/kFreeBSD} + confine :kernel => %w{SunOS Linux AIX GNU/kFreeBSD} end diff -Nru facter-1.6.4/lib/facter/util/collection.rb facter-1.6.5/lib/facter/util/collection.rb --- facter-1.6.4/lib/facter/util/collection.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/lib/facter/util/collection.rb 2012-01-18 18:11:40.000000000 +0000 @@ -31,9 +31,8 @@ end end - if block - resolve = fact.add(&block) - # Set any resolve-appropriate options + if block_given? and resolve = fact.add(&block) + # If the resolve was actually added, set any resolve-appropriate options options.each do |opt, value| method = opt.to_s + "=" if resolve.respond_to?(method) diff -Nru facter-1.6.4/lib/facter/util/config.rb facter-1.6.5/lib/facter/util/config.rb --- facter-1.6.4/lib/facter/util/config.rb 2011-09-21 20:31:59.000000000 +0000 +++ facter-1.6.5/lib/facter/util/config.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,9 +1,9 @@ +require 'rbconfig' + # A module to return config related data # module Facter::Util::Config - require 'rbconfig' - def self.is_windows? - Config::CONFIG['host_os'] =~ /mswin|win32|dos|mingw|cygwin/i + RbConfig::CONFIG['host_os'] =~ /mswin|win32|dos|mingw|cygwin/i end end diff -Nru facter-1.6.4/lib/facter/util/ec2.rb facter-1.6.5/lib/facter/util/ec2.rb --- facter-1.6.4/lib/facter/util/ec2.rb 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/lib/facter/util/ec2.rb 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,49 @@ +require 'timeout' +require 'open-uri' + +# Provide a set of utility static methods that help with resolving the EC2 +# fact. +module Facter::Util::EC2 + class << self + # Test if we can connect to the EC2 api. Return true if able to connect. + # On failure this function fails silently and returns false. + # + # The +wait_sec+ parameter provides you with an adjustable timeout. + # + def can_connect?(wait_sec=2) + url = "http://169.254.169.254:80/" + Timeout::timeout(wait_sec) {open(url)} + return true + rescue Timeout::Error + return false + rescue + return false + end + + # Test if this host has a mac address used by Eucalyptus clouds, which + # normally is +d0:0d+. + def has_euca_mac? + !!(Facter.value(:macaddress) =~ %r{^[dD]0:0[dD]:}) + end + + # Test if the host has an arp entry in its cache that matches the EC2 arp, + # which is normally +fe:ff:ff:ff:ff:ff+. + def has_ec2_arp? + mac_address = "fe:ff:ff:ff:ff:ff" + if Facter.value(:kernel) == 'windows' + arp_command = "arp -a" + mac_address.gsub!(":","-") + else + arp_command = "arp -an" + end + + arp_table = Facter::Util::Resolution.exec(arp_command) + if not arp_table.nil? + arp_table.each_line do |line| + return true if line.include?(mac_address) + end + end + return false + end + end +end diff -Nru facter-1.6.4/lib/facter/util/fact.rb facter-1.6.5/lib/facter/util/fact.rb --- facter-1.6.4/lib/facter/util/fact.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/lib/facter/util/fact.rb 2012-01-18 18:11:40.000000000 +0000 @@ -33,17 +33,22 @@ def add(&block) raise ArgumentError, "You must pass a block to Fact.add" unless block_given? - resolve = Facter::Util::Resolution.new(@name) + begin + resolve = Facter::Util::Resolution.new(@name) - resolve.instance_eval(&block) + resolve.instance_eval(&block) - @resolves << resolve + @resolves << resolve - # Immediately sort the resolutions, so that we always have - # a sorted list for looking up values. - @resolves.sort! { |a, b| b.weight <=> a.weight } + # Immediately sort the resolutions, so that we always have + # a sorted list for looking up values. + @resolves.sort! { |a, b| b.weight <=> a.weight } - return resolve + resolve + rescue => e + Facter.warn "Unable to add resolve for #{@name}: #{e}" + nil + end end # Flush any cached values. diff -Nru facter-1.6.4/lib/facter/util/monkey_patches.rb facter-1.6.5/lib/facter/util/monkey_patches.rb --- facter-1.6.4/lib/facter/util/monkey_patches.rb 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/lib/facter/util/monkey_patches.rb 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,7 @@ +# This provides an alias for RbConfig to Config for versions of Ruby older then +# version 1.8.5. This allows us to use RbConfig in place of the older Config in +# our code and still be compatible with at least Ruby 1.8.1. +require 'rbconfig' +unless defined? ::RbConfig + ::RbConfig = ::Config +end diff -Nru facter-1.6.4/lib/facter/util/uptime.rb facter-1.6.5/lib/facter/util/uptime.rb --- facter-1.6.4/lib/facter/util/uptime.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/lib/facter/util/uptime.rb 2012-01-18 18:11:40.000000000 +0000 @@ -27,7 +27,7 @@ def self.uptime_sysctl if output = Facter::Util::Resolution.exec("#{uptime_sysctl_cmd} 2>/dev/null") - compute_uptime(Time.at(output.unpack('L').first)) + compute_uptime(Time.at(output.match(/\d+/)[0].to_i)) end end @@ -52,7 +52,7 @@ end def self.uptime_sysctl_cmd - 'sysctl -b kern.boottime' + 'sysctl -n kern.boottime' end def self.uptime_kstat_cmd diff -Nru facter-1.6.4/lib/facter/util/virtual.rb facter-1.6.5/lib/facter/util/virtual.rb --- facter-1.6.4/lib/facter/util/virtual.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/lib/facter/util/virtual.rb 2012-01-18 18:11:40.000000000 +0000 @@ -55,7 +55,7 @@ def self.kvm? txt = if FileTest.exists?("/proc/cpuinfo") File.read("/proc/cpuinfo") - elsif Facter.value(:kernel)=="FreeBSD" + elsif ["FreeBSD", "OpenBSD"].include? Facter.value(:kernel) Facter::Util::Resolution.exec("/sbin/sysctl -n hw.model") end (txt =~ /QEMU Virtual CPU/) ? true : false diff -Nru facter-1.6.4/lib/facter/virtual.rb facter-1.6.5/lib/facter/virtual.rb --- facter-1.6.4/lib/facter/virtual.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/lib/facter/virtual.rb 2012-01-18 18:11:40.000000000 +0000 @@ -52,7 +52,7 @@ setcode do - if Facter.value(:operatingsystem) == "Solaris" and Facter::Util::Virtual.zone? + if Facter.value(:kernel) == "SunOS" and Facter::Util::Virtual.zone? result = "zone" end @@ -131,6 +131,16 @@ result = "xenhvm" if pd =~ /HVM domU/ end end + elsif Facter.value(:kernel) == 'OpenBSD' + output = Facter::Util::Resolution.exec('sysctl -n hw.product 2>/dev/null') + if not output.nil? + output.each_line do |pd| + result = "parallels" if pd =~ /Parallels/ + result = "vmware" if pd =~ /VMware/ + result = "virtualbox" if pd =~ /VirtualBox/ + result = "xenhvm" if pd =~ /HVM domU/ + end + end end end diff -Nru facter-1.6.4/lib/facter.rb facter-1.6.5/lib/facter.rb --- facter-1.6.4/lib/facter.rb 2011-12-01 01:56:14.000000000 +0000 +++ facter-1.6.5/lib/facter.rb 2012-01-18 18:13:16.000000000 +0000 @@ -20,11 +20,12 @@ require 'facter/util/fact' require 'facter/util/collection' + require 'facter/util/monkey_patches' include Comparable include Enumerable - FACTERVERSION = '1.6.4' + FACTERVERSION = '1.6.5' # = Facter # Functions as a hash of 'facts' you might care about about your # system, such as mac address, IP address, Video card, etc. diff -Nru facter-1.6.4/spec/fixtures/unit/selinux/selinux_sestatus facter-1.6.5/spec/fixtures/unit/selinux/selinux_sestatus --- facter-1.6.4/spec/fixtures/unit/selinux/selinux_sestatus 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/fixtures/unit/selinux/selinux_sestatus 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,6 @@ +SELinux status: enabled +SELinuxfs mount: /selinux +Current Mode: permissive +Mode from config file: permissive +Policy version: 16 +Policy from config file: targeted diff -Nru facter-1.6.4/spec/fixtures/unit/util/ec2/linux-arp-ec2.out facter-1.6.5/spec/fixtures/unit/util/ec2/linux-arp-ec2.out --- facter-1.6.4/spec/fixtures/unit/util/ec2/linux-arp-ec2.out 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/fixtures/unit/util/ec2/linux-arp-ec2.out 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1 @@ +? (10.240.93.1) at fe:ff:ff:ff:ff:ff [ether] on eth0 diff -Nru facter-1.6.4/spec/fixtures/unit/util/ec2/linux-arp-not-ec2.out facter-1.6.5/spec/fixtures/unit/util/ec2/linux-arp-not-ec2.out --- facter-1.6.4/spec/fixtures/unit/util/ec2/linux-arp-not-ec2.out 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/fixtures/unit/util/ec2/linux-arp-not-ec2.out 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,5 @@ +? (46.4.106.97) at 00:26:88:75:c1:17 [ether] on eth0 +? (10.1.2.14) at 02:00:0a:01:02:0e [ether] on virbr1 +? (10.1.2.12) at 02:00:0a:01:02:0c [ether] on virbr1 +? (10.1.2.11) at 02:00:0a:01:02:0b [ether] on virbr1 +? (10.1.2.200) at 02:00:0a:01:02:0e [ether] on virbr1 diff -Nru facter-1.6.4/spec/fixtures/unit/util/ec2/windows-2008-arp-a-not-ec2.out facter-1.6.5/spec/fixtures/unit/util/ec2/windows-2008-arp-a-not-ec2.out --- facter-1.6.4/spec/fixtures/unit/util/ec2/windows-2008-arp-a-not-ec2.out 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/fixtures/unit/util/ec2/windows-2008-arp-a-not-ec2.out 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,6 @@ + +Interface: 192.168.5.4 --- 0xd + Internet Address Physical Address Type + 192.168.5.1 c8-02-14-0c-5d-18 dynamic + 192.168.5.255 ff-ff-ff-ff-ff-ff static + 255.255.255.255 ff-ff-ff-ff-ff-ff static diff -Nru facter-1.6.4/spec/fixtures/unit/util/ec2/windows-2008-arp-a.out facter-1.6.5/spec/fixtures/unit/util/ec2/windows-2008-arp-a.out --- facter-1.6.4/spec/fixtures/unit/util/ec2/windows-2008-arp-a.out 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/fixtures/unit/util/ec2/windows-2008-arp-a.out 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,10 @@ + +Interface: 10.32.123.54 --- 0xd + Internet Address Physical Address Type + 10.32.120.163 fe-ff-ff-ff-ff-ff dynamic + 10.32.122.1 fe-ff-ff-ff-ff-ff dynamic + 10.32.123.255 ff-ff-ff-ff-ff-ff static + 169.254.169.254 fe-ff-ff-ff-ff-ff dynamic + 224.0.0.22 01-00-5e-00-00-16 static + 224.0.0.252 01-00-5e-00-00-fc static + 255.255.255.255 ff-ff-ff-ff-ff-ff static \ No newline at end of file diff -Nru facter-1.6.4/spec/fixtures/unit/util/ip/6.0-STABLE_FreeBSD_ifconfig facter-1.6.5/spec/fixtures/unit/util/ip/6.0-STABLE_FreeBSD_ifconfig --- facter-1.6.4/spec/fixtures/unit/util/ip/6.0-STABLE_FreeBSD_ifconfig 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/fixtures/unit/util/ip/6.0-STABLE_FreeBSD_ifconfig 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,12 @@ +fxp0: flags=8843 mtu 1500 + options=b + inet x.x.58.26 netmask 0xfffffff8 broadcast x.x.58.31 + inet x.x.58.27 netmask 0xffffffff broadcast x.x.58.27 + inet x.x.58.28 netmask 0xffffffff broadcast x.x.58.28 + inet x.x.58.29 netmask 0xffffffff broadcast x.x.58.29 + inet x.x.58.30 netmask 0xffffffff broadcast x.x.58.30 + ether 00:0e:0c:68:67:7c + media: Ethernet autoselect (100baseTX ) + status: active +lo0: flags=8049 mtu 16384 + inet 127.0.0.1 netmask 0xff000000 \ No newline at end of file diff -Nru facter-1.6.4/spec/fixtures/unit/util/ip/darwin_ifconfig_all_with_multiple_interfaces facter-1.6.5/spec/fixtures/unit/util/ip/darwin_ifconfig_all_with_multiple_interfaces --- facter-1.6.4/spec/fixtures/unit/util/ip/darwin_ifconfig_all_with_multiple_interfaces 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/fixtures/unit/util/ip/darwin_ifconfig_all_with_multiple_interfaces 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,10 @@ +lo0: flags=8049 mtu 16384 + inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 + inet 127.0.0.1 netmask 0xff000000 + inet6 ::1 prefixlen 128 +en0: flags=8863 mtu 1500 + inet6 fe80::223:6cff:fe99:602b%en1 prefixlen 64 scopeid 0x5 + inet 192.168.0.10 netmask 0xffffff00 broadcast 192.168.0.255 + ether 00:23:6c:99:60:2b + media: autoselect status: active + supported media: autoselect diff -Nru facter-1.6.4/spec/fixtures/unit/util/ip/darwin_ifconfig_single_interface facter-1.6.5/spec/fixtures/unit/util/ip/darwin_ifconfig_single_interface --- facter-1.6.4/spec/fixtures/unit/util/ip/darwin_ifconfig_single_interface 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/fixtures/unit/util/ip/darwin_ifconfig_single_interface 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,6 @@ +en1: flags=8863 mtu 1500 + inet6 fe80::21c:b3ff:febe:81c9%en1 prefixlen 64 scopeid 0x6 + inet 10.0.0.101 netmask 0xffffff00 broadcast 10.0.0.255 + ether 00:1c:b3:be:81:c9 + media: autoselect status: active + supported media: autoselect diff -Nru facter-1.6.4/spec/fixtures/unit/util/ip/debian_kfreebsd_ifconfig facter-1.6.5/spec/fixtures/unit/util/ip/debian_kfreebsd_ifconfig --- facter-1.6.4/spec/fixtures/unit/util/ip/debian_kfreebsd_ifconfig 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/fixtures/unit/util/ip/debian_kfreebsd_ifconfig 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,40 @@ +em0: flags=8843 metric 0 mtu 1500 + options=209b + ether 0:11:a:59:67:90 + inet6 fe80::211:aff:fe59:6790%em0 prefixlen 64 scopeid 0x1 + nd6 options=3 + media: Ethernet autoselect (1000baseT ) + status: active +em1: flags=8843 metric 0 mtu 1500 + options=209b + ether 0:11:a:59:67:91 + inet6 fe80::211:aff:fe59:6791%em1 prefixlen 64 scopeid 0x2 + inet 192.168.10.10 netmask 0xffffff00 broadcast 192.168.10.255 + nd6 options=3 + media: Ethernet autoselect (100baseTX ) + status: active +bge0: flags=8802 metric 0 mtu 1500 + options=8009b + ether 0:14:c2:3f:ea:e4 + media: Ethernet autoselect (none) + status: no carrier +bge1: flags=8802 metric 0 mtu 1500 + options=8009b + ether 0:14:c2:3f:ea:e3 + media: Ethernet autoselect (none) + status: no carrier +lo0: flags=8049 metric 0 mtu 16384 + options=3 + inet6 ::1 prefixlen 128 + inet6 fe80::1%lo0 prefixlen 64 scopeid 0x5 + inet 127.0.0.1 netmask 0xff000000 + nd6 options=3 +vlan0: flags=8843 metric 0 mtu 1500 + options=3 + ether 0:11:a:59:67:90 + inet6 fe80::211:aff:fe59:6790%vlan0 prefixlen 64 scopeid 0x6 + inet 192.168.192.2 netmask 0xffffff00 broadcast 192.168.192.255 + nd6 options=3 + media: Ethernet autoselect (1000baseT ) + status: active + vlan: 192 parent interface: em0 diff -Nru facter-1.6.4/spec/fixtures/unit/util/ip/hpux_ifconfig_single_interface facter-1.6.5/spec/fixtures/unit/util/ip/hpux_ifconfig_single_interface --- facter-1.6.4/spec/fixtures/unit/util/ip/hpux_ifconfig_single_interface 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/fixtures/unit/util/ip/hpux_ifconfig_single_interface 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,3 @@ +lan0: flags=1843 + inet 168.24.80.71 netmask ffffff00 broadcast 168.24.80.255 +00:13:21:BD:9C:B7 diff -Nru facter-1.6.4/spec/fixtures/unit/util/ip/hpux_netstat_all_interfaces facter-1.6.5/spec/fixtures/unit/util/ip/hpux_netstat_all_interfaces --- facter-1.6.4/spec/fixtures/unit/util/ip/hpux_netstat_all_interfaces 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/fixtures/unit/util/ip/hpux_netstat_all_interfaces 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,3 @@ +lan1 1500 192.168.100.0 192.168.100.182 12964 0 900 0 0 +lan0 1500 192.168.100.0 192.168.100.181 12964 0 715 0 0 +lo0 4136 127.0.0.0 127.0.0.1 98 0 98 0 0 diff -Nru facter-1.6.4/spec/fixtures/unit/util/ip/linux_ifconfig_all_with_single_interface facter-1.6.5/spec/fixtures/unit/util/ip/linux_ifconfig_all_with_single_interface --- facter-1.6.4/spec/fixtures/unit/util/ip/linux_ifconfig_all_with_single_interface 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/fixtures/unit/util/ip/linux_ifconfig_all_with_single_interface 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,18 @@ +eth0 Link encap:Ethernet HWaddr 00:0c:29:52:15:e9 + inet addr:172.16.15.133 Bcast:172.16.15.255 Mask:255.255.255.0 + inet6 addr: fe80::20c:29ff:fe52:15e9/64 Scope:Link + UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 + RX packets:173 errors:173 dropped:0 overruns:0 frame:0 + TX packets:208 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:1000 + RX bytes:40970 (40.0 KB) TX bytes:24760 (24.1 KB) + Interrupt:16 Base address:0x2024 + +lo Link encap:Local Loopback + inet addr:127.0.0.1 Mask:255.0.0.0 + inet6 addr: ::1/128 Scope:Host + UP LOOPBACK RUNNING MTU:16436 Metric:1 + RX packets:1630 errors:0 dropped:0 overruns:0 frame:0 + TX packets:1630 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:81500 (79.5 KB) TX bytes:81500 (79.5 KB) \ No newline at end of file diff -Nru facter-1.6.4/spec/fixtures/unit/util/ip/Mac_OS_X_10.5.5_ifconfig facter-1.6.5/spec/fixtures/unit/util/ip/Mac_OS_X_10.5.5_ifconfig --- facter-1.6.4/spec/fixtures/unit/util/ip/Mac_OS_X_10.5.5_ifconfig 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/fixtures/unit/util/ip/Mac_OS_X_10.5.5_ifconfig 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,26 @@ +lo0: flags=8049 mtu 16384 + inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 + inet 127.0.0.1 netmask 0xff000000 + inet6 ::1 prefixlen 128 +gif0: flags=8010 mtu 1280 +stf0: flags=0<> mtu 1280 +en0: flags=8863 mtu 1500 + ether 00:1b:63:ae:02:66 + media: autoselect status: inactive + supported media: autoselect 10baseT/UTP 10baseT/UTP 10baseT/UTP 10baseT/UTP 100baseTX 100baseTX 100baseTX 100baseTX 1000baseT 1000baseT 1000baseT none +fw0: flags=8863 mtu 4078 + lladdr 00:1e:52:ff:fe:31:1a:80 + media: autoselect status: inactive + supported media: autoselect +en1: flags=8863 mtu 1500 + inet6 fe80::21e:52ff:fe70:d7b6%en1 prefixlen 64 scopeid 0x6 + inet 192.168.0.4 netmask 0xffffff00 broadcast 192.168.0.255 + ether 00:1e:52:70:d7:b6 + media: autoselect status: active + supported media: autoselect +vmnet8: flags=8863 mtu 1500 + inet 172.16.15.1 netmask 0xffffff00 broadcast 172.16.15.255 + ether 00:50:56:c0:00:08 +vmnet1: flags=8863 mtu 1500 + inet 192.168.89.1 netmask 0xffffff00 broadcast 192.168.89.255 + ether 00:50:56:c0:00:01 diff -Nru facter-1.6.4/spec/fixtures/unit/util/ip/solaris_ifconfig_all_with_multiple_interfaces facter-1.6.5/spec/fixtures/unit/util/ip/solaris_ifconfig_all_with_multiple_interfaces --- facter-1.6.4/spec/fixtures/unit/util/ip/solaris_ifconfig_all_with_multiple_interfaces 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/fixtures/unit/util/ip/solaris_ifconfig_all_with_multiple_interfaces 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,8 @@ +lo0: flags=2001000849 mtu 8232 index 1 + inet 127.0.0.1 netmask ff000000 +e1000g0: flags=201004843 mtu 1500 index 2 + inet 192.168.162.130 netmask ffffff00 broadcast 192.168.162.255 +lo0: flags=2002000849 mtu 8252 index 1 + inet6 ::1/128 +e1000g0: flags=202004841 mtu 1500 index 2 + inet6 fe80::20c:29ff:fe09:627e/10 diff -Nru facter-1.6.4/spec/fixtures/unit/util/ip/solaris_ifconfig_single_interface facter-1.6.5/spec/fixtures/unit/util/ip/solaris_ifconfig_single_interface --- facter-1.6.4/spec/fixtures/unit/util/ip/solaris_ifconfig_single_interface 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/fixtures/unit/util/ip/solaris_ifconfig_single_interface 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,3 @@ +e1000g0: flags=201004843 mtu 1500 index 2 + inet 172.16.15.138 netmask ffffff00 broadcast 172.16.15.255 + ether 0:c:29:c1:70:2a \ No newline at end of file diff -Nru facter-1.6.4/spec/fixtures/unit/util/ip/windows_netsh_all_interfaces facter-1.6.5/spec/fixtures/unit/util/ip/windows_netsh_all_interfaces --- facter-1.6.4/spec/fixtures/unit/util/ip/windows_netsh_all_interfaces 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/fixtures/unit/util/ip/windows_netsh_all_interfaces 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,12 @@ +Idx Met MTU State Name +--- ---------- ---------- ------------ --------------------------- + 1 50 4294967295 connected Loopback Pseudo-Interface 1 + 9 10 1500 connected Local Area Connection + + +Idx Met MTU State Name +--- ---------- ---------- ------------ --------------------------- + 1 50 4294967295 connected Loopback Pseudo-Interface 1 + 9 10 1500 connected Local Area Connection + 11 50 1280 disconnected isatap.localdomain + 12 50 1280 connected Teredo Tunneling Pseudo-Interface diff -Nru facter-1.6.4/spec/fixtures/unit/util/ip/windows_netsh_single_interface facter-1.6.5/spec/fixtures/unit/util/ip/windows_netsh_single_interface --- facter-1.6.4/spec/fixtures/unit/util/ip/windows_netsh_single_interface 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/fixtures/unit/util/ip/windows_netsh_single_interface 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,7 @@ +Configuration for interface "Local Area Connection" + DHCP enabled: Yes + IP Address: 172.16.138.216 + Subnet Prefix: 172.16.138.0/24 (mask 255.255.255.0) + Default Gateway: 172.16.138.2 + Gateway Metric: 0 + InterfaceMetric: 10 diff -Nru facter-1.6.4/spec/fixtures/unit/util/ip/windows_netsh_single_interface6 facter-1.6.5/spec/fixtures/unit/util/ip/windows_netsh_single_interface6 --- facter-1.6.4/spec/fixtures/unit/util/ip/windows_netsh_single_interface6 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/fixtures/unit/util/ip/windows_netsh_single_interface6 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,18 @@ + +Address fe80::2087:77a:53ef:7527%12 Parameters +--------------------------------------------------------- +Interface Luid : Teredo Tunneling Pseudo-Interface +Scope Id : 0.12 +Valid Lifetime : infinite +Preferred Lifetime : infinite +DAD State : Preferred +Address Type : Other + +Address 2001:0:4137:9e76:2087:77a:53ef:7527 Parameters +--------------------------------------------------------- +Interface Luid : Teredo Tunneling Pseudo-Interface +Scope Id : 0.0 +Valid Lifetime : infinite +Preferred Lifetime : infinite +DAD State : Preferred +Address Type : Public diff -Nru facter-1.6.4/spec/fixtures/unit/util/manufacturer/freebsd_dmidecode facter-1.6.5/spec/fixtures/unit/util/manufacturer/freebsd_dmidecode --- facter-1.6.4/spec/fixtures/unit/util/manufacturer/freebsd_dmidecode 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/fixtures/unit/util/manufacturer/freebsd_dmidecode 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,42 @@ +# dmidecode 2.10 +SMBIOS 2.5 present. +5 structures occupying 352 bytes. +Table at 0x000E1000. + +Handle 0x0000, DMI type 0, 20 bytes +BIOS Information + Vendor: innotek GmbH + Version: VirtualBox + Release Date: 12/01/2006 + Address: 0xE0000 + Runtime Size: 128 kB + ROM Size: 128 kB + Characteristics: + ISA is supported + PCI is supported + Boot from CD is supported + Selectable boot is supported + 8042 keyboard services are supported (int 9h) + CGA/mono video services are supported (int 10h) + ACPI is supported + +Handle 0x0001, DMI type 1, 27 bytes +System Information + Manufacturer: innotek GmbH + Product Name: VirtualBox + Version: 1.2 + Serial Number: 0 + UUID: 3BD58031-AE9E-4F06-8A57-941942861939 + Wake-up Type: Power Switch + SKU Number: Not Specified + Family: Virtual Machine + +Handle 0x0003, DMI type 126, 13 bytes +Inactive + +Handle 0x0002, DMI type 126, 7 bytes +Inactive + +Handle 0xFEFF, DMI type 127, 147 bytes +End Of Table + diff -Nru facter-1.6.4/spec/fixtures/unit/util/manufacturer/linux_dmidecode_with_spaces facter-1.6.5/spec/fixtures/unit/util/manufacturer/linux_dmidecode_with_spaces --- facter-1.6.4/spec/fixtures/unit/util/manufacturer/linux_dmidecode_with_spaces 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/fixtures/unit/util/manufacturer/linux_dmidecode_with_spaces 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,60 @@ +# dmidecode 2.2 +SMBIOS 2.3 present. +32 structures occupying 994 bytes. +Table at 0x000F0800. +Handle 0x0000 + DMI type 0, 20 bytes. + BIOS Information + Vendor: Award Software International, Inc. + Version: 6.00 PG + Release Date: 01/03/2003 + Address: 0xE0000 + Runtime Size: 128 kB + ROM Size: 256 kB + Characteristics: + ISA is supported + PCI is supported + PNP is supported + APM is supported + BIOS is upgradeable + BIOS shadowing is allowed + ESCD support is available + Boot from CD is supported + Selectable boot is supported + BIOS ROM is socketed + EDD is supported + 5.25"/360 KB floppy services are supported (int 13h) + 5.25"/1.2 MB floppy services are supported (int 13h) + 3.5"/720 KB floppy services are supported (int 13h) + 3.5"/2.88 MB floppy services are supported (int 13h) + Print screen service is supported (int 5h) + 8042 keyboard services are supported (int 9h) + Serial services are supported (int 14h) + Printer services are supported (int 17h) + CGA/mono video services are supported (int 10h) + ACPI is supported + USB legacy is supported + AGP is supported + LS-120 boot is supported + ATAPI Zip drive boot is supported +Handle 0x0001 + DMI type 1, 25 bytes. + System Information + Manufacturer: MICRO-STAR INTERNATIONAL CO., LTD + Product Name: MS-6754 + Version: + Serial Number: + UUID: Not Present + Wake-up Type: Power Switch +Handle 0x0002 + DMI type 2, 8 bytes. + Base Board Information + Manufacturer: MICRO-STAR INTERNATIONAL CO., LTD + Product Name: MS-6754 + Version: + Serial Number: + +Handle 0x001F + DMI type 127, 4 bytes. + End Of Table + diff -Nru facter-1.6.4/spec/fixtures/unit/util/manufacturer/opensolaris_smbios facter-1.6.5/spec/fixtures/unit/util/manufacturer/opensolaris_smbios --- facter-1.6.4/spec/fixtures/unit/util/manufacturer/opensolaris_smbios 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/fixtures/unit/util/manufacturer/opensolaris_smbios 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,33 @@ +ID SIZE TYPE +0 54 SMB_TYPE_BIOS (BIOS information) + + Vendor: innotek GmbH + Version String: VirtualBox + Release Date: 12/01/2006 + Address Segment: 0xe000 + ROM Size: 131072 bytes + Image Size: 131072 bytes + Characteristics: 0x48018090 + SMB_BIOSFL_ISA (ISA is supported) + SMB_BIOSFL_PCI (PCI is supported) + SMB_BIOSFL_CDBOOT (Boot from CD is supported) + SMB_BIOSFL_SELBOOT (Selectable Boot supported) + SMB_BIOSFL_I9_KBD (int 0x9 8042 keyboard svcs) + SMB_BIOSFL_I10_CGA (int 0x10 CGA svcs) + Characteristics Extension Byte 1: 0x1 + SMB_BIOSXB1_ACPI (ACPI is supported) + Characteristics Extension Byte 2: 0x0 + +ID SIZE TYPE +1 72 SMB_TYPE_SYSTEM (system information) + + Manufacturer: innotek GmbH + Product: VirtualBox + Version: 1.2 + Serial Number: 0 + + UUID: cf4bff06-0b33-4891-bda0-5ec17bea5511 + Wake-Up Event: 0x6 (power switch) + SKU Number: + Family: Virtual Machine + diff -Nru facter-1.6.4/spec/fixtures/unit/util/uptime/kstat_boot_time facter-1.6.5/spec/fixtures/unit/util/uptime/kstat_boot_time --- facter-1.6.4/spec/fixtures/unit/util/uptime/kstat_boot_time 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/fixtures/unit/util/uptime/kstat_boot_time 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1 @@ +unix:0:system_misc:boot_time 1236919980 diff -Nru facter-1.6.4/spec/fixtures/unit/util/uptime/sysctl_kern_boottime_darwin facter-1.6.5/spec/fixtures/unit/util/uptime/sysctl_kern_boottime_darwin --- facter-1.6.4/spec/fixtures/unit/util/uptime/sysctl_kern_boottime_darwin 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/fixtures/unit/util/uptime/sysctl_kern_boottime_darwin 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1 @@ +{ sec = 1320011547, usec = 0 } Sun Oct 30 21:52:27 2011 diff -Nru facter-1.6.4/spec/fixtures/unit/util/uptime/sysctl_kern_boottime_openbsd facter-1.6.5/spec/fixtures/unit/util/uptime/sysctl_kern_boottime_openbsd --- facter-1.6.4/spec/fixtures/unit/util/uptime/sysctl_kern_boottime_openbsd 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/fixtures/unit/util/uptime/sysctl_kern_boottime_openbsd 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1 @@ +1323465106 diff -Nru facter-1.6.4/spec/fixtures/unit/util/uptime/ubuntu_proc_uptime facter-1.6.5/spec/fixtures/unit/util/uptime/ubuntu_proc_uptime --- facter-1.6.4/spec/fixtures/unit/util/uptime/ubuntu_proc_uptime 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/fixtures/unit/util/uptime/ubuntu_proc_uptime 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1 @@ +5097686.63 40756306.43 diff -Nru facter-1.6.4/spec/fixtures/unit/util/uptime/who_b_boottime facter-1.6.5/spec/fixtures/unit/util/uptime/who_b_boottime --- facter-1.6.4/spec/fixtures/unit/util/uptime/who_b_boottime 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/fixtures/unit/util/uptime/who_b_boottime 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1 @@ +reboot ~ Aug 1 14:13 diff -Nru facter-1.6.4/spec/fixtures/unit/util/vlans/linux_vlan_config facter-1.6.5/spec/fixtures/unit/util/vlans/linux_vlan_config --- facter-1.6.4/spec/fixtures/unit/util/vlans/linux_vlan_config 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/fixtures/unit/util/vlans/linux_vlan_config 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,6 @@ +VLAN Dev name | VLAN ID +Name-Type: VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD +eth0.400 | 400 | eth0 +eth0.300 | 300 | eth0 +eth0.200 | 200 | eth0 +eth0.100 | 100 | eth0 diff -Nru facter-1.6.4/spec/fixtures/unit/util/xendomains/xendomains facter-1.6.5/spec/fixtures/unit/util/xendomains/xendomains --- facter-1.6.4/spec/fixtures/unit/util/xendomains/xendomains 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/fixtures/unit/util/xendomains/xendomains 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,4 @@ +Name ID Mem VCPUs State Time(s) +Domain-0 0 656 4 r----- 48140.9 +web01 48 512 2 -b---- 97651.5 +mailserver 53 512 4 -b---- 7536.1 diff -Nru facter-1.6.4/spec/fixtures/uptime/kstat_boot_time facter-1.6.5/spec/fixtures/uptime/kstat_boot_time --- facter-1.6.4/spec/fixtures/uptime/kstat_boot_time 2011-09-13 23:19:13.000000000 +0000 +++ facter-1.6.5/spec/fixtures/uptime/kstat_boot_time 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -unix:0:system_misc:boot_time 1236919980 Binary files /tmp/dhfqkR33S6/facter-1.6.4/spec/fixtures/uptime/sysctl_kern_boottime_big_endian and /tmp/E01UASgmUr/facter-1.6.5/spec/fixtures/uptime/sysctl_kern_boottime_big_endian differ Binary files /tmp/dhfqkR33S6/facter-1.6.4/spec/fixtures/uptime/sysctl_kern_boottime_little_endian and /tmp/E01UASgmUr/facter-1.6.5/spec/fixtures/uptime/sysctl_kern_boottime_little_endian differ diff -Nru facter-1.6.4/spec/fixtures/uptime/ubuntu_proc_uptime facter-1.6.5/spec/fixtures/uptime/ubuntu_proc_uptime --- facter-1.6.4/spec/fixtures/uptime/ubuntu_proc_uptime 2011-09-13 23:19:13.000000000 +0000 +++ facter-1.6.5/spec/fixtures/uptime/ubuntu_proc_uptime 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -5097686.63 40756306.43 diff -Nru facter-1.6.4/spec/fixtures/uptime/who_b_boottime facter-1.6.5/spec/fixtures/uptime/who_b_boottime --- facter-1.6.4/spec/fixtures/uptime/who_b_boottime 2011-09-13 23:19:13.000000000 +0000 +++ facter-1.6.5/spec/fixtures/uptime/who_b_boottime 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -reboot ~ Aug 1 14:13 diff -Nru facter-1.6.4/spec/integration/facter_spec.rb facter-1.6.5/spec/integration/facter_spec.rb --- facter-1.6.4/spec/integration/facter_spec.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/spec/integration/facter_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,6 +1,6 @@ -#!/usr/bin/env ruby +#!/usr/bin/env rspec -require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') +require 'spec_helper' describe Facter do before do diff -Nru facter-1.6.4/spec/puppetlabs_spec/files.rb facter-1.6.5/spec/puppetlabs_spec/files.rb --- facter-1.6.4/spec/puppetlabs_spec/files.rb 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/puppetlabs_spec/files.rb 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,57 @@ +require 'fileutils' +require 'tempfile' +require 'pathname' + +# A support module for testing files. +module PuppetlabsSpec::Files + # This code exists only to support tests that run as root, pretty much. + # Once they have finally been eliminated this can all go... --daniel 2011-04-08 + def self.in_tmp(path) + tempdir = Dir.tmpdir + + Pathname.new(path).ascend do |dir| + return true if File.identical?(tempdir, dir) + end + + false + end + + def self.cleanup + $global_tempfiles ||= [] + while path = $global_tempfiles.pop do + fail "Not deleting tmpfile #{path} outside regular tmpdir" unless in_tmp(path) + + begin + FileUtils.rm_r path, :secure => true + rescue Errno::ENOENT + # nothing to do + end + end + end + + def make_absolute(path) + path = File.expand_path(path) + path[0] = 'c' if Puppet.features.microsoft_windows? + path + end + + def tmpfilename(name) + # Generate a temporary file, just for the name... + source = Tempfile.new(name) + path = source.path + source.close! + + # ...record it for cleanup, + $global_tempfiles ||= [] + $global_tempfiles << File.expand_path(path) + + # ...and bam. + path + end + + def tmpdir(name) + path = tmpfilename(name) + FileUtils.mkdir_p(path) + path + end +end diff -Nru facter-1.6.4/spec/puppetlabs_spec/fixtures.rb facter-1.6.5/spec/puppetlabs_spec/fixtures.rb --- facter-1.6.4/spec/puppetlabs_spec/fixtures.rb 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/puppetlabs_spec/fixtures.rb 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,49 @@ +# This module provides some helper methods to assist with fixtures. It's +# methods are designed to help when you have a conforming fixture layout so we +# get project consistency. +module PuppetlabsSpec::Fixtures + + # Returns the joined path of the global FIXTURE_DIR plus any path given to it + def fixtures(*rest) + File.join(PuppetlabsSpec::FIXTURE_DIR, *rest) + end + + # Returns the path to your relative fixture dir. So if your spec test is + # /spec/unit/facter/foo_spec.rb then your relative dir will be + # /spec/fixture/unit/facter/foo + def my_fixture_dir + callers = caller + while line = callers.shift do + next unless found = line.match(%r{/spec/(.*)_spec\.rb:}) + return fixtures(found[1]) + end + fail "sorry, I couldn't work out your path from the caller stack!" + end + + # Given a name, returns the full path of a file from your relative fixture + # dir as returned by my_fixture_dir. + def my_fixture(name) + file = File.join(my_fixture_dir, name) + unless File.readable? file then + fail "fixture '#{name}' for #{my_fixture_dir} is not readable" + end + return file + end + + # Return the contents of the file using read when given a name. Uses + # my_fixture to work out the relative path. + def my_fixture_read(name) + File.read(my_fixture(name)) + end + + # Provides a block mechanism for iterating across the files in your fixture + # area. + def my_fixtures(glob = '*', flags = 0) + files = Dir.glob(File.join(my_fixture_dir, glob), flags) + unless files.length > 0 then + fail "fixture '#{glob}' for #{my_fixture_dir} had no files!" + end + block_given? and files.each do |file| yield file end + files + end +end diff -Nru facter-1.6.4/spec/puppetlabs_spec/matchers.rb facter-1.6.5/spec/puppetlabs_spec/matchers.rb --- facter-1.6.4/spec/puppetlabs_spec/matchers.rb 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/puppetlabs_spec/matchers.rb 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,87 @@ +require 'stringio' + +######################################################################## +# Backward compatibility for Jenkins outdated environment. +module RSpec + module Matchers + module BlockAliases + alias_method :to, :should unless method_defined? :to + alias_method :to_not, :should_not unless method_defined? :to_not + alias_method :not_to, :should_not unless method_defined? :not_to + end + end +end + + +######################################################################## +# Custom matchers... +RSpec::Matchers.define :have_matching_element do |expected| + match do |actual| + actual.any? { |item| item =~ expected } + end +end + + +RSpec::Matchers.define :exit_with do |expected| + actual = nil + match do |block| + begin + block.call + rescue SystemExit => e + actual = e.status + end + actual and actual == expected + end + failure_message_for_should do |block| + "expected exit with code #{expected} but " + + (actual.nil? ? " exit was not called" : "we exited with #{actual} instead") + end + failure_message_for_should_not do |block| + "expected that exit would not be called with #{expected}" + end + description do + "expect exit with #{expected}" + end +end + + +RSpec::Matchers.define :have_printed do |expected| + match do |block| + $stderr = $stdout = StringIO.new + + begin + block.call + ensure + $stdout.rewind + @actual = $stdout.read + + $stdout = STDOUT + $stderr = STDERR + end + + if @actual then + case expected + when String + @actual.include? expected + when Regexp + expected.match @actual + else + raise ArgumentError, "No idea how to match a #{@actual.class.name}" + end + end + end + + failure_message_for_should do |actual| + if actual.nil? then + "expected #{expected.inspect}, but nothing was printed" + else + "expected #{expected.inspect} to be printed; got:\n#{actual}" + end + end + + description do + "expect #{expected.inspect} to be printed" + end + + diffable +end diff -Nru facter-1.6.4/spec/puppetlabs_spec_helper.rb facter-1.6.5/spec/puppetlabs_spec_helper.rb --- facter-1.6.4/spec/puppetlabs_spec_helper.rb 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/puppetlabs_spec_helper.rb 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,25 @@ +# Define the main module namespace for use by the helper modules +module PuppetlabsSpec + # FIXTURE_DIR represents the standard locations of all fixture data. Normally + # this represents /spec/fixtures. This will be used by the fixtures + # library to find relative fixture data. + FIXTURE_DIR = File.join(dir = File.expand_path(File.dirname(__FILE__)), \ + "fixtures") unless defined?(FIXTURE_DIR) +end + +# Require all necessary helper libraries so they can be used later +require 'puppetlabs_spec/files' +require 'puppetlabs_spec/fixtures' +require 'puppetlabs_spec/matchers' + +RSpec.configure do |config| + # Include PuppetlabsSpec helpers so they can be called at convenience + config.extend PuppetlabsSpec::Files + config.extend PuppetlabsSpec::Fixtures + config.include PuppetlabsSpec::Fixtures + + # This will cleanup any files that were created with tmpdir or tmpfile + config.after :each do + PuppetlabsSpec::Files.cleanup + end +end diff -Nru facter-1.6.4/spec/spec_helper.rb facter-1.6.5/spec/spec_helper.rb --- facter-1.6.4/spec/spec_helper.rb 2011-11-09 19:10:25.000000000 +0000 +++ facter-1.6.5/spec/spec_helper.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,37 +1,34 @@ +# Add the projects lib directory to our load path so we can require libraries +# within it easily. dir = File.expand_path(File.dirname(__FILE__)) SPECDIR = dir - -def fixture_data(file) - File.read(File.join(SPECDIR, "fixtures", file)) -end - - -$LOAD_PATH.unshift("#{dir}/") $LOAD_PATH.unshift("#{dir}/../lib") require 'rubygems' require 'mocha' require 'rspec' require 'facter' - -# load any monkey-patches -Dir["#{dir}/monkey_patches/*.rb"].map { |file| require file } +require 'fileutils' +require 'puppetlabs_spec_helper' RSpec.configure do |config| config.mock_with :mocha - # Ensure that we don't accidentally cache facts and environment - # between test cases. config.before :each do + # Ensure that we don't accidentally cache facts and environment + # between test cases. Facter::Util::Loader.any_instance.stubs(:load_all) Facter.clear Facter.clear_messages + + # Store any environment variables away to be restored later @old_env = {} ENV.each_key {|k| @old_env[k] = ENV[k]} end config.after :each do + # Restore environment variables after execution of each test @old_env.each_pair {|k, v| ENV[k] = v} to_remove = ENV.keys.reject {|key| @old_env.include? key } to_remove.each {|key| ENV.delete key } diff -Nru facter-1.6.4/spec/unit/architecture_spec.rb facter-1.6.5/spec/unit/architecture_spec.rb --- facter-1.6.4/spec/unit/architecture_spec.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/spec/unit/architecture_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,8 +1,6 @@ -#!/usr/bin/env ruby +#!/usr/bin/env rspec -require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') - -require 'facter' +require 'spec_helper' describe "Architecture fact" do diff -Nru facter-1.6.4/spec/unit/data/6.0-STABLE_FreeBSD_ifconfig facter-1.6.5/spec/unit/data/6.0-STABLE_FreeBSD_ifconfig --- facter-1.6.4/spec/unit/data/6.0-STABLE_FreeBSD_ifconfig 2011-09-13 23:19:13.000000000 +0000 +++ facter-1.6.5/spec/unit/data/6.0-STABLE_FreeBSD_ifconfig 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -fxp0: flags=8843 mtu 1500 - options=b - inet x.x.58.26 netmask 0xfffffff8 broadcast x.x.58.31 - inet x.x.58.27 netmask 0xffffffff broadcast x.x.58.27 - inet x.x.58.28 netmask 0xffffffff broadcast x.x.58.28 - inet x.x.58.29 netmask 0xffffffff broadcast x.x.58.29 - inet x.x.58.30 netmask 0xffffffff broadcast x.x.58.30 - ether 00:0e:0c:68:67:7c - media: Ethernet autoselect (100baseTX ) - status: active -lo0: flags=8049 mtu 16384 - inet 127.0.0.1 netmask 0xff000000 \ No newline at end of file diff -Nru facter-1.6.4/spec/unit/data/darwin_ifconfig_all_with_multiple_interfaces facter-1.6.5/spec/unit/data/darwin_ifconfig_all_with_multiple_interfaces --- facter-1.6.4/spec/unit/data/darwin_ifconfig_all_with_multiple_interfaces 2011-09-13 23:19:13.000000000 +0000 +++ facter-1.6.5/spec/unit/data/darwin_ifconfig_all_with_multiple_interfaces 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -lo0: flags=8049 mtu 16384 - inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 - inet 127.0.0.1 netmask 0xff000000 - inet6 ::1 prefixlen 128 -en0: flags=8863 mtu 1500 - inet6 fe80::223:6cff:fe99:602b%en1 prefixlen 64 scopeid 0x5 - inet 192.168.0.10 netmask 0xffffff00 broadcast 192.168.0.255 - ether 00:23:6c:99:60:2b - media: autoselect status: active - supported media: autoselect diff -Nru facter-1.6.4/spec/unit/data/darwin_ifconfig_single_interface facter-1.6.5/spec/unit/data/darwin_ifconfig_single_interface --- facter-1.6.4/spec/unit/data/darwin_ifconfig_single_interface 2011-09-13 23:19:13.000000000 +0000 +++ facter-1.6.5/spec/unit/data/darwin_ifconfig_single_interface 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ -en1: flags=8863 mtu 1500 - inet6 fe80::21c:b3ff:febe:81c9%en1 prefixlen 64 scopeid 0x6 - inet 10.0.0.101 netmask 0xffffff00 broadcast 10.0.0.255 - ether 00:1c:b3:be:81:c9 - media: autoselect status: active - supported media: autoselect diff -Nru facter-1.6.4/spec/unit/data/debian_kfreebsd_ifconfig facter-1.6.5/spec/unit/data/debian_kfreebsd_ifconfig --- facter-1.6.4/spec/unit/data/debian_kfreebsd_ifconfig 2011-09-13 23:19:13.000000000 +0000 +++ facter-1.6.5/spec/unit/data/debian_kfreebsd_ifconfig 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -em0: flags=8843 metric 0 mtu 1500 - options=209b - ether 0:11:a:59:67:90 - inet6 fe80::211:aff:fe59:6790%em0 prefixlen 64 scopeid 0x1 - nd6 options=3 - media: Ethernet autoselect (1000baseT ) - status: active -em1: flags=8843 metric 0 mtu 1500 - options=209b - ether 0:11:a:59:67:91 - inet6 fe80::211:aff:fe59:6791%em1 prefixlen 64 scopeid 0x2 - inet 192.168.10.10 netmask 0xffffff00 broadcast 192.168.10.255 - nd6 options=3 - media: Ethernet autoselect (100baseTX ) - status: active -bge0: flags=8802 metric 0 mtu 1500 - options=8009b - ether 0:14:c2:3f:ea:e4 - media: Ethernet autoselect (none) - status: no carrier -bge1: flags=8802 metric 0 mtu 1500 - options=8009b - ether 0:14:c2:3f:ea:e3 - media: Ethernet autoselect (none) - status: no carrier -lo0: flags=8049 metric 0 mtu 16384 - options=3 - inet6 ::1 prefixlen 128 - inet6 fe80::1%lo0 prefixlen 64 scopeid 0x5 - inet 127.0.0.1 netmask 0xff000000 - nd6 options=3 -vlan0: flags=8843 metric 0 mtu 1500 - options=3 - ether 0:11:a:59:67:90 - inet6 fe80::211:aff:fe59:6790%vlan0 prefixlen 64 scopeid 0x6 - inet 192.168.192.2 netmask 0xffffff00 broadcast 192.168.192.255 - nd6 options=3 - media: Ethernet autoselect (1000baseT ) - status: active - vlan: 192 parent interface: em0 diff -Nru facter-1.6.4/spec/unit/data/freebsd_dmidecode facter-1.6.5/spec/unit/data/freebsd_dmidecode --- facter-1.6.4/spec/unit/data/freebsd_dmidecode 2011-09-13 23:19:13.000000000 +0000 +++ facter-1.6.5/spec/unit/data/freebsd_dmidecode 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -# dmidecode 2.10 -SMBIOS 2.5 present. -5 structures occupying 352 bytes. -Table at 0x000E1000. - -Handle 0x0000, DMI type 0, 20 bytes -BIOS Information - Vendor: innotek GmbH - Version: VirtualBox - Release Date: 12/01/2006 - Address: 0xE0000 - Runtime Size: 128 kB - ROM Size: 128 kB - Characteristics: - ISA is supported - PCI is supported - Boot from CD is supported - Selectable boot is supported - 8042 keyboard services are supported (int 9h) - CGA/mono video services are supported (int 10h) - ACPI is supported - -Handle 0x0001, DMI type 1, 27 bytes -System Information - Manufacturer: innotek GmbH - Product Name: VirtualBox - Version: 1.2 - Serial Number: 0 - UUID: 3BD58031-AE9E-4F06-8A57-941942861939 - Wake-up Type: Power Switch - SKU Number: Not Specified - Family: Virtual Machine - -Handle 0x0003, DMI type 126, 13 bytes -Inactive - -Handle 0x0002, DMI type 126, 7 bytes -Inactive - -Handle 0xFEFF, DMI type 127, 147 bytes -End Of Table - diff -Nru facter-1.6.4/spec/unit/data/hpux_ifconfig_single_interface facter-1.6.5/spec/unit/data/hpux_ifconfig_single_interface --- facter-1.6.4/spec/unit/data/hpux_ifconfig_single_interface 2011-09-13 23:19:13.000000000 +0000 +++ facter-1.6.5/spec/unit/data/hpux_ifconfig_single_interface 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -lan0: flags=1843 - inet 168.24.80.71 netmask ffffff00 broadcast 168.24.80.255 -00:13:21:BD:9C:B7 diff -Nru facter-1.6.4/spec/unit/data/hpux_netstat_all_interfaces facter-1.6.5/spec/unit/data/hpux_netstat_all_interfaces --- facter-1.6.4/spec/unit/data/hpux_netstat_all_interfaces 2011-09-13 23:19:13.000000000 +0000 +++ facter-1.6.5/spec/unit/data/hpux_netstat_all_interfaces 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -lan1 1500 192.168.100.0 192.168.100.182 12964 0 900 0 0 -lan0 1500 192.168.100.0 192.168.100.181 12964 0 715 0 0 -lo0 4136 127.0.0.0 127.0.0.1 98 0 98 0 0 diff -Nru facter-1.6.4/spec/unit/data/linux_dmidecode_with_spaces facter-1.6.5/spec/unit/data/linux_dmidecode_with_spaces --- facter-1.6.4/spec/unit/data/linux_dmidecode_with_spaces 2011-09-13 23:19:13.000000000 +0000 +++ facter-1.6.5/spec/unit/data/linux_dmidecode_with_spaces 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -# dmidecode 2.2 -SMBIOS 2.3 present. -32 structures occupying 994 bytes. -Table at 0x000F0800. -Handle 0x0000 - DMI type 0, 20 bytes. - BIOS Information - Vendor: Award Software International, Inc. - Version: 6.00 PG - Release Date: 01/03/2003 - Address: 0xE0000 - Runtime Size: 128 kB - ROM Size: 256 kB - Characteristics: - ISA is supported - PCI is supported - PNP is supported - APM is supported - BIOS is upgradeable - BIOS shadowing is allowed - ESCD support is available - Boot from CD is supported - Selectable boot is supported - BIOS ROM is socketed - EDD is supported - 5.25"/360 KB floppy services are supported (int 13h) - 5.25"/1.2 MB floppy services are supported (int 13h) - 3.5"/720 KB floppy services are supported (int 13h) - 3.5"/2.88 MB floppy services are supported (int 13h) - Print screen service is supported (int 5h) - 8042 keyboard services are supported (int 9h) - Serial services are supported (int 14h) - Printer services are supported (int 17h) - CGA/mono video services are supported (int 10h) - ACPI is supported - USB legacy is supported - AGP is supported - LS-120 boot is supported - ATAPI Zip drive boot is supported -Handle 0x0001 - DMI type 1, 25 bytes. - System Information - Manufacturer: MICRO-STAR INTERNATIONAL CO., LTD - Product Name: MS-6754 - Version: - Serial Number: - UUID: Not Present - Wake-up Type: Power Switch -Handle 0x0002 - DMI type 2, 8 bytes. - Base Board Information - Manufacturer: MICRO-STAR INTERNATIONAL CO., LTD - Product Name: MS-6754 - Version: - Serial Number: - -Handle 0x001F - DMI type 127, 4 bytes. - End Of Table - diff -Nru facter-1.6.4/spec/unit/data/linux_ifconfig_all_with_single_interface facter-1.6.5/spec/unit/data/linux_ifconfig_all_with_single_interface --- facter-1.6.4/spec/unit/data/linux_ifconfig_all_with_single_interface 2011-09-13 23:19:13.000000000 +0000 +++ facter-1.6.5/spec/unit/data/linux_ifconfig_all_with_single_interface 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -eth0 Link encap:Ethernet HWaddr 00:0c:29:52:15:e9 - inet addr:172.16.15.133 Bcast:172.16.15.255 Mask:255.255.255.0 - inet6 addr: fe80::20c:29ff:fe52:15e9/64 Scope:Link - UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 - RX packets:173 errors:173 dropped:0 overruns:0 frame:0 - TX packets:208 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:40970 (40.0 KB) TX bytes:24760 (24.1 KB) - Interrupt:16 Base address:0x2024 - -lo Link encap:Local Loopback - inet addr:127.0.0.1 Mask:255.0.0.0 - inet6 addr: ::1/128 Scope:Host - UP LOOPBACK RUNNING MTU:16436 Metric:1 - RX packets:1630 errors:0 dropped:0 overruns:0 frame:0 - TX packets:1630 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:0 - RX bytes:81500 (79.5 KB) TX bytes:81500 (79.5 KB) \ No newline at end of file diff -Nru facter-1.6.4/spec/unit/data/linux_vlan_config facter-1.6.5/spec/unit/data/linux_vlan_config --- facter-1.6.4/spec/unit/data/linux_vlan_config 2011-09-13 23:19:13.000000000 +0000 +++ facter-1.6.5/spec/unit/data/linux_vlan_config 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ -VLAN Dev name | VLAN ID -Name-Type: VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD -eth0.400 | 400 | eth0 -eth0.300 | 300 | eth0 -eth0.200 | 200 | eth0 -eth0.100 | 100 | eth0 diff -Nru facter-1.6.4/spec/unit/data/Mac_OS_X_10.5.5_ifconfig facter-1.6.5/spec/unit/data/Mac_OS_X_10.5.5_ifconfig --- facter-1.6.4/spec/unit/data/Mac_OS_X_10.5.5_ifconfig 2011-09-13 23:19:13.000000000 +0000 +++ facter-1.6.5/spec/unit/data/Mac_OS_X_10.5.5_ifconfig 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -lo0: flags=8049 mtu 16384 - inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 - inet 127.0.0.1 netmask 0xff000000 - inet6 ::1 prefixlen 128 -gif0: flags=8010 mtu 1280 -stf0: flags=0<> mtu 1280 -en0: flags=8863 mtu 1500 - ether 00:1b:63:ae:02:66 - media: autoselect status: inactive - supported media: autoselect 10baseT/UTP 10baseT/UTP 10baseT/UTP 10baseT/UTP 100baseTX 100baseTX 100baseTX 100baseTX 1000baseT 1000baseT 1000baseT none -fw0: flags=8863 mtu 4078 - lladdr 00:1e:52:ff:fe:31:1a:80 - media: autoselect status: inactive - supported media: autoselect -en1: flags=8863 mtu 1500 - inet6 fe80::21e:52ff:fe70:d7b6%en1 prefixlen 64 scopeid 0x6 - inet 192.168.0.4 netmask 0xffffff00 broadcast 192.168.0.255 - ether 00:1e:52:70:d7:b6 - media: autoselect status: active - supported media: autoselect -vmnet8: flags=8863 mtu 1500 - inet 172.16.15.1 netmask 0xffffff00 broadcast 172.16.15.255 - ether 00:50:56:c0:00:08 -vmnet1: flags=8863 mtu 1500 - inet 192.168.89.1 netmask 0xffffff00 broadcast 192.168.89.255 - ether 00:50:56:c0:00:01 diff -Nru facter-1.6.4/spec/unit/data/opensolaris_smbios facter-1.6.5/spec/unit/data/opensolaris_smbios --- facter-1.6.4/spec/unit/data/opensolaris_smbios 2011-09-13 23:19:13.000000000 +0000 +++ facter-1.6.5/spec/unit/data/opensolaris_smbios 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -ID SIZE TYPE -0 54 SMB_TYPE_BIOS (BIOS information) - - Vendor: innotek GmbH - Version String: VirtualBox - Release Date: 12/01/2006 - Address Segment: 0xe000 - ROM Size: 131072 bytes - Image Size: 131072 bytes - Characteristics: 0x48018090 - SMB_BIOSFL_ISA (ISA is supported) - SMB_BIOSFL_PCI (PCI is supported) - SMB_BIOSFL_CDBOOT (Boot from CD is supported) - SMB_BIOSFL_SELBOOT (Selectable Boot supported) - SMB_BIOSFL_I9_KBD (int 0x9 8042 keyboard svcs) - SMB_BIOSFL_I10_CGA (int 0x10 CGA svcs) - Characteristics Extension Byte 1: 0x1 - SMB_BIOSXB1_ACPI (ACPI is supported) - Characteristics Extension Byte 2: 0x0 - -ID SIZE TYPE -1 72 SMB_TYPE_SYSTEM (system information) - - Manufacturer: innotek GmbH - Product: VirtualBox - Version: 1.2 - Serial Number: 0 - - UUID: cf4bff06-0b33-4891-bda0-5ec17bea5511 - Wake-Up Event: 0x6 (power switch) - SKU Number: - Family: Virtual Machine - diff -Nru facter-1.6.4/spec/unit/data/selinux_sestatus facter-1.6.5/spec/unit/data/selinux_sestatus --- facter-1.6.4/spec/unit/data/selinux_sestatus 2011-09-13 23:19:13.000000000 +0000 +++ facter-1.6.5/spec/unit/data/selinux_sestatus 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ -SELinux status: enabled -SELinuxfs mount: /selinux -Current Mode: permissive -Mode from config file: permissive -Policy version: 16 -Policy from config file: targeted diff -Nru facter-1.6.4/spec/unit/data/solaris_ifconfig_all_with_multiple_interfaces facter-1.6.5/spec/unit/data/solaris_ifconfig_all_with_multiple_interfaces --- facter-1.6.4/spec/unit/data/solaris_ifconfig_all_with_multiple_interfaces 2011-09-13 23:19:13.000000000 +0000 +++ facter-1.6.5/spec/unit/data/solaris_ifconfig_all_with_multiple_interfaces 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -lo0: flags=2001000849 mtu 8232 index 1 - inet 127.0.0.1 netmask ff000000 -e1000g0: flags=201004843 mtu 1500 index 2 - inet 192.168.162.130 netmask ffffff00 broadcast 192.168.162.255 -lo0: flags=2002000849 mtu 8252 index 1 - inet6 ::1/128 -e1000g0: flags=202004841 mtu 1500 index 2 - inet6 fe80::20c:29ff:fe09:627e/10 diff -Nru facter-1.6.4/spec/unit/data/solaris_ifconfig_single_interface facter-1.6.5/spec/unit/data/solaris_ifconfig_single_interface --- facter-1.6.4/spec/unit/data/solaris_ifconfig_single_interface 2011-09-13 23:19:13.000000000 +0000 +++ facter-1.6.5/spec/unit/data/solaris_ifconfig_single_interface 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -e1000g0: flags=201004843 mtu 1500 index 2 - inet 172.16.15.138 netmask ffffff00 broadcast 172.16.15.255 - ether 0:c:29:c1:70:2a \ No newline at end of file diff -Nru facter-1.6.4/spec/unit/data/windows_netsh_all_interfaces facter-1.6.5/spec/unit/data/windows_netsh_all_interfaces --- facter-1.6.4/spec/unit/data/windows_netsh_all_interfaces 2011-09-21 20:31:59.000000000 +0000 +++ facter-1.6.5/spec/unit/data/windows_netsh_all_interfaces 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -Idx Met MTU State Name ---- ---------- ---------- ------------ --------------------------- - 1 50 4294967295 connected Loopback Pseudo-Interface 1 - 9 10 1500 connected Local Area Connection - - -Idx Met MTU State Name ---- ---------- ---------- ------------ --------------------------- - 1 50 4294967295 connected Loopback Pseudo-Interface 1 - 9 10 1500 connected Local Area Connection - 11 50 1280 disconnected isatap.localdomain - 12 50 1280 connected Teredo Tunneling Pseudo-Interface diff -Nru facter-1.6.4/spec/unit/data/windows_netsh_single_interface facter-1.6.5/spec/unit/data/windows_netsh_single_interface --- facter-1.6.4/spec/unit/data/windows_netsh_single_interface 2011-09-21 20:31:59.000000000 +0000 +++ facter-1.6.5/spec/unit/data/windows_netsh_single_interface 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ -Configuration for interface "Local Area Connection" - DHCP enabled: Yes - IP Address: 172.16.138.216 - Subnet Prefix: 172.16.138.0/24 (mask 255.255.255.0) - Default Gateway: 172.16.138.2 - Gateway Metric: 0 - InterfaceMetric: 10 diff -Nru facter-1.6.4/spec/unit/data/windows_netsh_single_interface6 facter-1.6.5/spec/unit/data/windows_netsh_single_interface6 --- facter-1.6.4/spec/unit/data/windows_netsh_single_interface6 2011-09-21 20:31:59.000000000 +0000 +++ facter-1.6.5/spec/unit/data/windows_netsh_single_interface6 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ - -Address fe80::2087:77a:53ef:7527%12 Parameters ---------------------------------------------------------- -Interface Luid : Teredo Tunneling Pseudo-Interface -Scope Id : 0.12 -Valid Lifetime : infinite -Preferred Lifetime : infinite -DAD State : Preferred -Address Type : Other - -Address 2001:0:4137:9e76:2087:77a:53ef:7527 Parameters ---------------------------------------------------------- -Interface Luid : Teredo Tunneling Pseudo-Interface -Scope Id : 0.0 -Valid Lifetime : infinite -Preferred Lifetime : infinite -DAD State : Preferred -Address Type : Public diff -Nru facter-1.6.4/spec/unit/data/xendomains facter-1.6.5/spec/unit/data/xendomains --- facter-1.6.4/spec/unit/data/xendomains 2011-09-13 23:19:13.000000000 +0000 +++ facter-1.6.5/spec/unit/data/xendomains 1970-01-01 00:00:00.000000000 +0000 @@ -1,4 +0,0 @@ -Name ID Mem VCPUs State Time(s) -Domain-0 0 656 4 r----- 48140.9 -web01 48 512 2 -b---- 97651.5 -mailserver 53 512 4 -b---- 7536.1 diff -Nru facter-1.6.4/spec/unit/domain_spec.rb facter-1.6.5/spec/unit/domain_spec.rb --- facter-1.6.4/spec/unit/domain_spec.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/spec/unit/domain_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,4 +1,6 @@ -require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') +#!/usr/bin/env rspec + +require 'spec_helper' describe "Domain name facts" do diff -Nru facter-1.6.4/spec/unit/ec2_spec.rb facter-1.6.5/spec/unit/ec2_spec.rb --- facter-1.6.4/spec/unit/ec2_spec.rb 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/unit/ec2_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,140 @@ +#!/usr/bin/env rspec + +require 'spec_helper' +require 'facter/util/ec2' + +describe "ec2 facts" do + # This is the standard prefix for making an API call in EC2 (or fake) + # environments. + let(:api_prefix) { "http://169.254.169.254" } + + describe "when running on ec2" do + before :each do + # This is an ec2 instance, not a eucalyptus instance + Facter::Util::EC2.expects(:has_euca_mac?).at_least_once.returns(false) + Facter::Util::EC2.expects(:has_ec2_arp?).at_least_once.returns(true) + + # Assume we can connect + Facter::Util::EC2.expects(:can_connect?).at_least_once.returns(true) + end + + it "should create flat meta-data facts" do + Object.any_instance.expects(:open). + with("#{api_prefix}/2008-02-01/meta-data/"). + at_least_once.returns(StringIO.new("foo")) + + Object.any_instance.expects(:open). + with("#{api_prefix}/2008-02-01/meta-data/foo"). + at_least_once.returns(StringIO.new("bar")) + + # No user-data + Object.any_instance.expects(:open). + with("#{api_prefix}/2008-02-01/user-data/"). + at_least_once.returns(StringIO.new("")) + + Facter.collection.loader.load(:ec2) + Facter.fact(:ec2_foo).value.should == "bar" + end + + it "should create flat meta-data facts with comma seperation" do + Object.any_instance.expects(:open). + with("#{api_prefix}/2008-02-01/meta-data/"). + at_least_once.returns(StringIO.new("foo")) + + Object.any_instance.expects(:open). + with("#{api_prefix}/2008-02-01/meta-data/foo"). + at_least_once.returns(StringIO.new("bar\nbaz")) + + # No user-data + Object.any_instance.expects(:open). + with("#{api_prefix}/2008-02-01/user-data/"). + at_least_once.returns(StringIO.new("")) + + Facter.collection.loader.load(:ec2) + Facter.fact(:ec2_foo).value.should == "bar,baz" + end + + it "should create structured meta-data facts" do + Object.any_instance.expects(:open). + with("#{api_prefix}/2008-02-01/meta-data/"). + at_least_once.returns(StringIO.new("foo/")) + + Object.any_instance.expects(:open). + with("#{api_prefix}/2008-02-01/meta-data/foo/"). + at_least_once.returns(StringIO.new("bar")) + + Object.any_instance.expects(:open). + with("#{api_prefix}/2008-02-01/meta-data/foo/bar"). + at_least_once.returns(StringIO.new("baz")) + + # No user-data + Object.any_instance.expects(:open). + with("#{api_prefix}/2008-02-01/user-data/"). + at_least_once.returns(StringIO.new("")) + + Facter.collection.loader.load(:ec2) + Facter.fact(:ec2_foo_bar).value.should == "baz" + end + + it "should create ec2_user_data fact" do + # No meta-data + Object.any_instance.expects(:open). + with("#{api_prefix}/2008-02-01/meta-data/"). + at_least_once.returns(StringIO.new("")) + + Object.any_instance.expects(:open). + with("#{api_prefix}/2008-02-01/user-data/"). + at_least_once.returns(StringIO.new("test")) + + Facter.collection.loader.load(:ec2) + Facter.fact(:ec2_userdata).value.should == ["test"] + end + end + + describe "when running on eucalyptus" do + before :each do + # Return false for ec2, true for eucalyptus + Facter::Util::EC2.expects(:has_euca_mac?).at_least_once.returns(true) + Facter::Util::EC2.expects(:has_ec2_arp?).never + + # Assume we can connect + Facter::Util::EC2.expects(:can_connect?).at_least_once.returns(true) + end + + it "should create ec2_user_data fact" do + # No meta-data + Object.any_instance.expects(:open).\ + with("#{api_prefix}/2008-02-01/meta-data/").\ + at_least_once.returns(StringIO.new("")) + + Object.any_instance.expects(:open).\ + with("#{api_prefix}/2008-02-01/user-data/").\ + at_least_once.returns(StringIO.new("test")) + + # Force a fact load + Facter.collection.loader.load(:ec2) + + Facter.fact(:ec2_userdata).value.should == ["test"] + end + end + + describe "when api connect test fails" do + it "should not populate ec2_userdata" do + # Emulate ec2 for now as it matters little to this test + Facter::Util::EC2.expects(:has_euca_mac?).at_least_once.returns(true) + Facter::Util::EC2.expects(:has_ec2_arp?).never + Facter::Util::EC2.expects(:can_connect?).at_least_once.returns(false) + + # The API should never be called at this point + Object.any_instance.expects(:open). + with("#{api_prefix}/2008-02-01/meta-data/").never + Object.any_instance.expects(:open). + with("#{api_prefix}/2008-02-01/user-data/").never + + # Force a fact load + Facter.collection.loader.load(:ec2) + + Facter.fact(:ec2_userdata).should == nil + end + end +end diff -Nru facter-1.6.4/spec/unit/facter_spec.rb facter-1.6.5/spec/unit/facter_spec.rb --- facter-1.6.4/spec/unit/facter_spec.rb 2011-12-01 01:44:50.000000000 +0000 +++ facter-1.6.5/spec/unit/facter_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,6 +1,6 @@ -#!/usr/bin/env ruby +#!/usr/bin/env rspec -require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') +require 'spec_helper' describe Facter do diff -Nru facter-1.6.4/spec/unit/hardwareisa_spec.rb facter-1.6.5/spec/unit/hardwareisa_spec.rb --- facter-1.6.4/spec/unit/hardwareisa_spec.rb 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/unit/hardwareisa_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,34 @@ +#!/usr/bin/env ruby + +require 'spec_helper' +require 'facter' + +describe "Hardwareisa fact" do + it "should match uname -p on Linux" do + Facter.fact(:kernel).stubs(:value).returns("Linux") + Facter::Util::Resolution.stubs(:exec).with("uname -p").returns("Inky") + + Facter.fact(:hardwareisa).value.should == "Inky" + end + + it "should match uname -p on Darwin" do + Facter.fact(:kernel).stubs(:value).returns("Darwin") + Facter::Util::Resolution.stubs(:exec).with("uname -p").returns("Blinky") + + Facter.fact(:hardwareisa).value.should == "Blinky" + end + + it "should match uname -p on SunOS" do + Facter.fact(:kernel).stubs(:value).returns("SunOS") + Facter::Util::Resolution.stubs(:exec).with("uname -p").returns("Pinky") + + Facter.fact(:hardwareisa).value.should == "Pinky" + end + + it "should match uname -p on FreeBSD" do + Facter.fact(:kernel).stubs(:value).returns("FreeBSD") + Facter::Util::Resolution.stubs(:exec).with("uname -p").returns("Clyde") + + Facter.fact(:hardwareisa).value.should == "Clyde" + end +end diff -Nru facter-1.6.4/spec/unit/hostname_spec.rb facter-1.6.5/spec/unit/hostname_spec.rb --- facter-1.6.4/spec/unit/hostname_spec.rb 2011-09-21 20:31:59.000000000 +0000 +++ facter-1.6.5/spec/unit/hostname_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,4 +1,6 @@ -require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') +#!/usr/bin/env rspec + +require 'spec_helper' describe "Hostname facts" do diff -Nru facter-1.6.4/spec/unit/id_spec.rb facter-1.6.5/spec/unit/id_spec.rb --- facter-1.6.4/spec/unit/id_spec.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/spec/unit/id_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,6 +1,6 @@ -#!/usr/bin/env ruby +#!/usr/bin/env rspec -require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') +require 'spec_helper' describe "id fact" do diff -Nru facter-1.6.4/spec/unit/interfaces_spec.rb facter-1.6.5/spec/unit/interfaces_spec.rb --- facter-1.6.4/spec/unit/interfaces_spec.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/spec/unit/interfaces_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,8 +1,6 @@ -#!/usr/bin/env ruby +#!/usr/bin/env rspec -require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') - -require 'facter' +require 'spec_helper' require 'facter/util/ip' describe "Per Interface IP facts" do diff -Nru facter-1.6.4/spec/unit/ipaddress6_spec.rb facter-1.6.5/spec/unit/ipaddress6_spec.rb --- facter-1.6.4/spec/unit/ipaddress6_spec.rb 2011-09-21 20:31:59.000000000 +0000 +++ facter-1.6.5/spec/unit/ipaddress6_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,16 +1,13 @@ -#!/usr/bin/env ruby +#!/usr/bin/env rspec -$basedir = File.expand_path(File.dirname(__FILE__) + '/..') -require File.join($basedir, 'spec_helper') - -require 'facter' +require 'spec_helper' def ifconfig_fixture(filename) - ifconfig = File.new(File.join($basedir, 'fixtures', 'ifconfig', filename)).read + File.read(fixtures('ifconfig', filename)) end def netsh_fixture(filename) - ifconfig = File.new(File.join($basedir, 'fixtures', 'netsh', filename)).read + File.read(fixtures('netsh', filename)) end describe "IPv6 address fact" do diff -Nru facter-1.6.4/spec/unit/lsbmajdistrelease_spec.rb facter-1.6.5/spec/unit/lsbmajdistrelease_spec.rb --- facter-1.6.4/spec/unit/lsbmajdistrelease_spec.rb 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/unit/lsbmajdistrelease_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,13 @@ +#!/usr/bin/env ruby + +require 'spec_helper' +require 'facter' + +describe "LSB distribution major release fact" do + it "should be derived from lsb_release" do + Facter.fact(:kernel).stubs(:value).returns("Linux") + Facter.stubs(:value).with(:lsbdistrelease).returns("10.10") + + Facter.fact(:lsbmajdistrelease).value.should == "10" + end +end diff -Nru facter-1.6.4/spec/unit/macaddress_spec.rb facter-1.6.5/spec/unit/macaddress_spec.rb --- facter-1.6.4/spec/unit/macaddress_spec.rb 2011-12-01 01:44:50.000000000 +0000 +++ facter-1.6.5/spec/unit/macaddress_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,16 +1,13 @@ -#!/usr/bin/env ruby +#!/usr/bin/env rspec -$basedir = File.expand_path(File.dirname(__FILE__) + '/..') -require File.join($basedir, 'spec_helper') - -require 'facter' +require 'spec_helper' def ifconfig_fixture(filename) - ifconfig = File.new(File.join($basedir, 'fixtures', 'ifconfig', filename)).read + File.read(fixtures('ifconfig', filename)) end def netsh_fixture(filename) - ifconfig = File.new(File.join($basedir, 'fixtures', 'netsh', filename)).read + File.read(fixtures('netsh', filename)) end describe "macaddress fact" do diff -Nru facter-1.6.4/spec/unit/memory_spec.rb facter-1.6.5/spec/unit/memory_spec.rb --- facter-1.6.4/spec/unit/memory_spec.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/spec/unit/memory_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,8 +1,6 @@ -#!/usr/bin/env ruby +#!/usr/bin/env rspec -require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') - -require 'facter' +require 'spec_helper' describe "Memory facts" do before do @@ -78,7 +76,7 @@ end it "should return the current memorysize" do - Facter.fact(:memorytotal).value.should == "254.94 MB" + Facter.fact(:memorysize).value.should == "254.94 MB" end end @@ -118,7 +116,7 @@ end it "should return the current memorysize" do - Facter.fact(:memorytotal).value.should == "237.00 MB" + Facter.fact(:memorysize).value.should == "237.00 MB" end end @@ -147,4 +145,11 @@ Facter.fact(:MemoryTotal).value.should == '3.91 GB' end end + + it "should use the memorysize fact for the memorytotal fact" do + Facter.fact("memorysize").expects(:value).once.returns "yay" + Facter::Util::Resolution.expects(:exec).never + Facter::Memory.expects(:meminfo_number).never + Facter.fact("memorytotal").value.should == "yay" + end end diff -Nru facter-1.6.4/spec/unit/operatingsystemrelease_spec.rb facter-1.6.5/spec/unit/operatingsystemrelease_spec.rb --- facter-1.6.4/spec/unit/operatingsystemrelease_spec.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/spec/unit/operatingsystemrelease_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,8 +1,6 @@ -#!/usr/bin/env ruby +#!/usr/bin/env rspec -require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') - -require 'facter' +require 'spec_helper' describe "Operating System Release fact" do diff -Nru facter-1.6.4/spec/unit/operatingsystem_spec.rb facter-1.6.5/spec/unit/operatingsystem_spec.rb --- facter-1.6.4/spec/unit/operatingsystem_spec.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/spec/unit/operatingsystem_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,17 +1,11 @@ -#!/usr/bin/env ruby +#!/usr/bin/env rspec -require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') - -require 'facter' +require 'spec_helper' describe "Operating System fact" do - before do - Facter.clear - end - - after do - Facter.clear + before :each do + FileTest.stubs(:exists?).returns false end it "should default to the kernel name" do @@ -19,74 +13,112 @@ Facter.fact(:operatingsystem).value.should == "Nutmeg" end - - it "should be Solaris for SunOS" do - Facter.fact(:kernel).stubs(:value).returns("SunOS") - - Facter.fact(:operatingsystem).value.should == "Solaris" - end - it "should be ESXi for VMkernel" do Facter.fact(:kernel).stubs(:value).returns("VMkernel") Facter.fact(:operatingsystem).value.should == "ESXi" end - it "should identify Oracle VM as OVS" do - Facter.fact(:kernel).stubs(:value).returns("Linux") - Facter.stubs(:value).with(:lsbdistid).returns(nil) - FileTest.stubs(:exists?).returns false - - FileTest.expects(:exists?).with("/etc/ovs-release").returns true - FileTest.expects(:exists?).with("/etc/enterprise-release").returns true - - Facter.fact(:operatingsystem).value.should == "OVS" - end - - it "should identify VMWare ESX" do - Facter.fact(:kernel).stubs(:value).returns("Linux") - Facter.stubs(:value).with(:lsbdistid).returns(nil) - FileTest.stubs(:exists?).returns false - - FileTest.expects(:exists?).with("/etc/vmware-release").returns true - - Facter.fact(:operatingsystem).value.should == "VMWareESX" - end - - it "should identify Alpine Linux" do - Facter.fact(:kernel).stubs(:value).returns("Linux") - - FileTest.stubs(:exists?).returns false - - FileTest.expects(:exists?).with("/etc/alpine-release").returns true - - Facter.fact(:operatingsystem).value.should == "Alpine" - end - - it "should identify Scientific Linux" do - Facter.fact(:kernel).stubs(:value).returns("Linux") - FileTest.stubs(:exists?).returns false - - FileTest.expects(:exists?).with("/etc/redhat-release").returns true - File.expects(:read).with("/etc/redhat-release").returns("Scientific Linux SLC 5.7 (Boron)") - Facter.fact(:operatingsystem).value.should == "Scientific" - end - - it "should differentiate between Scientific Linux CERN and Scientific Linux" do - Facter.fact(:kernel).stubs(:value).returns("Linux") - FileTest.stubs(:exists?).returns false - - FileTest.expects(:exists?).with("/etc/redhat-release").returns true - File.expects(:read).with("/etc/redhat-release").returns("Scientific Linux CERN SLC 5.7 (Boron)") - Facter.fact(:operatingsystem).value.should == "SLC" - end - - it "should identify Ascendos Linux" do - Facter.fact(:kernel).stubs(:value).returns("Linux") - FileTest.stubs(:exists?).returns false - - FileTest.expects(:exists?).with("/etc/redhat-release").returns true - File.expects(:read).with("/etc/redhat-release").returns("Ascendos release 6.0 (Nameless)") - Facter.fact(:operatingsystem).value.should == "Ascendos" + describe "on Solaris variants" do + before :each do + Facter.fact(:kernel).stubs(:value).returns("SunOS") + end + + it "should be Nexenta if /etc/debian_version is present" do + FileTest.expects(:exists?).with("/etc/debian_version").returns true + Facter.fact(:operatingsystem).value.should == "Nexenta" + end + + it "should be Solaris for SunOS if no other variants match" do + Facter.fact(:operatingsystem).value.should == "Solaris" + end + end + + describe "on Linux" do + before :each do + Facter.fact(:kernel).stubs(:value).returns("Linux") + end + + { + "Debian" => "/etc/debian_version", + "Gentoo" => "/etc/gentoo-release", + "Fedora" => "/etc/fedora-release", + "Mandriva" => "/etc/mandriva-release", + "Mandrake" => "/etc/mandrake-release", + "MeeGo" => "/etc/meego-release", + "Archlinux" => "/etc/arch-release", + "OracleLinux" => "/etc/oracle-release", + "Alpine" => "/etc/alpine-release", + "VMWareESX" => "/etc/vmware-release", + "Bluewhite64" => "/etc/bluewhite64-version", + "Slamd64" => "/etc/slamd64-version", + "Slackware" => "/etc/slackware-version", + "Amazon" => "/etc/system-release", + }.each_pair do |distribution, releasefile| + it "should be #{distribution} if #{releasefile} exists" do + FileTest.expects(:exists?).with(releasefile).returns true + Facter.fact(:operatingsystem).value.should == distribution + end + end + + describe "depending on LSB release information" do + before :each do + Facter.collection.loader.load(:lsb) + end + + it "on Ubuntu should use the lsbdistid fact" do + FileUtils.stubs(:exists?).with("/etc/debian_version").returns true + + Facter.fact(:lsbdistid).expects(:value).returns("Ubuntu") + Facter.fact(:operatingsystem).value.should == "Ubuntu" + end + + end + + + # Check distributions that rely on the contents of /etc/redhat-release + { + "RedHat" => "Red Hat Enterprise Linux Server release 6.0 (Santiago)", + "CentOS" => "CentOS release 5.6 (Final)", + "Scientific" => "Scientific Linux release 6.0 (Carbon)", + "SLC" => "Scientific Linux CERN SLC release 5.7 (Boron)", + "Ascendos" => "Ascendos release 6.0 (Nameless)", + "CloudLinux" => "CloudLinux Server release 5.5", + }.each_pair do |operatingsystem, string| + it "should be #{operatingsystem} based on /etc/redhat-release contents #{string}" do + FileTest.expects(:exists?).with("/etc/redhat-release").returns true + File.expects(:read).with("/etc/redhat-release").returns string + + Facter.fact(:operatingsystem).value.should == operatingsystem + end + end + + describe "Oracle variant" do + it "should be OVS if /etc/ovs-release exists" do + Facter.stubs(:value).with(:lsbdistid) + FileTest.expects(:exists?).with("/etc/enterprise-release").returns true + FileTest.expects(:exists?).with("/etc/ovs-release").returns true + Facter.fact(:operatingsystem).value.should == "OVS" + end + + it "should be OEL if /etc/ovs-release doesn't exist" do + FileTest.expects(:exists?).with("/etc/enterprise-release").returns true + FileTest.expects(:exists?).with("/etc/ovs-release").returns false + Facter.fact(:operatingsystem).value.should == "OEL" + end + end + + it "should identify VMWare ESX" do + Facter.stubs(:value).with(:lsbdistid).returns(nil) + + FileTest.expects(:exists?).with("/etc/vmware-release").returns true + Facter.fact(:operatingsystem).value.should == "VMWareESX" + end + + it "should differentiate between Scientific Linux CERN and Scientific Linux" do + FileTest.expects(:exists?).with("/etc/redhat-release").returns true + File.expects(:read).with("/etc/redhat-release").returns("Scientific Linux CERN SLC 5.7 (Boron)") + Facter.fact(:operatingsystem).value.should == "SLC" + end end end diff -Nru facter-1.6.4/spec/unit/physicalprocessorcount_spec.rb facter-1.6.5/spec/unit/physicalprocessorcount_spec.rb --- facter-1.6.4/spec/unit/physicalprocessorcount_spec.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/spec/unit/physicalprocessorcount_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,6 +1,6 @@ #!/usr/bin/env rspec -require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') +require 'spec_helper' describe "Physical processor count facts" do diff -Nru facter-1.6.4/spec/unit/processor_spec.rb facter-1.6.5/spec/unit/processor_spec.rb --- facter-1.6.4/spec/unit/processor_spec.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/spec/unit/processor_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,12 +1,9 @@ -#!/usr/bin/env ruby +#!/usr/bin/env rspec -$basedir = File.expand_path(File.dirname(__FILE__) + '/..') -require File.join($basedir, 'spec_helper') - -require 'facter' +require 'spec_helper' def cpuinfo_fixture(filename) - cpuinfo = File.open(File.join($basedir, 'fixtures', 'cpuinfo', filename)).readlines + File.open(fixtures('cpuinfo', filename)).readlines end describe "Processor facts" do @@ -74,18 +71,18 @@ end it "should detect the correct processor count on x86_64" do - fixture_data = File.read(File.expand_path(File.dirname(__FILE__) + '/../fixtures/processorcount/solaris-x86_64-kstat-cpu-info')) + fixture_data = File.read(fixtures('processorcount','solaris-x86_64-kstat-cpu-info')) Facter::Util::Resolution.expects(:exec).with("/usr/bin/kstat cpu_info").returns(fixture_data) Facter.fact(:processorcount).value.should == 8 end it "should detect the correct processor count on sparc" do - fixture_data = File.read(File.expand_path(File.dirname(__FILE__) + '/../fixtures/processorcount/solaris-sparc-kstat-cpu-info')) + fixture_data = File.read(fixtures('processorcount','solaris-sparc-kstat-cpu-info')) Facter::Util::Resolution.expects(:exec).with("/usr/bin/kstat cpu_info").returns(fixture_data) Facter.fact(:processorcount).value.should == 8 end end - + describe "on Unixes" do before :each do Facter.collection.loader.load(:processor) @@ -106,102 +103,102 @@ Facter.fact(:architecture).stubs(:value).returns("ppc64") File.stubs(:exists?).with("/proc/cpuinfo").returns(true) File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("ppc64")) - + Facter.fact(:processorcount).value.should == "2" end - + it "should be 2 in panda-armel fixture on Linux" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:architecture).stubs(:value).returns("arm") File.stubs(:exists?).with("/proc/cpuinfo").returns(true) File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("panda-armel")) - + Facter.fact(:processorcount).value.should == "2" end - + it "should be 1 in bbg3-armel fixture on Linux" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:architecture).stubs(:value).returns("arm") File.stubs(:exists?).with("/proc/cpuinfo").returns(true) File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("bbg3-armel")) - + Facter.fact(:processorcount).value.should == "1" end - + it "should be 1 in beaglexm-armel fixture on Linux" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:architecture).stubs(:value).returns("arm") File.stubs(:exists?).with("/proc/cpuinfo").returns(true) File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("beaglexm-armel")) - + Facter.fact(:processorcount).value.should == "1" end - + it "should be 1 in amd64solo fixture on Linux" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:architecture).stubs(:value).returns("amd64") File.stubs(:exists?).with("/proc/cpuinfo").returns(true) File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("amd64solo")) - + Facter.fact(:processorcount).value.should == "1" end - + it "should be 2 in amd64dual fixture on Linux" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:architecture).stubs(:value).returns("amd64") File.stubs(:exists?).with("/proc/cpuinfo").returns(true) File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("amd64dual")) - + Facter.fact(:processorcount).value.should == "2" end - + it "should be 3 in amd64tri fixture on Linux" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:architecture).stubs(:value).returns("amd64") File.stubs(:exists?).with("/proc/cpuinfo").returns(true) File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("amd64tri")) - + Facter.fact(:processorcount).value.should == "3" end - + it "should be 4 in amd64quad fixture on Linux" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:architecture).stubs(:value).returns("amd64") File.stubs(:exists?).with("/proc/cpuinfo").returns(true) File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("amd64quad")) - + Facter.fact(:processorcount).value.should == "4" end - + it "should be 2 on dual-processor Darwin box" do Facter.fact(:kernel).stubs(:value).returns("Darwin") Facter::Util::Resolution.stubs(:exec).with("sysctl -n hw.ncpu").returns('2') - + Facter.fact(:processorcount).value.should == "2" end - + it "should be 2 on dual-processor OpenBSD box" do Facter.fact(:kernel).stubs(:value).returns("OpenBSD") Facter::Util::Resolution.stubs(:exec).with("sysctl -n hw.ncpu").returns('2') - + Facter.fact(:processorcount).value.should == "2" end it "should be 2 on dual-processor DragonFly box" do Facter.fact(:kernel).stubs(:value).returns("DragonFly") Facter::Util::Resolution.stubs(:exec).with("sysctl -n hw.ncpu").returns('2') - + Facter.fact(:processorcount).value.should == "2" end - + it "should be 6 on six-processor AIX box" do Facter.fact(:kernel).stubs(:value).returns("AIX") Facter::Util::Resolution.stubs(:exec).with("lsdev -Cc processor").returns("proc0 Available 00-00 Processor\nproc2 Available 00-02 Processor\nproc4 Available 00-04 Processor\nproc6 Available 00-06 Processor\nproc8 Available 00-08 Processor\nproc10 Available 00-10 Processor") Facter::Util::Resolution.stubs(:exec).with("lsattr -El proc0 -a type").returns("type PowerPC_POWER3 Processor type False") - + Facter.fact(:processorcount).value.should == "6" end - + it "should be 2 via sysfs when cpu0 and cpu1 are present" do Facter.fact(:kernel).stubs(:value).returns("Linux") File.stubs(:exists?).with('/sys/devices/system/cpu').returns(true) @@ -212,10 +209,10 @@ /sys/devices/system/cpu/cpu0 /sys/devices/system/cpu/cpu1 }) - + Facter.fact(:processorcount).value.should == "2" end - + it "should be 16 via sysfs when cpu0 through cpu15 are present" do Facter.fact(:kernel).stubs(:value).returns("Linux") File.stubs(:exists?).with('/sys/devices/system/cpu').returns(true) @@ -240,7 +237,7 @@ /sys/devices/system/cpu/cpu14 /sys/devices/system/cpu/cpu15 }) - + Facter.fact(:processorcount).value.should == "16" end end diff -Nru facter-1.6.4/spec/unit/selinux_spec.rb facter-1.6.5/spec/unit/selinux_spec.rb --- facter-1.6.4/spec/unit/selinux_spec.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/spec/unit/selinux_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,8 +1,6 @@ -#!/usr/bin/env ruby +#!/usr/bin/env rspec -require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') - -require 'facter' +require 'spec_helper' describe "SELinux facts" do @@ -50,8 +48,7 @@ it "should return the SELinux current mode" do Facter.fact(:selinux).stubs(:value).returns("true") - sample_output_file = File.dirname(__FILE__) + '/data/selinux_sestatus' - selinux_sestatus = File.read(sample_output_file) + selinux_sestatus = my_fixture_read("selinux_sestatus") Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/sestatus').returns(selinux_sestatus) @@ -61,8 +58,7 @@ it "should return the SELinux mode from the configuration file" do Facter.fact(:selinux).stubs(:value).returns("true") - sample_output_file = File.dirname(__FILE__) + '/data/selinux_sestatus' - selinux_sestatus = File.read(sample_output_file) + selinux_sestatus = my_fixture_read("selinux_sestatus") Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/sestatus').returns(selinux_sestatus) @@ -72,8 +68,7 @@ it "should return the SELinux configuration file policy" do Facter.fact(:selinux).stubs(:value).returns("true") - sample_output_file = File.dirname(__FILE__) + '/data/selinux_sestatus' - selinux_sestatus = File.read(sample_output_file) + selinux_sestatus = my_fixture_read("selinux_sestatus") Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/sestatus').returns(selinux_sestatus) diff -Nru facter-1.6.4/spec/unit/uniqueid_spec.rb facter-1.6.5/spec/unit/uniqueid_spec.rb --- facter-1.6.4/spec/unit/uniqueid_spec.rb 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/unit/uniqueid_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby + +require 'spec_helper' +require 'facter' + +describe "Uniqueid fact" do + it "should match hostid on Solaris" do + Facter.fact(:kernel).stubs(:value).returns("SunOS") + Facter::Util::Resolution.stubs(:exec).with("hostid").returns("Larry") + + Facter.fact(:uniqueid).value.should == "Larry" + end + + it "should match hostid on Linux" do + Facter.fact(:kernel).stubs(:value).returns("Linux") + Facter::Util::Resolution.stubs(:exec).with("hostid").returns("Curly") + + Facter.fact(:uniqueid).value.should == "Curly" + end + + it "should match hostid on AIX" do + Facter.fact(:kernel).stubs(:value).returns("AIX") + Facter::Util::Resolution.stubs(:exec).with("hostid").returns("Moe") + + Facter.fact(:uniqueid).value.should == "Moe" + end +end diff -Nru facter-1.6.4/spec/unit/uptime_spec.rb facter-1.6.5/spec/unit/uptime_spec.rb --- facter-1.6.4/spec/unit/uptime_spec.rb 2011-09-13 23:19:13.000000000 +0000 +++ facter-1.6.5/spec/unit/uptime_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,8 +1,6 @@ -#!/usr/bin/env ruby +#!/usr/bin/env rspec -require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') - -require 'facter' +require 'spec_helper' require 'facter/util/uptime' describe "uptime facts:" do diff -Nru facter-1.6.4/spec/unit/util/collection_spec.rb facter-1.6.5/spec/unit/util/collection_spec.rb --- facter-1.6.4/spec/unit/util/collection_spec.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/spec/unit/util/collection_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,7 +1,6 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') +#!/usr/bin/env rspec +require 'spec_helper' require 'facter/util/collection' describe Facter::Util::Collection do @@ -93,6 +92,16 @@ @coll.add(:myname) {} end + + it "should discard resolutions that throw an exception when added" do + lambda { + @coll.add('yay') do + raise + setcode { 'yay' } + end + }.should_not raise_error + @coll.value('yay').should be_nil + end end end diff -Nru facter-1.6.4/spec/unit/util/config_spec.rb facter-1.6.5/spec/unit/util/config_spec.rb --- facter-1.6.4/spec/unit/util/config_spec.rb 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/unit/util/config_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,24 @@ +#!/usr/bin/env rspec + +require 'spec_helper' +require 'facter/util/config' + +describe Facter::Util::Config do + describe "is_windows? function" do + it "should detect windows if RbConfig returns a windows OS" do + host_os = ["mswin","win32","dos","mingw","cygwin"] + host_os.each do |h| + RbConfig::CONFIG.expects(:[]).with('host_os').returns(h) + Facter::Util::Config.is_windows?.should be_true + end + end + + it "should not detect windows if RbConfig returns a non-windows OS" do + host_os = ["darwin","linux"] + host_os.each do |h| + RbConfig::CONFIG.expects(:[]).with('host_os').returns(h) + Facter::Util::Config.is_windows?.should be_false + end + end + end +end diff -Nru facter-1.6.4/spec/unit/util/confine_spec.rb facter-1.6.5/spec/unit/util/confine_spec.rb --- facter-1.6.4/spec/unit/util/confine_spec.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/spec/unit/util/confine_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,7 +1,6 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') +#!/usr/bin/env rspec +require 'spec_helper' require 'facter/util/confine' require 'facter/util/values' diff -Nru facter-1.6.4/spec/unit/util/ec2_spec.rb facter-1.6.5/spec/unit/util/ec2_spec.rb --- facter-1.6.4/spec/unit/util/ec2_spec.rb 1970-01-01 00:00:00.000000000 +0000 +++ facter-1.6.5/spec/unit/util/ec2_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -0,0 +1,112 @@ +#!/usr/bin/env rspec + +require 'spec_helper' +require 'facter/util/ec2' + +describe Facter::Util::EC2 do + # This is the standard prefix for making an API call in EC2 (or fake) + # environments. + let(:api_prefix) { "http://169.254.169.254" } + + describe "is_ec2_arp? method" do + describe "on linux" do + before :each do + # Return fake kernel + Facter.stubs(:value).with(:kernel).returns("linux") + end + + it "should succeed if arp table contains fe:ff:ff:ff:ff:ff" do + ec2arp = my_fixture_read("linux-arp-ec2.out") + Facter::Util::Resolution.expects(:exec).with("arp -an").\ + at_least_once.returns(ec2arp) + Facter::Util::EC2.has_ec2_arp?.should == true + end + + it "should fail if arp table does not contain fe:ff:ff:ff:ff:ff" do + ec2arp = my_fixture_read("linux-arp-not-ec2.out") + Facter::Util::Resolution.expects(:exec).with("arp -an"). + at_least_once.returns(ec2arp) + Facter::Util::EC2.has_ec2_arp?.should == false + end + end + + describe "on windows" do + before :each do + # Return fake kernel + Facter.stubs(:value).with(:kernel).returns("windows") + end + + it "should succeed if arp table contains fe-ff-ff-ff-ff-ff" do + ec2arp = my_fixture_read("windows-2008-arp-a.out") + Facter::Util::Resolution.expects(:exec).with("arp -a").\ + at_least_once.returns(ec2arp) + Facter::Util::EC2.has_ec2_arp?.should == true + end + + it "should fail if arp table does not contain fe-ff-ff-ff-ff-ff" do + ec2arp = my_fixture_read("windows-2008-arp-a-not-ec2.out") + Facter::Util::Resolution.expects(:exec).with("arp -a"). + at_least_once.returns(ec2arp) + Facter::Util::EC2.has_ec2_arp?.should == false + end + end + end + + describe "is_euca_mac? method" do + it "should return true when the mac is a eucalyptus one" do + Facter.expects(:value).with(:macaddress).\ + at_least_once.returns("d0:0d:1a:b0:a1:00") + + Facter::Util::EC2.has_euca_mac?.should == true + end + + it "should return false when the mac is not a eucalyptus one" do + Facter.expects(:value).with(:macaddress).\ + at_least_once.returns("0c:1d:a0:bc:aa:02") + + Facter::Util::EC2.has_euca_mac?.should == false + end + end + + describe "can_connect? method" do + it "returns true if api responds" do + # Return something upon connecting to the root + Module.any_instance.expects(:open).with("#{api_prefix}:80/").\ + at_least_once.returns("2008-02-01\nlatest") + + Facter::Util::EC2.can_connect?.should == true + end + + describe "when connection times out" do + before :each do + # Emulate a timeout when connecting by throwing an exception + Module.any_instance.expects(:open).with("#{api_prefix}:80/").\ + at_least_once.raises(Timeout::Error) + end + + it "should not raise exception" do + expect { Facter::Util::EC2.can_connect? }.to_not raise_error + end + + it "should return false" do + Facter::Util::EC2.can_connect?.should == false + end + end + + describe "when connection is refused" do + before :each do + # Emulate a connection refused + Module.any_instance.expects(:open).with("#{api_prefix}:80/").\ + at_least_once.raises(Errno::ECONNREFUSED) + end + + it "should not raise exception" do + expect { Facter::Util::EC2.can_connect? }.to_not raise_error + end + + it "should return false" do + Facter::Util::EC2.can_connect?.should == false + end + end + end +end diff -Nru facter-1.6.4/spec/unit/util/fact_spec.rb facter-1.6.5/spec/unit/util/fact_spec.rb --- facter-1.6.4/spec/unit/util/fact_spec.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/spec/unit/util/fact_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,7 +1,6 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') +#!/usr/bin/env rspec +require 'spec_helper' require 'facter/util/fact' describe Facter::Util::Fact do diff -Nru facter-1.6.4/spec/unit/util/ip_spec.rb facter-1.6.5/spec/unit/util/ip_spec.rb --- facter-1.6.4/spec/unit/util/ip_spec.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/spec/unit/util/ip_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,7 +1,6 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') +#!/usr/bin/env rspec +require 'spec_helper' require 'facter/util/ip' describe Facter::Util::IP do @@ -26,44 +25,38 @@ end it "should return a list with a single interface and the loopback interface on Linux with a single interface" do - sample_output_file = File.dirname(__FILE__) + '/../data/linux_ifconfig_all_with_single_interface' - linux_ifconfig = File.read(sample_output_file) + linux_ifconfig = my_fixture_read("linux_ifconfig_all_with_single_interface") Facter::Util::IP.stubs(:get_all_interface_output).returns(linux_ifconfig) Facter::Util::IP.get_interfaces().should == ["eth0", "lo"] end it "should return a list two interfaces on Darwin with two interfaces" do - sample_output_file = File.dirname(__FILE__) + '/../data/darwin_ifconfig_all_with_multiple_interfaces' - darwin_ifconfig = File.read(sample_output_file) + darwin_ifconfig = my_fixture_read("darwin_ifconfig_all_with_multiple_interfaces") Facter::Util::IP.stubs(:get_all_interface_output).returns(darwin_ifconfig) Facter::Util::IP.get_interfaces().should == ["lo0", "en0"] end it "should return a list two interfaces on Solaris with two interfaces multiply reporting" do - sample_output_file = File.dirname(__FILE__) + '/../data/solaris_ifconfig_all_with_multiple_interfaces' - solaris_ifconfig = File.read(sample_output_file) + solaris_ifconfig = my_fixture_read("solaris_ifconfig_all_with_multiple_interfaces") Facter::Util::IP.stubs(:get_all_interface_output).returns(solaris_ifconfig) Facter::Util::IP.get_interfaces().should == ["lo0", "e1000g0"] end it "should return a list three interfaces on HP-UX with three interfaces multiply reporting" do - sample_output_file = File.dirname(__FILE__) + '/../data/hpux_netstat_all_interfaces' - hpux_netstat = File.read(sample_output_file) + hpux_netstat = my_fixture_read("hpux_netstat_all_interfaces") Facter::Util::IP.stubs(:get_all_interface_output).returns(hpux_netstat) Facter::Util::IP.get_interfaces().should == ["lan1", "lan0", "lo0"] end it "should return a list of six interfaces on a GNU/kFreeBSD with six interfaces" do - sample_output_file = File.dirname(__FILE__) + '/../data/debian_kfreebsd_ifconfig' - kfreebsd_ifconfig = File.read(sample_output_file) + kfreebsd_ifconfig = my_fixture_read("debian_kfreebsd_ifconfig") Facter::Util::IP.stubs(:get_all_interface_output).returns(kfreebsd_ifconfig) Facter::Util::IP.get_interfaces().should == ["em0", "em1", "bge0", "bge1", "lo0", "vlan0"] end it "should return a list of only connected interfaces on Windows" do Facter.fact(:kernel).stubs(:value).returns("windows") - sample_output_file = File.dirname(__FILE__) + '/../data/windows_netsh_all_interfaces' - windows_netsh = File.read(sample_output_file) + windows_netsh = my_fixture_read("windows_netsh_all_interfaces") Facter::Util::IP.stubs(:get_all_interface_output).returns(windows_netsh) Facter::Util::IP.get_interfaces().should == ["Loopback Pseudo-Interface 1", "Local Area Connection", "Teredo Tunneling Pseudo-Interface"] end @@ -78,8 +71,7 @@ end it "should return ipaddress information for Solaris" do - sample_output_file = File.dirname(__FILE__) + "/../data/solaris_ifconfig_single_interface" - solaris_ifconfig_interface = File.read(sample_output_file) + solaris_ifconfig_interface = my_fixture_read("solaris_ifconfig_single_interface") Facter::Util::IP.expects(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface) Facter.stubs(:value).with(:kernel).returns("SunOS") @@ -88,8 +80,7 @@ end it "should return netmask information for Solaris" do - sample_output_file = File.dirname(__FILE__) + "/../data/solaris_ifconfig_single_interface" - solaris_ifconfig_interface = File.read(sample_output_file) + solaris_ifconfig_interface = my_fixture_read("solaris_ifconfig_single_interface") Facter::Util::IP.expects(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface) Facter.stubs(:value).with(:kernel).returns("SunOS") @@ -98,8 +89,7 @@ end it "should return calculated network information for Solaris" do - sample_output_file = File.dirname(__FILE__) + "/../data/solaris_ifconfig_single_interface" - solaris_ifconfig_interface = File.read(sample_output_file) + solaris_ifconfig_interface = my_fixture_read("solaris_ifconfig_single_interface") Facter::Util::IP.stubs(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface) Facter.stubs(:value).with(:kernel).returns("SunOS") @@ -108,8 +98,7 @@ end it "should return ipaddress information for HP-UX" do - sample_output_file = File.dirname(__FILE__) + "/../data/hpux_ifconfig_single_interface" - hpux_ifconfig_interface = File.read(sample_output_file) + hpux_ifconfig_interface = my_fixture_read("hpux_ifconfig_single_interface") Facter::Util::IP.expects(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface) Facter.stubs(:value).with(:kernel).returns("HP-UX") @@ -118,8 +107,7 @@ end it "should return macaddress information for HP-UX" do - sample_output_file = File.dirname(__FILE__) + "/../data/hpux_ifconfig_single_interface" - hpux_ifconfig_interface = File.read(sample_output_file) + hpux_ifconfig_interface = my_fixture_read("hpux_ifconfig_single_interface") Facter::Util::IP.expects(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface) Facter.stubs(:value).with(:kernel).returns("HP-UX") @@ -128,8 +116,7 @@ end it "should return macaddress with leading zeros stripped off for GNU/kFreeBSD" do - sample_output_file = File.dirname(__FILE__) + "/../data/debian_kfreebsd_ifconfig" - kfreebsd_ifconfig = File.read(sample_output_file) + kfreebsd_ifconfig = my_fixture_read("debian_kfreebsd_ifconfig") Facter::Util::IP.expects(:get_single_interface_output).with("em0").returns(kfreebsd_ifconfig) Facter.stubs(:value).with(:kernel).returns("GNU/kFreeBSD") @@ -138,8 +125,7 @@ end it "should return netmask information for HP-UX" do - sample_output_file = File.dirname(__FILE__) + "/../data/hpux_ifconfig_single_interface" - hpux_ifconfig_interface = File.read(sample_output_file) + hpux_ifconfig_interface = my_fixture_read("hpux_ifconfig_single_interface") Facter::Util::IP.expects(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface) Facter.stubs(:value).with(:kernel).returns("HP-UX") @@ -148,8 +134,7 @@ end it "should return calculated network information for HP-UX" do - sample_output_file = File.dirname(__FILE__) + "/../data/hpux_ifconfig_single_interface" - hpux_ifconfig_interface = File.read(sample_output_file) + hpux_ifconfig_interface = my_fixture_read("hpux_ifconfig_single_interface") Facter::Util::IP.stubs(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface) Facter.stubs(:value).with(:kernel).returns("HP-UX") @@ -158,8 +143,7 @@ end it "should return interface information for FreeBSD supported via an alias" do - sample_output_file = File.dirname(__FILE__) + "/../data/6.0-STABLE_FreeBSD_ifconfig" - ifconfig_interface = File.read(sample_output_file) + ifconfig_interface = my_fixture_read("6.0-STABLE_FreeBSD_ifconfig") Facter::Util::IP.expects(:get_single_interface_output).with("fxp0").returns(ifconfig_interface) Facter.stubs(:value).with(:kernel).returns("FreeBSD") @@ -168,8 +152,7 @@ end it "should return macaddress information for OS X" do - sample_output_file = File.dirname(__FILE__) + "/../data/Mac_OS_X_10.5.5_ifconfig" - ifconfig_interface = File.read(sample_output_file) + ifconfig_interface = my_fixture_read("Mac_OS_X_10.5.5_ifconfig") Facter::Util::IP.expects(:get_single_interface_output).with("en1").returns(ifconfig_interface) Facter.stubs(:value).with(:kernel).returns("Darwin") @@ -178,8 +161,7 @@ end it "should return all interfaces correctly on OS X" do - sample_output_file = File.dirname(__FILE__) + "/../data/Mac_OS_X_10.5.5_ifconfig" - ifconfig_interface = File.read(sample_output_file) + ifconfig_interface = my_fixture_read("Mac_OS_X_10.5.5_ifconfig") Facter::Util::IP.expects(:get_all_interface_output).returns(ifconfig_interface) Facter.stubs(:value).with(:kernel).returns("Darwin") @@ -188,8 +170,7 @@ end it "should return a human readable netmask on Solaris" do - sample_output_file = File.dirname(__FILE__) + "/../data/solaris_ifconfig_single_interface" - solaris_ifconfig_interface = File.read(sample_output_file) + solaris_ifconfig_interface = my_fixture_read("solaris_ifconfig_single_interface") Facter::Util::IP.expects(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface) Facter.stubs(:value).with(:kernel).returns("SunOS") @@ -198,8 +179,7 @@ end it "should return a human readable netmask on HP-UX" do - sample_output_file = File.dirname(__FILE__) + "/../data/hpux_ifconfig_single_interface" - hpux_ifconfig_interface = File.read(sample_output_file) + hpux_ifconfig_interface = my_fixture_read("hpux_ifconfig_single_interface") Facter::Util::IP.expects(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface) Facter.stubs(:value).with(:kernel).returns("HP-UX") @@ -208,9 +188,7 @@ end it "should return a human readable netmask on Darwin" do - sample_output_file = File.dirname(__FILE__) + "/../data/darwin_ifconfig_single_interface" - - darwin_ifconfig_interface = File.read(sample_output_file) + darwin_ifconfig_interface = my_fixture_read("darwin_ifconfig_single_interface") Facter::Util::IP.expects(:get_single_interface_output).with("en1").returns(darwin_ifconfig_interface) Facter.stubs(:value).with(:kernel).returns("Darwin") @@ -219,9 +197,7 @@ end it "should return a human readable netmask on GNU/kFreeBSD" do - sample_output_file = File.dirname(__FILE__) + "/../data/debian_kfreebsd_ifconfig" - - kfreebsd_ifconfig = File.read(sample_output_file) + kfreebsd_ifconfig = my_fixture_read("debian_kfreebsd_ifconfig") Facter::Util::IP.expects(:get_single_interface_output).with("em1").returns(kfreebsd_ifconfig) Facter.stubs(:value).with(:kernel).returns("GNU/kFreeBSD") @@ -260,8 +236,7 @@ end it "should return ipaddress information" do - sample_output_file = File.dirname(__FILE__) + "/../data/windows_netsh_single_interface" - windows_netsh = File.read(sample_output_file) + windows_netsh = my_fixture_read("windows_netsh_single_interface") Facter::Util::IP.expects(:get_output_for_interface_and_label).with("Local Area Connection", "ipaddress").returns(windows_netsh) @@ -269,8 +244,7 @@ end it "should return a human readable netmask" do - sample_output_file = File.dirname(__FILE__) + "/../data/windows_netsh_single_interface" - windows_netsh = File.read(sample_output_file) + windows_netsh = my_fixture_read("windows_netsh_single_interface") Facter::Util::IP.expects(:get_output_for_interface_and_label).with("Local Area Connection", "netmask").returns(windows_netsh) @@ -278,8 +252,7 @@ end it "should return network information" do - sample_output_file = File.dirname(__FILE__) + "/../data/windows_netsh_single_interface" - windows_netsh = File.read(sample_output_file) + windows_netsh = my_fixture_read("windows_netsh_single_interface") Facter::Util::IP.stubs(:get_output_for_interface_and_label).with("Local Area Connection", "ipaddress").returns(windows_netsh) Facter::Util::IP.stubs(:get_output_for_interface_and_label).with("Local Area Connection", "netmask").returns(windows_netsh) @@ -288,8 +261,7 @@ end it "should return ipaddress6 information" do - sample_output_file = File.dirname(__FILE__) + "/../data/windows_netsh_single_interface6" - windows_netsh = File.read(sample_output_file) + windows_netsh = my_fixture_read("windows_netsh_single_interface6") Facter::Util::IP.expects(:get_output_for_interface_and_label).with("Teredo Tunneling Pseudo-Interface", "ipaddress6").returns(windows_netsh) diff -Nru facter-1.6.4/spec/unit/util/loader_spec.rb facter-1.6.5/spec/unit/util/loader_spec.rb --- facter-1.6.4/spec/unit/util/loader_spec.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/spec/unit/util/loader_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,10 +1,8 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') +#!/usr/bin/env rspec +require 'spec_helper' require 'facter/util/loader' - # loader subclass for making assertions about file/directory ordering class TestLoader < Facter::Util::Loader def loaded_files diff -Nru facter-1.6.4/spec/unit/util/macaddress_spec.rb facter-1.6.5/spec/unit/util/macaddress_spec.rb --- facter-1.6.4/spec/unit/util/macaddress_spec.rb 2011-12-01 01:44:50.000000000 +0000 +++ facter-1.6.5/spec/unit/util/macaddress_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,7 +1,6 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') +#!/usr/bin/env rspec +require 'spec_helper' require 'facter/util/macaddress' describe "standardized MAC address" do @@ -29,8 +28,8 @@ ] test_cases.each do |version, default_iface, macaddress, fallback_macaddress| - netstat_file = File.join(SPECDIR, "fixtures", "netstat", "darwin_#{version.tr('.', '_')}") - ifconfig_file_no_iface = File.join(SPECDIR, "fixtures", "ifconfig", "darwin_#{version.tr('.', '_')}") + netstat_file = fixtures("netstat", "darwin_#{version.tr('.', '_')}") + ifconfig_file_no_iface = fixtures("ifconfig", "darwin_#{version.tr('.', '_')}") ifconfig_file = "#{ifconfig_file_no_iface}_#{default_iface}" describe "version #{version}" do diff -Nru facter-1.6.4/spec/unit/util/macosx_spec.rb facter-1.6.5/spec/unit/util/macosx_spec.rb --- facter-1.6.4/spec/unit/util/macosx_spec.rb 2011-11-09 19:09:52.000000000 +0000 +++ facter-1.6.5/spec/unit/util/macosx_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,7 +1,6 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') +#!/usr/bin/env rspec +require 'spec_helper' require 'facter/util/macosx' describe Facter::Util::Macosx do diff -Nru facter-1.6.4/spec/unit/util/manufacturer_spec.rb facter-1.6.5/spec/unit/util/manufacturer_spec.rb --- facter-1.6.4/spec/unit/util/manufacturer_spec.rb 2011-11-09 19:10:25.000000000 +0000 +++ facter-1.6.5/spec/unit/util/manufacturer_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,5 +1,6 @@ -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') +#!/usr/bin/env rspec +require 'spec_helper' require 'facter/util/manufacturer' describe Facter::Manufacturer do @@ -17,14 +18,14 @@ end it "should parse prtdiag output on a sunfire v120" do - Facter::Util::Resolution.stubs(:exec).returns(fixture_data(File.join("unit", "util", "manufacturer", "solaris_sunfire_v120_prtdiag"))) + Facter::Util::Resolution.stubs(:exec).returns(my_fixture_read("solaris_sunfire_v120_prtdiag")) Facter::Manufacturer.prtdiag_sparc_find_system_info() Facter.value(:manufacturer).should == "Sun Microsystems" Facter.value(:productname).should == "Sun Fire V120 (UltraSPARC-IIe 648MHz)" end it "should parse prtdiag output on a t5220" do - Facter::Util::Resolution.stubs(:exec).returns(fixture_data(File.join("unit", "util", "manufacturer", "solaris_t5220_prtdiag"))) + Facter::Util::Resolution.stubs(:exec).returns(my_fixture_read("solaris_t5220_prtdiag")) Facter::Manufacturer.prtdiag_sparc_find_system_info() Facter.value(:manufacturer).should == "Sun Microsystems" Facter.value(:productname).should == "SPARC Enterprise T5220" @@ -41,8 +42,7 @@ end it "should strip white space on dmi output with spaces" do - sample_output_file = File.dirname(__FILE__) + "/../data/linux_dmidecode_with_spaces" - dmidecode_output = File.new(sample_output_file).read() + dmidecode_output = my_fixture_read("linux_dmidecode_with_spaces") Facter::Manufacturer.expects(:get_dmi_table).returns(dmidecode_output) Facter.fact(:kernel).stubs(:value).returns("Linux") @@ -53,8 +53,7 @@ end it "should handle output from smbios when run under sunos" do - sample_output_file = File.dirname(__FILE__) + "/../data/opensolaris_smbios" - smbios_output = File.new(sample_output_file).read() + smbios_output = my_fixture_read("opensolaris_smbios") Facter::Manufacturer.expects(:get_dmi_table).returns(smbios_output) Facter.fact(:kernel).stubs(:value).returns("SunOS") @@ -126,8 +125,8 @@ def find_product_name(os) output_file = case os - when "FreeBSD" then File.dirname(__FILE__) + "/../data/freebsd_dmidecode" - when "SunOS" then File.dirname(__FILE__) + "/../data/opensolaris_smbios" + when "FreeBSD" then my_fixture("freebsd_dmidecode") + when "SunOS" then my_fixture("opensolaris_smbios") end output = File.new(output_file).read() diff -Nru facter-1.6.4/spec/unit/util/processor_spec.rb facter-1.6.5/spec/unit/util/processor_spec.rb --- facter-1.6.4/spec/unit/util/processor_spec.rb 2011-11-09 19:09:53.000000000 +0000 +++ facter-1.6.5/spec/unit/util/processor_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,12 +1,10 @@ -#!/usr/bin/env ruby - -$basedir = File.expand_path(File.dirname(__FILE__) + '/../..') -require File.join($basedir, 'spec_helper') +#!/usr/bin/env rspec +require 'spec_helper' require 'facter/util/processor' def cpuinfo_fixture(filename) - cpuinfo = File.open(File.join($basedir, 'fixtures', 'cpuinfo', filename)).readlines + File.open(fixtures('cpuinfo', filename)).readlines end describe Facter::Util::Processor do @@ -15,7 +13,7 @@ Facter.fact(:architecture).stubs(:value).returns("amd64") File.stubs(:exists?).with("/proc/cpuinfo").returns(true) File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("amd64solo")) - + Facter::Util::Processor.enum_cpuinfo[0].should == "Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz" end @@ -24,22 +22,22 @@ Facter.fact(:architecture).stubs(:value).returns("amd64") File.stubs(:exists?).with("/proc/cpuinfo").returns(true) File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("amd64dual")) - + Facter::Util::Processor.enum_cpuinfo[0].should == "Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz" Facter::Util::Processor.enum_cpuinfo[1].should == "Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz" end - + it "should get the processor descriptions from the amd64tri fixture" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:architecture).stubs(:value).returns("amd64") File.stubs(:exists?).with("/proc/cpuinfo").returns(true) File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("amd64tri")) - + Facter::Util::Processor.enum_cpuinfo[0].should == "Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz" Facter::Util::Processor.enum_cpuinfo[1].should == "Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz" Facter::Util::Processor.enum_cpuinfo[2].should == "Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz" end - + it "should get the processor descriptions from the amd64quad fixture" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:architecture).stubs(:value).returns("amd64") diff -Nru facter-1.6.4/spec/unit/util/resolution_spec.rb facter-1.6.5/spec/unit/util/resolution_spec.rb --- facter-1.6.4/spec/unit/util/resolution_spec.rb 2011-11-09 19:09:53.000000000 +0000 +++ facter-1.6.5/spec/unit/util/resolution_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,7 +1,6 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') +#!/usr/bin/env rspec +require 'spec_helper' require 'facter/util/resolution' describe Facter::Util::Resolution do diff -Nru facter-1.6.4/spec/unit/util/uptime_spec.rb facter-1.6.5/spec/unit/util/uptime_spec.rb --- facter-1.6.4/spec/unit/util/uptime_spec.rb 2011-11-09 19:09:53.000000000 +0000 +++ facter-1.6.5/spec/unit/util/uptime_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,7 +1,6 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') +#!/usr/bin/env rspec +require 'spec_helper' require 'facter/util/uptime' describe Facter::Util::Uptime do @@ -9,7 +8,7 @@ describe ".get_uptime_seconds_unix", :unless => Facter.value(:operatingsystem) == 'windows' do describe "when /proc/uptime is available" do before do - uptime_file = File.join(SPECDIR, "fixtures", "uptime", "ubuntu_proc_uptime") + uptime_file = my_fixture("ubuntu_proc_uptime") Facter::Util::Uptime.stubs(:uptime_file).returns("\"#{uptime_file}\"") end @@ -26,15 +25,17 @@ Facter::Util::Uptime.stubs(:uptime_file).returns(@nonexistent_file) end - it "should use 'sysctl kern.boottime'" do - if [1].pack("L") == [1].pack("V") # Determine endianness - sysctl_output_filename = 'sysctl_kern_boottime_little_endian' - else - sysctl_output_filename = 'sysctl_kern_boottime_big_endian' - end - sysctl_output_file = File.join(SPECDIR, 'fixtures', 'uptime', sysctl_output_filename) # Aug 01 14:13:47 -0700 2010 + it "should use 'sysctl -n kern.boottime' on OpenBSD" do + sysctl_output_file = my_fixture('sysctl_kern_boottime_openbsd') # Dec 09 21:11:46 +0000 2011 + Facter::Util::Uptime.stubs(:uptime_sysctl_cmd).returns("cat \"#{sysctl_output_file}\"") + Time.stubs(:now).returns Time.parse("Dec 09 22:11:46 +0000 2011") # one hour later + Facter::Util::Uptime.get_uptime_seconds_unix.should == 60 * 60 + end + + it "should use 'sysctl -n kern.boottime' on Darwin, etc." do + sysctl_output_file = my_fixture('sysctl_kern_boottime_darwin') # Oct 30 21:52:27 +0000 2011 Facter::Util::Uptime.stubs(:uptime_sysctl_cmd).returns("cat \"#{sysctl_output_file}\"") - Time.stubs(:now).returns Time.parse("Aug 01 15:13:47 -0700 2010") # one hour later + Time.stubs(:now).returns Time.parse("Oct 30 22:52:27 +0000 2011") # one hour later Facter::Util::Uptime.get_uptime_seconds_unix.should == 60 * 60 end @@ -44,7 +45,7 @@ end it "should use 'kstat -p unix:::boot_time'" do - kstat_output_file = File.join(SPECDIR, 'fixtures', 'uptime', 'kstat_boot_time') # unix:0:system_misc:boot_time 1236919980 + kstat_output_file = my_fixture('kstat_boot_time') # unix:0:system_misc:boot_time 1236919980 Facter::Util::Uptime.stubs(:uptime_kstat_cmd).returns("cat \"#{kstat_output_file}\"") Time.stubs(:now).returns Time.at(1236923580) #one hour later Facter::Util::Uptime.get_uptime_seconds_unix.should == 60 * 60 @@ -56,7 +57,7 @@ end it "should use 'who -b'" do - who_b_output_file = File.join(SPECDIR, 'fixtures', 'uptime', 'who_b_boottime') # Aug 1 14:13 + who_b_output_file = my_fixture('who_b_boottime') # Aug 1 14:13 Facter::Util::Uptime.stubs(:uptime_who_cmd).returns("cat \"#{who_b_output_file}\"") Time.stubs(:now).returns Time.parse("Aug 01 15:13") # one hour later Facter::Util::Uptime.get_uptime_seconds_unix.should == 60 * 60 diff -Nru facter-1.6.4/spec/unit/util/virtual_spec.rb facter-1.6.5/spec/unit/util/virtual_spec.rb --- facter-1.6.4/spec/unit/util/virtual_spec.rb 2011-11-09 19:09:53.000000000 +0000 +++ facter-1.6.5/spec/unit/util/virtual_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,5 +1,6 @@ -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') +#!/usr/bin/env rspec +require 'spec_helper' require 'facter/util/virtual' describe Facter::Util::Virtual do @@ -79,7 +80,7 @@ Facter::Util::Virtual.should_not be_vserver end - fixture_path = File.join(SPECDIR, 'fixtures', 'virtual', 'proc_self_status') + fixture_path = fixtures('virtual', 'proc_self_status') test_cases = [ [File.join(fixture_path, 'vserver_2_1', 'guest'), true, 'vserver 2.1 guest'], @@ -149,6 +150,13 @@ Facter::Util::Virtual.should be_kvm end + it "should detect kvm on OpenBSD" do + FileTest.stubs(:exists?).with("/proc/cpuinfo").returns(false) + Facter.fact(:kernel).stubs(:value).returns("OpenBSD") + Facter::Util::Resolution.stubs(:exec).with("/sbin/sysctl -n hw.model").returns('QEMU Virtual CPU version (cpu64-rhel6) ("AuthenticAMD" 686-class, 512KB L2 cache)') + Facter::Util::Virtual.should be_kvm + end + it "should identify FreeBSD jail when in jail" do Facter.fact(:kernel).stubs(:value).returns("FreeBSD") Facter::Util::Resolution.stubs(:exec).with("/sbin/sysctl -n security.jail.jailed").returns("1") diff -Nru facter-1.6.4/spec/unit/util/vlans_spec.rb facter-1.6.5/spec/unit/util/vlans_spec.rb --- facter-1.6.4/spec/unit/util/vlans_spec.rb 2011-11-09 19:09:53.000000000 +0000 +++ facter-1.6.5/spec/unit/util/vlans_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,13 +1,11 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') +#!/usr/bin/env rspec +require 'spec_helper' require 'facter/util/vlans' describe Facter::Util::Vlans do it "should return a list of vlans on Linux" do - sample_output_file = File.dirname(__FILE__) + '/../data/linux_vlan_config' - linux_vlanconfig = File.new(sample_output_file).read(); + linux_vlanconfig = my_fixture_read("linux_vlan_config") Facter::Util::Vlans.stubs(:get_vlan_config).returns(linux_vlanconfig) Facter::Util::Vlans.get_vlans().should == %{400,300,200,100} end diff -Nru facter-1.6.4/spec/unit/util/wmi_spec.rb facter-1.6.5/spec/unit/util/wmi_spec.rb --- facter-1.6.4/spec/unit/util/wmi_spec.rb 2011-09-21 20:31:59.000000000 +0000 +++ facter-1.6.5/spec/unit/util/wmi_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,7 +1,6 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') +#!/usr/bin/env rspec +require 'spec_helper' require 'facter/util/wmi' describe Facter::Util::WMI do diff -Nru facter-1.6.4/spec/unit/util/xendomains_spec.rb facter-1.6.5/spec/unit/util/xendomains_spec.rb --- facter-1.6.4/spec/unit/util/xendomains_spec.rb 2011-09-13 23:19:13.000000000 +0000 +++ facter-1.6.5/spec/unit/util/xendomains_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,14 +1,12 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') +#!/usr/bin/env rspec +require 'spec_helper' require 'facter/util/xendomains' describe Facter::Util::Xendomains do describe ".get_domains" do it "should return a list of running Xen Domains on Xen0" do - sample_output_file = File.dirname(__FILE__) + '/../data/xendomains' - xen0_domains = File.read(sample_output_file) + xen0_domains = my_fixture_read("xendomains") Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/xm list 2>/dev/null').returns(xen0_domains) Facter::Util::Xendomains.get_domains.should == %{web01,mailserver} end diff -Nru facter-1.6.4/spec/unit/virtual_spec.rb facter-1.6.5/spec/unit/virtual_spec.rb --- facter-1.6.4/spec/unit/virtual_spec.rb 2011-11-09 19:09:53.000000000 +0000 +++ facter-1.6.5/spec/unit/virtual_spec.rb 2012-01-18 18:11:40.000000000 +0000 @@ -1,6 +1,6 @@ -require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') +#!/usr/bin/env rspec -require 'facter' +require 'spec_helper' require 'facter/util/virtual' require 'facter/util/macosx' @@ -112,6 +112,25 @@ Facter.fact(:virtual).value.should == "vmware" end + it "should be xen0 with xen dom0 files in /proc" do + Facter.fact(:kernel).stubs(:value).returns("Linux") + Facter.fact(:operatingsystem).stubs(:value).returns("Linux") + Facter.fact(:hardwaremodel).stubs(:value).returns("i386") + Facter::Util::Virtual.expects(:xen?).returns(true) + FileTest.expects(:exists?).with("/proc/xen/xsd_kva").returns(true) + Facter.fact(:virtual).value.should == "xen0" + end + + it "should be xenu with xen domU files in /proc" do + Facter.fact(:kernel).stubs(:value).returns("Linux") + Facter.fact(:operatingsystem).stubs(:value).returns("Linux") + Facter.fact(:hardwaremodel).stubs(:value).returns("i386") + Facter::Util::Virtual.expects(:xen?).returns(true) + FileTest.expects(:exists?).with("/proc/xen/xsd_kva").returns(false) + FileTest.expects(:exists?).with("/proc/xen/capabilities").returns(true) + Facter.fact(:virtual).value.should == "xenu" + end + it "should be xenhvm with Xen HVM vendor name from lspci" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter::Util::Resolution.stubs(:exec).with('lspci').returns("00:03.0 Unassigned class [ff80]: XenSource, Inc. Xen Platform Device (rev 01)") @@ -184,24 +203,35 @@ Facter::Util::Resolution.stubs(:exec).with('prtdiag').returns("System Configuration: innotek GmbH VirtualBox") Facter.fact(:virtual).value.should == "virtualbox" end + end - it "should be xen0 with xen dom0 files in /proc" do - Facter.fact(:kernel).stubs(:value).returns("Linux") - Facter.fact(:operatingsystem).stubs(:value).returns("Linux") - Facter.fact(:hardwaremodel).stubs(:value).returns("i386") - Facter::Util::Virtual.expects(:xen?).returns(true) - FileTest.expects(:exists?).with("/proc/xen/xsd_kva").returns(true) - Facter.fact(:virtual).value.should == "xen0" + describe "on OpenBSD" do + before do + Facter::Util::Resolution.stubs(:exec).with("vmware -v").returns false + Facter.fact(:kernel).stubs(:value).returns("OpenBSD") + Facter.fact(:hardwaremodel).stubs(:value).returns(nil) + Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil) + Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns(nil) end - - it "should be xenu with xen domU files in /proc" do - Facter.fact(:kernel).stubs(:value).returns("Linux") - Facter.fact(:operatingsystem).stubs(:value).returns("Linux") - Facter.fact(:hardwaremodel).stubs(:value).returns("i386") - Facter::Util::Virtual.expects(:xen?).returns(true) - FileTest.expects(:exists?).with("/proc/xen/xsd_kva").returns(false) - FileTest.expects(:exists?).with("/proc/xen/capabilities").returns(true) - Facter.fact(:virtual).value.should == "xenu" + + it "should be parallels with Parallels product name from sysctl" do + Facter::Util::Resolution.stubs(:exec).with('sysctl -n hw.product 2>/dev/null').returns("Parallels Virtual Platform") + Facter.fact(:virtual).value.should == "parallels" + end + + it "should be vmware with VMware product name from sysctl" do + Facter::Util::Resolution.stubs(:exec).with('sysctl -n hw.product 2>/dev/null').returns("VMware Virtual Platform") + Facter.fact(:virtual).value.should == "vmware" + end + + it "should be virtualbox with VirtualBox product name from sysctl" do + Facter::Util::Resolution.stubs(:exec).with('sysctl -n hw.product 2>/dev/null').returns("VirtualBox") + Facter.fact(:virtual).value.should == "virtualbox" + end + + it "should be xenhvm with Xen HVM product name from sysctl" do + Facter::Util::Resolution.stubs(:exec).with('sysctl -n hw.product 2>/dev/null').returns("HVM domU") + Facter.fact(:virtual).value.should == "xenhvm" end end end