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

Tests for the rate limited logging macros. More...

#include <freeradius-devel/util/test/acutest.h>
#include <freeradius-devel/util/test/acutest_helpers.h>
#include <freeradius-devel/server/log.h>
+ Include dependency graph for log_tests.c:

Go to the source code of this file.

Macros

#define CAPTURE_LOG(_fmt, ...)    ((void) snprintf(captured, sizeof(captured), _fmt, ## __VA_ARGS__), logged++)
 

Functions

static void capture_reset (void)
 
static void test_first_message_logged (void)
 The first message from a fresh entry is logged, even in the first second of the process.
 
static void test_repeat_count_reported (void)
 A message one second after the last one reports the repeats suppressed in between.
 
static void test_repeat_suppressed (void)
 A second message in the same second is counted, not logged.
 

Variables

static char captured [256]
 
static int logged
 
 TEST_LIST
 

Detailed Description

Tests for the rate limited logging macros.

Definition in file log_tests.c.

Macro Definition Documentation

◆ CAPTURE_LOG

#define CAPTURE_LOG (   _fmt,
  ... 
)     ((void) snprintf(captured, sizeof(captured), _fmt, ## __VA_ARGS__), logged++)

Definition at line 36 of file log_tests.c.

Function Documentation

◆ capture_reset()

static void capture_reset ( void  )
static

Definition at line 39 of file log_tests.c.

+ Here is the caller graph for this function:

◆ test_first_message_logged()

static void test_first_message_logged ( void  )
static

The first message from a fresh entry is logged, even in the first second of the process.

fr_time() counts from fr_time_start(). A fresh entry has last_complained of zero, which is second 0, and a message in second 0 of the process compared equal to it and was counted as a repeat instead of being logged.

Definition at line 52 of file log_tests.c.

+ Here is the call graph for this function:

◆ test_repeat_count_reported()

static void test_repeat_count_reported ( void  )
static

A message one second after the last one reports the repeats suppressed in between.

The macro set last_complained to now before computing the time since the last complaint, which was then always zero, and the suffix never appeared.

Definition at line 86 of file log_tests.c.

+ Here is the call graph for this function:

◆ test_repeat_suppressed()

static void test_repeat_suppressed ( void  )
static

A second message in the same second is counted, not logged.

Definition at line 68 of file log_tests.c.

+ Here is the call graph for this function:

Variable Documentation

◆ captured

char captured[256]
static

Definition at line 33 of file log_tests.c.

◆ logged

int logged
static

Definition at line 34 of file log_tests.c.

◆ TEST_LIST

TEST_LIST
Initial value:
= {
{ "first_message_logged", test_first_message_logged },
{ "repeat_suppressed", test_repeat_suppressed },
{ "repeat_count_reported", test_repeat_count_reported },
}
#define TEST_TERMINATOR
Definition acutest.h:77
static void test_first_message_logged(void)
The first message from a fresh entry is logged, even in the first second of the process.
Definition log_tests.c:52
static void test_repeat_suppressed(void)
A second message in the same second is counted, not logged.
Definition log_tests.c:68
static void test_repeat_count_reported(void)
A message one second after the last one reports the repeats suppressed in between.
Definition log_tests.c:86

Definition at line 101 of file log_tests.c.