BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
tlcore.c File Reference
#include "tlcore.h"

Functions

static void copy (uint8_t *to, const uint8_t *from, size_t n)
static struct basictest_str str (const char *s)
static struct basictest_entry entry (int kind)
static void flush (struct tl_state *st)
static int fresh (const struct tl_state *st)
static int alive (struct tl_state *st)
static void out (struct tl_state *st, const uint8_t *line, size_t n, int force)
static size_t emit (struct tl_state *st, struct basictest_entry *e, int force)
static void broken (struct tl_state *st, const char *reason)
static void simple (struct tl_state *st, int kind)
static void inside (struct tl_state *st)
void tl_begin (struct tl_state *st)
 Clears the state and writes begin.
int tl_block (struct tl_state *st, int block, const uint8_t *name, size_t length)
 Opens a block (block: enum basictest_block; name and length: the case name, ignored for the batch init and end).
void tl_blockend (struct tl_state *st)
 Closes the open block.
static void init_check (struct tl_state *st, size_t n)
void tl_check (struct tl_state *st, uint32_t k, uint32_t expected, uint32_t actual)
 A check of two longs: ok if they are equal.
void tl_checkq (struct tl_state *st, uint32_t k, uint32_t expected, uint32_t actual)
 A check of two quicks (their 32 bits): ok if they are equal.
void tl_checkflt (struct tl_state *st, uint32_t k, uint32_t expected, uint32_t actual, uint32_t delta)
 A check of two FFP floats: ok if |actual-expected| <= delta.
void tl_checkstr (struct tl_state *st, uint32_t k, const uint8_t *expected, size_t expected_length, const uint8_t *actual, size_t actual_length)
 A check of two strings (bytes): ok if they are equal.
int tl_require (struct tl_state *st, uint32_t k, uint32_t condition)
 A precondition.
void tl_expect_error (struct tl_state *st, uint32_t k)
 The announcement of an expected runtime error.
void tl_finit (struct tl_state *st)
 The end of the run: kept entries, incomplete if a block is open, end.
static void run_clear (struct tl_run *r, struct tl_run_text *t)
int tl_run_start (struct tl_state *st, uint32_t k, struct tl_run *r, struct tl_run_text *t)
 A program is to start (TLRunProgram): the result r and its text t cleared (rc 0, unknown, nothing printed: printed the empty string), and run K written if it may start.
void tl_run_end (struct tl_state *st, uint32_t k, struct tl_run *r, struct tl_run_text *t, int known, int32_t rc, size_t n, uint32_t size)
 The program ended (after tl_run_start gave 1): its output's first n bytes are in t->chars (n <= TL_RUN_TEXT), size the whole output; the result filled (printed of n bytes and a 0 behind, cut if size > n) and runend K written with rc if known, else -.

Variables

static const char damaged [] = "broken\tstate damaged\n"
static const char lost [] = "broken\tentries lost while kept\n"

Function Documentation

◆ alive()

int alive ( struct tl_state * st)
static

◆ broken()

void broken ( struct tl_state * st,
const char * reason )
static

◆ copy()

void copy ( uint8_t * to,
const uint8_t * from,
size_t n )
static

◆ emit()

size_t emit ( struct tl_state * st,
struct basictest_entry * e,
int force )
static

◆ entry()

struct basictest_entry entry ( int kind)
static

◆ flush()

void flush ( struct tl_state * st)
static

◆ fresh()

int fresh ( const struct tl_state * st)
static

◆ init_check()

void init_check ( struct tl_state * st,
size_t n )
static

◆ inside()

void inside ( struct tl_state * st)
static

◆ out()

void out ( struct tl_state * st,
const uint8_t * line,
size_t n,
int force )
static

◆ run_clear()

void run_clear ( struct tl_run * r,
struct tl_run_text * t )
static

◆ simple()

void simple ( struct tl_state * st,
int kind )
static

◆ str()

struct basictest_str str ( const char * s)
static

◆ tl_begin()

void tl_begin ( struct tl_state * st)

Clears the state and writes begin.

◆ tl_block()

int tl_block ( struct tl_state * st,
int block,
const uint8_t * name,
size_t length )

Opens a block (block: enum basictest_block; name and length: the case name, ignored for the batch init and end).

Returns
1 if the block runs, 0 if it does not (no tl_begin, or after a batch init whose precondition failed).

◆ tl_blockend()

void tl_blockend ( struct tl_state * st)

Closes the open block.

◆ tl_check()

void tl_check ( struct tl_state * st,
uint32_t k,
uint32_t expected,
uint32_t actual )

A check of two longs: ok if they are equal.

◆ tl_checkflt()

void tl_checkflt ( struct tl_state * st,
uint32_t k,
uint32_t expected,
uint32_t actual,
uint32_t delta )

A check of two FFP floats: ok if |actual-expected| <= delta.

◆ tl_checkq()

void tl_checkq ( struct tl_state * st,
uint32_t k,
uint32_t expected,
uint32_t actual )

A check of two quicks (their 32 bits): ok if they are equal.

◆ tl_checkstr()

void tl_checkstr ( struct tl_state * st,
uint32_t k,
const uint8_t * expected,
size_t expected_length,
const uint8_t * actual,
size_t actual_length )

A check of two strings (bytes): ok if they are equal.

◆ tl_expect_error()

void tl_expect_error ( struct tl_state * st,
uint32_t k )

The announcement of an expected runtime error.

◆ tl_finit()

void tl_finit ( struct tl_state * st)

The end of the run: kept entries, incomplete if a block is open, end.

◆ tl_require()

int tl_require ( struct tl_state * st,
uint32_t k,
uint32_t condition )

A precondition.

Returns
1 if it failed inside a block: the caller leaves the block (the block's call returns a second time, with 0); 0 otherwise.

◆ tl_run_end()

void tl_run_end ( struct tl_state * st,
uint32_t k,
struct tl_run * r,
struct tl_run_text * t,
int known,
int32_t rc,
size_t n,
uint32_t size )

The program ended (after tl_run_start gave 1): its output's first n bytes are in t->chars (n <= TL_RUN_TEXT), size the whole output; the result filled (printed of n bytes and a 0 behind, cut if size > n) and runend K written with rc if known, else -.

◆ tl_run_start()

int tl_run_start ( struct tl_state * st,
uint32_t k,
struct tl_run * r,
struct tl_run_text * t )

A program is to start (TLRunProgram): the result r and its text t cleared (rc 0, unknown, nothing printed: printed the empty string), and run K written if it may start.

Returns
1 if it may start; 0 if not: no tl_begin, a damaged state, or refused with broken (outside a block, or while entries cannot be written: Blitz mode, Forbid, Disable).

Variable Documentation

◆ damaged

const char damaged[] = "broken\tstate damaged\n"
static

◆ lost

const char lost[] = "broken\tentries lost while kept\n"
static