diff options
| author | Marc Fournier <marc.fournier@camptocamp.com> | 2010-09-10 19:02:44 +0200 |
|---|---|---|
| committer | Daniel Pittman <daniel@rimspace.net> | 2011-01-31 12:55:25 -0800 |
| commit | 0d7a2e683125028758ae91d3754c0466fd068cf3 (patch) | |
| tree | 476f9a0af5446613d1ebb7519bcb2ba3ecc77d6d /spec | |
| parent | ecd7cda64bdf3c8cd97b7c05f9cf7eb890d3682b (diff) | |
| download | facter-0d7a2e683125028758ae91d3754c0466fd068cf3.tar.gz facter-0d7a2e683125028758ae91d3754c0466fd068cf3.tar.xz facter-0d7a2e683125028758ae91d3754c0466fd068cf3.zip | |
Fix #4755: add support for GNU/kFreeBSD platform where missing.
Merged manually to the current state of the art. Minimal conflicts resolved
by adding both Darwin and GNU/KFreeBSD to the confine lines.
Author: Marc Fournier <marc.fournier@camptocamp.com>
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Signed-off-by: Rick Bradley <rick@rickbradley.com>
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/unit/data/debian_kfreebsd_ifconfig | 40 | ||||
| -rwxr-xr-x | spec/unit/util/ip_spec.rb | 30 | ||||
| -rw-r--r-- | spec/unit/util/virtual_spec.rb | 6 |
3 files changed, 73 insertions, 3 deletions
diff --git a/spec/unit/data/debian_kfreebsd_ifconfig b/spec/unit/data/debian_kfreebsd_ifconfig new file mode 100644 index 0000000..44a3b62 --- /dev/null +++ b/spec/unit/data/debian_kfreebsd_ifconfig @@ -0,0 +1,40 @@ +em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500 + options=209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC> + ether 0:11:a:59:67:90 + inet6 fe80::211:aff:fe59:6790%em0 prefixlen 64 scopeid 0x1 + nd6 options=3<PERFORMNUD,ACCEPT_RTADV> + media: Ethernet autoselect (1000baseT <full-duplex>) + status: active +em1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500 + options=209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC> + 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<PERFORMNUD,ACCEPT_RTADV> + media: Ethernet autoselect (100baseTX <full-duplex>) + status: active +bge0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500 + options=8009b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,LINKSTATE> + ether 0:14:c2:3f:ea:e4 + media: Ethernet autoselect (none) + status: no carrier +bge1: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500 + options=8009b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,LINKSTATE> + ether 0:14:c2:3f:ea:e3 + media: Ethernet autoselect (none) + status: no carrier +lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384 + options=3<RXCSUM,TXCSUM> + inet6 ::1 prefixlen 128 + inet6 fe80::1%lo0 prefixlen 64 scopeid 0x5 + inet 127.0.0.1 netmask 0xff000000 + nd6 options=3<PERFORMNUD,ACCEPT_RTADV> +vlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500 + options=3<RXCSUM,TXCSUM> + 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<PERFORMNUD,ACCEPT_RTADV> + media: Ethernet autoselect (1000baseT <full-duplex>) + status: active + vlan: 192 parent interface: em0 diff --git a/spec/unit/util/ip_spec.rb b/spec/unit/util/ip_spec.rb index d87b4b9..ceceb3f 100755 --- a/spec/unit/util/ip_spec.rb +++ b/spec/unit/util/ip_spec.rb @@ -5,7 +5,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'facter/util/ip' describe Facter::Util::IP do - [:freebsd, :linux, :netbsd, :openbsd, :sunos, :darwin, :"hp-ux"].each do |platform| + [:freebsd, :linux, :netbsd, :openbsd, :sunos, :darwin, :"hp-ux", :"gnu/kfreebsd"].each do |platform| it "should be supported on #{platform}" do Facter::Util::IP.supported_platforms.should be_include(platform) end @@ -48,6 +48,13 @@ describe Facter::Util::IP do 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.new(sample_output_file).read() + 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 value for a specific interface" do Facter::Util::IP.should respond_to(:get_interface_value) end @@ -107,6 +114,16 @@ describe Facter::Util::IP do Facter::Util::IP.get_interface_value("lan0", "macaddress").should == "00:13:21:BD:9C:B7" 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.new(sample_output_file).read() + + Facter::Util::IP.expects(:get_single_interface_output).with("em0").returns(kfreebsd_ifconfig) + Facter.stubs(:value).with(:kernel).returns("GNU/kFreeBSD") + + Facter::Util::IP.get_interface_value("em0", "macaddress").should == "0:11:a:59:67:90" + 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.new(sample_output_file).read() @@ -188,6 +205,17 @@ describe Facter::Util::IP do Facter::Util::IP.get_interface_value("en1", "netmask").should == "255.255.255.0" 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.new(sample_output_file).read() + + Facter::Util::IP.expects(:get_single_interface_output).with("em1").returns(kfreebsd_ifconfig) + Facter.stubs(:value).with(:kernel).returns("GNU/kFreeBSD") + + Facter::Util::IP.get_interface_value("em1", "netmask").should == "255.255.255.0" + end + it "should not get bonding master on interface aliases" do Facter.stubs(:value).with(:kernel).returns("Linux") diff --git a/spec/unit/util/virtual_spec.rb b/spec/unit/util/virtual_spec.rb index 12ba0ac..aa2de5a 100644 --- a/spec/unit/util/virtual_spec.rb +++ b/spec/unit/util/virtual_spec.rb @@ -128,12 +128,14 @@ describe Facter::Util::Virtual do 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") Facter::Util::Virtual.should be_jail end - it "should not identify FreeBSD jail when not in jail" do - Facter::Util::Resolution.stubs(:exec).with("/sbin/sysctl -n security.jail.jailed").returns("0") + it "should not identify GNU/kFreeBSD jail when not in jail" do + Facter.fact(:kernel).stubs(:value).returns("GNU/kFreeBSD") + Facter::Util::Resolution.stubs(:exec).with("/bin/sysctl -n security.jail.jailed").returns("0") Facter::Util::Virtual.should_not be_jail end |
