The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
unit_test_attribute.c File Reference

Provides a test harness for various internal libraries and functions. More...

#include <freeradius-devel/io/test_point.h>
#include <freeradius-devel/server/cf_parse.h>
#include <freeradius-devel/server/cf_util.h>
#include <freeradius-devel/server/command.h>
#include <freeradius-devel/server/dependency.h>
#include <freeradius-devel/server/dl_module.h>
#include <freeradius-devel/server/log.h>
#include <freeradius-devel/server/map.h>
#include <freeradius-devel/server/tmpl.h>
#include <freeradius-devel/unlang/base.h>
#include <freeradius-devel/unlang/xlat.h>
#include <freeradius-devel/unlang/xlat_func.h>
#include <freeradius-devel/util/atexit.h>
#include <freeradius-devel/util/base64.h>
#include <freeradius-devel/util/calc.h>
#include <freeradius-devel/util/conf.h>
#include <freeradius-devel/util/dict.h>
#include <freeradius-devel/util/dns.h>
#include <freeradius-devel/util/file.h>
#include <freeradius-devel/util/log.h>
#include <freeradius-devel/util/skip.h>
#include <freeradius-devel/util/pair_legacy.h>
#include <freeradius-devel/util/sha1.h>
#include <freeradius-devel/util/syserror.h>
#include <freeradius-devel/util/dict_priv.h>
#include <ctype.h>
#include <assert.h>
#include <fcntl.h>
#include <libgen.h>
#include <limits.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/wait.h>
+ Include dependency graph for unit_test_attribute.c:

Go to the source code of this file.

Data Structures

struct  command_config_t
 Configuration parameters passed to command functions. More...
 
struct  command_entry_t
 
struct  command_file_ctx_t
 
struct  command_line_range_t
 
struct  command_result_t
 
union  command_result_t.__unnamed3__
 

Macros

#define ASAN_POISON_MEMORY_REGION(_start, _end)
 
#define ASAN_UNPOISON_MEMORY_REGION(_start, _end)
 
#define ATTR_COMMON
 
#define BUFF_POISON_END   0
 
#define BUFF_POISON_START   0
 
#define CLEAR_TEST_POINT(_cc)
 
#define COMMAND_OUTPUT_MAX   8192
 
#define DEFAULT_BUFFER_SIZE   1024
 Default buffer size for a command_file_ctx_t.
 
#define EXIT_WITH_FAILURE
 
#define EXIT_WITH_FAILURE
 
#define POISONED_BUFFER_END(_p)   ((_p) + BUFF_POISON_START + (talloc_array_length(_p) - (BUFF_POISON_START + BUFF_POISON_END)))
 
#define POISONED_BUFFER_START(_p)   ((_p) + BUFF_POISON_START)
 
#define RETURN_COMMAND_ERROR()
 
#define RETURN_EXIT(_ret)
 
#define RETURN_MISMATCH(_len)
 
#define RETURN_NOOP(_len)
 
#define RETURN_OK(_len)
 
#define RETURN_OK_WITH_ERROR()
 
#define RETURN_PARSE_ERROR(_offset)
 
#define RETURN_SKIP_FILE()
 

Typedefs

typedef size_t(* command_func_t) (command_result_t *result, command_file_ctx_t *cc, char *data, size_t data_used, char *in, size_t inlen)
 Command to execute.
 
typedef ssize_t(* command_tmpl_rule_func) (TALLOC_CTX *ctx, tmpl_rules_t *rules, fr_sbuff_t *value)
 Callback for a tmpl rule parser.
 
typedef struct request_s request_t
 

Enumerations

enum  command_rcode_t {
  RESULT_OK = 0 ,
  RESULT_NOOP ,
  RESULT_SKIP_FILE ,
  RESULT_PARSE_ERROR ,
  RESULT_COMMAND_ERROR ,
  RESULT_MISMATCH ,
  RESULT_EXIT
}
 

Functions

static int _command_ctx_free (command_file_ctx_t *cc)
 
static size_t command_allow_unresolved (command_result_t *result, command_file_ctx_t *cc, UNUSED char *data, UNUSED size_t data_used, char *in, size_t inlen)
 Determine if unresolved attributes are allowed.
 
static size_t command_attr_children (command_result_t *result, command_file_ctx_t *cc, UNUSED char *data, UNUSED size_t data_used, char *in, size_t inlen)
 Print attribute information.
 
static size_t command_attr_flags (command_result_t *result, command_file_ctx_t *cc, UNUSED char *data, UNUSED size_t data_used, char *in, size_t inlen)
 Print attribute information.
 
static size_t command_attr_name (command_result_t *result, command_file_ctx_t *cc, UNUSED char *data, UNUSED size_t data_used, char *in, size_t inlen)
 Print attribute information.
 
static size_t command_attr_oid (command_result_t *result, command_file_ctx_t *cc, UNUSED char *data, UNUSED size_t data_used, char *in, size_t inlen)
 Print attribute information.
 
static size_t command_attr_type (command_result_t *result, command_file_ctx_t *cc, UNUSED char *data, UNUSED size_t data_used, char *in, size_t inlen)
 Print attribute information.
 
static size_t command_calc (command_result_t *result, command_file_ctx_t *cc, char *data, UNUSED size_t data_used, char *in, size_t inlen)
 Perform calculations.
 
static size_t command_calc_nary (command_result_t *result, command_file_ctx_t *cc, char *data, UNUSED size_t data_used, char *in, size_t inlen)
 Perform calculations on multi-valued ops.
 
static size_t command_cast (command_result_t *result, command_file_ctx_t *cc, char *data, UNUSED size_t data_used, char *in, size_t inlen)
 Perform casting.
 
static size_t command_cd (command_result_t *result, command_file_ctx_t *cc, char *data, UNUSED size_t data_used, char *in, size_t inlen)
 Change the working directory.
 
static size_t command_clear (command_result_t *result, UNUSED command_file_ctx_t *cc, char *data, size_t UNUSED data_used, UNUSED char *in, UNUSED size_t inlen)
 
static size_t command_comment (UNUSED command_result_t *result, UNUSED command_file_ctx_t *cc, UNUSED char *data, UNUSED size_t data_used, UNUSED char *in, UNUSED size_t inlen)
 Placeholder function for comments.
 
static size_t command_condition_normalise (command_result_t *result, command_file_ctx_t *cc, char *data, UNUSED size_t data_used, char *in, size_t inlen)
 Parse and reprint a condition.
 
static size_t command_count (command_result_t *result, command_file_ctx_t *cc, char *data, UNUSED size_t data_used, UNUSED char *in, UNUSED size_t inlen)
 
static command_file_ctx_tcommand_ctx_alloc (TALLOC_CTX *ctx, command_config_t const *config, char const *path, char const *filename)
 
static void command_ctx_reset (command_file_ctx_t *cc, TALLOC_CTX *ctx)
 
static size_t command_decode_dns_label (command_result_t *result, command_file_ctx_t *cc, char *data, UNUSED size_t data_used, char *in, size_t inlen)
 
static size_t command_decode_pair (command_result_t *result, command_file_ctx_t *cc, char *data, size_t data_used, char *in, size_t inlen)
 
static size_t command_decode_proto (command_result_t *result, command_file_ctx_t *cc, char *data, size_t data_used, char *in, size_t inlen)
 
