QuickIO  0.2
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Functions
test.h File Reference

Utilities for running tests. More...

#include <check.h>
#include "quickio.h"
#include "check_compat.h"

Go to the source code of this file.

Functions

void test_new (const gchar *suite_name, SRunner **sr, Suite **s)
 Create a new test suite, ready for running. More...
 
gboolean test_do (SRunner *sr)
 Runs a test and returns if everything passed. More...
 
void test_config ()
 Create the default test config file.
 
void test_config_rm ()
 Remove the created configuration file.
 
void test_setup ()
 A checked fixture: starts up QIO and gets everything ready for a test.
 
void test_setup_with_config (gchar *config)
 Setup the server including the given config path.
 
void test_teardown ()
 A checked teardown: tears down QIO and frees up all memory used.
 
qev_fd_t test_socket ()
 Get a new socket connected to localhost on the test's port.
 
qev_fd_t test_client ()
 Get a client connected to QIO.
 
void test_send (qev_fd_t tc, const gchar *data)
 Send a message from the client to the server. More...
 
void test_send_len (qev_fd_t tc, const gchar *data, const guint64 len)
 Send a message from the client to the server. More...
 
guint64 test_recv (qev_fd_t tc, gchar *data, const guint64 len)
 Receive a message from the server to the client. More...
 
void test_msg (qev_fd_t tc, const gchar *data)
 Tests that the received message is what is given.
 
void test_cb (qev_fd_t tc, const gchar *msg, const gchar *data)
 Tests that the given callback is recieved in response to the message.
 
void test_ping (qev_fd_t tc)
 Tests that the client is alive by pinging the server.
 
void test_wait_for_buff (const guint len)
 Waits for all of the connected clients to have userspace buffers. More...
 
struct clienttest_get_client ()
 Get the last client in the clients list.
 
struct clienttest_get_client_raw ()
 Get the last client in the clients list, not waiting for it to be handshaked or anything.
 
void test_heartbeat ()
 Force send out heartbeats.
 
void test_client_dead (qev_fd_t tc)
 Tests that the client was closed by the server.
 
void test_close (qev_fd_t tc)
 Close and free up any resources the client was using.
 

Detailed Description

Utilities for running tests.

Author
Andrew Stone andre.nosp@m.w@cl.nosp@m.ovar..nosp@m.com

This file is part of QuickIO and is released under the MIT License: http://opensource.org/licenses/MIT

Function Documentation

gboolean test_do ( SRunner *  sr)

Runs a test and returns if everything passed.

Parameters
srThe test runner to run and free
void test_new ( const gchar *  suite_name,
SRunner **  sr,
Suite **  s 
)

Create a new test suite, ready for running.

Parameters
suite_nameName of the test suite
srWhere the test runner should be put
sWhere the test suite should be put
guint64 test_recv ( qev_fd_t  tc,
gchar *  data,
const guint64  len 
)

Receive a message from the server to the client.

Parameters
tcThe client to read from.
dataWhere the data should be put. Will be null-terminated.
lenThe length of the data buffer.
Returns
The number of bytes read.
void test_send ( qev_fd_t  tc,
const gchar *  data 
)

Send a message from the client to the server.

Parameters
tcThe test client to write to
dataThe data to frame and send
void test_send_len ( qev_fd_t  tc,
const gchar *  data,
const guint64  len 
)

Send a message from the client to the server.

Parameters
tcThe test client to write to
dataThe data to frame and send
lenThe length of the data. 0 to strlen() it data to find out.
void test_wait_for_buff ( const guint  len)

Waits for all of the connected clients to have userspace buffers.

Typically, this is only useful when testing 1 connected client.

Parameters
lenThe MINIMUM length that the buffer must be before returning.