C test module for PICurv.
More...
#include "test_support.h"
#include "logging.h"
#include <stdlib.h>
Go to the source code of this file.
C test module for PICurv.
Definition in file test_logging.c.
◆ TestGetLogLevelFromEnvironment()
| static PetscErrorCode TestGetLogLevelFromEnvironment |
( |
void |
| ) |
|
|
static |
Test-local routine.
Definition at line 15 of file test_logging.c.
16{
17 PetscFunctionBeginUser;
19 "get_log_level should honor LOG_LEVEL=INFO in this test binary"));
21 PetscFunctionReturn(0);
22}
PetscErrorCode print_log_level(void)
Prints the current logging level to the console.
LogLevel get_log_level()
Retrieves the current logging level from the environment variable LOG_LEVEL.
@ LOG_INFO
Informational messages about program execution.
PetscErrorCode PicurvAssertIntEqual(PetscInt expected, PetscInt actual, const char *context)
Shared test-support routine.
◆ TestAllowedFunctionsFilter()
| static PetscErrorCode TestAllowedFunctionsFilter |
( |
void |
| ) |
|
|
static |
Test-local routine.
Definition at line 27 of file test_logging.c.
28{
29 const char *allow_list[] = {"ComputeSpecificKE", "WriteEulerianFile"};
30
31 PetscFunctionBeginUser;
34 "Allowed list should include ComputeSpecificKE"));
36 "Allowed list should exclude unknown function names"));
37
40 "Empty allow-list should permit all functions"));
41 PetscFunctionReturn(0);
42}
void set_allowed_functions(const char **functionList, int count)
Sets the global list of function names that are allowed to log.
PetscBool is_function_allowed(const char *functionName)
Checks if a given function is in the allow-list.
PetscErrorCode PicurvAssertBool(PetscBool value, const char *context)
Shared test-support routine.
◆ TestParticleConsoleSnapshotCadence()
| static PetscErrorCode TestParticleConsoleSnapshotCadence |
( |
void |
| ) |
|
|
static |
Test-local routine.
Definition at line 47 of file test_logging.c.
48{
50
51 PetscFunctionBeginUser;
52 PetscCall(PetscMemzero(&simCtx, sizeof(simCtx)));
55
57 "Particle snapshot contract should be enabled when particles and cadence are configured"));
59 "Snapshot should emit on cadence-aligned completed steps"));
61 "Snapshot should not emit off-cadence"));
62
65 "Zero cadence should disable periodic particle snapshots"));
67 "NULL SimCtx should never emit periodic snapshots"));
68 PetscFunctionReturn(0);
69}
PetscBool ShouldEmitPeriodicParticleConsoleSnapshot(const SimCtx *simCtx, PetscInt completed_step)
Returns whether a particle console snapshot should be emitted for the completed timestep.
PetscBool IsParticleConsoleSnapshotEnabled(const SimCtx *simCtx)
Returns whether periodic particle console snapshots are enabled.
PetscInt particleConsoleOutputFreq
The master context for the entire simulation.
◆ main()
| int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Entry point for this unit-test binary.
Definition at line 74 of file test_logging.c.
75{
76 PetscErrorCode ierr;
81 };
82
83 (void)setenv("LOG_LEVEL", "INFO", 1);
84
85 ierr = PetscInitialize(&argc, &argv, NULL, "PICurv logging tests");
86 if (ierr) {
87 return (int)ierr;
88 }
89
90 ierr =
PicurvRunTests(
"unit-logging", cases,
sizeof(cases) /
sizeof(cases[0]));
91 if (ierr) {
92 PetscFinalize();
93 return (int)ierr;
94 }
95
97
98 ierr = PetscFinalize();
99 return (int)ierr;
100}
static PetscErrorCode TestParticleConsoleSnapshotCadence(void)
Test-local routine.
static PetscErrorCode TestGetLogLevelFromEnvironment(void)
Test-local routine.
static PetscErrorCode TestAllowedFunctionsFilter(void)
Test-local routine.
PetscErrorCode PicurvRunTests(const char *suite_name, const PicurvTestCase *cases, size_t case_count)
Shared test-support routine.
Named test case descriptor consumed by PicurvRunTests.