The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
Loading...
Searching...
No Matches
Macros | Functions | Variables
value_tests.c File Reference

Tests for value box functions. More...

#include "acutest_common_init.h"
#include "acutest_helpers.h"
#include <freeradius-devel/util/value.h>
+ Include dependency graph for value_tests.c:

Go to the source code of this file.

Macros

#define SAFE_FOR_X   ((fr_value_box_safe_for_t) 0x1000)
 
#define SAFE_FOR_Y   ((fr_value_box_safe_for_t) 0x2000)
 
#define TEST_GLOBAL_INIT   test_init()
 

Functions

static void safe_for_concat_check (fr_type_t type, fr_value_box_safe_for_t const tokens[], size_t num, fr_value_box_safe_for_t expect)
 Concatenate a list into a separate output box and check the resulting safe_for.
 
static void safe_for_list_build (fr_value_box_list_t *list, fr_value_box_safe_for_t const tokens[], size_t num)
 Build a list of single character string boxes, each marked with the matching token.
 
static void test_as_uint64 (void)
 
static void test_asprintf (void)
 
static void test_bstrndup (void)
 
static void test_bstrndup_replace (void)
 
static void test_cast_bool_to_uint32 (void)
 
static void test_cast_float_to_date_bounds (void)
 A float cast to a date must fail when the date does not fit in int64_t nanoseconds.
 
static void test_cast_float_to_int64_bounds (void)
 A float at or past the top of a 64-bit integer must fail the cast, not convert.
 
static void test_cast_in_place_uint32_to_string (void)
 
static void test_cast_in_place_uint32_to_uint64 (void)
 
static void test_cast_int32_to_int64 (void)
 
static void test_cast_octets_to_string_preserves_safe_for (void)
 
static void test_cast_same_type (void)
 
static void test_cast_string_returns_zero (void)
 
static void test_cast_string_to_octets_preserves_safe_for (void)
 
static void test_cast_string_to_uint32 (void)
 
static void test_cast_uint32_to_bool (void)
 
static void test_cast_uint32_to_string (void)
 
static void test_cast_uint32_to_string_clears_safe_for (void)
 
static void test_cast_uint32_to_uint64 (void)
 
static void test_cast_uint8_to_uint32 (void)
 
static void test_clear (void)
 
static void test_clear_string (void)
 
static void test_cmp_bool (void)
 
static void test_cmp_different_types (void)
 
static void test_cmp_float64 (void)
 
static void test_cmp_int32 (void)
 
static void test_cmp_octets (void)
 
static void test_cmp_octets_length (void)
 
static void test_cmp_op_eq (void)
 
static void test_cmp_op_ge (void)
 
static void test_cmp_op_gt (void)
 
static void test_cmp_op_le (void)
 
static void test_cmp_op_lt (void)
 
static void test_cmp_op_ne (void)
 
static void test_cmp_string (void)
 
static void test_cmp_uint32_equal (void)
 
static void test_cmp_uint32_less (void)
 
static void test_concat_any_any_is_any (void)
 
static void test_concat_any_x_is_x (void)
 
static void test_concat_into_head_x_x_is_x (void)
 The list head doubles as the output box.
 
static void test_concat_octets_x_x_is_x (void)
 
static void test_concat_x_any_is_x (void)
 
static void test_concat_x_none_is_none (void)
 
static void test_concat_x_x_is_x (void)
 
static void test_concat_x_y_is_none (void)
 
static void test_copy_octets (void)
 
static void test_copy_preserves_safe_for (void)
 
static void test_copy_preserves_tainted (void)
 
static void test_copy_string (void)
 
static void test_copy_uint32 (void)
 
static void test_escape_in_place_func_cast (void)
 
static void test_escape_in_place_func_string (void)
 
static void test_escape_in_place_func_unchanged (void)
 
static void test_from_str_bool (void)
 
static void test_from_str_float64 (void)
 
static void test_from_str_int32 (void)
 
static void test_from_str_octets (void)
 
static void test_from_str_string (void)
 
static void test_from_str_uint32 (void)
 
static void test_hash_different_values (void)
 
static void test_hash_same_values (void)
 
static void test_hash_string (void)
 
static void test_increment_int32 (void)
 
static void test_increment_uint32 (void)
 
static void test_increment_uint8_overflow (void)
 
static void test_init (void)
 
