No unit tests for the logging module (log.c/log.h) #62

Closed
opened 2026-07-20 17:14:08 +02:00 by TapTap · 0 comments
Owner

Description

The src/shared/log.c and src/shared/log.h logging module has no dedicated unit tests. While logging is a straightforward module, there are behaviors worth testing:

  1. set_log_level() filtering works correctly (messages below threshold are suppressed)
  2. log_message() with various log levels
  3. Thread safety of the logging (the module uses no synchronization)

Location

src/shared/log.c, src/shared/log.h

Suggested Fix

Add a simple test that:

  1. Sets log level to ERROR
  2. Verifies that DEBUG/INFO/WARNING messages are suppressed
  3. Sets log level to DEBUG
  4. Verifies all messages are logged

A simple approach is to capture stderr output using freopen() or pipe redirection, or to add a test-only function that checks the current log level.

Severity

Low

Category

Quality

## Description The `src/shared/log.c` and `src/shared/log.h` logging module has no dedicated unit tests. While logging is a straightforward module, there are behaviors worth testing: 1. `set_log_level()` filtering works correctly (messages below threshold are suppressed) 2. `log_message()` with various log levels 3. Thread safety of the logging (the module uses no synchronization) ## Location `src/shared/log.c`, `src/shared/log.h` ## Suggested Fix Add a simple test that: 1. Sets log level to ERROR 2. Verifies that DEBUG/INFO/WARNING messages are suppressed 3. Sets log level to DEBUG 4. Verifies all messages are logged A simple approach is to capture stderr output using `freopen()` or pipe redirection, or to add a test-only function that checks the current log level. ## Severity Low ## Category Quality
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TapTap/FastSync#62