static size_t command_dictionary_attribute_parse (command_result_t *result, command_file_ctx_t *cc, char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen)
 Parse a dictionary attribute, writing "ok" to the data buffer is everything was ok.
 
static size_t command_dictionary_dump (command_result_t *result, command_file_ctx_t *cc, UNUSED char *data, size_t data_used, UNUSED char *in, UNUSED size_t inlen)
 Print the currently loaded dictionary.
 
static size_t command_encode_dns_label (command_result_t *result, command_file_ctx_t *cc, char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen)
 
static size_t command_encode_pair (command_result_t *result, command_file_ctx_t *cc, char *data, UNUSED size_t data_used, char *in, size_t inlen)
 
static size_t command_encode_proto (command_result_t *result, command_file_ctx_t *cc, char *data, UNUSED size_t data_used, char *in, size_t inlen)
 
static size_t command_encode_raw (command_result_t *result, command_file_ctx_t *cc, char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen)
 Encode a RADIUS attribute writing the result to the data buffer as space separated hexits.
 
static size_t command_eof (UNUSED command_result_t *result, UNUSED command_file_ctx_t *cc, UNUSED char *data, UNUSED size_t data_used, UNUSED char *in, UNUSED size_t inlen)
 Command eof.
 
static size_t command_exit (command_result_t *result, UNUSED command_file_ctx_t *cc, UNUSED char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen)
 Exit gracefully with the specified code.
 
static int command_func (UNUSED FILE *fp, UNUSED FILE *fp_err, UNUSED void *ctx, UNUSED fr_cmd_info_t const *info)
 
static size_t command_fuzzer_out (command_result_t *result, command_file_ctx_t *cc, UNUSED char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen)
 Enable fuzzer output.
 
static size_t command_include (command_result_t *result, command_file_ctx_t *cc, UNUSED char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen)
 Execute another test file.
 
static size_t command_load_dictionary (command_result_t *result, command_file_ctx_t *cc, UNUSED char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen)
 
static size_t command_match (command_result_t *result, command_file_ctx_t *cc, char *data, size_t data_used, char *in, size_t inlen)
 Compare the data buffer to an expected value.
 
static size_t command_match_regex (command_result_t *result, command_file_ctx_t *cc, char *data, size_t data_used, char *in, size_t inlen)
 Compare the data buffer against an expected expression.
 
static size_t command_max_buffer_size (command_result_t *result, command_file_ctx_t *cc, char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen)
 Artificially limit the maximum packet size.
 
static size_t command_migrate (command_result_t *result, command_file_ctx_t *cc, UNUSED char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen)
 Set or clear migration flags.
 
static size_t command_need_feature (command_result_t *result, command_file_ctx_t *cc, UNUSED char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen)
 Skip the test file if we're missing a particular feature.
 
static size_t command_no (command_result_t *result, command_file_ctx_t *cc, char *data, size_t data_used, char *in, size_t inlen)
 Negate the result of a match command or any command which returns "OK".
 
static size_t command_pair (command_result_t *result, command_file_ctx_t *cc, char *data, size_t data_used, char *in, size_t inlen)
 
static size_t command_pair_common (command_result_t *result, command_file_ctx_t *cc, char *data, UNUSED size_t data_used, char *in, size_t inlen, bool allow_compare)
 Parse an print an attribute pair or pair list.
 
static size_t command_pair_compare (command_result_t *result, command_file_ctx_t *cc, char *data, size_t data_used, char *in, size_t inlen)
 
static void command_print (void)
 
static size_t command_proto (command_result_t *result, command_file_ctx_t *cc, UNUSED char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen)
 Dynamically load a protocol library.
 
static size_t command_proto_dictionary (command_result_t *result, command_file_ctx_t *cc, UNUSED char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen)
 
static size_t command_proto_dictionary_root (command_result_t *result, command_file_ctx_t *cc, UNUSED char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen)
 
static size_t command_radmin_add (command_result_t *result, command_file_ctx_t *cc, char *data, size_t UNUSED data_used, char *in, UNUSED size_t inlen)
 
static size_t command_radmin_tab (command_result_t *result, command_file_ctx_t *cc, char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen)
 
static size_t command_read_file (command_result_t *result, command_file_ctx_t *cc, char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen)
 Parse a list of pairs.
 
static size_t command_returned (command_result_t *result, command_file_ctx_t *cc, char *data, UNUSED size_t data_used, UNUSED char *in, UNUSED size_t inlen)
 
static size_t command_tmpl (command_result_t *result, command_file_ctx_t *cc, char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen)
 Parse an reprint a tmpl expansion.
 
static ssize_t command_tmpl_rule_allow_foreign (UNUSED TALLOC_CTX *ctx, tmpl_rules_t *rules, fr_sbuff_t *value)
 
static ssize_t command_tmpl_rule_allow_unknown (UNUSED TALLOC_CTX *ctx, tmpl_rules_t *rules, fr_sbuff_t *value)
 
static ssize_t command_tmpl_rule_allow_unresolved (UNUSED TALLOC_CTX *ctx, tmpl_rules_t *rules, fr_sbuff_t *value)
 
static ssize_t command_tmpl_rule_attr_parent (UNUSED TALLOC_CTX *ctx, tmpl_rules_t *rules, fr_sbuff_t *value)
 
static ssize_t command_tmpl_rule_list_def (UNUSED TALLOC_CTX *ctx, tmpl_rules_t *rules, fr_sbuff_t *value)
 
static ssize_t command_tmpl_rule_request_def (TALLOC_CTX *ctx, tmpl_rules_t *rules, fr_sbuff_t *value)
 
static size_t command_tmpl_rules (command_result_t *result, command_file_ctx_t *cc, UNUSED char *data, UNUSED size_t data_used, char *in, size_t inlen)
 
static size_t command_touch (command_result_t *result, UNUSED command_file_ctx_t *cc, UNUSED char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen)
 Touch a file to indicate a test completed.
 
static size_t command_value_box_normalise (command_result_t *result, command_file_ctx_t *cc, char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen)
 
static int command_walk (UNUSED void *ctx, fr_cmd_walk_info_t *info)
 
static size_t command_write (command_result_t *result, command_file_ctx_t *cc, char *data, size_t data_used, char *in, size_t inlen)
 
static size_t command_xlat_argv (command_result_t *result, command_file_ctx_t *cc, char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen)
 Parse an reprint and xlat argv expansion.
 
static size_t command_xlat_expr (command_result_t *result, command_file_ctx_t *cc, char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen)
 Parse and reprint an xlat expression expansion.
 
static size_t command_xlat_normalise (command_result_t *result, command_file_ctx_t *cc, char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen)
 Parse an reprint and xlat expansion.
 
static size_t command_xlat_purify (command_result_t *result, command_file_ctx_t *cc, char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen)
 Parse, purify, and reprint an xlat expression expansion.
 
static size_t command_xlat_purify_condition (command_result_t *result, command_file_ctx_t *cc, char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen)
 Parse, purify, and reprint an xlat expression expansion.
 
static void commands_print (void)
 
static int decode_attr (char *buffer, char **endptr)
 
static int decode_vendor (char *buffer, char **endptr)
 
static fr_dict_tdictionary_current (command_file_ctx_t *cc)
 
static int dictionary_load_common (command_result_t *result, command_file_ctx_t *cc, char const *in, char const *default_subdir)
 Common dictionary load function.
 
static int dump_fuzzer_data (int fd_dir, char const *text, uint8_t const *data, size_t data_len)
 
static ssize_t encode_data (char *p, uint8_t *output, size_t outlen)
 
static ssize_t encode_data_string (char *buffer, uint8_t *output, size_t outlen)
 
static ssize_t encode_data_tlv (char *buffer, char **endptr, uint8_t *output, size_t outlen)
 
static ssize_t encode_evs (char *buffer, uint8_t *output, size_t outlen)
 
static ssize_t encode_extended (char *buffer, uint8_t *output, size_t outlen)
 
static ssize_t encode_long_extended (char *buffer, uint8_t *output, size_t outlen)
 
static ssize_t encode_rfc (char *buffer, uint8_t *output, size_t outlen)
 
static ssize_t encode_tlv (char *buffer, uint8_t *output, size_t outlen)
 
static ssize_t encode_vsa (char *buffer, uint8_t *output, size_t outlen)
 
static void features_print (CONF_SECTION *features)
 
static size_t hex_print (char *out, size_t outlen, uint8_t const *in, size_t inlen)
 Print hex string to buffer.
 
static ssize_t hex_to_bin (uint8_t *out, size_t outlen, char *in, size_t inlen)
 
static int line_ranges_parse (TALLOC_CTX *ctx, fr_dlist_head_t *out, fr_sbuff_t *in)
 
static ssize_t load_proto_library (char const *proto_name)
 
static ssize_t load_test_point_by_command (void **symbol, char *command, char const *dflt_symbol)
 
int main (int argc, char *argv[])
 
static void mismatch_print (command_file_ctx_t *cc, char const *command, char *expected, size_t expected_len, char *got, size_t got_len, bool print_diff)
 
static size_t parse_typed_value (command_result_t *result, command_file_ctx_t *cc, fr_value_box_t *box, char const **out, char const *in, size_t inlen)
 
static int poisoned_buffer_allocate (TALLOC_CTX *ctx, uint8_t **buff, size_t size)
 Allocate a special buffer with poisoned memory regions at the start and end.
 
static int process_file (bool *exit_now, TALLOC_CTX *ctx, command_config_t const *config, const char *root_dir, char const *filename, fr_dlist_head_t *lines)
 
size_t process_line (command_result_t *result, command_file_ctx_t *cc, char *data, size_t data_used, char *in, size_t inlen)
 
size_t process_line (command_result_t *result, command_file_ctx_t *cc, char *data, size_t data_used, char *in, UNUSED size_t inlen)
 
static int process_path (bool *exit_now, TALLOC_CTX *ctx, command_config_t const *config, const char *path)
 
static size_t strerror_concat (char *out, size_t outlen)
 Concatenate error stack.
 
static void unload_proto_library (void)
 
static void usage (char const *name)
 
static xlat_action_t xlat_test (UNUSED TALLOC_CTX *ctx, UNUSED fr_dcursor_t *out, UNUSED xlat_ctx_t const *xctx, UNUSED request_t *request, UNUSED fr_value_box_list_t *in)
 

Variables

static bool allow_purify = false
 
static fr_cmd_tcommand_head = NULL
 
static fr_table_num_sorted_t command_rcode_table []
 
static size_t command_rcode_table_len = NUM_ELEMENTS(command_rcode_table)
 
static fr_table_ptr_sorted_t commands []
 
static size_t commands_len = NUM_ELEMENTS(commands)
 
static dl_tdl = NULL
 
static dl_loader_tdl_loader = NULL
 
static fr_event_list_tel = NULL
 
static char const * fail_file = ""
 
static char const hextab [] = "0123456789abcdef"
 
static char proto_name_prev [128] = {}
 
static char const * receipt_dir = NULL
 
static char const * receipt_file = NULL
 
static const fr_token_t token2op [UINT8_MAX+1]
 
static char const * write_filename = NULL
 
static FILE * write_fp = NULL
 
static xlat_arg_parser_t const xlat_test_args []
 
static xlat_arg_parser_t const xlat_test_no_args []
 

Detailed Description

Provides a test harness for various internal libraries and functions.

Id
955acaa7e29e77275586fbd84d3ec7a81662c104

Definition in file unit_test_attribute.c.


Data Structure Documentation

◆ command_config_t

struct command_config_t

Configuration parameters passed to command functions.

Definition at line 203 of file unit_test_attribute.c.

+ Collaboration diagram for command_config_t:
Data Fields
fr_dict_t * dict Dictionary to "reset" to.
char const * dict_dir
fr_dict_gctx_t const * dict_gctx Dictionary gctx to "reset" to.
CONF_SECTION * features Enabled features.
char const * fuzzer_dir Where to write fuzzer files.
char const * raddb_dir

◆ command_entry_t

struct command_entry_t

Definition at line 255 of file unit_test_attribute.c.

+ Collaboration diagram for command_entry_t:
Data Fields
char const * description
command_func_t func
char const * usage

◆ command_file_ctx_t

struct command_file_ctx_t

Definition at line 212 of file unit_test_attribute.c.

+ Collaboration diagram for command_file_ctx_t:
Data Fields
uint8_t * buffer Temporary resizable buffer we use for holding non-string data.
uint8_t * buffer_end Where the non-poisoned region of the buffer ends.
uint8_t * buffer_start Where the non-poisoned region of the buffer starts.
command_config_t const * config
char const * filename Current file we're operating on.
int fuzzer_dir File descriptor pointing to a a directory to write fuzzer output.
ssize_t last_ret Last return value.
uint32_t lineno Current line number.
char * path Current path we're operating in.
uint32_t test_count How many tests we've executed in this file.
fr_dict_gctx_t const * test_gctx Dictionary context for test dictionaries.
fr_dict_t * test_internal_dict Internal dictionary of test_gctx.
TALLOC_CTX * tmp_ctx Talloc context for test points.
tmpl_rules_t tmpl_rules To pass to parsing functions.

◆ command_line_range_t

struct command_line_range_t

Definition at line 237 of file unit_test_attribute.c.

+ Collaboration diagram for command_line_range_t:
Data Fields
uint32_t end End of line range.
fr_dlist_t entry Entry in the dlist.
uint32_t start Start of line range.

◆ command_result_t

struct command_result_t

Definition at line 187 of file unit_test_attribute.c.

Data Fields
union command_result_t.__unnamed3__ __unnamed__
bool error_to_data
char const * file
int line
command_rcode_t rcode
TALLOC_CTX * tmp_ctx Temporary context to hold buffers in this.

◆ command_result_t.__unnamed3__

union command_result_t.__unnamed3__

Definition at line 190 of file unit_test_attribute.c.

Data Fields
size_t offset Where we failed parsing the command.
int ret What code we should exit with.

Macro Definition Documentation

◆ ASAN_POISON_MEMORY_REGION

#define ASAN_POISON_MEMORY_REGION (   _start,
  _end 
)

Definition at line 82 of file unit_test_attribute.c.

◆ ASAN_UNPOISON_MEMORY_REGION

#define ASAN_UNPOISON_MEMORY_REGION (   _start,
  _end 
)

Definition at line 83 of file unit_test_attribute.c.

◆ ATTR_COMMON

