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

Tests for a generic string buffer structure for string printing and parsing. More...

#include "acutest.h"
#include "acutest_helpers.h"
#include <freeradius-devel/util/time.h>
+ Include dependency graph for time_tests.c:

Go to the source code of this file.

Macros

#define ROUNDS   (100000)
 

Functions

static void check_delta_from_str (char const *in, fr_time_res_t hint, int64_t expected)
 
static void check_delta_from_str_fail (char const *in, fr_time_res_t hint)
 
static void time_benchmark (void)
 
static void time_delta_from_str (void)
 Parse time deltas from strings: integers, floats, scale suffixes, timestamps and errors.
 
static void time_delta_to_str (void)
 Format time deltas to strings across sign, fraction and the unsigned flag.
 
static void time_delta_to_str_int64_min (void)
 Format the most negative delta possible.
 
static void time_elapsed_update (void)
 Test fr_time_elapsed_update sorts delays into the correct histogram bins.
 
static void time_scale (void)
 Test fr_time_scale: per-resolution multipliers, clamping and invalid hints.
 
static void unix_time_from_tm (void)
 Test fr_unix_time_from_tm against well-known UTC epochs.
 
static void unix_time_str (void)
 Round-trip fr_unix_time_from_str() and fr_unix_time_to_str() in UTC.
 

Variables

 TEST_LIST
 

Detailed Description

Tests for a generic string buffer structure for string printing and parsing.

Definition in file time_tests.c.

Macro Definition Documentation

◆ ROUNDS

#define ROUNDS   (100000)

Definition at line 27 of file time_tests.c.

Function Documentation

◆ check_delta_from_str()

static void check_delta_from_str ( char const *  in,
fr_time_res_t  hint,
int64_t  expected 
)
static

Definition at line 87 of file time_tests.c.

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

◆ check_delta_from_str_fail()

static void check_delta_from_str_fail ( char const *  in,
fr_time_res_t  hint 
)
static

Definition at line 100 of file time_tests.c.

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

◆ time_benchmark()

static void time_benchmark ( void  )
static

Definition at line 30 of file time_tests.c.

+ Here is the call graph for this function:

◆ time_delta_from_str()

static void time_delta_from_str ( void  )
static

Parse time deltas from strings: integers, floats, scale suffixes, timestamps and errors.

Definition at line 111 of file time_tests.c.

+ Here is the call graph for this function:

◆ time_delta_to_str()

static void time_delta_to_str ( void  )
static

Format time deltas to strings across sign, fraction and the unsigned flag.

Definition at line 184 of file time_tests.c.

+ Here is the call graph for this function:

◆ time_delta_to_str_int64_min()

static void time_delta_to_str_int64_min ( void  )
static

Format the most negative delta possible.

fr_time_delta_to_str() takes the magnitude of the delta with a MOD()
macro.  INT64_MIN is the awkward case: negating it in a signed type is
undefined (its positive counterpart, 2^63, isn't representable in
int64_t), so the magnitude has to be taken in the unsigned domain.
This checks the boundary formats correctly rather than tripping UBSan.

Definition at line 60 of file time_tests.c.

+ Here is the call graph for this function:

◆ time_elapsed_update()

static void time_elapsed_update ( void  )
static

Test fr_time_elapsed_update sorts delays into the correct histogram bins.

Definition at line 310 of file time_tests.c.

+ Here is the call graph for this function:

◆ time_scale()

static void time_scale ( void  )
static

Test fr_time_scale: per-resolution multipliers, clamping and invalid hints.

Definition at line 215 of file time_tests.c.

+ Here is the call graph for this function:

◆ unix_time_from_tm()

static void unix_time_from_tm ( void  )
static

Test fr_unix_time_from_tm against well-known UTC epochs.

Definition at line 234 of file time_tests.c.

+ Here is the call graph for this function:

◆ unix_time_str()

static void unix_time_str ( void  )
static

Round-trip fr_unix_time_from_str() and fr_unix_time_to_str() in UTC.

Definition at line 272 of file time_tests.c.

+ Here is the call graph for this function:

Variable Documentation

◆ TEST_LIST

TEST_LIST
Initial value:
= {
{ "time_const_benchmark", time_benchmark },
{ "time_delta_to_str_int64_min", time_delta_to_str_int64_min },
{ "time_delta_from_str", time_delta_from_str },
{ "time_delta_to_str", time_delta_to_str },
{ "time_scale", time_scale },
{ "unix_time_from_tm", unix_time_from_tm },
{ "unix_time_str", unix_time_str },
{ "time_elapsed_update", time_elapsed_update },
{ 0 }
}
static void unix_time_str(void)
Round-trip fr_unix_time_from_str() and fr_unix_time_to_str() in UTC.
Definition time_tests.c:272
static void time_delta_from_str(void)
Parse time deltas from strings: integers, floats, scale suffixes, timestamps and errors.
Definition time_tests.c:111
static void time_delta_to_str_int64_min(void)
Format the most negative delta possible.
Definition time_tests.c:60
static void time_delta_to_str(void)
Format time deltas to strings across sign, fraction and the unsigned flag.
Definition time_tests.c:184
static void unix_time_from_tm(void)
Test fr_unix_time_from_tm against well-known UTC epochs.
Definition time_tests.c:234
static void time_elapsed_update(void)
Test fr_time_elapsed_update sorts delays into the correct histogram bins.
Definition time_tests.c:310
static void time_benchmark(void)
Definition time_tests.c:30
static void time_scale(void)
Test fr_time_scale: per-resolution multipliers, clamping and invalid hints.
Definition time_tests.c:215

Definition at line 341 of file time_tests.c.