Output captured data on failure
eerimoq opened this issue · 2 comments
eerimoq commented
Hello!
The program at the end of the issue produces the output "Current output" with the latest unicorn implementation. It would be helpful to output the captured data as well, as seen in "Requested output".
Current output:
test_1 failed:
...
Output:
1 | Before capture!
2 | After capture!
3 |
test_2 failed:
...
Output:
1 | Before capture!
2 |
Requested output:
test_1 failed:
...
Output:
1 | Before capture!
2 | In capture!
3 | After capture!
4 |
test_2 failed:
...
Output:
1 | Before capture!
2 | In capture!
3 |
Sample program:
#include <unicorn/unicorn.h>
TEST(test_1)
{
printf("Before capture!\n");
CAPTURE_OUTPUT(output) {
printf("In capture!\n");
}
printf("After capture!\n");
ASSERT(0);
}
TEST(test_2)
{
printf("Before capture!\n");
CAPTURE_OUTPUT(output) {
printf("In capture!\n");
ASSERT(0);
}
printf("After capture!\n");
}
int main()
{
return RUN_TESTS(
test_1,
test_2
);
}
vberlier commented
I think I knew about that and thought it would make sense to leave it as is. After all, CAPTURE_OUTPUT
makes it clear that everything is getting redirected and that the output won't actually be printed out. That's why it doesn't get collected in the test output. But yeah I guess you're right, for debugging purposes it makes much more sense to be able to inspect the output as a whole.