#define ATTR_COMMON
Value:
fr_slen_t slen; \
fr_dict_attr_t const *root; \
fr_dict_attr_t const *da; \
root = cc->tmpl_rules.attr.dict_def ? \
fr_dict_root(cc->tmpl_rules.attr.dict_def) : \
&da, \
root, \
&our_in, NULL); \
static fr_slen_t err
Definition dict.h:884
fr_slen_t fr_dict_attr_by_oid_substr(fr_dict_attr_err_t *err, fr_dict_attr_t const **out, fr_dict_attr_t const *parent, fr_sbuff_t *in, fr_sbuff_term_t const *tt))
Resolve an attribute using an OID string.
Definition dict_util.c:2593
fr_dict_attr_t const * fr_dict_root(fr_dict_t const *dict)
Return the root attribute of a dictionary.
Definition dict_util.c:2669
fr_dict_t const * fr_dict_internal(void)
Definition dict_util.c:4938
fr_dict_attr_err_t
Errors returned by attribute lookup functions.
Definition dict.h:319
@ FR_DICT_ATTR_OK
No error.
Definition dict.h:320
static fr_slen_t in
Definition dict.h:884
ssize_t fr_slen_t
#define FR_SBUFF_IN(_start, _len_or_end)
#define FR_SBUFF_ERROR_RETURN(_sbuff_or_marker)
static size_t char fr_sbuff_t size_t inlen
Definition value.h:1025

Definition at line 1252 of file unit_test_attribute.c.

◆ BUFF_POISON_END

#define BUFF_POISON_END   0

Definition at line 314 of file unit_test_attribute.c.

◆ BUFF_POISON_START

#define BUFF_POISON_START   0

Definition at line 313 of file unit_test_attribute.c.

◆ CLEAR_TEST_POINT

#define CLEAR_TEST_POINT (   _cc)
Value:
do { \
talloc_free_children((_cc)->tmp_ctx); \
tp = NULL; \
} while (0)

Definition at line 1189 of file unit_test_attribute.c.

◆ COMMAND_OUTPUT_MAX

#define COMMAND_OUTPUT_MAX   8192

Definition at line 92 of file unit_test_attribute.c.

◆ DEFAULT_BUFFER_SIZE

#define DEFAULT_BUFFER_SIZE   1024

Default buffer size for a command_file_ctx_t.

Definition at line 164 of file unit_test_attribute.c.

◆ EXIT_WITH_FAILURE [1/2]

#define EXIT_WITH_FAILURE
Value:
do { \
ret = EXIT_FAILURE; \
goto cleanup; \
} while (0)
static bool cleanup
Definition radsniff.c:60

Definition at line 86 of file unit_test_attribute.c.

◆ EXIT_WITH_FAILURE [2/2]

#define EXIT_WITH_FAILURE
Value:
do { \
ret = EXIT_FAILURE; \
error_str = fr_strerror(); \
if (error_str) error_str = talloc_strdup(NULL, error_str); \
goto fail; \
} while (0)
char const * fr_strerror(void)
Get the last library error.
Definition strerror.c:553

Definition at line 86 of file unit_test_attribute.c.

◆ POISONED_BUFFER_END

#define POISONED_BUFFER_END (   _p)    ((_p) + BUFF_POISON_START + (talloc_array_length(_p) - (BUFF_POISON_START + BUFF_POISON_END)))

Definition at line 357 of file unit_test_attribute.c.

◆ POISONED_BUFFER_START

#define POISONED_BUFFER_START (   _p)    ((_p) + BUFF_POISON_START)

Definition at line 356 of file unit_test_attribute.c.

◆ RETURN_COMMAND_ERROR

#define RETURN_COMMAND_ERROR ( )
Value:
do { \
result->rcode = RESULT_COMMAND_ERROR; \
result->file = __FILE__; \
result->line = __LINE__; \
return 0; \
} while (0)
@ RESULT_COMMAND_ERROR
Fatal error - Command operation error.

Definition at line 136 of file unit_test_attribute.c.

◆ RETURN_EXIT

#define RETURN_EXIT (   _ret)
Value:
do { \
result->rcode = RESULT_EXIT; \
result->ret = _ret; \
result->file = __FILE__; \
result->line = __LINE__; \
return 0; \
} while (0)
@ RESULT_EXIT
Stop processing files and exit.

Definition at line 152 of file unit_test_attribute.c.

◆ RETURN_MISMATCH

#define RETURN_MISMATCH (   _len)
Value:
do { \
result->rcode = RESULT_MISMATCH; \
result->file = __FILE__; \
result->line = __LINE__; \
return (_len); \
} while (0)
@ RESULT_MISMATCH
Fatal error - Result didn't match what we expected.

Definition at line 144 of file unit_test_attribute.c.

◆ RETURN_NOOP

#define RETURN_NOOP (   _len)
Value:
do { \
result->rcode = RESULT_NOOP; \
result->file = __FILE__; \
result->line = __LINE__; \
return (_len); \
} while (0)
@ RESULT_NOOP
Not an error - Did nothing...

Definition at line 111 of file unit_test_attribute.c.

◆ RETURN_OK

#define RETURN_OK (   _len)
Value:
do { \
result->rcode = RESULT_OK; \
result->file = __FILE__; \
result->line = __LINE__; \
return (_len); \
} while (0)
@ RESULT_OK
Not an error - Result as expected.

Definition at line 94 of file unit_test_attribute.c.

◆ RETURN_OK_WITH_ERROR

#define RETURN_OK_WITH_ERROR ( )
Value:
do { \
result->rcode = RESULT_OK; \
result->file = __FILE__; \
result->line = __LINE__; \
result->error_to_data = true; \
return 0; \
} while (0)

Definition at line 102 of file unit_test_attribute.c.

◆ RETURN_PARSE_ERROR

#define RETURN_PARSE_ERROR (   _offset)
Value:
do { \
result->rcode = RESULT_PARSE_ERROR; \
result->offset = _offset; \
result->file = __FILE__; \
result->line = __LINE__; \
return 0; \
} while (0)
@ RESULT_PARSE_ERROR
Fatal error - Command syntax error.

Definition at line 127 of file unit_test_attribute.c.

◆ RETURN_SKIP_FILE

#define RETURN_SKIP_FILE ( )
Value:
do { \
result->rcode = RESULT_SKIP_FILE; \
result->file = __FILE__; \
result->line = __LINE__; \
return 0; \
} while (0)
@ RESULT_SKIP_FILE
Not an error - Skip the rest of this file, or until we reach an "eof" command.

Definition at line 119 of file unit_test_attribute.c.

Typedef Documentation

◆ command_func_t

typedef size_t(* command_func_t) (command_result_t *result, command_file_ctx_t *cc, char *data, size_t data_used, char *in, size_t inlen)

Command to execute.

Parameters
[out]resultOf executing the command.
[in]ccInformation about the file being processed.
[in,out]dataOutput of this command, or the previous command.
[in]data_usedLength of data in the data buffer.
[in]inCommand text to process.
[in]inlenLength of the remainder of the command to process.

Definition at line 252 of file unit_test_attribute.c.

◆ command_tmpl_rule_func

typedef ssize_t(* command_tmpl_rule_func) (TALLOC_CTX *ctx, tmpl_rules_t *rules, fr_sbuff_t *value)

Callback for a tmpl rule parser.

Definition at line 2885 of file unit_test_attribute.c.

◆ request_t

