Commit 375216ce authored by Tails developers's avatar Tails developers
Browse files

Reorganise features/, unifying both test suites.

Now all .feature:s reside directly in the root of features/, and they
are differentiated with tags: source tests are tagged '@source' and
product (i.e. Tails ISO image) tests are tagged '@product'. These tags
then set up the appropriate environment on a feature-by-feature basis.
parent 98d4fcbe
@product
Feature: Installing packages through APT
As a Tails user
when I set an administration password in Tails Greeter
......
@source
Feature: custom APT sources to build branches
As a Tails developer, when I build Tails, I'd be happy if
the proper APT sources were automatically picked depending
......
require 'java'
require 'rubygems'
require 'time'
require 'fileutils'
require "#{Dir.pwd}/features/cucumber/support/extra_hooks.rb"
def delete_snapshot(snapshot)
if snapshot and File.exist?(snapshot)
File.delete(snapshot)
end
rescue Errno::EACCES => e
STDERR.puts "Couldn't delete background snapshot: #{e.to_s}"
end
def scenario_clean_up
if @sniffer
@sniffer.stop
@sniffer.clear
end
@vm.destroy if @vm
end
def feature_clean_up
delete_snapshot($background_snapshot) if !$keep_snapshots
VM.storage.clear_volumes if VM.storage
end
def delete_all_snapshots
Dir.glob("#{$tmp_dir}/*.state").each do |snapshot|
delete_snapshot(snapshot)
end
end
def exit_clean_up
scenario_clean_up
feature_clean_up
delete_all_snapshots if !$keep_snapshots
VM.storage.clear_pool if VM.storage
end
$time_at_start = Time.now
$tmp_dir = ENV['TEMP_DIR'] || "/tmp/TailsToaster"
if File.exist?($tmp_dir)
if !File.directory?($tmp_dir)
raise "Temporary directory '#{$tmp_dir}' exists but is not a " +
"directory"
end
if !File.owned?($tmp_dir)
raise "Temporary directory '#{$tmp_dir}' must be owned by the " +
"current user"
end
FileUtils.chmod(0755, $tmp_dir)
else
begin
Dir.mkdir($tmp_dir)
rescue Errno::EACCES => e
raise "Cannot create temporary directory: #{e.to_s}"
end
end
$vm_xml_path = ENV['VM_XML_PATH'] || "#{Dir.pwd}/features/cucumber/domains"
$misc_files_dir = "#{Dir.pwd}/features/cucumber/misc_files"
$keep_snapshots = !ENV['KEEP_SNAPSHOTS'].nil?
delete_all_snapshots if !$keep_snapshots
$tails_iso = ENV['ISO'] || get_last_iso
if $tails_iso.nil?
raise "No Tails ISO image specified, and none could be found in the " +
"current directory"
end
if File.exist?($tails_iso)
# Workaround: when libvirt takes ownership of the ISO image it may
# become unreadable for the live user inside the guest in the
# host-to-guest share used for some tests.
# jruby 1.5.6 doesn't have world_readable? in File or File::Stat so we
# manually check for it in the mode string
if !(File.stat($tails_iso).mode & 04)
if File.owned?($tails_iso)
chmod(0644, $tails_iso)
else
raise "warning: the Tails ISO image must be world readable or be owned" +
"by the current user to be available inside the guest VM via " +
"host-to-guest shares, which is required by some tests"
end
end
else
raise "The specified Tails ISO image '#{$tails_iso}' does not exist"
end
$x_display = ENV['DISPLAY']
$live_user = "amnesia"
at_exit { exit_clean_up }
BeforeFeature do |feature|
base = File.basename(feature.file, ".feature").to_s
$background_snapshot = "#{$tmp_dir}/#{base}_background.state"
end
AfterFeature do
feature_clean_up
end
# BeforeScenario
Before do
@screen = Sikuli::Screen.new
if File.size?($background_snapshot)
@skip_steps_while_restoring_background = true
else
@skip_steps_while_restoring_background = false
end
@theme = "gnome"
end
# AfterScenario
After do |scenario|
if (scenario.status != :passed)
time_of_fail = Time.now - $time_at_start
secs = "%02d" % (time_of_fail % 60)
mins = "%02d" % ((time_of_fail / 60) % 60)
hrs = "%02d" % (time_of_fail / (60*60))
STDERR.puts "Scenario failed at time #{hrs}:#{mins}:#{secs}"
base = File.basename(scenario.feature.file, ".feature").to_s
@vm.take_screenshot("#{base}-#{DateTime.now}") if @vm
end
scenario_clean_up
end
@product
Feature: Encryption and verification using GnuPG
As a Tails user
I want to be able to easily encrypt and sign messages using GnuPG
......
@product
Feature: System memory erasure on shutdown
As a Tails user
when I shutdown Tails
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment