-
Notifications
You must be signed in to change notification settings - Fork 2
/
wpt-check
executable file
·100 lines (87 loc) · 2.64 KB
/
wpt-check
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env bash
set -euo pipefail
WPTCHECK_ROOT="$(dirname "$(realpath $0)")"
REGISTRY=ghcr.io/secpriv
RUNNER="${REGISTRY}/wpt-runner:latest"
TRACEMATCHING="${REGISTRY}/wpt-trace-matching:latest"
print_usage () {
echo "Usage: $0 [ -h | -l FOLDER | -t TIMEOUT ] ( pull | build | clean | run BROWSER TEST| verify JSON-TRACE )"
}
docker info &> /dev/null || {
echo "Error connecting to docker daemon. Make sure your user has the correct permissions, e.g., is part of the 'docker' group."
exit 1
}
tmpfile=$(mktemp -d)
time=$(date +%s.%N)
trap "rm -fr \"${tmpfile}\"" EXIT
TIMEOUT="600"
CONTAINER_NAME_OVERRIDE=""
run () {
local browser=$1
local test=$2
local name="wpt-runner-${browser}-${time}"
if [ ! -z $CONTAINER_NAME_OVERRIDE ]; then
name="${CONTAINER_NAME_OVERRIDE}"
fi
docker run --stop-timeout "${TIMEOUT}" --name "${name}" --rm -ti -v "${tmpfile}:/home/test/Downloads/" "${RUNNER}" "${browser}" "${test}" || true
}
verify () {
local json="$(ls "$tmpfile" | head -n1)"
local name="z3-${time}"
if [ ! -z $CONTAINER_NAME_OVERRIDE ]; then
name="${CONTAINER_NAME_OVERRIDE}"
fi
docker run --name "parse-trace-${time}" --rm -i -v "${tmpfile}:/mnt" "${TRACEMATCHING}" parse_trace "$json" | \
docker run --name "${name}" --rm -i "${TRACEMATCHING}" z3_wrapper -t "${TIMEOUT}"
}
if [[ $# -gt 0 ]]; then
while getopts ":n:t:l:h" ARG; do
case "$ARG" in
n)
CONTAINER_NAME_OVERRIDE="${OPTARG}"
;;
t)
TIMEOUT="${OPTARG}"
;;
l)
docker run --name "list-tests-${time}" --rm -ti "${RUNNER}" list-tests "${OPTARG}"
exit 0
;;
h)
print_usage; exit 0
;;
?)
echo "Invalid option: ${OPTARG}"
;;
esac
done
shift "$((OPTIND - 1))"
case $1 in
pull) make pull "REGISTRY=${REGISTRY}" ;;
build) make build "REGISTRY=${REGISTRY}" ;;
clean) make clean "REGISTRY=${REGISTRY}" ;;
run)
shift
[[ $# -eq 2 ]] || {
echo "Please specify a browser and a test!"
print_usage; exit 1
}
run "$@"
verify
;;
verify)
shift
[[ $# -eq 1 ]] || {
echo "Please specify a json file"
print_usage; exit 1
}
cp "$1" "${tmpfile}"
verify
;;
*)
echo 'Unknown command!'
print_usage; exit 1
esac
else
print_usage
fi