/* driver program for testing the mysockets library */ #include <mysockets.h> #include <tutti_api.h> static const char* g_message = NULL; void read_cb( sock_t* client ) { size_t bytes = strlen( g_message ); TUTTI_ASSERT( client != NULL ); TUTTI_CHECK( client->msg_length == bytes ); TUTTI_CHECK( strcmp( client->message, g_message) == 0 ); } int main ( void ) { int port = 8888; sock_t client = NULL; sock_t server = NULL; sock_result_t result = SOCK_OK; /* start server socket that listens to port 8888 read_cb is automatically called when data becomes available */ TUTTI_INIT; server = sock_create_server( port, (sock_cb_t) read_cb ); TUTTI_ASSERT( server != NULL ); client = sock_create_client( NULL, port ); TUTTI_ASSERT( client != NULL ); g_message="hello_world"; result = client->write( g_message ); TUTTI_CHECK( result == SOCK_OK ); g_message=NULL; result = client->write( g_message ); TUTTI_CHECK( result == SOCK_ERR_INVALID_MSG ); TUTTI_EXIT; return 0; }As shown by the examples, 4 macros are available. When compiled with a an ordinary compiler, the macros do not have any effect. When compiled with -DTUTTI, these macro add extra instructions to the code. The compiler wrapper tutti_compiler this this automatically which results in the next behavior:
ut_socket.c:40:result == SOCK_ERR_INVALID_MSG? Verdict: failThis means that the check failed at line 40 of the test driver application.
It will compile the software such that the macros defined in tutti_api.h will be effectuated. The wrapper can be invoked as the gnu compiler collection (GCC). After execution of the program compiled with this script (and using these macros), a file tutti.out results in the working directory. This output should be analyzed with the tutti_scan tool.