static void test_list_safety_merge (void)
 
static void test_memdup (void)
 
static void test_network_bool (void)
 
static void test_network_int32 (void)
 
static void test_network_ipv6addr_scope_id (void)
 The scope_id of an IPv6 address is one byte on the wire, not the four bytes of fr_ipaddr_t.scope_id.
 
static void test_network_length (void)
 
static void test_network_uint32 (void)
 
static void test_network_uint64 (void)
 
static fr_slen_t test_percent_escape (fr_sbuff_t *out, fr_sbuff_t *in)
 Escape function for the in-place escape tests, writes '' as "%25".
 
static void test_print_bool (void)
 
static void test_print_int32_negative (void)
 
static void test_print_octets (void)
 
static void test_print_string (void)
 
static void test_print_uint32 (void)
 
static void test_round_trip_bool (void)
 
static void test_round_trip_int64 (void)
 
static void test_round_trip_network_uint32 (void)
 
static void test_round_trip_uint32 (void)
 
static void test_strdup (void)
 
static void test_tainted_flag (void)
 
static void test_truthy_bool (void)
 
static void test_truthy_octets (void)
 
static void test_truthy_string (void)
 
static void test_truthy_uint32 (void)
 

Variables

static TALLOC_CTX * autofree
 
 TEST_LIST
 

Detailed Description

Tests for value box functions.

Definition in file value_tests.c.

Macro Definition Documentation

◆ SAFE_FOR_X

#define SAFE_FOR_X   ((fr_value_box_safe_for_t) 0x1000)

Definition at line 568 of file value_tests.c.

◆ SAFE_FOR_Y

#define SAFE_FOR_Y   ((fr_value_box_safe_for_t) 0x2000)

Definition at line 569 of file value_tests.c.

◆ TEST_GLOBAL_INIT

#define TEST_GLOBAL_INIT   test_init()

Definition at line 24 of file value_tests.c.

Function Documentation

◆ safe_for_concat_check()

static void safe_for_concat_check ( fr_type_t  type,
fr_value_box_safe_for_t const  tokens[],
size_t  num,
fr_value_box_safe_for_t  expect 
)
static

Concatenate a list into a separate output box and check the resulting safe_for.

Definition at line 656 of file value_tests.c.

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

◆ safe_for_list_build()

static void safe_for_list_build ( fr_value_box_list_t *  list,
fr_value_box_safe_for_t const  tokens[],
size_t  num 
)
static

Build a list of single character string boxes, each marked with the matching token.

Definition at line 638 of file value_tests.c.

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

◆ test_as_uint64()

static void test_as_uint64 ( void  )
static

Definition at line 956 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_asprintf()

static void test_asprintf ( void  )
static

Definition at line 793 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_bstrndup()

static void test_bstrndup ( void  )
static

Definition at line 804 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_bstrndup_replace()

static void test_bstrndup_replace ( void  )
static

Definition at line 1419 of file value_tests.c.

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

◆ test_cast_bool_to_uint32()

static void test_cast_bool_to_uint32 ( void  )
static

Definition at line 442 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cast_float_to_date_bounds()

static void test_cast_float_to_date_bounds ( void  )
static

A float cast to a date must fail when the date does not fit in int64_t nanoseconds.

A date is a signed 64-bit count of nanoseconds, which holds about 9.2e9 seconds. The float branches converted the seconds to int64_t and multiplied by NSEC. The float32 branch had no check, the float64 branch checked after a conversion that was already undefined above 2^63, and a value in the last second before the bound overflowed when the fraction was added.

Definition at line 313 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cast_float_to_int64_bounds()

static void test_cast_float_to_int64_bounds ( void  )
static

A float at or past the top of a 64-bit integer must fail the cast, not convert.

UINT64_MAX and INT64_MAX are not representable as a double, and round up to 2^64 and 2^63. A source of exactly 2^64 or 2^63 passed a "greater than the maximum" check, and the conversion to the integer type was undefined.

Definition at line 273 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cast_in_place_uint32_to_string()

static void test_cast_in_place_uint32_to_string ( void  )
static

Definition at line 486 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cast_in_place_uint32_to_uint64()

static void test_cast_in_place_uint32_to_uint64 ( void  )
static

Definition at line 475 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cast_int32_to_int64()

static void test_cast_int32_to_int64 ( void  )
static

