Commit 1a749b0a authored by intrigeri's avatar intrigeri
Browse files

Merge remote-tracking branch 'origin/test/10148-capture-per-scenario-videos' into stable

Fix-committed: #10148, #10001
parents 4ddbc9da 863204b0
CAPTURE: false
CAPTURE_ALL: false
PAUSE_ON_FAIL: false
SIKULI_RETRY_FINDFAILED: false
MAX_NEW_TOR_CIRCUIT_RETRIES: 5
......
......@@ -111,8 +111,27 @@ AfterFeature('@product') do
end
# BeforeScenario
Before('@product') do
Before('@product') do |scenario|
@screen = Sikuli::Screen.new
if $config["CAPTURE"]
video_name = "capture-" + "#{scenario.name}-#{TIME_AT_START}.mkv"
# Sanitize the filename from unix-hostile filename characters
bad_filename_chars = Regexp.new("[^A-Za-z0-9_\\-.,+:]")
video_name.gsub!(bad_filename_chars, '_')
@video_path = "#{$config['TMPDIR']}/#{video_name}"
capture = IO.popen(['avconv',
'-f', 'x11grab',
'-s', '1024x768',
'-r', '15',
'-i', "#{$config['DISPLAY']}.0",
'-an',
'-c:v', 'libx264',
'-y',
@video_path,
:err => ['/dev/null', 'w'],
])
@video_capture_pid = capture.pid
end
if File.size?($background_snapshot)
@skip_steps_while_restoring_background = true
else
......@@ -126,6 +145,14 @@ end
# AfterScenario
After('@product') do |scenario|
if @video_capture_pid
# We can be incredibly fast at detecting errors sometimes, so the
# screen barely "settles" when we end up here and kill the video
# capture. Let's wait a few seconds more to make it easier to see
# what the error was.
sleep 3 if scenario.failed?
Process.kill("INT", @video_capture_pid)
end
if scenario.failed?
time_of_fail = Time.now - TIME_AT_START
secs = "%02d" % (time_of_fail % 60)
......@@ -142,6 +169,10 @@ After('@product') do |scenario|
STDERR.puts "Press ENTER to continue running the test suite"
STDIN.gets
end
else
if @video_path && File.exist?(@video_path) && not($config['CAPTURE_ALL'])
FileUtils.rm(@video_path)
end
end
@vm.destroy_and_undefine if @vm
end
......
......@@ -51,8 +51,13 @@ Sets up an appropriate environment and invokes cucumber. Note that this script
must be run from the Tails source directory root.
Options for '@product' features:
--capture FILE Captures the test session into FILE using VP8 encoding.
Requires libvpx1.
--capture Captures failed scenarios into videos stored in the
temporary directory (see --tmpdir below) using x264
encoding. Requires x264.
--capture-all Keep videos for all scenarios, including those that
succeed (implies --capture).
--debug Display various debugging information while running the
test suite.
--pause-on-fail On failure, pause test suite until pressing Enter. This is
useful for investigating the state of the VM guest to see
exactly why a test failed.
......@@ -79,12 +84,12 @@ Options for '@product' features:
Note that '@source' features has no relevant options.
CUCUMBER_ARGS can be used to specify which features to be run, but also any
cucumber option, although then you must pass `--` first to let this wrapper
cucumber option, although then you must pass \`--\` first to let this wrapper
script know that we're done with *its* options. For debugging purposes, a
'debug' formatter has been added so pretty debugging can be enabled with
`--format debug`. You could even combine the default (pretty) formatter with
pretty debugging printed to a file with `--format pretty --format debug
--out debug.log`.
\`--format debug\`. You could even combine the default (pretty) formatter with
pretty debugging printed to a file with \`--format pretty --format debug
--out debug.log\`.
"
}
......@@ -168,7 +173,8 @@ capture_session() {
# Unset all environment variables used by this script to pass options
# to cucumber, except TMPDIR since we explicitly want to support
# setting it that way.
CAPTURE_FILE=
CAPTURE=
CAPTURE_ALL=
LOG_FILE=
VNC_VIEWER=
VNC_SERVER=
......@@ -178,7 +184,7 @@ SIKULI_RETRY_FINDFAILED=
TAILS_ISO=
OLD_TAILS_ISO=
LONGOPTS="view,vnc-server-only,capture:,help,tmpdir:,keep-snapshots,retry-find,iso:,old-iso:,pause-on-fail"
LONGOPTS="view,vnc-server-only,capture,capture-all,help,tmpdir:,keep-snapshots,retry-find,iso:,old-iso:,pause-on-fail"
OPTS=$(getopt -o "" --longoptions $LONGOPTS -n "${NAME}" -- "$@")
eval set -- "$OPTS"
while [ $# -gt 0 ]; do
......@@ -192,8 +198,13 @@ while [ $# -gt 0 ]; do
VNC_SERVER=yes
;;
--capture)
shift
CAPTURE_FILE="$1"
check_dependencies x264
export CAPTURE="yes"
;;
--capture-all)
check_dependencies x264
export CAPTURE="yes"
export CAPTURE_ALL="yes"
;;
--pause-on-fail)
export PAUSE_ON_FAIL="yes"
......@@ -236,9 +247,6 @@ TARGET_DISPLAY=$(next_free_display)
start_xvfb
if [ -n "${CAPTURE_FILE}" ]; then
capture_session
fi
if [ -n "${VNC_SERVER}" ]; then
start_vnc_server
fi
......
......@@ -83,6 +83,13 @@ can be use by concurrent test suite runs):
Here's a list of all non-secret key-value pairs that can be supported
by the local configuration file:
* `CAPTURE`: Captures failed scenarios into videos stored in the
temporary directory (see `TMPDIR` below) using x264
encoding. Defaults to `false`.
* `CAPTURE_ALL`: Keep videos for all scenarios, including those that
succeed (implies `CAPTURE`). Defaults to `false`.
* `MAX_NEW_TOR_CIRCUIT_RETRIES`: Integer. Upon failure, some test steps may be
run again after requesting that connections are made using new Tor circuits. This
configuration variable limits how many times forcing a circuit will be
......@@ -98,7 +105,7 @@ by the local configuration file:
after pressing ENTER. This is useful for updating outdated images,
or when extracting new images. Defaults to `false`.
* `TEMP_DIR`: String value. Directory where various temporary files
* `TMPDIR`: String value. Directory where various temporary files
are written during a test, e.g. VM snapshots and memory dumps,
failure screenshots, pcap files and disk images. Defaults to
`"/tmp/TailsToaster"`.
......
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