typedef struct request_s request_t

Definition at line 28 of file unit_test_attribute.c.

Enumeration Type Documentation

◆ command_rcode_t

Enumerator
RESULT_OK 

Not an error - Result as expected.

RESULT_NOOP 

Not an error - Did nothing...

RESULT_SKIP_FILE 

Not an error - Skip the rest of this file, or until we reach an "eof" command.

RESULT_PARSE_ERROR 

Fatal error - Command syntax error.

RESULT_COMMAND_ERROR 

Fatal error - Command operation error.

RESULT_MISMATCH 

Fatal error - Result didn't match what we expected.

RESULT_EXIT 

Stop processing files and exit.

Definition at line 166 of file unit_test_attribute.c.

Function Documentation

◆ _command_ctx_free()

static int _command_ctx_free ( command_file_ctx_t cc)
static

Definition at line 3764 of file unit_test_attribute.c.

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

◆ command_allow_unresolved()

static size_t command_allow_unresolved ( command_result_t result,
command_file_ctx_t cc,
UNUSED char *  data,
UNUSED size_t  data_used,
char *  in,
size_t  inlen 
)
static

Determine if unresolved attributes are allowed.

Definition at line 1237 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_attr_children()

static size_t command_attr_children ( command_result_t result,
command_file_ctx_t cc,
UNUSED char *  data,
UNUSED size_t  data_used,
char *  in,
size_t  inlen 
)
static

Print attribute information.

Definition at line 1271 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_attr_flags()

static size_t command_attr_flags ( command_result_t result,
command_file_ctx_t cc,
UNUSED char *  data,
UNUSED size_t  data_used,
char *  in,
size_t  inlen 
)
static

Print attribute information.

Definition at line 1314 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_attr_name()

static size_t command_attr_name ( command_result_t result,
command_file_ctx_t cc,
UNUSED char *  data,
UNUSED size_t  data_used,
char *  in,
size_t  inlen 
)
static

Print attribute information.

Definition at line 1328 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_attr_oid()

static size_t command_attr_oid ( command_result_t result,
command_file_ctx_t cc,
UNUSED char *  data,
UNUSED size_t  data_used,
char *  in,
size_t  inlen 
)
static

Print attribute information.

Definition at line 1342 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_attr_type()

static size_t command_attr_type ( command_result_t result,
command_file_ctx_t cc,
UNUSED char *  data,
UNUSED size_t  data_used,
char *  in,
size_t  inlen 
)
static

Print attribute information.

Definition at line 1356 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_calc()

static size_t command_calc ( command_result_t result,
command_file_ctx_t cc,
char *  data,
UNUSED size_t  data_used,
char *  in,
size_t  inlen 
)
static

Perform calculations.

Definition at line 1382 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_calc_nary()

static size_t command_calc_nary ( command_result_t result,
command_file_ctx_t cc,
char *  data,
UNUSED size_t  data_used,
char *  in,
size_t  inlen 
)
static

Perform calculations on multi-valued ops.

Definition at line 1467 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_cast()

static size_t command_cast ( command_result_t result,
command_file_ctx_t cc,
char *  data,
UNUSED size_t  data_used,
char *  in,
size_t  inlen 
)
static

Perform casting.

Definition at line 1532 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_cd()

static size_t command_cd ( command_result_t result,
command_file_ctx_t cc,
char *  data,
UNUSED size_t  data_used,
char *  in,
size_t  inlen 
)
static

Change the working directory.

Definition at line 1582 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_clear()

static size_t command_clear ( command_result_t result,
UNUSED command_file_ctx_t cc,
char *  data,
size_t UNUSED  data_used,
UNUSED char *  in,
UNUSED size_t  inlen 
)
static

Definition at line 1598 of file unit_test_attribute.c.

◆ command_comment()

static size_t command_comment ( UNUSED command_result_t result,
UNUSED command_file_ctx_t cc,
UNUSED char *  data,
UNUSED size_t  data_used,
UNUSED char *  in,
UNUSED size_t  inlen 
)
static

Placeholder function for comments.

Definition at line 1198 of file unit_test_attribute.c.

◆ command_condition_normalise()

static size_t command_condition_normalise ( command_result_t result,
command_file_ctx_t cc,
char *  data,
UNUSED size_t  data_used,
char *  in,
size_t  inlen 
)
static

Parse and reprint a condition.

Definition at line 1719 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_count()

static size_t command_count ( command_result_t result,
command_file_ctx_t cc,
char *  data,
UNUSED size_t  data_used,
UNUSED char *  in,
UNUSED size_t  inlen 
)
static

Definition at line 1763 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_ctx_alloc()

static command_file_ctx_t * command_ctx_alloc ( TALLOC_CTX *  ctx,
command_config_t const *  config,
char const *  path,
char const *  filename 
)
static

Definition at line 3781 of file unit_test_attribute.c.

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

◆ command_ctx_reset()

static void command_ctx_reset ( command_file_ctx_t cc,
TALLOC_CTX *  ctx 
)
static

Definition at line 3836 of file unit_test_attribute.c.

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

◆ command_decode_dns_label()

static size_t command_decode_dns_label ( command_result_t result,
command_file_ctx_t cc,
char *  data,
UNUSED size_t  data_used,
char *  in,
size_t  inlen 
)
static

Definition at line 2054 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_decode_pair()

static size_t command_decode_pair ( command_result_t result,
command_file_ctx_t cc,
char *  data,
size_t  data_used,
char *  in,
size_t  inlen 
)
static

Definition at line 1777 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_decode_proto()

static size_t command_decode_proto ( command_result_t result,
command_file_ctx_t cc,
char *  data,
size_t  data_used,
char *  in,
size_t  inlen 
)
static

Definition at line 1878 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_dictionary_attribute_parse()

static size_t command_dictionary_attribute_parse ( command_result_t result,
command_file_ctx_t cc,
char *  data,
UNUSED size_t  data_used,
char *  in,
UNUSED size_t  inlen 
)
static

Parse a dictionary attribute, writing "ok" to the data buffer is everything was ok.

Definition at line 1974 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_dictionary_dump()

static size_t command_dictionary_dump ( command_result_t result,
command_file_ctx_t cc,
UNUSED char *  data,
size_t  data_used,
UNUSED char *  in,
UNUSED size_t  inlen 
)
static

Print the currently loaded dictionary.

Definition at line 1985 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_encode_dns_label()

static size_t command_encode_dns_label ( command_result_t result,
command_file_ctx_t cc,
char *  data,
UNUSED size_t  data_used,
char *  in,
UNUSED size_t  inlen 
)
static

Definition at line 1997 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_encode_pair()

static size_t command_encode_pair ( command_result_t result,
command_file_ctx_t cc,
char *  data,
UNUSED size_t  data_used,
char *  in,
size_t  inlen 
)
static

Definition at line 2097 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_encode_proto()

static size_t command_encode_proto ( command_result_t result,
command_file_ctx_t cc,
char *  data,
UNUSED size_t  data_used,
char *  in,
size_t  inlen 
)
static

Definition at line 2342 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_encode_raw()

static size_t command_encode_raw ( command_result_t result,
command_file_ctx_t cc,
char *  data,
UNUSED size_t  data_used,
char *  in,
UNUSED size_t  inlen 
)
static

Encode a RADIUS attribute writing the result to the data buffer as space separated hexits.

