Data Structures | Macros | Functions
test.h File Reference

Self-test infrastructure. More...

#include <ipxe/tables.h>

Go to the source code of this file.

Data Structures

struct  self_test
 A self-test set. More...


#define SELF_TESTS   __table ( struct self_test, "self_tests" )
 Self-test table. More...
#define __self_test   __table_entry ( SELF_TESTS, 01 )
 Declare a self-test. More...
#define okx(success, file, line)   test_ok ( success, file, line, #success )
 Report test result. More...
#define ok(success)   okx ( success, __FILE__, __LINE__ )


void test_ok (int success, const char *file, unsigned int line, const char *test)
 Report test result. More...

Detailed Description

Self-test infrastructure.

Definition in file test.h.

Macro Definition Documentation


#define SELF_TESTS   __table ( struct self_test, "self_tests" )

Self-test table.

Definition at line 29 of file test.h.

◆ __self_test

struct self_test iobuf_test __self_test   __table_entry ( SELF_TESTS, 01 )

Declare a self-test.

I/O buffer self-test.

Definition at line 32 of file test.h.

◆ okx

#define okx (   success,
)    test_ok ( success, file, line, #success )

Report test result.

successTest succeeded
fileFile name
lineLine number

Definition at line 44 of file test.h.

◆ ok

#define ok (   success)    okx ( success, __FILE__, __LINE__ )

Definition at line 46 of file test.h.

Function Documentation



◆ test_ok()

void test_ok ( int  success,
const char *  file,
unsigned int  line,
const char *  test 

Report test result.

successTest succeeded
fileTest code file
lineTest code line
testTest code

Definition at line 55 of file test.c.

56  {
58  /* Sanity check */
59  assert ( current_tests != NULL );
61  /* Increment test counter */
64  /* Report failure if applicable */
65  if ( ! success ) {
67  printf ( "FAILURE: \"%s\" test failed at %s line %d: ( %s )\n",
68  current_tests->name, file, line, test );
69  }
70 }
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:464
unsigned int failures
Number of test failures.
Definition: test.h:23
unsigned int total
Number of tests run.
Definition: test.h:21
const char * name
Test set name.
Definition: test.h:17
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static struct self_test * current_tests
Current self-test set.
Definition: test.c:45
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
static int test
Definition: epic100.c:73

References assert(), current_tests, self_test::failures, self_test::name, NULL, printf(), test, and self_test::total.