Files
mars-nwe/tests/nwnss/work/test_nwnss_work.c
Mario Fetka 0f82de2743
All checks were successful
Source release / source-package (push) Successful in 1m20s
0536 build: introduce libnwnss for imported NSS runtime
2026-06-14 22:34:04 +02:00

65 lines
1.6 KiB
C

#include <include/control.h>
#include <include/fsm.h>
#include <include/pssmpk.h>
#include <include/register.h>
#include <include/schedule.h>
#include <internal/pssConfig.h>
#include <stdio.h>
#include <stdlib.h>
#define CHECK(expr) do { \
if (!(expr)) { \
fprintf(stderr, "CHECK failed: %s:%d: %s\n", __FILE__, __LINE__, #expr); \
return EXIT_FAILURE; \
} \
} while (0)
extern STATUS WORK_Startup(void);
extern void WORK_Shutdown(void);
extern void WORK_Schedule(FsmLite_s *fsm, voidfunc_t action, ADDR parameter);
extern void WORK_Schedule_HIGH(FsmLite_s *fsm, voidfunc_t action, ADDR parameter);
extern void WORK_Schedule_LOW(FsmLite_s *fsm, voidfunc_t action, ADDR parameter);
extern NINT PendingWork;
typedef struct WorkTest_s {
int value;
} WorkTest_s;
static void work_action(FsmLite_s *fsm, ADDR parameter)
{
WorkTest_s *state = (WorkTest_s *)parameter;
if (fsm != NULL)
{
state->value++;
}
}
int main(void)
{
WorkTest_s state = {0};
FsmLite_s fsm;
FsmLite_s high;
FsmLite_s low;
configStartup();
nssInitializeSpinLockCode();
CHECK(COMN_RegisterLibraryResourceTags("nwnss.work") == zOK);
MPKNSS_LOCK();
CHECK(WORK_Startup() == zOK);
FSMLITE_INIT(&fsm, "work", 0);
FSMLITE_INIT(&high, "work-high", 1);
FSMLITE_INIT(&low, "work-low", 2);
WORK_Schedule(&fsm, (voidfunc_t)work_action, (ADDR)&state);
WORK_Schedule_HIGH(&high, (voidfunc_t)work_action, (ADDR)&state);
WORK_Schedule_LOW(&low, (voidfunc_t)work_action, (ADDR)&state);
CHECK(state.value == 3);
CHECK(PendingWork == 0);
WORK_Shutdown();
MPKNSS_UNLOCK();
return EXIT_SUCCESS;
}