UEFIStarter
a simple UEFI framework
Macros | Functions | Variables
logger.c File Reference

Tests for the logging facility. More...

#include <Uefi.h>
#include <Library/UefiLib.h>
#include <UEFIStarter/core.h>
#include <UEFIStarter/tests/tests.h>

Macros

#define LOG_COUNT_ENTRIES   6
 The number of entries in the log counter array. More...
 

Functions

static void _reset_log_counts ()
 Reset's the log message counters to 0.
 
static void _counting_logger (LOGLEVEL level, CHAR16 *msg)
 A (mostly silent) log printer: instead of showing messages somewhere it just counts how many log entries were generated at which log level. More...
 
static void _assert_log_counts (UINTN error, UINTN warn, UINTN info, UINTN debug, UINTN trace)
 Assertion for log counters. More...
 
void test_logger ()
 Makes sure the log level threshold works. More...
 
BOOLEAN run_logger_tests ()
 Test runner for this group. More...
 

Variables

static UINTN _log_counts [LOG_COUNT_ENTRIES]
 Internal storage for the _counting_logger() function. More...
 

Detailed Description

Tests for the logging facility.

Author
Richard Nusser
License
GPLv3 (see http://www.gnu.org/licenses/)
See also
https://github.com/rinusser/UEFIStarter

Macro Definition Documentation

◆ LOG_COUNT_ENTRIES

#define LOG_COUNT_ENTRIES   6

The number of entries in the log counter array.

Index is of type LOGLEVEL: "OFF" is 0, "TRACE" starts at 1, so we need to reserve the index 0 entry.

Function Documentation

◆ _counting_logger()

static void _counting_logger ( LOGLEVEL  level,
CHAR16 *  msg 
)
static

A (mostly silent) log printer: instead of showing messages somewhere it just counts how many log entries were generated at which log level.

Parameters
levelthe entry's log level
msgthe entry's log message

◆ _assert_log_counts()

static void _assert_log_counts ( UINTN  error,
UINTN  warn,
UINTN  info,
UINTN  debug,
UINTN  trace 
)
static

Assertion for log counters.

Compares all counters to expected values.

Parameters
errorthe expected number of entries at level ERROR
warnthe expected number of entries at level WARN
infothe expected number of entries at level INFO
debugthe expected number of entries at level DEBUG
tracethe expected number of entries at level TRACE

◆ test_logger()

void test_logger ( )

Makes sure the log level threshold works.

Test:

a log event at the current log level should be printed

a log event above the current log level should be printed

a log event below the current log level should be ignored

when the current log level is OFF all log events should be ignored

◆ run_logger_tests()

BOOLEAN run_logger_tests ( )

Test runner for this group.

Gets called via the generated test runner.

Returns
whether the test group was executed

Variable Documentation

◆ _log_counts

UINTN _log_counts[LOG_COUNT_ENTRIES]
static

Internal storage for the _counting_logger() function.

Contains the number of entries issued per log level.