7 NAME
=$
(basename "${0}")
51 echo "Usage: $NAME [OPTION]... [--] [CUCUMBER_ARGS]...
52 Sets up an appropriate environment and invokes cucumber. Note that this script
53 must be run from the Tails source directory root.
55 Options for '@product' features:
56 --allow-non-root Normally the test suite must be run as root, but if you
57 really know what you are doing this option allows any
59 --artifacts-base-uri URI
60 Pretend that the artifact is located at URI when printing
61 its location during a scenario failure. This is useful if
62 you intend to serve the artifacts via the web, for
64 --capture Captures failed scenarios into videos stored in the
65 temporary directory (see --tmpdir below) using x264
66 encoding. Requires x264.
67 --capture-all Keep videos for all scenarios, including those that
68 succeed (implies --capture).
69 --interactive-debugging
70 On failure, pause test suite until pressing Enter. Also
71 offer the option to open an interactive Ruby shell (pry)
72 in the Cucumber world's context.
74 When any image matching fails, enter an interactive mode
75 that allows to update the image. If run from a graphical
76 environment, any found candidate image will be displayed
78 --keep-chutney Don't ever clean Chutney data directory.
79 This can be a big time saver when debugging steps
80 when --keep-snapshots is not an option.
81 --keep-snapshots Don't ever delete any snapshots (including ones marked as
82 temporary). This can be a big time saver when debugging new
83 features. Implies --keep-chutney.
84 --tmpdir Directory where various temporary files are written
85 during a test, e.g. VM snapshots and memory dumps,
86 failure screenshots, pcap files and disk images
87 (default is TMPDIR in the environment, and if unset,
89 --view Shows the test session in a windows. Requires x11vnc
91 --vnc-server-only Starts a VNC server for the test session. Requires x11vnc.
92 --iso IMAGE Test '@product' features using IMAGE.
93 --old-iso IMAGE For some '@product' features (e.g. usb_install) we need
94 an older version of Tails, which this options sets to
95 IMAGE. If none is given, it defaults to the same IMAGE
96 given by --iso, which will be good enough for most testing
99 Note that '@source' features has no relevant options.
101 CUCUMBER_ARGS can be used to specify which features to be run, but also any
102 cucumber option, although then you must pass \`--\` first to let this wrapper
103 script know that we're done with *its* options. For debugging purposes, a
104 'debug' formatter has been added so pretty debugging can be enabled with
105 \`--format debug\`. You could even combine the default (pretty) formatter with
106 pretty debugging printed to a file with \`--format pretty --format debug
112 echo "${NAME}: error: ${*}" >&2
116 package_installed
() {
119 if dpkg
-s "${1}" 2>/dev
/null |
grep -q "^Status:.*installed"; then
128 check_dependencies
() {
129 while [ -n "${1:-}" ]; do
130 if ! which "${1}" >/dev
/null
&& ! package_installed
"${1}" ; then
131 error
"'${1}' is missing, please install it and run again."
138 [ -e "/tmp/.X${1#:}-lock" ] ||
[ -e "/tmp/.X11-unix/X${1#:}" ]
141 next_free_display
() {
143 while display_in_use
":${display_nr}"; do
144 display_nr
=$
((display_nr
+1))
146 echo ":${display_nr}"
149 test_suite_cleanup
() {
150 if [ -n "${XVFB_PID:-}" ]; then
151 (kill -0 "${XVFB_PID}" 2>/dev
/null
&& kill "${XVFB_PID}") ||
/bin
/true
157 Xvfb
"$TARGET_DISPLAY" -screen 0 1024x768x24
+32 >/dev
/null
2>&1 &
159 # Wait for Xvfb to run on TARGET_DISPLAY
160 until display_in_use
"$TARGET_DISPLAY"; do
163 echo "Virtual X framebuffer started on display ${TARGET_DISPLAY}"
164 # Hide the mouse cursor so it won't be in the way when we are
165 # trying to match images.
166 unclutter
-display "$TARGET_DISPLAY" -root -idle 0.1 >/dev
/null
2>&1 &
170 check_dependencies x11vnc
171 VNC_SERVER_PORT
="$(x11vnc -listen localhost -display "${TARGET_DISPLAY}" \
172 -bg -nopw -forever 2>&1 | \
173 grep -m 1 "^PORT
=[0-9]\
+" | sed 's/^PORT=//')"
174 echo "VNC server running on: localhost:${VNC_SERVER_PORT}"
178 check_dependencies tigervnc-viewer
186 "localhost:${VNC_SERVER_PORT}" 1>/dev
/null
2>&1 &
191 # Unset all environment variables used by this script to pass options
192 # to cucumber, except TMPDIR since we explicitly want to support
193 # setting it that way.
200 INTERACTIVE_DEBUGGING
=
207 LONGOPTS
="allow-non-root,artifacts-base-uri:,view,vnc-server-only,capture,capture-all,help,tmpdir:,keep-chutney,keep-snapshots,iso:,old-iso:,interactive-debugging,image-bumping-mode"
208 OPTS
=$
(getopt
-o "" --longoptions $LONGOPTS -n "${NAME}" -- "$@")
210 while [ $# -gt 0 ]; do
215 --artifacts-base-uri)
217 export ARTIFACTS_BASE_URI
="${1}"
228 check_dependencies x264
232 check_dependencies x264
234 export CAPTURE_ALL
="yes"
236 --interactive-debugging)
237 export INTERACTIVE_DEBUGGING
="yes"
239 --image-bumping-mode)
240 export IMAGE_BUMPING_MODE
="yes"
243 export KEEP_CHUTNEY
="yes"
246 export KEEP_CHUTNEY
="yes"
247 export KEEP_SNAPSHOTS
="yes"
251 export TMPDIR
="$(readlink -f "$1")"
255 export TAILS_ISO
="$(realpath -s "$1")"
259 export OLD_TAILS_ISO
="$(realpath -s "$1")"
273 trap "test_suite_cleanup" EXIT HUP INT QUIT TERM
275 if [ "${EUID}" -ne 0 ] && [ -z "${ALLOW_NON_ROOT}" ]; then
276 error
"you are not running as root; if you really know what you are" \
277 "doing, see the --allow-non-root option"
280 check_dependencies
${GENERAL_DEPENDENCIES}
282 TARGET_DISPLAY
=$
(next_free_display
)
286 if [ -n "${VNC_SERVER:-}" ]; then
289 if [ -n "${VNC_VIEWER:-}" ]; then
294 if [ -n "${JENKINS_URL:-}" ]; then
295 # The current Git state may not reflect the state at the time the
296 # upstream job was started (e.g. since then we git fetch + git
297 # reset --hard) so we trust the Git state described in Jenkins'
298 # environment variables instead.
299 . auto
/scripts
/utils.sh
300 if echo "${GIT_BRANCH}" |
grep -q -E '[+-]force-all-tests$' \
302 ||
[ "${GIT_BRANCH#origin/}" = testing
] \
303 ||
[ "${GIT_BRANCH#origin/}" = feature
/tor-nightly-master
] \
304 ||
[ "${GIT_BRANCH#origin/}" = devel
] ; then
307 TAGS_ARGS
="--tag ~@fragile"
309 if [ "${UPSTREAMJOB_GIT_COMMIT}" != "${UPSTREAMJOB_GIT_BASE_BRANCH_HEAD}" ] && \
310 git_only_doc_changes_since
"${UPSTREAMJOB_GIT_BASE_BRANCH_HEAD}"; then
311 TAGS_ARGS
="${TAGS_ARGS} --tag @doc"
315 export USER_DISPLAY
="${DISPLAY:-}"
316 export DISPLAY
=${TARGET_DISPLAY}
318 cucumber
--expand ${TAGS_ARGS} "${@}"