Macros | Functions | Variables
TEST: Testsuite

The tests can be executed with "make test". More...

Macros

#define TEST_TAB   " "
 Tabulator to indent messages from test programs.
 
#define TEST_PERM   (posix_mode_t) (POSIX_S_IRUSR | POSIX_S_IWUSR)
 Permissions for test files.
 
#define CHECK_RV(rv)
 Check return value of test. More...
 
#define SKIP_TEST(s)
 Skip test and print info message. More...
 
#define TEST_CMPR_USE_NETWORK   0
 Use real network connection to echo daemon instead of regular file.
 

Functions

void ts_environ_init (void)
 Copy environment variables. More...
 
void ts_environ_exit (void)
 Destroy copy of environment variables. More...
 
void print_error (const char *msg)
 Print error message. More...
 
int main (int argc, char **argv)
 Test entry point. More...
 
int test_base64 (void)
 Test enc_mime_encode_base64() implementation. More...
 
int test_cancellock (void)
 Test core_get_cancel_lock() implementation. More...
 
int test_compression (void)
 Test cmpr_send() and cmpr_recv() implementation. More...
 
int test_inet_pton (void)
 Test posix_inet_pton() implementation. More...
 
int test_regex (void)
 Test posix_regcomp() and posix_regexec() implementation. More...
 
int test_snprintf (void)
 Test posix_snprintf() implementation. More...
 
int test_strcasecmp_l (void)
 Test posix_strcasecmp_l() implementation. More...
 
int test_timestamp (void)
 Test enc_timestamp_decode() implementation. More...
 
int test_unicode (void)
 Test enc_convert_to_utf8_nfc() implementation. More...
 

Variables

int main_debug = 0
 Enable additional debug output if nonzero.
 
const char * main_confprefix = NULL
 Configuration directory path from command line option (always NULL ) More...
 

Detailed Description

The tests can be executed with "make test".

Macro Definition Documentation

◆ CHECK_RV

#define CHECK_RV (   rv)
Value:
{ \
std::clog << std::flush; \
if(rv) \
{ \
std::cout << "A problem was detected!" << std::endl << std::flush; \
} \
else { std::cout << "OK" << std::endl << std::flush; } \
if(!res && rv) { res = rv; } \
}

Check return value of test.

Definition at line 48 of file test.cxx.

◆ SKIP_TEST

#define SKIP_TEST (   s)
Value:
{ \
std::cout << "Skipped (" << s << ")" << std::endl << std::flush; \
}

Skip test and print info message.

Definition at line 61 of file test.cxx.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Test entry point.

Parameters
[in]argcNumber of command line arguments
[in]argvArray containing command line argument strings

Exit status of program:

  • EXIT_SUCCESS on success
  • EXIT_FAILURE on error

Definition at line 124 of file test.cxx.

References ts_environ_init().

◆ print_error()

void print_error ( const char *  msg)

Print error message.

Exported as C style function

Parameters
[in]msgMessage to display on stderr

Definition at line 99 of file test.cxx.

Referenced by test_inet_pton(), test_snprintf(), and test_strcasecmp_l().

◆ test_base64()

int test_base64 ( void  )

Test enc_mime_encode_base64() implementation.

The following cases are tested:

  • Data size is a multiple of 3 bytes
  • One padding character required
  • Two padding characters required
Returns
  • EXIT_SUCCESS on success
  • EXIT_FAILURE on error

Definition at line 39 of file test_base64.c.

◆ test_cancellock()

int test_cancellock ( void  )

Test core_get_cancel_lock() implementation.

The following cases are tested:

  • Three different Message-ID/Secret pairs for Cancel-Lock with scheme SHA1
Returns
  • EXIT_SUCCESS on success
  • EXIT_FAILURE on error

Definition at line 38 of file test_cancellock.c.

◆ test_compression()

int test_compression ( void  )

Test cmpr_send() and cmpr_recv() implementation.

The following cases are tested:

  • Loopback test with DEFLATE algorithm
Returns
  • EXIT_SUCCESS on success
  • EXIT_FAILURE on error

Definition at line 82 of file test_compression.c.

◆ test_inet_pton()

int test_inet_pton ( void  )

Test posix_inet_pton() implementation.

The following cases are tested:

  • Valid IPv4 address with maximum length
  • Valid IPv4 address with minimum length
  • Invalid IPv4 address (must be rejected)
Returns
  • EXIT_SUCCESS on success
  • EXIT_FAILURE on error

Definition at line 40 of file test_inet_pton.c.

References print_error(), and TEST_TAB.

◆ test_regex()

int test_regex ( void  )

Test posix_regcomp() and posix_regexec() implementation.

