src/test/transport.h
author Tero Marttila <terom@fixme.fi>
Thu, 21 May 2009 16:57:56 +0300
changeset 213 f0e52e026197
parent 196 873796250c60
permissions -rw-r--r--
implement lua_console_on_interrupt to abort any executing thread
#ifndef TEST_TRANSPORT_H
#define TEST_TRANSPORT_H

/**
 * @file
 *
 * Functions for interacting with transports
 */
#include "../transport_test.h"

/**
 * Read strlen(str) bytes from the given transport, and assert that they match the given string.
 *
 * Note that this only performs one transport_read.
 */
void assert_transport_read (transport_t *transport, const char *str);

/**
 * Write strlen(str) bytes to the given transport, and assert that they all get written.
 *
 * Note that this only performs one transport_write.
 */
void assert_transport_write (transport_t *transport, const char *str);

/**
 * Attempt to read a single byte from the given transport, and assert that the attempt returns ERR_EOF.
 */
void assert_transport_eof (transport_t *transport);

/**
 * Compare the written data stored in the given transport_test with the given buffer.
 *
 * This will pull /all/ of the data in the transport.
 */
void assert_transport_data_buf (struct transport_test *tp, const char *data, size_t len);

/**
 * Use assert_transport_data_buf() with the given formatted string.
 */
void assert_transport_data (struct transport_test *tp, const char *fmt, ...);

/**
 * Create an empty transport_test, with NULL callbacks.
 *
 * You must bind a new set of callbacks to the transport before pushing any data to it.
 */
struct transport_test* setup_transport_test (void);

#endif