libcester icon indicating copy to clipboard operation
libcester copied to clipboard

Issue with capturing stderr stream

Open KamaroK opened this issue 2 years ago • 2 comments

I have an issue with this code

CESTER_CAPTURE_STDERR();
__wrap_infrsprin_(&n,rp,ip,c,&torq1);
cester_assert_stderr_stream_content_contain("constraint");
CESTER_RELEASE_STDERR();

that seems to not capture stderr stream content

KamaroK avatar Jun 09 '23 09:06 KamaroK

You can use the macro CESTER_STDERR_CONTENT to print out the stderr content to see if anything is in it

printf("%s", CESTER_STDERR_CONTENT())

Or verify the output stream the function is printing into, if it is not stderr you can capture the stream manually

// stream can be stdout, stderr, a FILE handle, etc.
CESTER_CAPTURE_STREAM(stream);
__wrap_infrsprin_(&n,rp,ip,c,&torq1);
cester_assert_stream_content_contain(stream, "constraint");
CESTER_RELEASE_STREAM(stream);

I assume the function _wrap_infrsprin prints to a stream in the course of it execution.

Thecarisma avatar Jun 09 '23 12:06 Thecarisma

The stderr content is not print out and cester do not capture any type of file handle or even stdout

KamaroK avatar Jun 12 '23 07:06 KamaroK