![]() |
The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
|
Tests for a generic string buffer structure for string printing and parsing. More...
#include "acutest_common_init.h"#include "acutest_helpers.h"#include <freeradius-devel/util/sbuff.h>
Include dependency graph for sbuff_tests.c:Go to the source code of this file.
Macros | |
| #define | PATTERN_LEN (sizeof(PATTERN) - 1) |
| #define | TEST_SBUFF_LEN(_sbuff, _num) |
| #define | TEST_SBUFF_USED(_sbuff, _num) |
Functions | |
| static void | test_adv_past_allowed (void) |
| static void | test_adv_past_str (void) |
| static void | test_adv_past_strcase (void) |
| static void | test_adv_past_whitespace (void) |
| static void | test_adv_to_chr (void) |
| static void | test_adv_to_str (void) |
| static void | test_adv_to_strcase (void) |
| static void | test_adv_to_utf8 (void) |
| static void | test_adv_until (void) |
| static void | test_bstrncpy (void) |
| static void | test_bstrncpy_allowed (void) |
| static void | test_bstrncpy_exact (void) |
| static void | test_bstrncpy_until (void) |
| static void | test_eof_terminal (void) |
| static void | test_file_extend (void) |
| static void | test_file_extend_error (void) |
| A read error on the file backing an sbuff is reported, not treated as the end of the input. | |
| static void | test_file_extend_max (void) |
| static void | test_is_char (void) |
| static void | test_marker_update_end (void) |
| static void | test_marker_update_end_after_shift (void) |
| Check that the budget is measured with fr_sbuff_used_total(), not fr_sbuff_used() | |
| static void | test_next_if_char (void) |
| static void | test_next_unless_char (void) |
| static void | test_no_advance (void) |
| static void | test_out_bool (void) |
| static void | test_out_float (void) |
| static void | test_out_int (void) |
| static void | test_out_uint (void) |
| static void | test_parse_init (void) |
| static void | test_shift_used_accounting (void) |
| static void | test_talloc_extend (void) |
| static void | test_talloc_extend_init_zero (void) |
| static void | test_talloc_extend_multi_level (void) |
| static void | test_talloc_extend_with_marker (void) |
| static void | test_talloc_extend_with_shift (void) |
| static void | test_terminal_merge (void) |
| static void | test_terminal_search_at_end_no_overrun (void) |
| static void | test_terminal_search_past_visible_end (void) |
| static void | test_unescape_multi_char_terminals (void) |
| static void | test_unescape_until (void) |
| static void | test_unescape_until_escape_bounds (void) |
| Check that a hex or octal escape sequence cannot consume more input than "len" allows. | |
Variables | |
| static bool | allow_lowercase_and_space [SBUFF_CHAR_CLASS] |
| static bool | allow_lowercase_and_space_no_t [SBUFF_CHAR_CLASS] |
| TEST_LIST | |
Tests for a generic string buffer structure for string printing and parsing.
Definition in file sbuff_tests.c.
| #define PATTERN_LEN (sizeof(PATTERN) - 1) |
| #define TEST_SBUFF_LEN | ( | _sbuff, | |
| _num | |||
| ) |
Definition at line 28 of file sbuff_tests.c.
| #define TEST_SBUFF_USED | ( | _sbuff, | |
| _num | |||
| ) |
Definition at line 37 of file sbuff_tests.c.
|
static |
|
static |
|
static |
|
static |
Definition at line 1907 of file sbuff_tests.c.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
A read error on the file backing an sbuff is reported, not treated as the end of the input.
Reading from a stream opened for writing fails, which sets the stream's error indicator without reaching EOF.
Definition at line 1700 of file sbuff_tests.c.
Here is the call graph for this function:
|
static |
|
static |
Definition at line 73 of file sbuff_tests.c.
|
static |
|
static |
Check that the budget is measured with fr_sbuff_used_total(), not fr_sbuff_used()
fr_sbuff_shift() moves data out of the buffer and adds the amount which fr_sbuff_start() can no longer account for to fr_sbuff_shifted(). So fr_sbuff_used_total() does not change across a shift, while fr_sbuff_used() shrinks. See test_shift_used_accounting().
fr_sbuff_out_unescape_until() re-runs fr_sbuff_marker_update_end() after every extension, and an extension is exactly when a shift happens. Measuring the budget with fr_sbuff_used() would therefore reset the budget on every shift, and the operation could copy more than it was allowed to.
The budget below is larger than fr_sbuff_used() but smaller than fr_sbuff_used_total(), so the two accessors give different answers.
Definition at line 1535 of file sbuff_tests.c.
Here is the call graph for this function:
|
static |
|
static |
|
static |
|
static |
Definition at line 1816 of file sbuff_tests.c.
|
static |
Definition at line 1795 of file sbuff_tests.c.
|
static |
Definition at line 1733 of file sbuff_tests.c.
|
static |
Definition at line 1766 of file sbuff_tests.c.
|
static |
Definition at line 46 of file sbuff_tests.c.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Check that a hex or octal escape sequence cannot consume more input than "len" allows.
fr_sbuff_out_unescape_until() bounds the input it consumes with a marker placed "len" bytes ahead of the start. The escape sequences are the one place where the input is advanced by more than a byte at a time, so they are the one place where the marker can be stepped over.
An escape sequence which does not fit within "len" is not a complete escape sequence, and is copied out as-is. That is the same thing which happens to an incomplete escape sequence at the end of the input.
Definition at line 788 of file sbuff_tests.c.
Here is the call graph for this function:
|
static |
Definition at line 239 of file sbuff_tests.c.
|
static |
Definition at line 248 of file sbuff_tests.c.
| TEST_LIST |
Definition at line 2290 of file sbuff_tests.c.
1.9.8