zabbix-agent2/tests/zbxmockfile.c
/******************************************************************************
 *                                                                            *
 * Comments: Note that simply wrapping read function will break any compiled  *
 *           in tool, that would attempt to use read() function. In this case *
 *           some safeguards must be added to implement pass-through          *
 *           functionality like it's done with open/fxstat etc functions for  *
 *           coverage builds.                                                 *
 *                                                                            *
 ******************************************************************************/
Note that simply wrapping read function will break any compiled
in tool, that would attempt to use read() function. In this case
some safeguards must be added to implement pass-through
functionality like it's done with open/fxstat etc functions for
coverage builds.
Note that simply wrapping read function will break any compiled in tool that would attempt to use read () function . In this case some safeguards must be added to implement pass - through functionality like it ' s done with open / fxstat etc functions for coverage builds .
ssize_t	__wrap_read(int fildes, void *buf, size_t nbyte)
{
	static int		remaining_length;
	static const char	*data;
	zbx_mock_error_t	error;
	zbx_mock_handle_t	fragment;
	size_t			length;
	ZBX_UNUSED(fildes);
	if (0 == remaining_length)
	{
		if (ZBX_MOCK_SUCCESS != zbx_mock_vector_element(fragments, &fragment))
			return 0;	
		if (ZBX_MOCK_SUCCESS != (error = zbx_mock_binary(fragment, &data, &length)))
			fail_msg("Cannot read data '%s'", zbx_mock_error_string(error));
	}
	else
		length = remaining_length;
	if (nbyte < length)
	{
		remaining_length = length - nbyte;
		length = nbyte;
	}
	else
		remaining_length = 0;
	memcpy(buf, data, length);
	if (0 != remaining_length)
		data += length;
	return length;
}
ssize_t __wrap_read ( int fildes , void * buf , size_t nbyte ) { static int remaining_length ; static const char * data ; zbx_mock_error_t error ; zbx_mock_handle_t fragment ; size_t length ; ZBX_UNUSED ( fildes ) ; if ( 0 == remaining_length ) { if ( ZBX_MOCK_SUCCESS != zbx_mock_vector_element ( fragments , & fragment ) ) return 0 ; if ( ZBX_MOCK_SUCCESS != ( error = zbx_mock_binary ( fragment , & data , & length ) ) ) fail_msg ( " " , zbx_mock_error_string ( error ) ) ; } else length = remaining_length ; if ( nbyte < length ) { remaining_length = length - nbyte ; length = nbyte ; } else remaining_length = 0 ; memcpy ( buf , data , length ) ; if ( 0 != remaining_length ) data += length ; return length ; }
Comments: Note that simply wrapping read function will break any compiled  
           in tool, that would attempt to use read() function.
Comments : Note that simply wrapping read function will break any compiled in tool that would attempt to use read () function .
/* no more data */