-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelitmus_many
executable file
·99 lines (74 loc) · 2.18 KB
/
delitmus_many
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
#!/usr/bin/env bash
# Runs the ACT fuzzer delitmusifier times on each of a set of C litmus tests,
# outputting the results into a directory.
#
# For usage information, scroll down to the `usage` function.
# TODO(@MattWindsor91): support -no-qualify-locals
# TODO(@MattWindsor91): support -style
set -euo pipefail
SCRIPTDIR="${SCRIPTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"}"
readonly SCRIPTDIR
# shellcheck source=scripts/act_bash/exec.sh
source "${SCRIPTDIR}/act_bash/exec.sh"
# shellcheck source=scripts/act_bash/log.sh
source "${SCRIPTDIR}/act_bash/log.sh"
# shellcheck source=scripts/act_bash/naming.sh
source "${SCRIPTDIR}/act_bash/naming.sh"
## Arguments ##
# The name to give to the fuzzing output directory.
DIR_NAME="delitmus"
# Whether or not we're running ACT programs through `dune exec`.
DUNE_EXEC="false"
# Whether or not verbose logging is enabled.
VERBOSE="false"
# Runs the delitmusifier on a litmus test, outputting the
# results to a directory with systematic naming.
#
# Globals:
# C4F_C: read
#
# Arguments:
# 1: fuzzer output directory
# 2: name of file to mutate
# 3: count
delitmus_file() {
local dir_name="${1}"
local in_file="${2}"
act::log "Delitmusifying %s..." "${in_file}"
local out_file
out_file="${dir_name}/$(basename "${in_file}" .litmus).c"
act::delitmus "${in_file}" -o "${out_file}"
act::log " done.\n"
}
# Prints usage information.
usage() {
echo "Usage: $0 [-d DIR_NAME] [-${ACT_STANDARD_FLAGS}] INFILES..."
echo
echo "-d: override autogenerated directory name"
act::standard_usage
exit 1
}
# The main function.
#
# Globals:
# DIR_NAME: read, write, set-readonly
# DUNE_EXEC: read, write, set-readonly
# VERBOSE: read, write, set-readonly
main() {
while getopts "c:d:ftqvx?h" a; do
case ${a} in
d) DIR_NAME=${OPTARG} ;;
*) act::parse_standard_args "${a}" "${OPTARG:-}" ;;
esac
done
readonly VERBOSE DUNE_EXEC
shift $((OPTIND-1))
if [[ $# -lt 1 ]]; then act::arg_error "need at least one file argument"; fi
mkdir -p "${DIR_NAME}"
act::log "Outputting delitmus to %s.\n" "${DIR_NAME}"
for file in "${@}"; do
delitmus_file "${DIR_NAME}" "${file}"
done
}
## Entry point. ##
main "${@}"