Definition at line 2268 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_eof()

static size_t command_eof ( UNUSED command_result_t result,
UNUSED command_file_ctx_t cc,
UNUSED char *  data,
UNUSED size_t  data_used,
UNUSED char *  in,
UNUSED size_t  inlen 
)
static

Command eof.

Mark the end of a test file if we're reading from stdin.

Doesn't actually do anything, is just a placeholder for the command processing loop.

Definition at line 2415 of file unit_test_attribute.c.

+ Here is the caller graph for this function:

◆ command_exit()

static size_t command_exit ( command_result_t result,
UNUSED command_file_ctx_t cc,
UNUSED char *  data,
UNUSED size_t  data_used,
char *  in,
UNUSED size_t  inlen 
)
static

Exit gracefully with the specified code.

Definition at line 2491 of file unit_test_attribute.c.

◆ command_func()

static int command_func ( UNUSED FILE *  fp,
UNUSED FILE *  fp_err,
UNUSED void *  ctx,
UNUSED fr_cmd_info_t const *  info 
)
static

Definition at line 1156 of file unit_test_attribute.c.

+ Here is the caller graph for this function:

◆ command_fuzzer_out()

static size_t command_fuzzer_out ( command_result_t result,
command_file_ctx_t cc,
UNUSED char *  data,
UNUSED size_t  data_used,
char *  in,
UNUSED size_t  inlen 
)
static

Enable fuzzer output.

Any commands that produce potentially useful corpus seed data will write that out data to files in the specified directory, using the md5 of the text input at as the file name.

Definition at line 2427 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_include()

static size_t command_include ( command_result_t result,
command_file_ctx_t cc,
UNUSED char *  data,
UNUSED size_t  data_used,
char *  in,
UNUSED size_t  inlen 
)
static

Execute another test file.

Definition at line 1207 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_load_dictionary()

static size_t command_load_dictionary ( command_result_t result,
command_file_ctx_t cc,
UNUSED char *  data,
UNUSED size_t  data_used,
char *  in,
UNUSED size_t  inlen 
)
static

Definition at line 2499 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_match()

static size_t command_match ( command_result_t result,
command_file_ctx_t cc,
char *  data,
size_t  data_used,
char *  in,
size_t  inlen 
)
static

Compare the data buffer to an expected value.

Definition at line 2543 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_match_regex()

static size_t command_match_regex ( command_result_t result,
command_file_ctx_t cc,
char *  data,
size_t  data_used,
char *  in,
size_t  inlen 
)
static

Compare the data buffer against an expected expression.

Definition at line 2567 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_max_buffer_size()

static size_t command_max_buffer_size ( command_result_t result,
command_file_ctx_t cc,
char *  data,
UNUSED size_t  data_used,
char *  in,
UNUSED size_t  inlen 
)
static

Artificially limit the maximum packet size.

Definition at line 2597 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_migrate()

static size_t command_migrate ( command_result_t result,
command_file_ctx_t cc,
UNUSED char *  data,
UNUSED size_t  data_used,
char *  in,
UNUSED size_t  inlen 
)
static

Set or clear migration flags.

Definition at line 2625 of file unit_test_attribute.c.

◆ command_need_feature()

static size_t command_need_feature ( command_result_t result,
command_file_ctx_t cc,
UNUSED char *  data,
UNUSED size_t  data_used,
char *  in,
UNUSED size_t  inlen 
)
static

Skip the test file if we're missing a particular feature.

Definition at line 2668 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_no()

static size_t command_no ( command_result_t result,
command_file_ctx_t cc,
char *  data,
size_t  data_used,
char *  in,
size_t  inlen 
)
static

Negate the result of a match command or any command which returns "OK".

Definition at line 2691 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_pair()

static size_t command_pair ( command_result_t result,
command_file_ctx_t cc,
char *  data,
size_t  data_used,
char *  in,
size_t  inlen 
)
static

Definition at line 2767 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_pair_common()

static size_t command_pair_common ( command_result_t result,
command_file_ctx_t cc,
char *  data,
UNUSED size_t  data_used,
char *  in,
size_t  inlen,
bool  allow_compare 
)
static

Parse an print an attribute pair or pair list.

Definition at line 2723 of file unit_test_attribute.c.

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

◆ command_pair_compare()

static size_t command_pair_compare ( command_result_t result,
command_file_ctx_t cc,
char *  data,
size_t  data_used,
char *  in,
size_t  inlen 
)
static

Definition at line 2773 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_print()

static void command_print ( void  )
static

Definition at line 1176 of file unit_test_attribute.c.

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

◆ command_proto()

static size_t command_proto ( command_result_t result,
command_file_ctx_t cc,
UNUSED char *  data,
UNUSED size_t  data_used,
char *  in,
UNUSED size_t  inlen 
)
static

Dynamically load a protocol library.

Definition at line 2783 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_proto_dictionary()

static size_t command_proto_dictionary ( command_result_t result,
command_file_ctx_t cc,
UNUSED char *  data,
UNUSED size_t  data_used,
char *  in,
UNUSED size_t  inlen 
)
static

Definition at line 2800 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_proto_dictionary_root()

static size_t command_proto_dictionary_root ( command_result_t result,
command_file_ctx_t cc,
UNUSED char *  data,
UNUSED size_t  data_used,
char *  in,
UNUSED size_t  inlen 
)
static

Definition at line 2807 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_radmin_add()

static size_t command_radmin_add ( command_result_t result,
command_file_ctx_t cc,
char *  data,
size_t UNUSED  data_used,
char *  in,
UNUSED size_t  inlen 
)
static

Definition at line 1608 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_radmin_tab()

static size_t command_radmin_tab ( command_result_t result,
command_file_ctx_t cc,
char *  data,
UNUSED size_t  data_used,
char *  in,
UNUSED size_t  inlen 
)
static

Definition at line 1667 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_read_file()

static size_t command_read_file ( command_result_t result,
command_file_ctx_t cc,
char *  data,
UNUSED size_t  data_used,
char *  in,
UNUSED size_t  inlen 
)
static

Parse a list of pairs.

Definition at line 2290 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_returned()

static size_t command_returned ( command_result_t result,
command_file_ctx_t cc,
char *  data,
UNUSED size_t  data_used,
UNUSED char *  in,
UNUSED size_t  inlen 
)
static

Definition at line 2336 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_tmpl()

static size_t command_tmpl ( command_result_t result,
command_file_ctx_t cc,
char *  data,
UNUSED size_t  data_used,
char *  in,
UNUSED size_t  inlen 
)
static

Parse an reprint a tmpl expansion.

Definition at line 2832 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_tmpl_rule_allow_foreign()

static ssize_t command_tmpl_rule_allow_foreign ( UNUSED TALLOC_CTX *  ctx,
tmpl_rules_t rules,
fr_sbuff_t value 
)
static

Definition at line 2887 of file unit_test_attribute.c.

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

◆ command_tmpl_rule_allow_unknown()

static ssize_t command_tmpl_rule_allow_unknown ( UNUSED TALLOC_CTX *  ctx,
tmpl_rules_t rules,
fr_sbuff_t value 
)
static

Definition at line 2897 of file unit_test_attribute.c.

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

◆ command_tmpl_rule_allow_unresolved()

