Skip to content

Commit

Permalink
Enable seeding corpus
Browse files Browse the repository at this point in the history
  • Loading branch information
eustas committed Aug 2, 2021
1 parent bcac67e commit 9b1488e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/conformance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ jobs:
run: |
mkdir -p ${RUNNER_TEMP}/conformance-corpus
cd ${RUNNER_TEMP}
echo "git clone --branch conformance-corpus --depth=1 https://github.com/eustas/nopb-worker.git"
echo "unzip nopb-worker/corpus.zip -d ${RUNNER_TEMP}/conformance-corpus"
git clone --branch conformance-corpus --depth=1 https://github.com/eustas/nopb-worker.git
unzip nopb-worker/corpus.zip -d ${RUNNER_TEMP}/conformance-corpus
cd ${GITHUB_WORKSPACE}/conformance
bazel run --config=jazzer //:ConformanceChecker_run -- \
--timeout_secs=3600 \
--timeout_secs=600 \
--fuzzing_output_root=${RUNNER_TEMP}/new-corpus \
--corpus_dir=${RUNNER_TEMP}/conformance-corpus
Expand Down
11 changes: 7 additions & 4 deletions conformance/ConformanceChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
import java.util.Random;

public class ConformanceChecker {

private static final String ROUNDTRIP_FAILURE = "Deserialized object does not match original one";

public static void fuzzerTestOneInput(byte[] data) throws IOException {
if (data.length == 0)
return;
Expand Down Expand Up @@ -86,11 +89,11 @@ static void checkRequest(ByteBuffer input) throws IOException {
if ((deserialized.requestId != orig.getRequestId()) ||
(deserialized.cancel != orig.getCancel()) ||
!Arrays.deepEquals(deserialized.arguments.toArray(), orig.getArgumentsList().toArray())) {
throw new RuntimeException("Deserilized object does not match original one");
throw new RuntimeException(ROUNDTRIP_FAILURE);
}

if (deserialized.inputs.size() != orig.getInputsList().size()) {
throw new RuntimeException("Deserilized object does not match original one");
throw new RuntimeException(ROUNDTRIP_FAILURE);
}
{
int numInputs = deserialized.inputs.size();
Expand All @@ -99,7 +102,7 @@ static void checkRequest(ByteBuffer input) throws IOException {
WorkerProtocol.Input origInput = orig.getInputsList().get(i);
if (!Objects.equals(deserializedInput.path, origInput.getPath()) ||
!Objects.deepEquals(deserializedInput.digest, origInput.getDigest().toByteArray())) {
throw new RuntimeException("Deserilized object does not match original one");
throw new RuntimeException(ROUNDTRIP_FAILURE);
}
}
}
Expand Down Expand Up @@ -132,7 +135,7 @@ static void checkResponse(ByteBuffer input) throws IOException {
!Objects.equals(orig.output, deserialized.getOutput()) ||
(orig.requestId != deserialized.getRequestId()) ||
(orig.wasCancelled != deserialized.getWasCancelled())) {
throw new RuntimeException("Deserilized object does not match original one");
throw new RuntimeException(ROUNDTRIP_FAILURE);
}
}
}

0 comments on commit 9b1488e

Please sign in to comment.