Macros for socket API remote calls
Overview
// macros #define CHECK_RPC_ERRNO(rpcs_, exp_errno_, err_msg_, args_...) #define CHECK_RPC_ERRNO_NOEXIT(rpcs_, exp_errno_, failed_, err_msg_, args_...) #define CLEANUP_RPC_CLOSE(rpcs_, sockd_) #define CLEANUP_RPC_FTP_CLOSE(rpcs_, sockd_) #define CLEANUP_RPC_SIGACTION(rpcs_, signum_, action_, old_handler_) #define MACRO_ERROR_EXIT #define MACRO_TEST_ERROR #define RPC_CHECK_READABILITY(rpcs_, sockd_, should_be_readable_) #define RPC_CHECK_WRITABILITY(rpcs_, sockd_, should_be_writable_) #define RPC_CLOSE(rpcs_, fd_) #define RPC_FUNC_WITH_EXACT_RETVAL(rpcs_, retval_, expect_, func_, args_...) #define RPC_FUNC_WITH_PTR_RETVAL(rpcs_, retval_, func_, args_...) #define RPC_FUNC_WITH_PTR_RETVAL0(rpcs_, retval_, func_) #define RPC_FUNC_ZERO_RETVAL(rpcs_, func_, args_...) #define RPC_GET_READABILITY(answer_, rpcs_, sockd_, timeout_) #define RPC_GET_WRITABILITY(answer_, rpcs_, sockd_, timeout_) #define RPC_SEND(sent_, rpcs_, sockd_, buf_, len_, flags_) #define RPC_SENDTO(sent_, rpcs_, sockd_, buf_, len_, flags_, addr_) #define RPC_SOCKET_TO_FILE(recv_, rpcs_, sockd_, file_name_, timeout_) #define RPC_WRITE(sent_, rpcs_, sockd_, buf_, len_)
Detailed Documentation
Macros
#define CHECK_RPC_ERRNO(rpcs_, exp_errno_, err_msg_, args_...)
Check current value of errno on a particular RPC server against some expected value
In case of failure it jumps to “cleanup” label
Parameters:
rpcs_ |
RPC server handle |
exp_errno_ |
Expected value of errno on the server |
err_msg_ |
Error message that should be used in case of failure |
args_ |
Arguments of err_msg_ |
#define CHECK_RPC_ERRNO_NOEXIT(rpcs_, exp_errno_, failed_, err_msg_, args_...)
Check current value of errno on a particular RPC server against some expected value
In case of failure it set failed_ to true
, otherwise to false
Parameters:
rpcs_ |
RPC server handle |
exp_errno_ |
Expected value of errno on the server |
failed_ |
Variable to store result of checking ( |
err_msg_ |
Error message that should be used in case of failure |
args_ |
Arguments of err_msg_ |
#define CLEANUP_RPC_CLOSE(rpcs_, sockd_)
Close a socket in cleanup part of the test
If cleanup_fd_leak_check test behaviour is enabled, this macro will check closed FD with rpc_fstat(). If cleanup_fd_close_enforce_libc test behaviour is enabled, this macro will call libc version of rpc_close().
Parameters:
rpcs_ |
RPC server handle |
sockd_ |
Socket descriptor to be closed |
#define CLEANUP_RPC_FTP_CLOSE(rpcs_, sockd_)
Close a FTP control socket in cleanup part of the test
Parameters:
rpcs_ |
RPC server handle |
sockd_ |
Socket descriptor to be closed |
#define CLEANUP_RPC_SIGACTION(rpcs_, signum_, action_, old_handler_)
Restore signal action set before the test
Parameters:
rpcs_ |
RPC server handle |
signum_ |
Signal number |
action_ |
Signal action to restore |
old_handler_ |
Expected value of rpc_signal function, NULL if we do not want to check return value |
#define MACRO_ERROR_EXIT
Cleanup on test exit
#define MACRO_TEST_ERROR
exit code on test failure
#define RPC_CHECK_READABILITY(rpcs_, sockd_, should_be_readable_)
Check readability of a particular socket.
In case of failure it calls TEST_FAIL macro, otherwise it gets back just after the checking
Parameters:
rpcs_ |
RPC server handle |
sockd_ |
Socket to be checked on readabilty |
should_be_readable_ |
Whether it should be readable or not (it should be of type |
#define RPC_CHECK_WRITABILITY(rpcs_, sockd_, should_be_writable_)
Check writability of a particular socket.
In case of failure it calls TEST_FAIL macro, otherwise it gets back just after the checking
Parameters:
rpcs_ |
RPC server handle |
sockd_ |
Socket to be checked on writabilty |
should_be_writable_ |
Whether it should be writable or not (it should be of type |
#define RPC_CLOSE(rpcs_, fd_)
Close a file descriptor on a particular RPC server.
fd_
parameter is updated to -1 after successfull completion of the macro.
Parameters:
rpcs_ |
RPC server handle |
fd_ |
file descriptor |
#define RPC_FUNC_WITH_EXACT_RETVAL(rpcs_, retval_, expect_, func_, args_...)
All the macros defined in the file expect user having in the calling context the following:
result
variable of typeint
;cleanup
label, which is responsible for freeing resources allocated or occuped in the test.
Macro to check function ‘func_’ on returning exactly specified value.
Parameters:
rpcs_ |
RPC server |
retval_ |
return value (OUT) |
expect_ |
expected return value |
func_ |
RPC function name to call (without rpc_ prefix) |
args_ |
a set of arguments pased to the function |
#define RPC_FUNC_WITH_PTR_RETVAL(rpcs_, retval_, func_, args_...)
REMOVE IT.
Macro to check function ‘func_’ on returning non NULL value
Parameters:
rpcs_ |
RPC server |
retval_ |
return value (OUT) |
func_ |
RPC function name to call (without rpc_ prefix) |
args_ |
a set of arguments pased to the function |
#define RPC_FUNC_WITH_PTR_RETVAL0(rpcs_, retval_, func_)
REMOVE IT.
Macro to check function ‘func_’ on returning non NULL value
Parameters:
rpcs_ |
RPC server |
retval_ |
return value (OUT) |
func_ |
RPC function name to call (without rpc_ prefix) |
#define RPC_FUNC_ZERO_RETVAL(rpcs_, func_, args_...)
REMOVE IT.
Macro to check function ‘func_’ on returning zero value
Parameters:
rpcs_ |
RPC server |
func_ |
RPC function name to call (without rpc_ prefix) |
args_ |
a set of arguments pased to the function |
#define RPC_GET_READABILITY(answer_, rpcs_, sockd_, timeout_)
Get readability of a particular socket.
In case of failure it calls TEST_FAIL macro, otherwise it gets back just after the checking
Parameters:
answer_ |
variable where stored is readable or not (it should be of type |
rpcs_ |
RPC server handle |
sockd_ |
Socket to be checked on readabilty |
timeout_ |
timeout in milliseconds |
#define RPC_GET_WRITABILITY(answer_, rpcs_, sockd_, timeout_)
Get writability of a particular socket.
In case of failure it calls TEST_FAIL macro, otherwise it gets back just after the checking
Parameters:
answer_ |
variable where stored is readable or not (it should be of type |
rpcs_ |
RPC server handle |
sockd_ |
Socket to be checked on writability |
timeout_ |
timeout in milliseconds |
#define RPC_SEND(sent_, rpcs_, sockd_, buf_, len_, flags_)
Call send() function on RPC server and check return value.
In case of failure it jumps to “cleanup” label
Parameters:
sent_ |
Number of sent bytes (OUT) |
rpcs_ |
RPC server handle |
sockd_ |
Socket descriptor |
buf_ |
Buffer pointer |
len_ |
Length of the data to be sent |
flags_ |
Operation flags |
#define RPC_SENDTO(sent_, rpcs_, sockd_, buf_, len_, flags_, addr_)
Call sendto() function on RPC server and check return value.
In case of failure it jumps to “cleanup” label
Parameters:
sent_ |
Number of sent bytes (OUT) |
rpcs_ |
RPC server handle |
sockd_ |
Socket descriptor |
buf_ |
Buffer pointer |
len_ |
Length of the data to be sent |
flags_ |
Operation flags |
addr_ |
Destination address |
#define RPC_SOCKET_TO_FILE(recv_, rpcs_, sockd_, file_name_, timeout_)
Call socket_to_file function on RPC server and check return value on errors.
In case of failure it jumps to “cleanup” label
Parameters:
recv_ |
Number of received bytes (OUT) |
rpcs_ |
RPC server handle |
sockd_ |
Socket descriptor |
file_name_ |
File name where write received data |
timeout_ |
timeout in seconds |
#define RPC_WRITE(sent_, rpcs_, sockd_, buf_, len_)
Call write() function on RPC server and check return value.
In case of failure it jumps to “cleanup” label
Parameters:
sent_ |
Number of sent bytes (OUT) |
rpcs_ |
RPC server handle |
sockd_ |
Socket descriptor |
buf_ |
Buffer pointer |
len_ |
Length of the data to be sent |