7
7
TMIN_LOG_FNAME : fuzz.tmin.log # File name to redirect the fuzzing input minimization log to.
8
8
GH_ISSUE_TEMPLATE_RFPATH : .github/ISSUE_TEMPLATE/fuzz_bug_report.md
9
9
# GitHub issue template rel file path.
10
- TARGET_NAME : compile # Fuzzing target name. Fuzzes the `compile` func of the Q# compiler.
11
10
ARTIFACTS_RDPATH : fuzz/artifacts # Fuzzing artifacts rel dir path.
12
11
SEEDS_RDPATH : fuzz/seed_inputs # Fuzzing seed inputs rel dir path.
13
12
SEEDS_FNAME : list.txt # Fuzzing seed inputs list file name.
@@ -31,11 +30,15 @@ jobs:
31
30
fuzz :
32
31
name : Fuzzing
33
32
strategy :
33
+ fail-fast : false
34
34
matrix :
35
35
os : [ubuntu-latest] # Fuzzing is not supported on Win. The macos is temporarily removed
36
36
# because of low availability.
37
- runs-on : ${{ matrix.os }}
37
+ target_name : [qsharp, qasm3]
38
38
39
+ runs-on : ${{ matrix.os }}
40
+ permissions :
41
+ issues : write
39
42
steps :
40
43
- name : Install and Configure Tools
41
44
run : |
@@ -49,29 +52,30 @@ jobs:
49
52
submodules : " true"
50
53
51
54
- name : Gather the Seed Inputs
55
+ if : matrix.target_name == 'qsharp'
52
56
run : |
53
57
cd $OWNER_RDPATH # Enter the dir containing the fuzzing infra.
54
58
55
59
# Clone the submodules of QDK:
56
60
REPOS="Quantum Quantum-NC QuantumKatas QuantumLibraries iqsharp qdk-python qsharp-compiler qsharp-runtime"
57
61
for REPO in $REPOS ; do
58
62
git clone --depth 1 --single-branch --no-tags --recurse-submodules --shallow-submodules --jobs 4 \
59
- https://github.com/microsoft/$REPO.git $SEEDS_RDPATH/$TARGET_NAME /$REPO
63
+ https://github.com/microsoft/$REPO.git $SEEDS_RDPATH/${{ matrix.target_name }} /$REPO
60
64
done
61
65
62
66
# Build a comma-separated list of all the .qs files in $SEEDS_FNAME file:
63
- find $SEEDS_RDPATH/$TARGET_NAME -name "*.qs" | tr "\n" "," > \
64
- $SEEDS_RDPATH/$TARGET_NAME /$SEEDS_FNAME
67
+ find $SEEDS_RDPATH/${{ matrix.target_name }} -name "*.qs" | tr "\n" "," > \
68
+ $SEEDS_RDPATH/${{ matrix.target_name }} /$SEEDS_FNAME
65
69
66
70
- name : Build and Run the Fuzz Target
67
71
run : |
68
72
cd $OWNER_RDPATH # Enter the dir containing the fuzzing infra.
69
- cargo fuzz build --release --sanitizer=none --features do_fuzz $TARGET_NAME # Build the fuzz target.
73
+ cargo fuzz build --release --sanitizer=none --features do_fuzz ${{ matrix.target_name }} # Build the fuzz target.
70
74
71
75
# Run fuzzing for specified number of seconds and redirect the `stderr` to a file
72
76
# whose name is specified by the STDERR_LOG_FNAME env var:
73
- RUST_BACKTRACE=1 cargo fuzz run --release --sanitizer=none --features do_fuzz $TARGET_NAME -- \
74
- -seed_inputs=@$SEEDS_RDPATH/$TARGET_NAME /$SEEDS_FNAME \
77
+ RUST_BACKTRACE=1 cargo fuzz run --release --sanitizer=none --features do_fuzz ${{ matrix.target_name }} -- \
78
+ -seed_inputs=@$SEEDS_RDPATH/${{ matrix.target_name }} /$SEEDS_FNAME \
75
79
-max_total_time=$DURATION_SEC \
76
80
-rss_limit_mb=4096 \
77
81
-max_len=20000 \
@@ -116,33 +120,33 @@ jobs:
116
120
# the subsequent `run:` and `uses:` steps.
117
121
118
122
# Determine the name of a file containing the input of interest (that triggers the panic/crash):
119
- if [ -e $ARTIFACTS_RDPATH/$TARGET_NAME /crash-* ]; then # Panic and Stack Overflow Cases.
123
+ if [ -e $ARTIFACTS_RDPATH/${{ matrix.target_name }} /crash-* ]; then # Panic and Stack Overflow Cases.
120
124
TO_MINIMIZE_FNAME=crash-*;
121
- elif [ -e $ARTIFACTS_RDPATH/$TARGET_NAME /oom-* ]; then # Out-of-Memory Case.
125
+ elif [ -e $ARTIFACTS_RDPATH/${{ matrix.target_name }} /oom-* ]; then # Out-of-Memory Case.
122
126
TO_MINIMIZE_FNAME=oom-*;
123
127
else
124
- echo -e "File to minimize not found.\nContents of artifacts dir \"$ARTIFACTS_RDPATH/$TARGET_NAME /\":"
125
- ls $ARTIFACTS_RDPATH/$TARGET_NAME /
128
+ echo -e "File to minimize not found.\nContents of artifacts dir \"$ARTIFACTS_RDPATH/${{ matrix.target_name }} /\":"
129
+ ls $ARTIFACTS_RDPATH/${{ matrix.target_name }} /
126
130
fi
127
131
128
132
if [ "$TO_MINIMIZE_FNAME" != "" ]; then
129
133
echo "TO_MINIMIZE_FNAME: $TO_MINIMIZE_FNAME"
130
134
131
135
# Minimize the input:
132
- ( cargo fuzz tmin --release --sanitizer=none --features do_fuzz -r 10000 $TARGET_NAME $ARTIFACTS_RDPATH/$TARGET_NAME /$TO_MINIMIZE_FNAME 2>&1 ) > \
136
+ ( cargo fuzz tmin --release --sanitizer=none --features do_fuzz -r 10000 ${{ matrix.target_name }} $ARTIFACTS_RDPATH/${{ matrix.target_name }} /$TO_MINIMIZE_FNAME 2>&1 ) > \
133
137
$TMIN_LOG_FNAME || MINIMIZATION_FAILED=1
134
138
135
139
# Get the minimized input relative faile path:
136
140
if [ "$MINIMIZATION_FAILED" == "1" ]; then
137
141
# Minimization failed, get the latest successful minimized input relative faile path:
138
142
MINIMIZED_INPUT_RFPATH=`
139
143
cat $TMIN_LOG_FNAME | grep "CRASH_MIN: minimizing crash input: " | tail -n 1 |
140
- sed "s|^.*\($ARTIFACTS_RDPATH/$TARGET_NAME /[^\']*\).*|\1|"`
144
+ sed "s|^.*\($ARTIFACTS_RDPATH/${{ matrix.target_name }} /[^\']*\).*|\1|"`
141
145
else
142
146
# Minimization Succeeded, get the reported minimized input relative faile path::
143
147
MINIMIZED_INPUT_RFPATH=`
144
148
cat $TMIN_LOG_FNAME | grep "failed to minimize beyond" |
145
- sed "s|.*\($ARTIFACTS_RDPATH/$TARGET_NAME /[^ ]*\).*|\1|" `
149
+ sed "s|.*\($ARTIFACTS_RDPATH/${{ matrix.target_name }} /[^ ]*\).*|\1|" `
146
150
fi
147
151
echo "MINIMIZED_INPUT_RFPATH: $MINIMIZED_INPUT_RFPATH"
148
152
echo "MINIMIZED_INPUT_RFPATH=$MINIMIZED_INPUT_RFPATH" >> "$GITHUB_ENV"
@@ -187,8 +191,8 @@ jobs:
187
191
path : |
188
192
${{ env.OWNER_RDPATH }}/${{ env.STDERR_LOG_FNAME }}
189
193
${{ env.OWNER_RDPATH }}/${{ env.TMIN_LOG_FNAME }}
190
- ${{ env.OWNER_RDPATH }}/${{ env.ARTIFACTS_RDPATH }}/${{ env.TARGET_NAME }}/*
191
- ${{ env.OWNER_RDPATH }}/${{ env.SEEDS_RDPATH }}/${{ env.TARGET_NAME }}/${{ env.SEEDS_FNAME }}
194
+ ${{ env.OWNER_RDPATH }}/${{ env.ARTIFACTS_RDPATH }}/${{ matrix.target_name }}/*
195
+ ${{ env.OWNER_RDPATH }}/${{ env.SEEDS_RDPATH }}/${{ matrix.target_name }}/${{ env.SEEDS_FNAME }}
192
196
if-no-files-found : error
193
197
194
198
- name : " If Fuzzing Failed: Report GutHub Issue"
0 commit comments