2015-09-15 12:38:19 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
|
|
|
|
# Tests configuration:
|
2015-09-16 10:10:03 +00:00
|
|
|
module Test
|
|
|
|
class << self
|
|
|
|
# MTime tracks the maximum range of modification time in seconds.
|
|
|
|
# i.e. MTime == 60*60*1 is 1 hour of modification time range,
|
|
|
|
# which translates to a modification time range of:
|
|
|
|
# [ now-1hour, now ]
|
|
|
|
def mtime
|
|
|
|
60 * 60 * 24 * 1
|
|
|
|
end
|
|
|
|
|
2015-09-16 10:11:23 +00:00
|
|
|
def dup(o)
|
|
|
|
Marshal.load(Marshal.dump(o))
|
|
|
|
end
|
|
|
|
|
2015-09-16 14:15:38 +00:00
|
|
|
def root_group(os)
|
|
|
|
if os[:family] == 'freebsd'
|
|
|
|
'wheel'
|
|
|
|
else
|
|
|
|
'root'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-16 10:10:03 +00:00
|
|
|
def selinux_label(os, path = nil)
|
|
|
|
labels = {}
|
|
|
|
|
|
|
|
h = {}
|
|
|
|
h.default = Hash.new(nil)
|
|
|
|
h['redhat'] = {}
|
|
|
|
h['redhat'].default = 'unconfined_u:object_r:user_tmp_t:s0'
|
|
|
|
h['redhat']['5.11'] = 'user_u:object_r:tmp_t'
|
2015-09-16 11:40:05 +00:00
|
|
|
h['fedora'] = h['redhat']
|
2015-09-16 10:11:23 +00:00
|
|
|
labels.default = dup(h)
|
|
|
|
|
|
|
|
h['redhat'].default = 'unconfined_u:object_r:tmp_t:s0'
|
|
|
|
labels['/tmp/block_device'] = dup(h)
|
2015-09-16 10:10:03 +00:00
|
|
|
|
|
|
|
h = {}
|
|
|
|
h.default = Hash.new(nil)
|
|
|
|
h['redhat'] = {}
|
|
|
|
h['redhat'].default = 'system_u:object_r:null_device_t:s0'
|
2015-09-16 11:40:05 +00:00
|
|
|
h['fedora'] = h['redhat']
|
2015-09-16 10:10:03 +00:00
|
|
|
h['redhat']['5.11'] = 'system_u:object_r:null_device_t'
|
2015-09-16 10:11:23 +00:00
|
|
|
labels['/dev/null'] = dup(h)
|
2015-09-16 10:10:03 +00:00
|
|
|
|
|
|
|
labels[path][os[:family]][os[:release]]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-09-15 12:38:19 +00:00
|
|
|
|
|
|
|
# Run all tests
|
2015-09-14 14:34:58 +00:00
|
|
|
require 'minitest/autorun'
|
|
|
|
require 'minitest/spec'
|
|
|
|
require 'vulcano/backend'
|
|
|
|
|
|
|
|
backends = {}
|
|
|
|
|
|
|
|
backends[:local] = proc {
|
|
|
|
backend_conf = Vulcano::Backend.target_config({})
|
|
|
|
backend_class = Vulcano::Backend.registry['local']
|
|
|
|
backend_class.new(backend_conf)
|
|
|
|
}
|
|
|
|
|
|
|
|
backends[:specinfra_local] = proc {
|
2015-09-15 10:38:51 +00:00
|
|
|
backend_conf = Vulcano::Backend.target_config({ 'backend' => 'exec' })
|
2015-09-14 14:34:58 +00:00
|
|
|
backend_class = Vulcano::Backend.registry['specinfra']
|
|
|
|
backend_class.new(backend_conf)
|
|
|
|
}
|
|
|
|
|
|
|
|
tests = ARGV
|
|
|
|
|
|
|
|
backends.each do |type, get_backend|
|
|
|
|
tests.each do |test|
|
|
|
|
instance_eval(File.read(test))
|
|
|
|
end
|
|
|
|
end
|