Skip to content

fuzzers: print verbose maketodo output to stderr, not stdout - #2571

Open
ylemiesa57 wants to merge 1 commit into
f4pga:masterfrom
ylemiesa57:fix/maketodo-verbose-stderr
Open

fuzzers: print verbose maketodo output to stderr, not stdout#2571
ylemiesa57 wants to merge 1 commit into
f4pga:masterfrom
ylemiesa57:fix/maketodo-verbose-stderr

Conversation

@ylemiesa57

Copy link
Copy Markdown

I was looking for a small, well scoped issue to get familiar with the prjxray codebase and #521 seemed like a good one, it's a clear bug with an obvious fix.

What I changed

fuzzers/int_maketodo.py prints its real output (the list of todo PIPs) to stdout, and pip_loop.mk pipes that stdout straight into todo_all.txt. The problem is that when you pass --verbose, all the diagnostic messages (verbose and print(...)) were also going to stdout, so they'd get mixed into the same stream and end up in the todo file, corrupting it. That's exactly what the issue describes.

The fix just sends all the verbose diagnostic prints to stderr instead, so stdout only ever has the actual todo entries the Makefile expects. I left the final print(todo) loop (the real output) on stdout since that's supposed to be there. I also ran yapf -i on the file afterward since a few of the print calls needed re-wrapping to match the repo's .style.yapf config.

Testing

There isn't a dedicated test file for int_maketodo.py and the one test file in tests/ (test_util.py) covers a different module (prjxray.util) and needs the full toolchain deps installed, so I wrote a quick manual check instead: I called maketodo() directly with a small fake pipfile/dbfile, once with verbose=True and once with verbose=False, and captured stdout/stderr separately.

With verbose=True, stdout only contained the 3 todo entries and all the diagnostic lines ("entries", "Loading ...", "Post db ...", etc) showed up on stderr instead, so redirecting stdout to a file would no longer corrupt it. With verbose=False the output was unchanged from before my edit, same 3 entries on stdout, nothing on stderr. Also ran python3 -m py_compile and yapf -d on the file to make sure it compiles and matches the repo's formatting style.

Let me know if I should tweak anything, still getting familiar with how the fuzzer scripts fit together here.

int_maketodo.py writes its actual output (the list of todo PIPs) to
stdout, and pip_loop.mk redirects that stdout straight into
todo_all.txt. When --verbose is passed, the diagnostic messages were
also going to stdout via 'verbose and print(...)', so they ended up
mixed into the same stream and corrupted the todo file.

This changes all the verbose diagnostic print() calls to write to
stderr instead, leaving stdout with only the actual todo PIP list
that the Makefile expects. Ran yapf -i on the file to match the
existing formatting.

Fixes f4pga#521

Signed-off-by: Yaphet Lemiesa <yaphkl75@mit.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant