The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
Loading...
Searching...
No Matches
Typedefs | Functions | Variables
dbuff_tests.c File Reference
#include "acutest.h"
#include "acutest_helpers.h"
#include <float.h>
#include <freeradius-devel/util/dbuff.h>
+ Include dependency graph for dbuff_tests.c:

Go to the source code of this file.

Typedefs

typedef void(* fr_dbuff_fd_test_body) (fr_dbuff_t *dbuff, uint8_t const data[])
 

Functions

static void fd_body (fr_dbuff_t *dbuff, uint8_t const data[])
 
static void max_body (fr_dbuff_t *dbuff, uint8_t const data[])
 
static void test_dbuff_advance_extend (void)
 Test fr_dbuff_advance_extend against a talloc-backed (extensible) dbuff.
 
static void test_dbuff_child (void)
 Test the child-dbuff macros: FR_DBUFF, FR_DBUFF_ABS, FR_DBUFF_BIND_CURRENT, FR_DBUFF_BIND_CURRENT_ABS, FR_DBUFF_BIND_END_ABS and FR_DBUFF_MAX.
 
static void test_dbuff_extend (void)
 Test the extension-request API: fr_dbuff_extend, fr_dbuff_extend_lowat, fr_dbuff_is_extendable and fr_dbuff_was_extended.
 
static void test_dbuff_fd (void)
 
static void test_dbuff_fd_max (void)
 
static void test_dbuff_fd_shell (fr_dbuff_fd_test_body body, uint8_t const data[], size_t datasize, uint8_t buff[], size_t buffsize, size_t max)
 
static void test_dbuff_in_memcpy (void)
 Test fr_dbuff_in_memcpy, fr_dbuff_in_memcpy_partial and fr_dbuff_in_bytes_partial.
 
static void test_dbuff_init (void)
 
static void test_dbuff_init_no_parent (void)
 
static void test_dbuff_marker_release (void)
 Test fr_dbuff_marker_release, fr_dbuff_marker_release_behind and _ahead.
 
static void test_dbuff_max (void)
 
static void test_dbuff_measure (void)
 Test the measurement / accessor macros against both a dbuff and a marker.
 
static void test_dbuff_memset (void)
 Test fr_dbuff_memset.
 
static void test_dbuff_move (void)
 
static void test_dbuff_net_encode (void)
 Test the various dbuff_net_encode() functions and macros.
 
static void test_dbuff_no_advance (void)
 
static void test_dbuff_out (void)
 Test functions that read from dbuffs.
 
static void test_dbuff_out_int64v (void)
 Test fr_dbuff_out_int64v, which sign-extends based on the most significant bit.
 
static void test_dbuff_set (void)
 Test fr_dbuff_set (by size_t, pointer, marker) and fr_dbuff_set_end.
 
static void test_dbuff_shift (void)
 Test fr_dbuff_shift moves unconsumed content to the front of the buffer.
 
static void test_dbuff_talloc_extend (void)
 Test extensible dbuffs.
 
static void test_dbuff_talloc_extend_multi_level (void)
 
static void test_dbuff_tmp (void)
 Test FR_DBUFF_TMP, the compound-literal dbuff.
 
static void test_dbuff_trim_reset_talloc (void)
 Test fr_dbuff_trim_talloc, fr_dbuff_reset_talloc and fr_dbuff_free_talloc.
 
static void test_dbuff_update (void)
 Test fr_dbuff_update repoints the dbuff and its markers after a buffer move.
 

Variables

 TEST_LIST
 

Typedef Documentation

◆ fr_dbuff_fd_test_body

typedef void(* fr_dbuff_fd_test_body) (fr_dbuff_t *dbuff, uint8_t const data[])

Definition at line 10 of file dbuff_tests.c.

Function Documentation

◆ fd_body()

static void fd_body ( fr_dbuff_t dbuff,
uint8_t const  data[] 
)
static

Definition at line 350 of file dbuff_tests.c.

+ Here is the caller graph for this function:

◆ max_body()

static void max_body ( fr_dbuff_t dbuff,
uint8_t const  data[] 
)
static

Definition at line 379 of file dbuff_tests.c.

+ Here is the caller graph for this function:

◆ test_dbuff_advance_extend()

static void test_dbuff_advance_extend ( void  )
static

Test fr_dbuff_advance_extend against a talloc-backed (extensible) dbuff.

Definition at line 663 of file dbuff_tests.c.

+ Here is the call graph for this function:

◆ test_dbuff_child()

static void test_dbuff_child ( void  )
static

Test the child-dbuff macros: FR_DBUFF, FR_DBUFF_ABS, FR_DBUFF_BIND_CURRENT, FR_DBUFF_BIND_CURRENT_ABS, FR_DBUFF_BIND_END_ABS and FR_DBUFF_MAX.

These differ only in where the child's 'start' pointer is set (parent 'current' vs parent 'start') and whether writing to the child advances the parent's 'current' pointer, 'end' pointer, or neither.

Definition at line 515 of file dbuff_tests.c.

◆ test_dbuff_extend()

static void test_dbuff_extend ( void  )
static

Test the extension-request API: fr_dbuff_extend, fr_dbuff_extend_lowat, fr_dbuff_is_extendable and fr_dbuff_was_extended.

Definition at line 908 of file dbuff_tests.c.

+ Here is the call graph for this function:

◆ test_dbuff_fd()

static void test_dbuff_fd ( void  )
static

