iPXE
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...

Macros

#define SELF_TESTS   __table ( struct self_test, "self_tests" )
 Self-test table.
#define __self_test   __table_entry ( SELF_TESTS, 01 )
 Declare a self-test.
#define okx(success, file, line)
 Report test result.
#define ok(success)
#define BINFILE(...)
 Define inline binary file content.
#define TEXTFILE(text)
 Define inline text file content.
#define __file_decl(file)
 Get file content array declaration.
#define __file_extract_decl(decl, init)
#define __file_init(file)
 Get file content array initialiser.
#define __file_extract_init(decl, init)
#define __file_extract_init_args(...)
#define FILE_ARRAY(file)
 Define a file content array.

Functions

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

Detailed Description

Self-test infrastructure.

Definition in file test.h.

Macro Definition Documentation

◆ SELF_TESTS

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

Self-test table.

Definition at line 29 of file test.h.

Referenced by run_all_tests().

◆ __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,
file,
line )
Value:
test_ok ( success, file, line, #success )
void test_ok(int success, const char *file, unsigned int line, const char *test)
Report test result.
Definition test.c:56

Report test result.

Parameters
successTest succeeded
fileFile name
lineLine number

Definition at line 44 of file test.h.

44#define okx( success, file, line ) \
45 test_ok ( success, file, line, #success )

Referenced by alloc_iob_fail_okx(), alloc_iob_okx(), archive_okx(), asn1_okx(), asr64_okx(), base16_decode_okx(), base16_encode_okx(), base64_decode_okx(), base64_encode_okx(), bigint_add_okx(), bigint_bit_is_set_okx(), bigint_is_geq_okx(), bigint_is_zero_okx(), bigint_max_set_bit_okx(), bigint_mod_exp_okx(), bigint_mod_invert_okx(), bigint_montgomery_okx(), bigint_multiply_okx(), bigint_reduce_okx(), bigint_shl_okx(), bigint_shr_okx(), bigint_subtract_okx(), bigint_swap_okx(), cipher_decrypt_okx(), cipher_encrypt_okx(), cipher_okx(), cms_decrypt_okx(), cms_keypair_okx(), cms_message_okx(), cms_verify_fail_okx(), cms_verify_okx(), cpio_okx(), datauri_fail_okx(), datauri_okx(), deflate_okx(), digest_frag_okx(), dns_compare_fail_okx(), dns_compare_okx(), dns_copy_fail_okx(), dns_copy_okx(), dns_decode_fail_okx(), dns_decode_okx(), dns_encode_fail_okx(), dns_encode_okx(), dns_list_okx(), editstring_okx(), elliptic_add_okx(), elliptic_curve_okx(), elliptic_multiply_okx(), exchange_okx(), ffsl_okx(), ffsll_okx(), flsl_okx(), flsll_okx(), hkdf_okx(), hmac_okx(), inet6_aton_fail_okx(), inet6_aton_okx(), inet6_ntoa_okx(), inet_aton_fail_okx(), inet_aton_okx(), inet_ntoa_okx(), ipv4_route_okx(), ipv6_route_okx(), ipv6_table_okx(), linebuf_accumulated_okx(), linebuf_consume_okx(), linebuf_empty_okx(), linebuf_init_okx(), lsl64_okx(), lsr64_okx(), mschapv2_okx(), ntlm_authenticate_okx(), ntlm_data_okx(), ntlm_key_okx(), peerdist_info_block_okx(), peerdist_info_okx(), peerdist_info_passphrase_okx(), peerdist_info_segment_okx(), pixbuf_okx(), profile_okx(), pubkey_okx(), pubkey_sign_okx(), s64divmod_okx(), setjmp_return_ok(), snprintf_okx(), tcpip_okx(), tcpip_random_okx(), testnet_close_okx(), testnet_okx(), testnet_open_okx(), testnet_remove_okx(), testnet_set_okx(), typeof(), u64divmod_okx(), uri_churi_okx(), uri_dup_okx(), uri_format_okx(), uri_okx(), uri_params_list_okx(), uri_params_okx(), uri_parse_okx(), uri_port_okx(), uri_pxe_okx(), uri_resolve_okx(), uri_resolve_path_okx(), utf8_accumulate_okx(), uuid_aton_fail_okx(), uuid_aton_okx(), uuid_ntoa_okx(), x25519_invert_okx(), x25519_key_okx(), x25519_multiply_okx(), x509_cached_okx(), x509_certificate_okx(), x509_chain_okx(), x509_check_issuer_fail_okx(), x509_check_issuer_okx(), x509_check_name_fail_okx(), x509_check_name_okx(), x509_check_root_fail_okx(), x509_check_root_okx(), x509_check_time_fail_okx(), x509_check_time_okx(), x509_fingerprint_okx(), x509_validate_chain_fail_okx(), and x509_validate_chain_okx().

◆ ok

#define ok ( success)
Value:
okx ( success, __FILE__, __LINE__ )
#define okx(success, file, line)
Report test result.
Definition test.h:44

Definition at line 46 of file test.h.

46#define ok( success ) \
47 okx ( success, __FILE__, __LINE__ )

Referenced by bitops_test_exec(), byteswap_test_exec(), deflate_test_exec(), entropy_sample(), fdt_test_exec(), ipv4_test_exec(), ipv6_test_exec(), list_test_exec(), math_test_exec(), mdio_clause45_links_ok(), memcpy_test_speed(), nap_test_exec(), net80211_filter_hw_channels(), net80211_process_ie(), rdrand_get_noise(), rsn_pick_desc(), settings_test_exec(), string_test_exec(), and x509_test_exec().

◆ BINFILE

#define BINFILE ( ...)
Value:
( [], ( { __VA_ARGS__ } ) )

Define inline binary file content.

Definition at line 50 of file test.h.

Referenced by ARCHIVE_TEST(), ARCHIVE_TEST(), ARCHIVE_TEST(), and ARCHIVE_TEST().

◆ TEXTFILE

#define TEXTFILE ( text)
Value:
( [ sizeof (text) - 1 /* strip NUL */ ], (text) )

Define inline text file content.

Definition at line 53 of file test.h.

Referenced by ARCHIVE_TEST(), ARCHIVE_TEST(), ARCHIVE_TEST(), ARCHIVE_TEST(), ARCHIVE_TEST(), ARCHIVE_TEST(), and ARCHIVE_TEST().

◆ __file_decl

#define __file_decl ( file)
Value:
#define __file_extract_decl(decl, init)
Definition test.h:57

Get file content array declaration.

Definition at line 56 of file test.h.

◆ __file_extract_decl

#define __file_extract_decl ( decl,
init )
Value:
decl

Definition at line 57 of file test.h.

◆ __file_init

#define __file_init ( file)
Value:
#define __file_extract_init(decl, init)
Definition test.h:61

Get file content array initialiser.

Definition at line 60 of file test.h.

◆ __file_extract_init

#define __file_extract_init ( decl,
init )
Value:
#define __file_extract_init_args(...)
Definition test.h:62

