17 PetscFunctionBeginUser;
19 "get_log_level should honor LOG_LEVEL=INFO in this test binary"));
21 PetscFunctionReturn(0);
29 const char *allow_list[] = {
"ComputeSpecificKE",
"WriteEulerianFile"};
31 PetscFunctionBeginUser;
34 "Allowed list should include ComputeSpecificKE"));
36 "Allowed list should exclude unknown function names"));
40 "Empty allow-list should permit all functions"));
41 PetscFunctionReturn(0);
51 PetscFunctionBeginUser;
52 PetscCall(PetscMemzero(&simCtx,
sizeof(simCtx)));
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"));
65 "Zero cadence should disable periodic particle snapshots"));
67 "NULL SimCtx should never emit periodic snapshots"));
68 PetscFunctionReturn(0);
74int main(
int argc,
char **argv)
83 (void)setenv(
"LOG_LEVEL",
"INFO", 1);
85 ierr = PetscInitialize(&argc, &argv, NULL,
"PICurv logging tests");
90 ierr =
PicurvRunTests(
"unit-logging", cases,
sizeof(cases) /
sizeof(cases[0]));
98 ierr = PetscFinalize();
Logging utilities and macros for PETSc-based applications.
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.
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.
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.
static PetscErrorCode TestParticleConsoleSnapshotCadence(void)
Test-local routine.
static PetscErrorCode TestGetLogLevelFromEnvironment(void)
Test-local routine.
int main(int argc, char **argv)
Entry point for this unit-test binary.
static PetscErrorCode TestAllowedFunctionsFilter(void)
Test-local routine.
PetscErrorCode PicurvRunTests(const char *suite_name, const PicurvTestCase *cases, size_t case_count)
Shared test-support routine.
PetscErrorCode PicurvAssertIntEqual(PetscInt expected, PetscInt actual, const char *context)
Shared test-support routine.
PetscErrorCode PicurvAssertBool(PetscBool value, const char *context)
Shared test-support routine.
C test module for PICurv.
Named test case descriptor consumed by PicurvRunTests.
PetscInt particleConsoleOutputFreq
The master context for the entire simulation.