Skip to content

Commit f8fa368

Browse files
authored
Update README.md
Added information about demo
1 parent 89a6a75 commit f8fa368

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,23 @@
11
# automotive-fuzzing-example
2+
For the demo:
3+
- Initialize Project
4+
- Create Fuzz Test for a function
5+
- To compile it the "extern" functions need to be implemented for this use the scripts in fuzzing/auto-mock-fuzz:
6+
- ```python3 gen_template.py /path_to_project/automotive-fuzzing-example/modules/*/src/*.c /path_to_project/automotive-fuzzing-example/modules/*/src/*.h```
7+
- This will create two excel sheets. The Sheet called testgen_mocks.xlsx will contain information about the functions that are declared as extern
8+
- Fill in the excel sheet like this:
9+
10+
| return: RETURN_INT(int) | position_as_bytes: WRITE_BYTES(12) | hmac_as_bytes: WRITE_BYTES(64) | | |
11+
|-----------------------------|------------------------------------|--------------------------------|------------------------|-----------------------|
12+
| return: RETURN_INT(int) | message: WRITE_BYTES(len) | key: WRITE_BYTES(64) | nonce: WRITE_BYTES(64) | hmac: WRITE_BYTES(64) |
13+
| return: RETURN_INT(uint8_t) | | | | |
14+
| return: RETURN_INT(int) | | | | |
15+
16+
- Run the second script to generate the mocking library from this:
17+
- ```python3 gen_tests.py mocklib gen_template/testgen_mocks.xlsx ../mocks```
18+
- This creates mocklib.h and mocklib.cpp in fuzzing/mocks
19+
- Add the mocklib.cpp to the compiler options and also add the include path fuzzing/mocks
20+
- In the fuzztest you need to create a FuzzedDataProvider object and give a pointer to it to the mocking library. Add the following to the beginning of the FUZZ function:
21+
```FuzzedDataProvider fuzz_data(Data, Size);```
22+
```mocklib_set_data(&fuzz_data);```
23+
- You also need to include the FuzzedDataProvider.h and mocklib.h in the fuzztest

0 commit comments

Comments
 (0)