summaryrefslogtreecommitdiffstats
path: root/features
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2016-10-30 07:41:31 +0000
committerintrigeri <intrigeri@boum.org>2016-10-30 07:52:10 +0000
commitd229ebd9ae7c54e8c5f6ac7382caa16e02c3dffd (patch)
treea9747cb220263e4a977a3b62736e97b516be086c /features
parent695dad03f49452d93e4ecea0c6ae4aadbec93b73 (diff)
parent589a4c0352ef4d47c4a88ab89046785aab5c8ba2 (diff)
Merge remote-tracking branch 'origin/test/10777-robust-boot-menu' into stable (fix-committed: #10777)
Diffstat (limited to 'features')
-rw-r--r--features/images/SampleLocalMp4VideoFrame.pngbin14887 -> 50014 bytes
-rw-r--r--features/images/TailsBootMenuKernelCmdline.pngbin0 -> 1629 bytes
-rw-r--r--features/images/TailsBootMenuKernelCmdlineUEFI.pngbin0 -> 2575 bytes
-rw-r--r--features/images/TailsBootSplash.pngbin5964 -> 0 bytes
-rw-r--r--features/images/TailsBootSplashUEFI.pngbin9188 -> 0 bytes
-rw-r--r--features/images/TailsBooting.pngbin0 -> 164 bytes
-rw-r--r--features/images/UEFIFirmwareSetup.pngbin0 -> 172 bytes
-rw-r--r--features/step_definitions/common_steps.rb84
-rw-r--r--features/step_definitions/erase_memory.rb8
-rw-r--r--features/step_definitions/totem.rb2
-rw-r--r--features/support/helpers/vm_helper.rb2
11 files changed, 71 insertions, 25 deletions
diff --git a/features/images/SampleLocalMp4VideoFrame.png b/features/images/SampleLocalMp4VideoFrame.png
index 336c955..df65c3a 100644
--- a/features/images/SampleLocalMp4VideoFrame.png
+++ b/features/images/SampleLocalMp4VideoFrame.png
Binary files differ
diff --git a/features/images/TailsBootMenuKernelCmdline.png b/features/images/TailsBootMenuKernelCmdline.png
new file mode 100644
index 0000000..efc5d89
--- /dev/null
+++ b/features/images/TailsBootMenuKernelCmdline.png
Binary files differ
diff --git a/features/images/TailsBootMenuKernelCmdlineUEFI.png b/features/images/TailsBootMenuKernelCmdlineUEFI.png
new file mode 100644
index 0000000..0a00fde
--- /dev/null
+++ b/features/images/TailsBootMenuKernelCmdlineUEFI.png
Binary files differ
diff --git a/features/images/TailsBootSplash.png b/features/images/TailsBootSplash.png
deleted file mode 100644
index 2bed76d..0000000
--- a/features/images/TailsBootSplash.png
+++ /dev/null
Binary files differ
diff --git a/features/images/TailsBootSplashUEFI.png b/features/images/TailsBootSplashUEFI.png
deleted file mode 100644
index 445f6dc..0000000
--- a/features/images/TailsBootSplashUEFI.png
+++ /dev/null
Binary files differ
diff --git a/features/images/TailsBooting.png b/features/images/TailsBooting.png
new file mode 100644
index 0000000..8a7a77b
--- /dev/null
+++ b/features/images/TailsBooting.png
Binary files differ
diff --git a/features/images/UEFIFirmwareSetup.png b/features/images/UEFIFirmwareSetup.png
new file mode 100644
index 0000000..368857d
--- /dev/null
+++ b/features/images/UEFIFirmwareSetup.png
Binary files differ
diff --git a/features/step_definitions/common_steps.rb b/features/step_definitions/common_steps.rb
index 98947e7..798aee6 100644
--- a/features/step_definitions/common_steps.rb
+++ b/features/step_definitions/common_steps.rb
@@ -257,16 +257,16 @@ When /^I destroy the computer$/ do
$vm.destroy_and_undefine
end
-def bootsplash
+def boot_menu_cmdline_image
case @os_loader
when "UEFI"
- 'TailsBootSplashUEFI.png'
+ 'TailsBootMenuKernelCmdlineUEFI.png'
else
- 'TailsBootSplash.png'
+ 'TailsBootMenuKernelCmdline.png'
end
end
-def bootsplash_tab_msg
+def boot_menu_tab_msg_image
case @os_loader
when "UEFI"
'TailsBootSplashTabMsgUEFI.png'
@@ -275,17 +275,70 @@ def bootsplash_tab_msg
end
end
-Given /^the computer (re)?boots Tails$/ do |reboot|
+def memory_wipe_timeout
+ nr_gigs_of_ram = convert_from_bytes($vm.get_ram_size_in_bytes, 'GiB').ceil
+ nr_gigs_of_ram*30
+end
- boot_timeout = 30
+Given /^Tails is at the boot menu's cmdline( after rebooting)?$/ do |reboot|
+ boot_timeout = 3*60
# We need some extra time for memory wiping if rebooting
- boot_timeout += 90 if reboot
-
- @screen.wait(bootsplash, boot_timeout)
- @screen.wait(bootsplash_tab_msg, 10)
- @screen.type(Sikuli::Key.TAB)
- @screen.waitVanish(bootsplash_tab_msg, 1)
+ boot_timeout += memory_wipe_timeout if reboot
+ # Simply looking for the boot splash image is not robust; sometimes
+ # sikuli is not fast enough to see it. Here we hope that spamming
+ # TAB, which will halt the boot process by showing the prompt for
+ # the kernel cmdline, will make this a bit more robust. We want this
+ # spamming to happen in parallel with Sikuli waiting for the image,
+ # but multi-threading etc is working extremely poor in our Ruby +
+ # jrb environment when Sikuli is involved. Hence we run the spamming
+ # from a separate process.
+ tab_spammer_code = <<-EOF
+ require 'libvirt'
+ tab_key_code = 0xf
+ virt = Libvirt::open("qemu:///system")
+ begin
+ domain = virt.lookup_domain_by_name('#{$vm.domain_name}')
+ loop do
+ domain.send_key(Libvirt::Domain::KEYCODE_SET_LINUX, 0, [tab_key_code])
+ sleep 0.1
+ end
+ ensure
+ virt.close
+ end
+ EOF
+ # Our UEFI firmware (OVMF) has the interesting "feature" that pressing
+ # any button will open its setup menu, so we have to exit the setup,
+ # and to not have the TAB spammer potentially interfering we pause
+ # it meanwhile.
+ dealt_with_uefi_setup = false
+ # The below code is not completely reliable, so we might have to
+ # retry by rebooting.
+ try_for(boot_timeout) do
+ begin
+ tab_spammer = IO.popen(['ruby', '-e', tab_spammer_code])
+ if not(dealt_with_uefi_setup) && @os_loader == 'UEFI'
+ @screen.wait('UEFIFirmwareSetup.png', 30)
+ Process.kill("TSTP", tab_spammer.pid)
+ @screen.type(Sikuli::Key.ENTER)
+ Process.kill("CONT", tab_spammer.pid)
+ dealt_with_uefi_setup = true
+ end
+ @screen.wait(boot_menu_cmdline_image, 15)
+ rescue FindFailed => e
+ debug_log('We missed the boot menu before we could deal with it, ' +
+ 'resetting...')
+ dealt_with_uefi_setup = false
+ $vm.reset
+ retry
+ ensure
+ Process.kill("TERM", tab_spammer.pid)
+ tab_spammer.close
+ end
+ end
+end
+Given /^the computer (re)?boots Tails$/ do |reboot|
+ step "Tails is at the boot menu's cmdline" + (reboot ? ' after rebooting' : '')
@screen.type(" autotest_never_use_this_option blacklist=psmouse #{@boot_options}" +
Sikuli::Key.ENTER)
@screen.wait('TailsGreeter.png', 5*60)
@@ -523,16 +576,13 @@ Given /^I kill the process "([^"]+)"$/ do |process|
end
Then /^Tails eventually shuts down$/ do
- nr_gibs_of_ram = convert_from_bytes($vm.get_ram_size_in_bytes, 'GiB').ceil
- timeout = nr_gibs_of_ram*5*60
- try_for(timeout, :msg => "VM is still running after #{timeout} seconds") do
+ try_for(memory_wipe_timeout, :msg => "VM is still running") do
! $vm.is_running?
end
end
Then /^Tails eventually restarts$/ do
- nr_gibs_of_ram = convert_from_bytes($vm.get_ram_size_in_bytes, 'GiB').ceil
- @screen.wait('TailsBootSplash.png', nr_gibs_of_ram*5*60)
+ step 'the computer reboots Tails'
end
Given /^I shutdown Tails and wait for the computer to power off$/ do
diff --git a/features/step_definitions/erase_memory.rb b/features/step_definitions/erase_memory.rb
index d96bdab..246a245 100644
--- a/features/step_definitions/erase_memory.rb
+++ b/features/step_definitions/erase_memory.rb
@@ -200,16 +200,12 @@ When /^I reboot without wiping the memory$/ do
end
When /^I stop the boot at the bootloader menu$/ do
- @screen.wait(bootsplash, 90)
- @screen.wait(bootsplash_tab_msg, 10)
- @screen.type(Sikuli::Key.TAB)
- @screen.waitVanish(bootsplash_tab_msg, 1)
+ step "Tails is at the boot menu's cmdline"
end
When /^I shutdown and wait for Tails to finish wiping the memory$/ do
$vm.spawn("halt")
- nr_gibs_of_ram = convert_from_bytes($vm.get_ram_size_in_bytes, 'GiB').ceil
- try_for(nr_gibs_of_ram*5*60, { :msg => "memory wipe didn't finish, probably the VM crashed" }) do
+ try_for(memory_wipe_timeout, { :msg => "memory wipe didn't finish, probably the VM crashed" }) do
# We spam keypresses to prevent console blanking from hiding the
# image we're waiting for
@screen.type(" ")
diff --git a/features/step_definitions/totem.rb b/features/step_definitions/totem.rb
index 7b45b2e..520e7d6 100644
--- a/features/step_definitions/totem.rb
+++ b/features/step_definitions/totem.rb
@@ -4,7 +4,7 @@ Given /^I create sample videos$/ do
FileUtils.mkdir_p(@shared_video_dir_on_host)
add_after_scenario_hook { FileUtils.rm_r(@shared_video_dir_on_host) }
fatal_system("avconv -loop 1 -t 30 -f image2 " +
- "-i 'features/images/TailsBootSplash.png' " +
+ "-i 'features/images/USBTailsLogo.png' " +
"-an -vcodec libx264 -y " +
'-filter:v "crop=in_w-mod(in_w\,2):in_h-mod(in_h\,2)" ' +
"'#{@shared_video_dir_on_host}/video.mp4' >/dev/null 2>&1")
diff --git a/features/support/helpers/vm_helper.rb b/features/support/helpers/vm_helper.rb
index 66b2736..04cf7bc 100644
--- a/features/support/helpers/vm_helper.rb
+++ b/features/support/helpers/vm_helper.rb
@@ -63,7 +63,7 @@ end
class VM
- attr_reader :domain, :display, :vmnet, :storage
+ attr_reader :domain, :domain_name, :display, :vmnet, :storage
def initialize(virt, xml_path, vmnet, storage, x_display)
@virt = virt