Commit 6ed2cf5
committed
Merge bitcoin/bitcoin#34169: fuzz: change fuzz runner test_runner.py to be cwd independent
77c9b3c change test_runner.py to be cwd independent by calling subprocess.run with cwd arg. (Robin David)
Pull request description:
Dear Maintainers,
While using `test_runner.py` that runs fuzz tests and produces coverage results I encountered the following error.
If not running the script from the project root directory the `git grep --function-context [...]` does not return the same output which results in the following Python error:
```
../../src/protocol.h-', '../../../src/protocol.h-/** nServices flags */']
Traceback (most recent call last):
File "/path/to/bitcoin/build_libfuzzer/test/fuzz/./test_runner.py", line 405, in <module>
main()
~~~~^^
File "/path/to/bitcoin/build_libfuzzer/test/fuzz/./test_runner.py", line 173, in main
return generate_corpus(
fuzz_pool=fuzz_pool,
...<3 lines>...
targets=test_list_selection,
)
File "/path/to/bitcoin/build_libfuzzer/test/fuzz/./test_runner.py", line 249, in generate_corpus
targets = transform_process_message_target(targets, Path(src_dir))
File "/path/to/build_libfuzzer/test/fuzz/./test_runner.py", line 218, in transform_process_message_target
assert len(lines)
~~~^^^^^^^
AssertionError
```
The script is not able to retrieve lines as the filter applied is:
```python
lines = [l.split("::", 1)[1].split(",")[0].lower() for l in lines if l.startswith("src/protocol.h- NetMsgType::")]
```
Which when running from the root directory returns:
```
[snip]
src/protocol.h- NetMsgType::VERSION,
[snip]
```
but returns a relative path to CWD when run from other directories e.g:
```
../../../src/protocol.h- NetMsgType::VERSION,
```
This is very unfortunate as the script rightfully read the `config.ini` relatively to itself and go fetch `BUILDDIR` and `SRCDIR` variables to obtain absolute paths.
Options are:
* enforce running the script from *bitcoin/* directory (and thus explicitly mentioning it in the doc)
* make the script independent from where it is being run
I chose the second option as it was fairly easy to make the script independent from where it is being run.
ACKs for top commit:
maflcko:
lgtm ACK 77c9b3c
dergoegge:
Code review ACK 77c9b3c
Tree-SHA512: fbc821c4790dd9ac125046a842498e0d9a48549d1c8ef150bce2193ee62bee9c3bfd4b17ce278411102dd200dc9ad86a176ecae29ca1667bb14d6f90ad67e01d1 file changed
+4
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
211 | | - | |
| 211 | + | |
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
| 215 | + | |
215 | 216 | | |
216 | 217 | | |
217 | 218 | | |
| |||
226 | 227 | | |
227 | 228 | | |
228 | 229 | | |
229 | | - | |
| 230 | + | |
230 | 231 | | |
231 | 232 | | |
232 | 233 | | |
| 234 | + | |
233 | 235 | | |
234 | 236 | | |
235 | 237 | | |
| |||
0 commit comments