specinfra 2.66.5 → 2.66.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 408f0f41631bffb6459f62f1d207cd09acfd969a
4
- data.tar.gz: 91fca84926d0775de1b89240bc2a25bce0ebf20a
3
+ metadata.gz: 8b3ab4b42d73fe5ddbe2f8a7b7b15dbf9c4cab08
4
+ data.tar.gz: f55c8d33ef771d0d3d37788fae05115090b18ed0
5
5
  SHA512:
6
- metadata.gz: b0d9ee631452081a3cb3708218349d43e69137e71b56233f1734d46a3ef364db0344d9bac89975346b7e8cf456916f26742769cd4c940740653de020b3c3c734
7
- data.tar.gz: ca6f5f7200e25b746a5add15f0f4ee2f081c7c6107ce9fbfb38145a0397d848abab0ee058f6b8fa3dcb39e987a9269e7f2731c8455505166463250f6fe46cc3e
6
+ metadata.gz: 0b7e4c706519eb56e678fbfc3745723884d65a335d9346f7eab94488093b773c35af336d82a27ac87176755784b8203c6ba614440a7f8c41a44f1da0cd56df50
7
+ data.tar.gz: d2b036de0e6b96fac03a9ad50d14f76ae2cdf04e91c29f029546884516603d232e8a97e146c02c6fde5b4051cd11b5c85b7915ee53dd27ff1819efaa5f2d31c7
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ if defined?(RSpec)
10
10
  task :default => 'spec:all'
11
11
 
12
12
  namespace :spec do
13
- task :all => [ :helper, :backend, :configuration, :command, :host_inventory ]
13
+ task :all => [ :helper, :backend, :configuration, :processor, :command, :host_inventory ]
14
14
 
15
15
  RSpec::Core::RakeTask.new(:helper) do |t|
16
16
  t.pattern = "spec/helper/*_spec.rb"
@@ -33,6 +33,10 @@ if defined?(RSpec)
33
33
  t.pattern = "spec/configuration_spec.rb"
34
34
  end
35
35
 
36
+ RSpec::Core::RakeTask.new(:processor) do |t|
37
+ t.pattern = "spec/processor_spec.rb"
38
+ end
39
+
36
40
  RSpec::Core::RakeTask.new(:command) do |t|
37
41
  t.pattern = "spec/command/**/*.rb"
38
42
  end
@@ -89,14 +89,23 @@ module Specinfra
89
89
  end
90
90
 
91
91
  mount = ret.stdout.scan(/\S+/)
92
- actual_attr = { :device => mount[0], :type => mount[4] }
93
- mount[5].gsub(/\(|\)/, '').split(',').each do |option|
94
- name, val = option.split('=')
95
- if val.nil?
96
- actual_attr[name.to_sym] = true
97
- else
98
- val = val.to_i if val.match(/^\d+$/)
99
- actual_attr[name.to_sym] = val
92
+ actual_attr = { }
93
+ actual_attr[:device] = mount[0]
94
+ # Output of mount depends on os:
95
+ # a) proc on /proc type proc (rw,noexec,nosuid,nodev)
96
+ # b) procfs on /proc (procfs, local)
97
+ actual_attr[:type] = mount[4] if mount[3] == 'type' # case a.
98
+ if match = ret.stdout.match(/\((.*)\)/)
99
+ options = match[1].split(',')
100
+ actual_attr[:type] ||= options.shift # case b.
101
+ options.each do |option|
102
+ name, val = option.split('=')
103
+ if val.nil?
104
+ actual_attr[name.strip.to_sym] = true
105
+ else
106
+ val = val.to_i if val.match(/^\d+$/)
107
+ actual_attr[name.strip.to_sym] = val
108
+ end
100
109
  end
101
110
  end
102
111
 
@@ -1,3 +1,3 @@
1
1
  module Specinfra
