2015-09-25 17:16:07 +00:00
|
|
|
# encoding: utf-8
|
2015-10-06 16:55:44 +00:00
|
|
|
# author: Dominik Richter
|
|
|
|
# author: Christoph Hartmann
|
|
|
|
|
2016-08-01 12:57:41 +00:00
|
|
|
#
|
|
|
|
# On most systems I've used a link to /proc/kcore is placed at
|
|
|
|
# /dev/core. However, on TravisCI we also see it at /dev/kcore.
|
|
|
|
#
|
|
|
|
# Since we are using this file to test some properties of symlinks, we
|
|
|
|
# don't particularly care where it is, so here we use /dev/kcore if it
|
|
|
|
# exists and otherwise fall back to /dev/core.
|
|
|
|
#
|
|
|
|
kcore_dev = if file('/dev/kcore').exist?
|
|
|
|
'/dev/kcore'
|
|
|
|
else
|
|
|
|
'/dev/core'
|
|
|
|
end
|
|
|
|
|
2015-09-03 14:17:52 +00:00
|
|
|
describe file('/tmp') do
|
|
|
|
it { should exist }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe file('/tmpest') do
|
|
|
|
it { should_not exist }
|
|
|
|
end
|
|
|
|
|
2015-09-03 12:14:57 +00:00
|
|
|
describe file('/tmp') do
|
2016-05-03 22:14:33 +00:00
|
|
|
its('type') { should eq :directory }
|
2015-09-03 14:17:52 +00:00
|
|
|
it { should be_directory }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe file('/proc/version') do
|
2016-05-03 22:14:33 +00:00
|
|
|
its('type') { should eq :file }
|
2015-09-03 14:17:52 +00:00
|
|
|
it { should be_file }
|
|
|
|
it { should_not be_directory }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe file('/dev/stdout') do
|
2016-05-03 22:14:33 +00:00
|
|
|
its('type') { should eq :pipe }
|
2016-04-28 23:56:13 +00:00
|
|
|
its('source.type') { should eq :symlink }
|
2015-09-03 14:17:52 +00:00
|
|
|
it { should be_symlink }
|
2016-04-28 23:56:13 +00:00
|
|
|
it { should be_pipe }
|
2015-09-03 14:17:52 +00:00
|
|
|
it { should_not be_file }
|
|
|
|
it { should_not be_directory }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe file('/dev/zero') do
|
2016-05-03 22:14:33 +00:00
|
|
|
its('type') { should eq :character_device }
|
2015-09-03 14:17:52 +00:00
|
|
|
it { should be_character_device }
|
|
|
|
it { should_not be_file }
|
|
|
|
it { should_not be_directory }
|
|
|
|
end
|
|
|
|
|
|
|
|
# describe file('...') do
|
2016-05-03 22:14:33 +00:00
|
|
|
# its('type') { should eq :block_device }
|
2015-09-03 14:17:52 +00:00
|
|
|
# it { should be_block_device }
|
|
|
|
# end
|
|
|
|
|
|
|
|
# describe file('...') do
|
2016-05-03 22:14:33 +00:00
|
|
|
# its('type') { should eq :socket }
|
2015-09-03 14:17:52 +00:00
|
|
|
# it { should be_socket }
|
|
|
|
# end
|
|
|
|
|
|
|
|
# describe file('...') do
|
2016-05-03 22:14:33 +00:00
|
|
|
# its('type') { should eq :pipe }
|
2015-09-03 14:17:52 +00:00
|
|
|
# it { should be_pipe }
|
|
|
|
# end
|
|
|
|
|
|
|
|
describe file('/dev') do
|
2016-05-03 22:14:33 +00:00
|
|
|
its('mode') { should eq 00755 }
|
2016-08-30 17:23:47 +00:00
|
|
|
its('mode') { should cmp '00755' }
|
|
|
|
its('mode') { should_not cmp '00777' }
|
2015-09-03 14:17:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe file('/dev') do
|
|
|
|
it { should be_mode 00755 }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe file('/root') do
|
2016-05-03 22:14:33 +00:00
|
|
|
its('owner') { should eq 'root' }
|
2015-09-03 14:17:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe file('/dev') do
|
|
|
|
it { should be_owned_by 'root' }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe file('/root') do
|
2016-05-03 22:14:33 +00:00
|
|
|
its('group') { should eq 'root' }
|
2015-09-03 14:17:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe file('/dev') do
|
|
|
|
it { should be_grouped_into 'root' }
|
|
|
|
end
|
|
|
|
|
2016-08-01 12:57:41 +00:00
|
|
|
describe file(kcore_dev) do
|
2016-05-03 22:14:33 +00:00
|
|
|
its('link_path') { should eq '/proc/kcore' }
|
2015-09-03 14:17:52 +00:00
|
|
|
end
|
|
|
|
|
2016-08-01 12:57:41 +00:00
|
|
|
describe file(kcore_dev) do
|
2015-09-03 14:17:52 +00:00
|
|
|
it { should be_linked_to '/proc/kcore' }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe file('/proc/cpuinfo') do
|
2016-05-03 22:14:33 +00:00
|
|
|
its('content') { should match /^processor/ }
|
2015-09-03 14:17:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe file('/').mtime.to_i do
|
|
|
|
it { should <= Time.now.to_i }
|
|
|
|
it { should >= Time.now.to_i - 1000}
|
|
|
|
end
|
|
|
|
|
|
|
|
describe file('/') do
|
2016-05-03 22:14:33 +00:00
|
|
|
its('size') { should be > 64 }
|
|
|
|
its('size') { should be < 10240 }
|
2015-09-03 14:17:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe file('/proc/cpuinfo') do
|
2016-05-03 22:14:33 +00:00
|
|
|
its('size') { should be 0 }
|
2015-09-03 14:17:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# @TODO selinux_label
|
|
|
|
|
2015-09-22 17:32:20 +00:00
|
|
|
# @TODO skip as the mount command is not reliably present on all test containers
|
|
|
|
# describe file('/proc') do
|
|
|
|
# it { should be_mounted }
|
|
|
|
# end
|
2015-09-03 14:17:52 +00:00
|
|
|
|
|
|
|
describe file('/proc/cpuinfo') do
|
|
|
|
it { should_not be_mounted }
|
|
|
|
end
|
|
|
|
|
|
|
|
# @TODO immutable?
|
|
|
|
# @TODO product_version
|
|
|
|
# @TODO file_version
|
|
|
|
# @TODO version?
|
|
|
|
|
|
|
|
require 'digest'
|
|
|
|
cpuinfo = file('/proc/cpuinfo').content
|
|
|
|
|
|
|
|
md5sum = Digest::MD5.hexdigest(cpuinfo)
|
|
|
|
describe file('/proc/cpuinfo') do
|
2016-05-03 22:14:33 +00:00
|
|
|
its('md5sum') { should eq md5sum }
|
2015-09-03 14:17:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
sha256sum = Digest::SHA256.hexdigest(cpuinfo)
|
|
|
|
describe file('/proc/cpuinfo') do
|
2016-05-03 22:14:33 +00:00
|
|
|
its('sha256sum') { should eq sha256sum }
|
2015-09-03 12:14:57 +00:00
|
|
|
end
|