static ssize_t command_tmpl_rule_allow_unresolved ( UNUSED TALLOC_CTX *  ctx,
tmpl_rules_t rules,
fr_sbuff_t value 
)
static

Definition at line 2907 of file unit_test_attribute.c.

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

◆ command_tmpl_rule_attr_parent()

static ssize_t command_tmpl_rule_attr_parent ( UNUSED TALLOC_CTX *  ctx,
tmpl_rules_t rules,
fr_sbuff_t value 
)
static

Definition at line 2917 of file unit_test_attribute.c.

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

◆ command_tmpl_rule_list_def()

static ssize_t command_tmpl_rule_list_def ( UNUSED TALLOC_CTX *  ctx,
tmpl_rules_t rules,
fr_sbuff_t value 
)
static

Definition at line 2931 of file unit_test_attribute.c.

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

◆ command_tmpl_rule_request_def()

static ssize_t command_tmpl_rule_request_def ( TALLOC_CTX *  ctx,
tmpl_rules_t rules,
fr_sbuff_t value 
)
static

Definition at line 2945 of file unit_test_attribute.c.

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

◆ command_tmpl_rules()

static size_t command_tmpl_rules ( command_result_t result,
command_file_ctx_t cc,
UNUSED char *  data,
UNUSED size_t  data_used,
char *  in,
size_t  inlen 
)
static

Definition at line 2960 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_touch()

static size_t command_touch ( command_result_t result,
UNUSED command_file_ctx_t cc,
UNUSED char *  data,
UNUSED size_t  data_used,
char *  in,
UNUSED size_t  inlen 
)
static

Touch a file to indicate a test completed.

Definition at line 2873 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_value_box_normalise()

static size_t command_value_box_normalise ( command_result_t result,
command_file_ctx_t cc,
char *  data,
UNUSED size_t  data_used,
char *  in,
UNUSED size_t  inlen 
)
static

Definition at line 3005 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_walk()

static int command_walk ( UNUSED void *  ctx,
fr_cmd_walk_info_t info 
)
static

Definition at line 1161 of file unit_test_attribute.c.

+ Here is the caller graph for this function:

◆ command_write()

static size_t command_write ( command_result_t result,
command_file_ctx_t cc,
char *  data,
size_t  data_used,
char *  in,
size_t  inlen 
)
static

Definition at line 3085 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_xlat_argv()

static size_t command_xlat_argv ( command_result_t result,
command_file_ctx_t cc,
char *  data,
UNUSED size_t  data_used,
char *  in,
UNUSED size_t  inlen 
)
static

Parse an reprint and xlat argv expansion.

Definition at line 3337 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_xlat_expr()

static size_t command_xlat_expr ( command_result_t result,
command_file_ctx_t cc,
char *  data,
UNUSED size_t  data_used,
char *  in,
UNUSED size_t  inlen 
)
static

Parse and reprint an xlat expression expansion.

Definition at line 3178 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_xlat_normalise()

static size_t command_xlat_normalise ( command_result_t result,
command_file_ctx_t cc,
char *  data,
UNUSED size_t  data_used,
char *  in,
UNUSED size_t  inlen 
)
static

Parse an reprint and xlat expansion.

Definition at line 3132 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_xlat_purify()

static size_t command_xlat_purify ( command_result_t result,
command_file_ctx_t cc,
char *  data,
UNUSED size_t  data_used,
char *  in,
UNUSED size_t  inlen 
)
static

Parse, purify, and reprint an xlat expression expansion.

Definition at line 3213 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ command_xlat_purify_condition()

static size_t command_xlat_purify_condition ( command_result_t result,
command_file_ctx_t cc,
char *  data,
UNUSED size_t  data_used,
char *  in,
UNUSED size_t  inlen 
)
static

Parse, purify, and reprint an xlat expression expansion.

Definition at line 3275 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ commands_print()

static void commands_print ( void  )
static

Definition at line 4060 of file unit_test_attribute.c.

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

◆ decode_attr()

static int decode_attr ( char *  buffer,
char **  endptr 
)
static

Definition at line 682 of file unit_test_attribute.c.

+ Here is the caller graph for this function:

◆ decode_vendor()

static int decode_vendor ( char *  buffer,
char **  endptr 
)
static

Definition at line 705 of file unit_test_attribute.c.

+ Here is the caller graph for this function:

◆ dictionary_current()

static fr_dict_t * dictionary_current ( command_file_ctx_t cc)
static

Definition at line 1008 of file unit_test_attribute.c.

+ Here is the caller graph for this function:

◆ dictionary_load_common()

static int dictionary_load_common ( command_result_t result,
command_file_ctx_t cc,
char const *  in,
char const *  default_subdir 
)
static

Common dictionary load function.

Callers call fr_dict_global_ctx_set to set the context the dictionaries will be loaded into.

Definition at line 1022 of file unit_test_attribute.c.

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

◆ dump_fuzzer_data()

static int dump_fuzzer_data ( int  fd_dir,
char const *  text,
uint8_t const *  data,
size_t  data_len 
)
inlinestatic

Definition at line 451 of file unit_test_attribute.c.

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

◆ encode_data()

static ssize_t encode_data ( char *  p,
uint8_t output,
size_t  outlen 
)
static

Definition at line 628 of file unit_test_attribute.c.

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

◆ encode_data_string()

static ssize_t encode_data_string ( char *  buffer,
uint8_t output,
size_t  outlen 
)
static

Definition at line 517 of file unit_test_attribute.c.

+ Here is the caller graph for this function:

◆ encode_data_tlv()

static ssize_t encode_data_tlv ( char *  buffer,
char **  endptr,
uint8_t output,
size_t  outlen 
)
static

Definition at line 562 of file unit_test_attribute.c.

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

◆ encode_evs()

static ssize_t encode_evs ( char *  buffer,
uint8_t output,
size_t  outlen 
)
static

Definition at line 794 of file unit_test_attribute.c.

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

◆ encode_extended()

static ssize_t encode_extended ( char *  buffer,
uint8_t output,
size_t  outlen 
)
static

Definition at line 819 of file unit_test_attribute.c.

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

◆ encode_long_extended()

static ssize_t encode_long_extended ( char *  buffer,
uint8_t output,
size_t  outlen 
)
static

Definition at line 844 of file unit_test_attribute.c.

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

◆ encode_rfc()

static ssize_t encode_rfc ( char *  buffer,
uint8_t output,
size_t  outlen 
)
static

Definition at line 895 of file unit_test_attribute.c.

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

◆ encode_tlv()

static ssize_t encode_tlv ( char *  buffer,
uint8_t output,
size_t  outlen 
)
static

Definition at line 739 of file unit_test_attribute.c.

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

◆ encode_vsa()

static ssize_t encode_vsa ( char *  buffer,
uint8_t output,
size_t  outlen 
)
static

Definition at line 770 of file unit_test_attribute.c.

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

◆ features_print()

static void features_print ( CONF_SECTION features)
static

Definition at line 4048 of file unit_test_attribute.c.

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

◆ hex_print()

static size_t hex_print ( char *  out,
size_t  outlen,
uint8_t const *  in,
size_t  inlen 
)
inlinestatic

Print hex string to buffer.

Definition at line 407 of file unit_test_attribute.c.

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

◆ hex_to_bin()

static ssize_t hex_to_bin ( uint8_t out,
size_t  outlen,
char *  in,
size_t  inlen 
)
static

