1---
2
3name: IPC fuzzing
4
5# 'workflow_dispatch' allows running this workflow manually from the
6# 'Actions' tab
7
8# yamllint disable-line rule:truthy
9on: [pull_request, workflow_dispatch]
10
11
12# For the actual fuzzer see tools/oss-fuzz/README.
13# also see
14# https://google.github.io/oss-fuzz/getting-started/continuous-integration/
15#
16# Build and run fuzzer for 5s just to check that it runs properly. If it
17# consistently fails in under 5s you probably did something wrong
18
19# If you came here to quickly copy/paste the invocation of some build
20# script in order to reproduce a failure reported by github then you
21# will be disappointed by the Github Action below: it's magical. For a
22# thorough reproduction you must follow the links above. For a quick,
23# dirty and incomplete reproduction hack you can try the following two
24# lines. Don't do this at home.
25#
26#   OUT=unused_dir  cmake -B oss-fuzz-build/ -S tools/oss-fuzz/
27#   make -j -C oss-fuzz-build sof_ep fuzz_ipc.o
28jobs:
29  ipc-fuzzer-build:
30    runs-on: ubuntu-latest
31    steps:
32      - name: Build Fuzzers
33        uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
34        with:
35          oss-fuzz-project-name: 'sound-open-firmware'
36
37      - name: Run Fuzzers
38        uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
39        with:
40          oss-fuzz-project-name: 'sound-open-firmware'
41          language: c
42          fuzz-seconds: 5
43
44
45  # TODO, to add IPC4 support fix compilation of:
46  #
47  #    ./scripts/fuzz.sh -t 1 -- -DCONFIG_IPC_MAJOR_4=y
48  #
49  # ... or of some other _IPC4_ -DOVERLAY_CONFIG=
50  #
51  # Then use a simple IPC3/IPC4 matrix like the one in zephyr.yml
52  simple-IPC3-fuzz_sh:
53    runs-on: ubuntu-22.04
54    steps:
55      - name: add i386 arch
56        run: |
57          sudo dpkg --add-architecture i386
58          sudo apt-get update
59
60      - name: apt-get install
61        run: sudo apt-get update && sudo apt-get -y install
62          clang llvm libc6-dev-i386 libstdc++-12-dev:i386
63          ninja-build device-tree-compiler python3-pyelftools
64
65      - uses: actions/checkout@v3
66        with:
67          path: ./workspace/sof
68
69      - name: west update
70        run: |
71          cd workspace/sof
72          pip3 install west
73          west init -l
74          west update --narrow --fetch-opt=--filter=tree:0
75
76      - name: build and run fuzzer for a few minutes
77        run: |
78          cd workspace
79          clang --verbose
80          set -x
81          sof/scripts/fuzz.sh -o _.log -t 300
82