Definition at line 61 of file test.h.

◆ __file_extract_init_args

#define __file_extract_init_args ( ...)
Value:
__VA_ARGS__

Definition at line 62 of file test.h.

◆ FILE_ARRAY

#define FILE_ARRAY ( file)
Value:
__file_decl ( file ) = __file_init ( file )
#define __file_decl(file)
Get file content array declaration.
Definition test.h:56
#define __file_init(file)
Get file content array initialiser.
Definition test.h:60

Define a file content array.

Parameters
nameArray name
fileFile content

Definition at line 70 of file test.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ test_ok()

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

Report test result.

Parameters
successTest succeeded
fileTest code file
lineTest code line
testTest code

Definition at line 56 of file test.c.

57 {
58
59 /* Sanity check */
61
62 /* Increment test counter */
63 current_tests->total++;
64
65 /* Report failure if applicable */
66 if ( ! success ) {
67 current_tests->failures++;
68 printf ( "FAILURE: \"%s\" test failed at %s line %d: ( %s )\n",
69 current_tests->name, file, line, test );
70 }
71}
#define NULL
NULL pointer (VOID *).
Definition Base.h:321
#define assert(condition)
Assert a condition at run-time.
Definition assert.h:50
static int test
Definition epic100.c:73
static struct self_test * current_tests
Current self-test set.
Definition test.c:46
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition vsprintf.c:465

References assert, current_tests, NULL, printf(), and test.