Definition at line 593 of file unit_test_attribute.c.

+ Here is the caller graph for this function:

◆ line_ranges_parse()

static int line_ranges_parse ( TALLOC_CTX *  ctx,
fr_dlist_head_t out,
fr_sbuff_t in 
)
static

Definition at line 4072 of file unit_test_attribute.c.

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

◆ load_proto_library()

static ssize_t load_proto_library ( char const *  proto_name)
static

Definition at line 946 of file unit_test_attribute.c.

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

◆ load_test_point_by_command()

static ssize_t load_test_point_by_command ( void **  symbol,
char *  command,
char const *  dflt_symbol 
)
static

Definition at line 973 of file unit_test_attribute.c.

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

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 4306 of file unit_test_attribute.c.

◆ mismatch_print()

static void mismatch_print ( command_file_ctx_t cc,
char const *  command,
char *  expected,
size_t  expected_len,
char *  got,
size_t  got_len,
bool  print_diff 
)
static

Definition at line 359 of file unit_test_attribute.c.

+ Here is the caller graph for this function:

◆ parse_typed_value()

static size_t parse_typed_value ( command_result_t result,
command_file_ctx_t cc,
fr_value_box_t box,
char const **  out,
char const *  in,
size_t  inlen 
)
static

Definition at line 1069 of file unit_test_attribute.c.

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

◆ poisoned_buffer_allocate()

static int poisoned_buffer_allocate ( TALLOC_CTX *  ctx,
uint8_t **  buff,
size_t  size 
)
static

Allocate a special buffer with poisoned memory regions at the start and end.

Definition at line 320 of file unit_test_attribute.c.

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

◆ process_file()

static int process_file ( bool exit_now,
TALLOC_CTX *  ctx,
command_config_t const *  config,
const char *  root_dir,
char const *  filename,
fr_dlist_head_t lines 
)
static

Definition at line 3859 of file unit_test_attribute.c.

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

◆ process_line() [1/2]

size_t process_line ( command_result_t result,
command_file_ctx_t cc,
char *  data,
size_t  data_used,
char *  in,
size_t  inlen 
)
+ Here is the caller graph for this function:

◆ process_line() [2/2]

size_t process_line ( command_result_t result,
command_file_ctx_t cc,
char *  data,
size_t  data_used,
char *  in,
UNUSED size_t  inlen 
)

Definition at line 3681 of file unit_test_attribute.c.

+ Here is the call graph for this function:

◆ process_path()

static int process_path ( bool exit_now,
TALLOC_CTX *  ctx,
command_config_t const *  config,
const char *  path 
)
static

Definition at line 4159 of file unit_test_attribute.c.

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

◆ strerror_concat()

static size_t strerror_concat ( char *  out,
size_t  outlen 
)
inlinestatic

Concatenate error stack.

Definition at line 434 of file unit_test_attribute.c.

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

◆ unload_proto_library()

static void unload_proto_library ( void  )
static

Definition at line 940 of file unit_test_attribute.c.

+ Here is the caller graph for this function:

◆ usage()

static void usage ( char const *  name)
static

Definition at line 4030 of file unit_test_attribute.c.

◆ xlat_test()

static xlat_action_t xlat_test ( UNUSED TALLOC_CTX *  ctx,
UNUSED fr_dcursor_t out,
UNUSED xlat_ctx_t const *  xctx,
UNUSED request_t request,
UNUSED fr_value_box_list_t *  in 
)
static

Definition at line 270 of file unit_test_attribute.c.

+ Here is the caller graph for this function:

Variable Documentation

◆ allow_purify

bool allow_purify = false
static

Definition at line 283 of file unit_test_attribute.c.

◆ command_head

fr_cmd_t* command_head = NULL
static

Definition at line 1154 of file unit_test_attribute.c.

◆ command_rcode_table

fr_table_num_sorted_t command_rcode_table[]
static
Initial value:
= {
{ L("command-error"), RESULT_COMMAND_ERROR },
{ L("exit"), RESULT_EXIT },
{ L("ok"), RESULT_OK },
{ L("parse-error"), RESULT_PARSE_ERROR },
{ L("result-mismatch"), RESULT_MISMATCH },
{ L("skip-file"), RESULT_SKIP_FILE },
}
#define L(_str)
Helper for initialising arrays of string literals.
Definition build.h:209

Definition at line 177 of file unit_test_attribute.c.

◆ command_rcode_table_len

size_t command_rcode_table_len = NUM_ELEMENTS(command_rcode_table)
static

Definition at line 185 of file unit_test_attribute.c.

◆ commands

fr_table_ptr_sorted_t commands[]
static

Definition at line 3387 of file unit_test_attribute.c.

◆ commands_len

size_t commands_len = NUM_ELEMENTS(commands)
static

Definition at line 3679 of file unit_test_attribute.c.

◆ dl

dl_t* dl = NULL
static

Definition at line 278 of file unit_test_attribute.c.

◆ dl_loader

dl_loader_t* dl_loader = NULL
static

Definition at line 279 of file unit_test_attribute.c.

◆ el

fr_event_list_t* el = NULL
static

Definition at line 281 of file unit_test_attribute.c.

◆ fail_file

char const* fail_file = ""
static

Definition at line 290 of file unit_test_attribute.c.

◆ hextab

char const hextab[] = "0123456789abcdef"
static

Definition at line 515 of file unit_test_attribute.c.

◆ proto_name_prev

char proto_name_prev[128] = {}
static

Definition at line 277 of file unit_test_attribute.c.

◆ receipt_dir

char const* receipt_dir = NULL
static

Definition at line 289 of file unit_test_attribute.c.

◆ receipt_file

char const* receipt_file = NULL
static

Definition at line 288 of file unit_test_attribute.c.

◆ token2op

const fr_token_t token2op[UINT8_MAX+1]
static
Initial value:
= {
[ '+' ] = T_ADD,
[ '-' ] = T_SUB,
[ '*' ] = T_MUL,
[ '/' ] = T_DIV,
[ '^' ] = T_XOR,
[ '.' ] = T_ADD,
[ '&' ] = T_AND,
[ '|' ] = T_OR,
[ '%' ] = T_MOD,
}
@ T_AND
Definition token.h:55
@ T_SUB
Definition token.h:52
@ T_XOR
Definition token.h:58
@ T_DIV
Definition token.h:54
@ T_MOD
Definition token.h:60
@ T_ADD
Definition token.h:51
@ T_MUL
Definition token.h:53
@ T_OR
Definition token.h:56

Definition at line 1367 of file unit_test_attribute.c.

◆ write_filename

char const* write_filename = NULL
static

Definition at line 285 of file unit_test_attribute.c.

◆ write_fp

FILE* write_fp = NULL
static

Definition at line 286 of file unit_test_attribute.c.

◆ xlat_test_args

xlat_arg_parser_t const xlat_test_args[]
static
Initial value:
= {
{ .required = true, .single = true, .type = FR_TYPE_STRING },
}
@ FR_TYPE_STRING
String of printable characters.
#define XLAT_ARG_PARSER_TERMINATOR
Definition xlat.h:170

Definition at line 261 of file unit_test_attribute.c.

◆ xlat_test_no_args

xlat_arg_parser_t const xlat_test_no_args[]
static
Initial value:

Definition at line 266 of file unit_test_attribute.c.