Definition at line 369 of file dbuff_tests.c.

+ Here is the call graph for this function:

◆ test_dbuff_fd_max()

static void test_dbuff_fd_max ( void  )
static

Definition at line 394 of file dbuff_tests.c.

+ Here is the call graph for this function:

◆ test_dbuff_fd_shell()

static void test_dbuff_fd_shell ( fr_dbuff_fd_test_body  body,
uint8_t const  data[],
size_t  datasize,
uint8_t  buff[],
size_t  buffsize,
size_t  max 
)
static

Definition at line 332 of file dbuff_tests.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ test_dbuff_in_memcpy()

static void test_dbuff_in_memcpy ( void  )
static

Test fr_dbuff_in_memcpy, fr_dbuff_in_memcpy_partial and fr_dbuff_in_bytes_partial.

Definition at line 704 of file dbuff_tests.c.

◆ test_dbuff_init()

static void test_dbuff_init ( void  )
static

Definition at line 12 of file dbuff_tests.c.

◆ test_dbuff_init_no_parent()

static void test_dbuff_init_no_parent ( void  )
static

Definition at line 39 of file dbuff_tests.c.

◆ test_dbuff_marker_release()

static void test_dbuff_marker_release ( void  )
static

Test fr_dbuff_marker_release, fr_dbuff_marker_release_behind and _ahead.

Definition at line 762 of file dbuff_tests.c.

+ Here is the call graph for this function:

◆ test_dbuff_max()

static void test_dbuff_max ( void  )
static

Definition at line 49 of file dbuff_tests.c.

◆ test_dbuff_measure()

static void test_dbuff_measure ( void  )
static

Test the measurement / accessor macros against both a dbuff and a marker.

Covers fr_dbuff_len, fr_dbuff_buff, fr_dbuff_end, fr_dbuff_ptr, fr_dbuff_behind and fr_dbuff_ahead, which the existing tests never touch.

Definition at line 586 of file dbuff_tests.c.

+ Here is the call graph for this function:

◆ test_dbuff_memset()

static void test_dbuff_memset ( void  )
static

Test fr_dbuff_memset.

Definition at line 686 of file dbuff_tests.c.

◆ test_dbuff_move()

static void test_dbuff_move ( void  )
static

Definition at line 221 of file dbuff_tests.c.

+ Here is the call graph for this function:

◆ test_dbuff_net_encode()

static void test_dbuff_net_encode ( void  )
static

Test the various dbuff_net_encode() functions and macros.

Note
Passing constants to fr_dbuff_in() as it is written results in warnings about narrowing casts on the constants–but those casts are in the underlying inlined fr_nbo_from*() functions. They have to be there; that's how those functions work. (The tests worked despite the warnings.) Using variables avoids the warnings, at least with the compile options the build system uses by default.

Definition at line 75 of file dbuff_tests.c.

+ Here is the call graph for this function:

◆ test_dbuff_no_advance()

static void test_dbuff_no_advance ( void  )
static

Definition at line 201 of file dbuff_tests.c.

◆ test_dbuff_out()

static void test_dbuff_out ( void  )
static

Test functions that read from dbuffs.

Definition at line 407 of file dbuff_tests.c.

+ Here is the call graph for this function:

◆ test_dbuff_out_int64v()

static void test_dbuff_out_int64v ( void  )
static

Test fr_dbuff_out_int64v, which sign-extends based on the most significant bit.

Definition at line 794 of file dbuff_tests.c.

◆ test_dbuff_set()

static void test_dbuff_set ( void  )
static

Test fr_dbuff_set (by size_t, pointer, marker) and fr_dbuff_set_end.

The backing array is deliberately larger than the dbuff window so that we can form a pointer past the dbuff 'end' without forming a pointer outside the real allocation (which would be undefined behaviour).

Definition at line 628 of file dbuff_tests.c.

+ Here is the call graph for this function:

◆ test_dbuff_shift()

static void test_dbuff_shift ( void  )
static

Test fr_dbuff_shift moves unconsumed content to the front of the buffer.

Definition at line 822 of file dbuff_tests.c.

+ Here is the call graph for this function:

◆ test_dbuff_talloc_extend()

static void test_dbuff_talloc_extend ( void  )
static

Test extensible dbuffs.

Definition at line 266 of file dbuff_tests.c.

+ Here is the call graph for this function:

◆ test_dbuff_talloc_extend_multi_level()

static void test_dbuff_talloc_extend_multi_level ( void  )
static

Definition at line 300 of file dbuff_tests.c.

+ Here is the call graph for this function:

◆ test_dbuff_tmp()

static void test_dbuff_tmp ( void  )
static

Test FR_DBUFF_TMP, the compound-literal dbuff.

Definition at line 891 of file dbuff_tests.c.

◆ test_dbuff_trim_reset_talloc()

static void test_dbuff_trim_reset_talloc ( void  )
static

Test fr_dbuff_trim_talloc, fr_dbuff_reset_talloc and fr_dbuff_free_talloc.

Definition at line 862 of file dbuff_tests.c.

+ Here is the call graph for this function:

◆ test_dbuff_update()

static void test_dbuff_update ( void  )
static

Test fr_dbuff_update repoints the dbuff and its markers after a buffer move.

Definition at line 839 of file dbuff_tests.c.

+ Here is the call graph for this function:

Variable Documentation

◆ TEST_LIST

TEST_LIST

Definition at line 937 of file dbuff_tests.c.