code queries

Dmitry V. Levin ldv at altlinux.org
Sun Jul 12 12:12:41 UTC 2020


On Fri, Jul 10, 2020 at 05:32:44PM +0530, Bran S wrote:
> I have seen tail_alloc() being used at a lot of places in tests. For
> example, in ioctl_hdio.c, and epoll_pwait.c.
> 
> File tests.h gives information about what it does but I don't
> understand the motive and use of allocating memory in such a manner.
> What is the purpose of it? How is it helpful in testing?

This way we check whether strace decoders handle incomplete read from
tracee's memory properly, and also check that strace decoders do not read
beyond the end of structures being decoded.

> Another query is about error_msg.c file:
> Link: https://github.com/strace/strace/blob/master/tests/error_msg.c#L9
> 
> In tests/error_msg.c:
>        #define perror_msg_and_fail perror_msg_and_fail
>        #define error_msg_and_fail error_msg_and_fail
> 
> What is the reason for doing this?

This way error_msg.c avoids definitions of perror_msg_and_fail and
error_msg_and_fail macros from tests/tests.h which wouldn't help
to define the corresponding functions.


-- 
ldv


More information about the Strace-devel mailing list