Definition at line 406 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cast_octets_to_string_preserves_safe_for()

static void test_cast_octets_to_string_preserves_safe_for ( void  )
static

Definition at line 586 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cast_same_type()

static void test_cast_same_type ( void  )
static

Definition at line 430 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cast_string_returns_zero()

static void test_cast_string_returns_zero ( void  )
static

Definition at line 373 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cast_string_to_octets_preserves_safe_for()

static void test_cast_string_to_octets_preserves_safe_for ( void  )
static

Definition at line 603 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cast_string_to_uint32()

static void test_cast_string_to_uint32 ( void  )
static

Definition at line 354 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cast_uint32_to_bool()

static void test_cast_uint32_to_bool ( void  )
static

Definition at line 457 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cast_uint32_to_string()

static void test_cast_uint32_to_string ( void  )
static

Definition at line 340 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cast_uint32_to_string_clears_safe_for()

static void test_cast_uint32_to_string_clears_safe_for ( void  )
static

Definition at line 620 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cast_uint32_to_uint64()

static void test_cast_uint32_to_uint64 ( void  )
static

Definition at line 255 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cast_uint8_to_uint32()

static void test_cast_uint8_to_uint32 ( void  )
static

Definition at line 418 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_clear()

static void test_clear ( void  )
static

Definition at line 979 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_clear_string()

static void test_clear_string ( void  )
static

Definition at line 990 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cmp_bool()

static void test_cmp_bool ( void  )
static

Definition at line 146 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cmp_different_types()

static void test_cmp_different_types ( void  )
static

Definition at line 160 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cmp_float64()

static void test_cmp_float64 ( void  )
static

Definition at line 85 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cmp_int32()

static void test_cmp_int32 ( void  )
static

Definition at line 71 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cmp_octets()

static void test_cmp_octets ( void  )
static

Definition at line 117 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cmp_octets_length()

static void test_cmp_octets_length ( void  )
static

Definition at line 131 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cmp_op_eq()

static void test_cmp_op_eq ( void  )
static

Definition at line 175 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cmp_op_ge()

static void test_cmp_op_ge ( void  )
static

Definition at line 238 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cmp_op_gt()

static void test_cmp_op_gt ( void  )
static

Definition at line 213 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cmp_op_le()

static void test_cmp_op_le ( void  )
static

Definition at line 224 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cmp_op_lt()

static void test_cmp_op_lt ( void  )
static

Definition at line 201 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cmp_op_ne()

static void test_cmp_op_ne ( void  )
static

Definition at line 188 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cmp_string()

static void test_cmp_string ( void  )
static

Definition at line 99 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cmp_uint32_equal()

static void test_cmp_uint32_equal ( void  )
static

Definition at line 50 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_cmp_uint32_less()

static void test_cmp_uint32_less ( void  )
static

Definition at line 60 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_concat_any_any_is_any()

static void test_concat_any_any_is_any ( void  )
static

Definition at line 675 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_concat_any_x_is_x()

static void test_concat_any_x_is_x ( void  )
static

Definition at line 696 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_concat_into_head_x_x_is_x()

static void test_concat_into_head_x_x_is_x ( void  )
static

The list head doubles as the output box.

Definition at line 726 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_concat_octets_x_x_is_x()

static void test_concat_octets_x_x_is_x ( void  )
static

Definition at line 717 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_concat_x_any_is_x()

static void test_concat_x_any_is_x ( void  )
static

Definition at line 689 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_concat_x_none_is_none()

static void test_concat_x_none_is_none ( void  )
static

Definition at line 710 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_concat_x_x_is_x()

static void test_concat_x_x_is_x ( void  )
static

Definition at line 682 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_concat_x_y_is_none()

static void test_concat_x_y_is_none ( void  )
static

Definition at line 703 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_copy_octets()

static void test_copy_octets ( void  )
static

Definition at line 532 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_copy_preserves_safe_for()

static void test_copy_preserves_safe_for ( void  )
static

Definition at line 571 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_copy_preserves_tainted()

static void test_copy_preserves_tainted ( void  )
static

Definition at line 551 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_copy_string()

static void test_copy_string ( void  )
static

Definition at line 514 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_copy_uint32()

static void test_copy_uint32 ( void  )
static

Definition at line 502 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_escape_in_place_func_cast()

static void test_escape_in_place_func_cast ( void  )
static

