forked from TokTok/qTox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmoke-test.sh
executable file
·60 lines (46 loc) · 1.79 KB
/
smoke-test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env bash
set -eux -o pipefail
# Release tags *or* master builds where the current commit is tagged
# with 'v.*' are considered stable.
if [ -n "$(echo "${GITHUB_REF:-}" | grep -o 'refs/tags/v.*')" ] ||
[ -n "$(git tag --points-at HEAD | grep '^v.*')" ]; then
REGEX="qTox v.* (stable)"
else
REGEX="qTox v.* (unstable)"
fi
if [ -n "${GITHUB_TOKEN:-}" ]; then
GITHUB_AUTH=(-H "Authorization: token $GITHUB_TOKEN")
else
GITHUB_AUTH=()
fi
VERSION=$(curl \
-H "Accept: application/vnd.github+json" \
"${GITHUB_AUTH[@]}" \
-L \
https://api.github.com/repos/TokTok/qTox/releases/latest |
grep '"tag_name": "v.*"' |
grep -o 'v[^"]*')
"$@" --version | grep "$REGEX" || ("$@" --version && false)
"$@" --update-check | grep "^Latest version: $VERSION" || ("$@" --update-check && false)
# If QTOX_SCREENSHOT isn't set, don't take a screenshot.
if [ -z "${QTOX_SCREENSHOT:-}" ]; then
exit 0
fi
# Otherwise, run the application, wait 10 seconds for it to start up, then send
# SIGUSR1 to take a screenshot.
set -m # Enable job control.
mkdir -p "$HOME/Pictures" # For the screenshot.
"$@" --portable "$PWD/test/resources/profile" --profile "qtox-test-user" 2>&1 | tee qtox.log &
sleep 10
# We need to get the real PID of the qtox process, which is a descendant of %1.
# %1 may be xvfb-run, wrapping bash, running AppRun, wrapping musl's ld.so.
QTOX_PID="$(grep -o ' : Debug: Process ID: [0-9]*' qtox.log | grep -o '[0-9]*')"
kill -USR1 "$QTOX_PID"
# Wait for another second to make sure the screenshot is taken.
sleep 1
# Kill the application with SIGINT.
kill -INT "$QTOX_PID"
# Wait for the application to exit gracefully. We use pgrep above, in case qtox
# is running inside xvfb-run. We use %1 here for job control (the & above).
fg %1
mv "$HOME/Pictures/$QTOX_SCREENSHOT" "$QTOX_SCREENSHOT"