Skip to content

Commit

Permalink
Add harness
Browse files Browse the repository at this point in the history
  • Loading branch information
rnshah9 authored and ForAllSecure Mayhem Bot committed Aug 24, 2024
1 parent 46c30ac commit 6b72a84
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/mayhem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ jobs:
fail-fast: false
matrix:
mayhemfile:
- mayhem/Mayhemfile
- mayhem/Mayhemfile_floor_log2i
- mayhem/Mayhemfile_basisu

steps:
- uses: actions/checkout@v3
Expand Down
4 changes: 3 additions & 1 deletion mayhem/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
FROM --platform=linux/amd64 ubuntu:22.04 as builder

RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential cmake
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential cmake clang

COPY . /repo
WORKDIR /repo/build
RUN cmake .. -DCMAKE_INSTALL_PREFIX=/install
RUN make -j8
RUN make install
RUN clang++ /repo/mayhem/fuzz_floor_log2i.cpp -fsanitize=fuzzer,address -I /repo/transcoder/ -o /fuzz

FROM ubuntu:22.04 as package
COPY --from=builder /install /install
COPY --from=builder /fuzz /fuzz_floor_log2i
7 changes: 3 additions & 4 deletions mayhem/Mayhemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
project: basis-universal
target: basisu
target: floor-log2i

cmds:
- cmd: /install/bin/basisu @@ -validate
env:
DISABLE_SMOKETEST: '1'
- cmd: /fuzz_floor_log2i
libfuzzer: true
7 changes: 7 additions & 0 deletions mayhem/Mayhemfile_basisu
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
project: basis-universal
target: basisu

cmds:
- cmd: /install/bin/basisu @@ -validate
env:
DISABLE_SMOKETEST: '1'
15 changes: 15 additions & 0 deletions mayhem/fuzz_floor_log2i.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <stdint.h>
#include <stdio.h>
#include <climits>

#include <fuzzer/FuzzedDataProvider.h>
#include "basisu_containers.h"

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
FuzzedDataProvider provider(data, size);

uint32_t v = provider.ConsumeIntegral<uint32_t>();
basisu::helpers::floor_log2i(v);
return 0;
}

0 comments on commit 6b72a84

Please sign in to comment.