|
29 | 29 | # Build host tests app (with all configs and targets supported) |
30 | 30 | python ./ci/build_apps.py components/mdns/tests/host_test/ |
31 | 31 | cd components/mdns/tests/host_test |
| 32 | + ls -la |
| 33 | + ls -ls build* |
32 | 34 | # First run the linux_app and send a quick A query and a reverse query |
33 | 35 | ./build_linux_app/mdns_host.elf & |
34 | 36 | python dnsfixture.py A myesp.local --ip_only | xargs python dnsfixture.py X |
|
55 | 57 | shell: bash |
56 | 58 | run: | |
57 | 59 | . ${IDF_PATH}/export.sh |
58 | | - cd components/mdns/tests/test_afl_fuzz_host/ |
59 | | - make INSTR=off |
| 60 | + cd components/mdns/tests/host_unit_test/ |
| 61 | + idf.py reconfigure |
| 62 | + mkdir build2 && cd build2 |
| 63 | + cmake .. |
| 64 | + cmake --build . |
60 | 65 | - name: Test no malloc functions |
61 | 66 | shell: bash |
62 | 67 | run: | |
|
69 | 74 | echo "OK" |
70 | 75 | done |
71 | 76 |
|
| 77 | + host_unit_test: |
| 78 | + if: contains(github.event.pull_request.labels.*.name, 'mdns') || github.event_name == 'push' |
| 79 | + name: Unit tests on host |
| 80 | + strategy: |
| 81 | + matrix: |
| 82 | + idf_ver: ["latest"] |
| 83 | + |
| 84 | + runs-on: ubuntu-22.04 |
| 85 | + container: espressif/idf:${{ matrix.idf_ver }} |
| 86 | + steps: |
| 87 | + - name: Checkout esp-protocols |
| 88 | + uses: actions/checkout@v4 |
| 89 | + - name: Install bsdlib and ruby |
| 90 | + run: | |
| 91 | + apt-get update -y |
| 92 | + apt-get install -y libbsd-dev ruby |
| 93 | + - name: Build and run unit tests |
| 94 | + shell: bash |
| 95 | + run: | |
| 96 | + . ${IDF_PATH}/export.sh |
| 97 | + cd components/mdns/tests/host_unit_test/ |
| 98 | + idf.py reconfigure |
| 99 | + mkdir build2 && cd build2 |
| 100 | + cmake -DUNIT_TESTS=test_receiver .. |
| 101 | + cmake --build . |
| 102 | + ctest --extra-verbose |
| 103 | + cd .. |
| 104 | + mkdir build3 && cd build3 |
| 105 | + cmake -DUNIT_TESTS=test_sender .. |
| 106 | + cmake --build . |
| 107 | + ctest --extra-verbose |
| 108 | +
|
| 109 | +
|
72 | 110 | fuzz_test: |
73 | 111 | if: contains(github.event.pull_request.labels.*.name, 'mdns-fuzz') || github.event_name == 'push' |
74 | 112 | name: Fuzzer tests for mdns lib |
@@ -98,13 +136,26 @@ jobs: |
98 | 136 | shell: bash |
99 | 137 | run: | |
100 | 138 | export IDF_PATH=$GITHUB_WORKSPACE/idf |
101 | | - cd components/mdns/tests/test_afl_fuzz_host/ |
102 | | - make fuzz |
| 139 | + cd components/mdns/tests/host_unit_test/ |
| 140 | + pip install dnslib |
| 141 | + cd input && python generate_cases.py && cd .. |
| 142 | + cmake -B build2 -S . -G "Ninja" -DCMAKE_C_COMPILER=afl-cc |
| 143 | + cmake --build build2 |
| 144 | + timeout 10m afl-fuzz -i input -o out -- build2/mdns_host_unit_test || \ |
| 145 | + if [ $? -eq 124 ]; then # timeout exit code |
| 146 | + if [ -n "$(find out/default/crashes -type f 2>/dev/null)" ]; then |
| 147 | + echo "Crashes found!"; |
| 148 | + tar -czf out/default/crashes.tar.gz -C out/default crashes; |
| 149 | + exit 1; |
| 150 | + fi |
| 151 | + else |
| 152 | + exit 1; |
| 153 | + fi |
103 | 154 |
|
104 | 155 | - name: Upload Crash Artifacts |
105 | 156 | if: failure() |
106 | 157 | uses: actions/upload-artifact@v4 |
107 | 158 | with: |
108 | 159 | name: fuzz-crashes |
109 | | - path: components/mdns/tests/test_afl_fuzz_host/out/default/crashes.tar.gz |
| 160 | + path: components/mdns/tests/host_unit_test/out/default/crashes.tar.gz |
110 | 161 | if-no-files-found: ignore |
0 commit comments