Definition at line 1481 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_escape_in_place_func_string()

static void test_escape_in_place_func_string ( void  )
static

Definition at line 1447 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_escape_in_place_func_unchanged()

static void test_escape_in_place_func_unchanged ( void  )
static

Definition at line 1465 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_from_str_bool()

static void test_from_str_bool ( void  )
static

Definition at line 1279 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_from_str_float64()

static void test_from_str_float64 ( void  )
static

Definition at line 1289 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_from_str_int32()

static void test_from_str_int32 ( void  )
static

Definition at line 1268 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_from_str_octets()

static void test_from_str_octets ( void  )
static

Definition at line 1300 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_from_str_string()

static void test_from_str_string ( void  )
static

Definition at line 1313 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_from_str_uint32()

static void test_from_str_uint32 ( void  )
static

Definition at line 1257 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_hash_different_values()

static void test_hash_different_values ( void  )
static

Definition at line 846 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_hash_same_values()

static void test_hash_same_values ( void  )
static

Definition at line 836 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_hash_string()

static void test_hash_string ( void  )
static

Definition at line 856 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_increment_int32()

static void test_increment_int32 ( void  )
static

Definition at line 943 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_increment_uint32()

static void test_increment_uint32 ( void  )
static

Definition at line 923 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_increment_uint8_overflow()

static void test_increment_uint8_overflow ( void  )
static

Definition at line 933 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_init()

static void test_init ( void  )
static

Definition at line 33 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_list_safety_merge()

static void test_list_safety_merge ( void  )
static

Definition at line 744 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_memdup()

static void test_memdup ( void  )
static

Definition at line 820 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_network_bool()

static void test_network_bool ( void  )
static

Definition at line 1138 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_network_int32()

static void test_network_int32 ( void  )
static

Definition at line 1111 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_network_ipv6addr_scope_id()

static void test_network_ipv6addr_scope_id ( void  )
static

The scope_id of an IPv6 address is one byte on the wire, not the four bytes of fr_ipaddr_t.scope_id.

Definition at line 1050 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_network_length()

static void test_network_length ( void  )
static

Definition at line 1159 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_network_uint32()

static void test_network_uint32 ( void  )
static

Definition at line 1018 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_network_uint64()

static void test_network_uint64 ( void  )
static

Definition at line 1086 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_percent_escape()

static fr_slen_t test_percent_escape ( fr_sbuff_t *  out,
fr_sbuff_t *  in 
)
static

Escape function for the in-place escape tests, writes '' as "%25".

Definition at line 1399 of file value_tests.c.

+ Here is the caller graph for this function:

◆ test_print_bool()

static void test_print_bool ( void  )
static

Definition at line 1220 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_print_int32_negative()

static void test_print_int32_negative ( void  )
static

Definition at line 1192 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_print_octets()

static void test_print_octets ( void  )
static

Definition at line 1239 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_print_string()

static void test_print_string ( void  )
static

Definition at line 1205 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_print_uint32()

static void test_print_uint32 ( void  )
static

Definition at line 1179 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_round_trip_bool()

static void test_round_trip_bool ( void  )
static

Definition at line 1360 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_round_trip_int64()

static void test_round_trip_int64 ( void  )
static

Definition at line 1344 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_round_trip_network_uint32()

static void test_round_trip_network_uint32 ( void  )
static

Definition at line 1376 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_round_trip_uint32()

static void test_round_trip_uint32 ( void  )
static

Definition at line 1328 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_strdup()

static void test_strdup ( void  )
static

Definition at line 781 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_tainted_flag()

static void test_tainted_flag ( void  )
static

Definition at line 1004 of file value_tests.c.

◆ test_truthy_bool()

static void test_truthy_bool ( void  )
static

Definition at line 872 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_truthy_octets()

static void test_truthy_octets ( void  )
static

Definition at line 907 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_truthy_string()

static void test_truthy_string ( void  )
static

Definition at line 894 of file value_tests.c.

+ Here is the call graph for this function:

◆ test_truthy_uint32()

static void test_truthy_uint32 ( void  )
static

Definition at line 883 of file value_tests.c.

+ Here is the call graph for this function:

Variable Documentation

◆ autofree

TALLOC_CTX* autofree
static

Definition at line 31 of file value_tests.c.

◆ TEST_LIST

TEST_LIST

Definition at line 1497 of file value_tests.c.