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.
34
33
matrix :
35
34
os : [ubuntu-latest] # Fuzzing is not supported on Win. The macos is temporarily removed
36
35
# because of low availability.
36
+ target_name : [qsharp, qasm3]
37
+
37
38
runs-on : ${{ matrix.os }}
38
39
39
40
steps :
@@ -49,29 +50,30 @@ jobs:
49
50
submodules : " true"
50
51
51
52
- name : Gather the Seed Inputs
53
+ if : matrix.target_name == 'qsharp'
52
54
run : |
53
55
cd $OWNER_RDPATH # Enter the dir containing the fuzzing infra.
54
56
55
57
# Clone the submodules of QDK:
56
58
REPOS="Quantum Quantum-NC QuantumKatas QuantumLibraries iqsharp qdk-python qsharp-compiler qsharp-runtime"
57
59
for REPO in $REPOS ; do
58
60
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
61
+ https://github.com/microsoft/$REPO.git $SEEDS_RDPATH/${{ matrix.target_name }} /$REPO
60
62
done
61
63
62
64
# 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
65
+ find $SEEDS_RDPATH/${{ matrix.target_name }} -name "*.qs" | tr "\n" "," > \
66
+ $SEEDS_RDPATH/${{ matrix.target_name }} /$SEEDS_FNAME
65
67
66
68
- name : Build and Run the Fuzz Target
67
69
run : |
68
70
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.
71
+ cargo fuzz build --release --sanitizer=none --features do_fuzz ${{ matrix.target_name }} # Build the fuzz target.
70
72
71
73
# Run fuzzing for specified number of seconds and redirect the `stderr` to a file
72
74
# 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 \
75
+ RUST_BACKTRACE=1 cargo fuzz run --release --sanitizer=none --features do_fuzz ${{ matrix.target_name }} -- \
76
+ -seed_inputs=@$SEEDS_RDPATH/${{ matrix.target_name }} /$SEEDS_FNAME \
75
77
-max_total_time=$DURATION_SEC \
76
78
-rss_limit_mb=4096 \
77
79
-max_len=20000 \
@@ -116,33 +118,33 @@ jobs:
116
118
# the subsequent `run:` and `uses:` steps.
117
119
118
120
# 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.
121
+ if [ -e $ARTIFACTS_RDPATH/${{ matrix.target_name }} /crash-* ]; then # Panic and Stack Overflow Cases.
120
122
TO_MINIMIZE_FNAME=crash-*;
121
- elif [ -e $ARTIFACTS_RDPATH/$TARGET_NAME /oom-* ]; then # Out-of-Memory Case.
123
+ elif [ -e $ARTIFACTS_RDPATH/${{ matrix.target_name }} /oom-* ]; then # Out-of-Memory Case.
122
124
TO_MINIMIZE_FNAME=oom-*;
123
125
else
124
- echo -e "File to minimize not found.\nContents of artifacts dir \"$ARTIFACTS_RDPATH/$TARGET_NAME /\":"
125
- ls $ARTIFACTS_RDPATH/$TARGET_NAME /
126
+ echo -e "File to minimize not found.\nContents of artifacts dir \"$ARTIFACTS_RDPATH/${{ matrix.target_name }} /\":"
127
+ ls $ARTIFACTS_RDPATH/${{ matrix.target_name }} /
126
128
fi
127
129
128
130
if [ "$TO_MINIMIZE_FNAME" != "" ]; then
129
131
echo "TO_MINIMIZE_FNAME: $TO_MINIMIZE_FNAME"
130
132
131
133
# 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 ) > \
134
+ ( 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
135
$TMIN_LOG_FNAME || MINIMIZATION_FAILED=1
134
136
135
137
# Get the minimized input relative faile path:
136
138
if [ "$MINIMIZATION_FAILED" == "1" ]; then
137
139
# Minimization failed, get the latest successful minimized input relative faile path:
138
140
MINIMIZED_INPUT_RFPATH=`
139
141
cat $TMIN_LOG_FNAME | grep "CRASH_MIN: minimizing crash input: " | tail -n 1 |
140
- sed "s|^.*\($ARTIFACTS_RDPATH/$TARGET_NAME /[^\']*\).*|\1|"`
142
+ sed "s|^.*\($ARTIFACTS_RDPATH/${{ matrix.target_name }} /[^\']*\).*|\1|"`
141
143
else
142
144
# Minimization Succeeded, get the reported minimized input relative faile path::
143
145
MINIMIZED_INPUT_RFPATH=`
144
146
cat $TMIN_LOG_FNAME | grep "failed to minimize beyond" |
145
- sed "s|.*\($ARTIFACTS_RDPATH/$TARGET_NAME /[^ ]*\).*|\1|" `
147
+ sed "s|.*\($ARTIFACTS_RDPATH/${{ matrix.target_name }} /[^ ]*\).*|\1|" `
146
148
fi
147
149
echo "MINIMIZED_INPUT_RFPATH: $MINIMIZED_INPUT_RFPATH"
148
150
echo "MINIMIZED_INPUT_RFPATH=$MINIMIZED_INPUT_RFPATH" >> "$GITHUB_ENV"
@@ -187,8 +189,8 @@ jobs:
187
189
path : |
188
190
${{ env.OWNER_RDPATH }}/${{ env.STDERR_LOG_FNAME }}
189
191
${{ 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 }}
192
+ ${{ env.OWNER_RDPATH }}/${{ env.ARTIFACTS_RDPATH }}/${{ matrix.target_name }}/*
193
+ ${{ env.OWNER_RDPATH }}/${{ env.SEEDS_RDPATH }}/${{ matrix.target_name }}/${{ env.SEEDS_FNAME }}
192
194
if-no-files-found : error
193
195
194
196
- name : " If Fuzzing Failed: Report GutHub Issue"
0 commit comments