-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbisect
More file actions
executable file
·105 lines (79 loc) · 2.52 KB
/
bisect
File metadata and controls
executable file
·105 lines (79 loc) · 2.52 KB
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
101
102
103
104
105
#!/usr/bin/env bash
# Copyright (c) 2020 Matt Windsor and contributors
#
# This file is part of c4-scripts.
# Licenced under the MIT licence; see `LICENSE`.
# Frontend for act's trace bisection. Remembers all the arguments so you
# don't have to.
set -euo pipefail
SCRIPTDIR="${SCRIPTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"}"
readonly SCRIPTDIR
# shellcheck source=act_bash/args.sh
source "${SCRIPTDIR}/act_bash/args.sh"
# shellcheck source=act_bash/exec.sh
source "${SCRIPTDIR}/act_bash/exec.sh"
# shellcheck source=act_bash/log.sh
source "${SCRIPTDIR}/act_bash/log.sh"
# shellcheck source=act_bash/naming.sh
source "${SCRIPTDIR}/act_bash/naming.sh"
## Arguments ##
# Whether or not we're running ACT programs through `dune exec`.
DUNE_EXEC="false"
# The name of the output directory.
# If empty, we use a temporary directory.
OUTPUT_DIR=""
# The ID of the machine to run.
MACHINE="localhost"
# The ID of the compiler to run.
COMPILER="gcc"
# The opt of the compiler to run.
OPT=""
# The mopt of the compiler to run.
MOPT=""
# Whether or not verbose logging is enabled.
VERBOSE="false"
## Functions ##
# Prints the script's usage and exits.
usage() {
echo "usage: $0 [-d DIR] [-m MACHINE] [-c COMPILER] [-O OPT] [-M OPT] [-${ACT_STANDARD_FLAGS}] TRACE BASE" >&2
echo
echo "-d: directory to use for outputting intermediate files"
echo "-m: ID of machine to use"
echo "-c: ID of compiler to use"
echo "-O: optimisation level to use"
echo "-M: machine optimisation profile to use"
act::standard_usage
exit 1
}
# The main function.
main() {
while getopts "d:m:c:O:M:qvx?h" a; do
case "${a}" in
d) OUTPUT_DIR="${OPTARG}" ;;
m) MACHINE="${OPTARG}" ;;
c) COMPILER="${OPTARG}" ;;
O) OPT="${OPTARG}" ;;
M) MOPT="${OPTARG}" ;;
*) act::parse_standard_args "${a}" "${OPTARG:-}" ;;
esac
done
# VERBOSE etc. are used indirectly by various library functions.
# shellcheck disable=SC2034
readonly VERBOSE FUZZ MACHINE
shift $((OPTIND-1))
if [[ $# -ne 2 ]]; then act::arg_error "need two file arguments"; fi
local trace="$1"
local base="$2"
local out_trace="$(basename trace).mini"
local out_litmus="${out_trace}.litmus"
act::fuzz bisect \
-command "${SCRIPTDIR}/bisect_oracle" \
-o "${out_trace}" \
"${trace}" -- "${base}" \
"${SCRIPTDIR}/bisect_driver" \
"$(act::flags_qvx)" \
-m "${MACHINE}" -c "${COMPILER}" -O "${OPT}" -M "${MOPT}"
act::fuzz replay -o "${out_litmus}" -trace "${out_trace}" "${base}"
diff -u "${base}" "${out_litmus}"
}
main "$@"