The following cases are tested:

  • Single field with arbitrary characters
  • Literal dot character
  • Bracket expression (first element)
  • Bracket expression (second element)
  • Start and end of line
Returns
  • EXIT_SUCCESS on success
  • EXIT_FAILURE on error

Definition at line 79 of file test_regex.c.

◆ test_snprintf()

int test_snprintf ( void  )

Test posix_snprintf() implementation.

The following cases are tested:

  • Literal percent conversion
  • Signed integer conversion with long modifier
  • Unsigned integer conversion with long modifier
  • Unsigned integer conversion to hex
  • Unsigned integer conversion to hex with long modifier
  • Minimum field width padding with unsigned integer conversion
  • Minimum field width zero padding with signed long integer conversion (on negative value)
  • Minimum field width padding with signed long integer conversion (on negative value)
  • Zero signed value without padding
  • Zero unsigned value without padding
  • Truncation of output
  • Zero length (C99/POSIX.1-2001/SUSv4 semantics)
  • Zero length and NULL pointer for buffer (C99/POSIX.1-2001/SUSv4 semantics)
Returns
  • EXIT_SUCCESS on success
  • EXIT_FAILURE on error

Definition at line 50 of file test_snprintf.c.

References print_error(), and TEST_TAB.

◆ test_strcasecmp_l()

int test_strcasecmp_l ( void  )

Test posix_strcasecmp_l() implementation.

The following cases are tested using POSIX locale:

  • Identical ASCII strings (equal, trivial case)
  • Different strings with same length (not equal)
  • First string longer (not equal)
  • Second string longer (not equal)
  • Strings that only differ in case of ASCII letters (equal)
  • Unicode strings with non-ASCII characters that only differ in their case (not equal in POSIX locale)
Returns
  • EXIT_SUCCESS on success
  • EXIT_FAILURE on error

Definition at line 44 of file test_strcasecmp_l.c.

References print_error(), and TEST_TAB.

◆ test_timestamp()

int test_timestamp ( void  )

Test enc_timestamp_decode() implementation.

The following cases are tested:

  • One second after epoche with timezone "+0000"
  • One second after epoche with timezone "GMT"
  • First second of Y2K using timezone "Z"
  • Optional day of week and timezone "-0400"
  • Optional day of week and timezone "+0200"
  • Obsolete timezone "PDT"
  • Leap year, leap second and timezone "+0131" (with nonzero minutes)
  • Time of day without optional seconds and obsolete timezone "UT"
Returns
  • EXIT_SUCCESS on success
  • EXIT_FAILURE on error

Definition at line 44 of file test_timestamp.c.

◆ test_unicode()

int test_unicode ( void  )

Test enc_convert_to_utf8_nfc() implementation.

Note
The UTF-7 transformation format use base64 encoded UTF-16BE as internal representation. Therefore all Unicode codepoints beyond the BMP must be encoded using surrogate codepoints (that are forbidden in UTF-8).

Part 1: The following cases are tested:

  • ASCII only (trivial)
  • Unicode already in NFC normalization (NFC quick check)
  • Unicode precomposed but with composition exception (requires lookup table)
  • Unicode with NFD normalization (trivial canonical composition)
  • Unicode with noncanonical order A (canonical reordering and composition)
  • Unicode with noncanonical order B (canonical reordering)
  • Unicode singleton (decomposition to another single codepoint)
  • Unicode algorithmic composition (used for hangul syllables)
  • UTF-7 to UTF-8 conversion (and conversion from NFD to NFC normalization)
  • UTF-7 to UTF-8 conversion (with codepoint that require surrogate pair)
  • UTF-7 to UTF-8 conversion (shift sequence terminated by SP or end-of-data)

Part2: The Unicode normalization conformance test data file is used.

Note
For part 2 all test strings are prepended with a space because our normalization implementation will intentionally strip "defective combining character sequences" at the start of strings (even if they are not "ill-formed" according to the standard).
Returns
  • EXIT_SUCCESS on success
  • EXIT_FAILURE on error

Definition at line 347 of file test_unicode.c.

◆ ts_environ_exit()

void ts_environ_exit ( void  )

Destroy copy of environment variables.

Call this function once after last use of ts_getenv() .

Definition at line 107 of file ts_functions.c.

◆ ts_environ_init()

void ts_environ_init ( void  )

Copy environment variables.

Must be called once before ts_getenv() is used and before additional threads are created.

Definition at line 58 of file ts_functions.c.

Referenced by main().

Variable Documentation

◆ main_confprefix

const char* main_confprefix = NULL

Configuration directory path from command line option (always NULL )

Configuration directory path from command line option or NULL otherwise.

Definition at line 76 of file test.cxx.

Referenced by xdg_get_confdir().


Generated at 2024-04-27 using  doxygen