2
- VERSION = "2.66.5"
2
+ VERSION = "2.66.6"
3
3
  end
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ describe Specinfra::Processor do
4
+ describe 'check_file_is_mounted' do
5
+ let(:path) { '/proc' }
6
+ let(:cmd) { Specinfra.command.get(:check_file_is_mounted, path) }
7
+
8
+ def mock_output(stdout)
9
+ Specinfra::CommandResult.new :stdout => stdout
10
+ end
11
+
12
+ context 'freebsd' do
13
+ before do
14
+ allow(Specinfra.backend).to receive(:run_command).with(cmd) { mock_output 'procfs on /proc (procfs, local)' }
15
+ end
16
+ it 'true when fs type matches' do
17
+ expect(Specinfra::Processor.check_file_is_mounted(path, {:type => 'procfs'}, false)).to eq(true)
18
+ end
19
+ it 'false when fs type is different' do
20
+ expect(Specinfra::Processor.check_file_is_mounted(path, {:type => 'ufs'}, false)).to eq(false)
21
+ end
22
+ it 'true when option matches' do
23
+ expect(Specinfra::Processor.check_file_is_mounted(path, {:local => true}, false)).to eq(true)
24
+ end
25
+ it 'false when option is different' do
26
+ expect(Specinfra::Processor.check_file_is_mounted(path, {:async => true}, false)).to eq(false)
27
+ end
28
+ context 'only_with' do
29
+ it 'false when extra options present' do
30
+ expect(Specinfra::Processor.check_file_is_mounted(path, {:local => true, :async => true}, true)).to eq(false)
31
+ end
32
+ it 'true when all options met' do
33
+ expect(Specinfra::Processor.check_file_is_mounted(path, {:device => "procfs", :type => "procfs", :local => true}, true)).to eq(true)
34
+ end
35
+ end
36
+ end
37
+ context 'linux' do
38
+ before do
39
+ allow(Specinfra.backend).to receive(:run_command).with(cmd) { mock_output 'proc on /proc type proc (rw,noexec,nosuid,nodev)' }
40
+ end
41
+ it 'true when fs type matches' do
42
+ expect(Specinfra::Processor.check_file_is_mounted(path, {:type => 'proc'}, false)).to eq(true)
43
+ end
44
+ it 'false when fs type is different' do
45
+ expect(Specinfra::Processor.check_file_is_mounted(path, {:type => 'ufs'}, false)).to eq(false)
46
+ end
47
+ it 'true when option matches' do
48
+ expect(Specinfra::Processor.check_file_is_mounted(path, {:noexec => true, :nosuid => true}, false)).to eq(true)
49
+ end
50
+ it 'false when option is different' do
51
+ expect(Specinfra::Processor.check_file_is_mounted(path, {:noexec => true, :unknown => true}, false)).to eq(false)
52
+ end
53
+ context 'only_with' do
54
+ it 'false when extra options present' do
55
+ expect(Specinfra::Processor.check_file_is_mounted(path, {:noexec => true, :nosuid => true}, true)).to eq(false)
56
+ end
57
+ it 'true when all options are same' do
58
+ expect(Specinfra::Processor.check_file_is_mounted(path, {:noexec => true, :nosuid => true, :nodev => true, :rw => true, :device => "proc", :type => "proc"}, true)).to eq(true)
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specinfra
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.66.5
4
+ version: 2.66.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gosuke Miyashita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-19 00:00:00.000000000 Z
11
+ date: 2017-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-scp
@@ -601,6 +601,7 @@ files:
601
601
  - spec/host_inventory/openbsd/virtualization_spec.rb
602
602
  - spec/host_inventory/solaris/filesystem_spec.rb
603
603
  - spec/host_inventory/solaris/virtualization_spec.rb
604
+ - spec/processor_spec.rb
604
605
  - spec/spec_helper.rb
605
606
  - specinfra.gemspec
606
607
  homepage: https://github.com/mizzy/specinfra
@@ -721,4 +722,5 @@ test_files:
721
722
  - spec/host_inventory/openbsd/virtualization_spec.rb
722
723
  - spec/host_inventory/solaris/filesystem_spec.rb
723
724
  - spec/host_inventory/solaris/virtualization_spec.rb
725
+ - spec/processor_spec.rb
724
726
  - spec/spec_helper.rb