next up previous contents index
Next: Glossary Up: TUTTI Reference Previous: depend   Contents   Index


TUTTI Run time library

The run-time library of TUTTI allows the user to create functional tests using macro's. It allows to introduce verification points in a driver program such that erroneous situations are detected and reported automatically.


/* 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
    server = sock_create_server( port, (sock_cb_t) read_cb  );
    TUTTI_ASSERT( server != NULL );

    client = sock_create_client( NULL, port );
    TUTTI_ASSERT( client != NULL );

    result = client->write( g_message );
    TUTTI_CHECK( result == SOCK_OK );
    result = client->write( g_message );

    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:
This macro initializes the tutti library and starts the required logging.
This macro closes the tutti library and logging. When this statement is not reached, this will also me reported in the output of tutti_scan.
Inserts an assertion into the code. When the predicate (logical expression) of the assertion results in a false, this is reported into the logging and the program is aborted.

Inserts a verification point in the code. The result of the predicate is always logged into the logging. The program is not aborted on a false result of the predicate.
Typical output would be:
ut_socket.c:40:result == SOCK_ERR_INVALID_MSG?
Verdict: fail
This means that the check failed at line 40 of the test driver application.


tutti_compiler is a wrapper for the TUTTI run time library.

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.


After executing a program instrumented with the tutti_compiler, a log files is generated in the working directory. Although this log file is human-readable, it is advisable to use tutti_scan to parse the logging and convert it to legible information. See tutti_scan(1).


Normally, the output format of tutti_scan is he same as the gcc compiler collection. This format is $<$file$>$,$<$line$>$,$<$message$>$. This allows the programming to parse the output by an editor. It is also possible to generate output in HTML output. Add -html as an optional argument for this purpose.

next up previous contents index
Next: Glossary Up: TUTTI Reference Previous: depend   Contents   Index