Commit 64d58e43 authored by intrigeri's avatar intrigeri

Merge branch 'test/16003-growing-system-partition' into feature/15292-usb-image (Closes: #16003)

parents 4c33052e eef12f0f
......@@ -29,9 +29,9 @@ Given /^I create an?( (\d+) ([[:alpha:]]+))? ([[:alnum:]]+) partition( labeled "
$vm.storage.disk_mkpartfs(name, parttype, fstype, opts)
end
Given /^I write the Tails ISO image to disk "([^"]+)"$/ do |name|
Given /^I write the Tails (ISO|USB) image to disk "([^"]+)"$/ do |type, name|
src_disk = {
:path => TAILS_ISO,
:path => (type == 'ISO' ? TAILS_ISO : TAILS_IMG),
:opts => {
:format => "raw",
:readonly => true
......
......@@ -274,7 +274,7 @@ def check_disk_integrity(name, dev, scheme)
"Unexpected partition scheme on USB drive '#{name}', '#{dev}'")
end
def check_part_integrity(name, dev, usage, fs_type, part_label, part_type = nil)
def check_part_integrity(name, dev, usage, fs_type, part_label = nil, part_type = nil)
info = $vm.execute("udisksctl info --block-device '#{dev}'").stdout
info_split = info.split("\n org\.freedesktop\.UDisks2\.Partition:\n")
dev_info = info_split[0]
......@@ -283,8 +283,10 @@ def check_part_integrity(name, dev, usage, fs_type, part_label, part_type = nil)
"Unexpected device field 'usage' on USB drive '#{name}', '#{dev}'")
assert(dev_info.match("^ IdType: +#{fs_type}$"),
"Unexpected device field 'IdType' on USB drive '#{name}', '#{dev}'")
assert(part_info.match("^ Name: +#{part_label}$"),
"Unexpected partition label on USB drive '#{name}', '#{dev}'")
if part_label
assert(part_info.match("^ Name: +#{part_label}$"),
"Unexpected partition label on USB drive '#{name}', '#{dev}'")
end
if part_type
assert(part_info.match("^ Type: +#{part_type}$"),
"Unexpected partition type on USB drive '#{name}', '#{dev}'")
......@@ -453,6 +455,32 @@ def boot_device_type
device_info(boot_device)['ID_BUS']
end
# Turn udisksctl info output into something more manipulable:
def parse_udisksctl_info(input)
tree = {}
section = nil
key = nil
input.chomp.split("\n").each { |line|
case line
when /^\/org\/freedesktop\/UDisks2\/block_devices\//
# no-op, ignore first line = device
when /^ (org\.freedesktop\.UDisks2\..+):$/
section = $1
tree[section] = {}
when /^\s+(.+?):\s+(.+)$/
key = $1
value = $2
tree[section][key] = value
else
# XXX: Best effort = consider this a continuation from previous
# line (e.g. Symlinks), and add the whole line, without
# stripping anything (e.g. leading whitespaces)
tree[section][key] += line
end
}
return tree
end
Then /^Tails is running from (.*) drive "([^"]+)"$/ do |bus, name|
bus = bus.downcase
case bus
......@@ -788,3 +816,83 @@ Then /^I can successfully install the incremental upgrade to version (.+)$/ do |
@screen.wait('TailsUpgraderApplyingUpgrade.png', 20)
@screen.wait('TailsUpgraderDone.png', 60)
end
Then /^the label of the system partition on "([^"]+)" is "([^"]+)"$/ do |name, label|
assert($vm.is_running?)
disk_dev = $vm.disk_dev(name)
part_dev = disk_dev + "1"
check_disk_integrity(name, disk_dev, "gpt")
check_part_integrity(name, part_dev, "filesystem", "vfat", label)
end
Then /^the system partition on "([^"]+)" is an EFI system partition$/ do |name|
assert($vm.is_running?)
disk_dev = $vm.disk_dev(name)
part_dev = disk_dev + "1"
check_disk_integrity(name, disk_dev, "gpt")
check_part_integrity(name, part_dev, "filesystem", "vfat", nil,
# EFI System Partition
'c12a7328-f81f-11d2-ba4b-00a0c93ec93b')
end
Then /^the FAT filesystem on the system partition on "([^"]+)" is at least (\d+)(.+) large$/ do |name, size, unit|
# Let's use bytes all the way:
wanted_size = convert_to_bytes(size.to_i, unit)
disk_dev = $vm.disk_dev(name)
part_dev = disk_dev + "1"
udisks_info = $vm.execute_successfully("udisksctl info --block-device #{part_dev}").stdout
partition_size = parse_udisksctl_info(udisks_info)['org.freedesktop.UDisks2.Partition']['Size'].to_i
# Partition size:
assert(partition_size >= wanted_size,
"FAT partition is too small: #{partition_size} is less than #{wanted_size}")
# -B 1 forces size to be expressed in bytes rather than (1K) blocks:
fs_size = $vm.execute_successfully(
"df --output=size -B 1 '/lib/live/mount/medium'"
).stdout.split("\n")[1].to_i
assert(fs_size >= wanted_size,
"FAT filesystem is too small: #{fs_size} is less than #{wanted_size}")
end
Then /^the UUID of the FAT filesystem on the system partition on "([^"]+)" was randomized$/ do |name|
disk_dev = $vm.disk_dev(name)
part_dev = disk_dev + "1"
# Get the UUID from the block area:
udisks_info = $vm.execute_successfully("udisksctl info --block-device #{part_dev}").stdout
fs_uuid = parse_udisksctl_info(udisks_info)['org.freedesktop.UDisks2.Block']['IdUUID']
static_uuid = 'A690-20D2'
assert(fs_uuid != static_uuid,
"FS UUID on #{name} wasn't randomized, it's still: #{fs_uuid}")
end
Then /^the label of the FAT filesystem on the system partition on "([^"]+)" is "([^"]+)"$/ do |name, label|
disk_dev = $vm.disk_dev(name)
part_dev = disk_dev + "1"
# Get FS label from the block area:
udisks_info = $vm.execute_successfully("udisksctl info --block-device #{part_dev}").stdout
fs_label = parse_udisksctl_info(udisks_info)['org.freedesktop.UDisks2.Block']['IdLabel']
assert(label == fs_label,
"FS label on #{part_dev} is #{fs_label} instead of the expected #{label}")
end
Then /^the system partition on "([^"]+)" has the expected flags$/ do |name|
disk_dev = $vm.disk_dev(name)
part_dev = disk_dev + "1"
# Look at the flags from the partition area:
udisks_info = $vm.execute_successfully("udisksctl info --block-device #{part_dev}").stdout
flags = parse_udisksctl_info(udisks_info)['org.freedesktop.UDisks2.Partition']['Flags']
# See SYSTEM_PARTITION_FLAGS in create-usb-image-from-iso: 0xd000000000000005,
# displayed in decimal (14987979559889010693) in udisksctl's output:
expected_flags = 0xd000000000000005
assert(flags == expected_flags.to_s,
"Got #{flags} as partition flags on #{part_dev} (for #{name}), instead of the expected #{expected_flags}")
end
......@@ -42,7 +42,9 @@ GIT_DIR = ENV['PWD']
KEEP_SNAPSHOTS = !ENV['KEEP_SNAPSHOTS'].nil?
LIVE_USER = cmd_helper(". config/chroot_local-includes/etc/live/config.d/username.conf; echo ${LIVE_USERNAME}").chomp
TAILS_ISO = ENV['TAILS_ISO']
TAILS_IMG = TAILS_ISO.sub(/\.iso/, '.img')
OLD_TAILS_ISO = ENV['OLD_TAILS_ISO'] || TAILS_ISO
OLD_TAILS_IMG = OLD_TAILS_ISO.sub(/\.iso/, '.img')
TIME_AT_START = Time.now
loop do
ARTIFACTS_DIR = $config['TMPDIR'] + "/run-" +
......
......@@ -159,30 +159,36 @@ def add_lan_host(ipaddr, port)
end
BeforeFeature('@product') do |feature|
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.
images = {'ISO' => TAILS_ISO, 'IMG' => TAILS_IMG}
images.each { |type, path|
if path.nil?
raise "No Tails #{type} image specified, and none could be found in the " +
"current directory"
end
if File.exist?(path)
# Workaround: when libvirt takes ownership of the ISO/IMG image it may
# become unreadable for the live user inside the guest in the
# host-to-guest share used for some tests.
if !File.world_readable?(TAILS_ISO)
if File.owned?(TAILS_ISO)
File.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"
if !File.world_readable?(path)
if File.owned?(path)
File.chmod(0644, path)
else
raise "warning: the Tails #{type} 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 #{type} image '#{path}' does not exist"
end
else
raise "The specified Tails ISO image '#{TAILS_ISO}' does not exist"
end
}
if !File.exist?(OLD_TAILS_ISO)
raise "The specified old Tails ISO image '#{OLD_TAILS_ISO}' does not exist"
end
if !File.exist?(OLD_TAILS_IMG)
raise "The specified old Tails IMG image '#{OLD_TAILS_IMG}' does not exist"
end
if not($started_first_product_feature)
$virt = Libvirt::open("qemu:///system")
VM.remove_all_snapshots if !KEEP_SNAPSHOTS
......
......@@ -3,6 +3,9 @@ Feature: Installing Tails to a USB drive
As a Tails user
I want to install Tails to a suitable USB drive
# XXX: rename to tails_installer.feature and move things that don't use Tails
# Installer elsewhere?
Scenario: Try installing Tails to a too small USB drive without partition table
Given I have started Tails from DVD without network and logged in
And I temporarily create a 4500 MiB disk named "too-small-device"
......@@ -53,21 +56,26 @@ Feature: Installing Tails to a USB drive
But there is no persistence partition on USB drive "install"
Scenario: Re-installing Tails over an existing USB installation with a persistent partition
# We reach this first checkpoint only to ensure that the ' __internal' disk has reached the state (Tails installed + persistent partition set up) we need before we clone it below.
# XXX: We reach this first checkpoint only to ensure that the ' __internal' disk has reached the state (Tails installed + persistent partition set up) we need before we clone it below.
# XXX: do this "Given" without Tails Installer
Given I have started Tails without network from a USB drive with a persistent partition enabled and logged in
Given I have started Tails from DVD without network and logged in
And I clone USB drive "__internal" to a temporary USB drive "install"
And I plug USB drive "install"
# XXX: keep doing reinstall with Tails Installer: that's what this scenario
# is about
When I reinstall Tails to USB drive "install" by cloning
Then the running Tails is installed on USB drive "install"
And there is no persistence partition on USB drive "install"
# XXX: do this without Tails Installer
Scenario: Booting Tails from a USB drive without a persistent partition and creating one
Given I have started Tails without network from a USB drive without a persistent partition and stopped at Tails Greeter's login screen
And I log in to a new session
When I create a persistent partition
Then a Tails persistence partition exists on USB drive "__internal"
# XXX: do this without Tails Installer
Scenario: Booting Tails from a USB drive without a persistent partition
Given I have started Tails without network from a USB drive without a persistent partition and stopped at Tails Greeter's login screen
When I log in to a new session
......@@ -75,6 +83,7 @@ Feature: Installing Tails to a USB drive
And the persistent Tor Browser directory does not exist
And there is no persistence partition on USB drive "__internal"
# XXX: do this without Tails Installer
#13459
@fragile
Scenario: Booting Tails from a USB drive in UEFI mode
......@@ -117,3 +126,16 @@ Feature: Installing Tails to a USB drive
Then Tails is running from USB drive "isohybrid"
And the boot device has safe access rights
And there is no persistence partition on USB drive "isohybrid"
Scenario: The system partition is updated when booting from a USB drive where a Tails USB image was copied
Given a computer
And I temporarily create a 7200 MiB disk named "usbimage"
And I write the Tails USB image to disk "usbimage"
And I start Tails from USB drive "usbimage" with network unplugged and I login
Then Tails is running from USB drive "usbimage"
And the label of the system partition on "usbimage" is "Tails"
And the system partition on "usbimage" is an EFI system partition
And the FAT filesystem on the system partition on "usbimage" is at least 4000M large
And the UUID of the FAT filesystem on the system partition on "usbimage" was randomized
And the label of the FAT filesystem on the system partition on "usbimage" is "TAILS"
And the system partition on "usbimage" has the expected flags
......@@ -18,6 +18,7 @@ Feature: Upgrading an old Tails USB installation
When I start Tails Installer
Then I am told by Tails Installer that I "need to use a downloaded Tails ISO image"
# XXX: take a shortcut and write the USB image directly to a USB drive
Scenario: Installing an old version of Tails to a pristine USB drive
Given a computer
And the computer is set to boot from the old Tails DVD
......@@ -79,6 +80,7 @@ Feature: Upgrading an old Tails USB installation
# Depends on scenario: Writing files to a read/write-enabled persistent partition with the old Tails USB installation
Scenario: Upgrading an old Tails USB installation from another Tails USB drive
# XXX: ensure we do this Given without Tails Installer (usb-install-tails-greeter)
Given I have started Tails without network from a USB drive without a persistent partition and stopped at Tails Greeter's login screen
And I log in to a new session
And I clone USB drive "old" to a new USB drive "to_upgrade"
......@@ -99,6 +101,7 @@ Feature: Upgrading an old Tails USB installation
And all persistent directories from the old Tails version have safe access rights
# Depends on scenario: Writing files to a read/write-enabled persistent partition with the old Tails USB installation
# XXX: still documented? if not, drop it.
Scenario: Upgrading an old Tails USB installation from an ISO image, running on the old version
Given a computer
And I clone USB drive "old" to a new USB drive "to_upgrade"
......@@ -110,6 +113,7 @@ Feature: Upgrading an old Tails USB installation
And I unplug USB drive "to_upgrade"
# Depends on scenario: Writing files to a read/write-enabled persistent partition with the old Tails USB installation
# XXX: still documented? if not, drop it.
Scenario: Upgrading an old Tails USB installation from an ISO image, running on the new version
Given I have started Tails from DVD without network and logged in
And I plug and mount a USB drive containing the Tails ISO
......@@ -120,6 +124,7 @@ Feature: Upgrading an old Tails USB installation
And I unplug USB drive "to_upgrade"
# Depends on scenario: Upgrading an old Tails USB installation from an ISO image, running on the new version
# XXX: still documented? if not, drop it.
Scenario: Booting a USB drive upgraded from ISO with persistence enabled
Given a computer
And I start Tails from USB drive "to_upgrade" with network unplugged and I login with persistence enabled
......@@ -130,6 +135,7 @@ Feature: Upgrading an old Tails USB installation
And all persistent directories from the old Tails version have safe access rights
Scenario: Upgrading Tails with Tails Upgrader through an incremental upgrade
# XXX: ensure we do this Given without Tails Installer (usb-install-tails-greeter)
Given I have started Tails without network from a USB drive with a persistent partition enabled and logged in
And Tails is fooled to think it is running version 1.0~test
And the file system changes introduced in version 1.1~test are not present
......
Markdown is supported
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