69 lines
1.5 KiB
C
69 lines
1.5 KiB
C
#include <msgGen.h>
|
|
#include <msg.h>
|
|
#include <xError.h>
|
|
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
|
|
#define CHECK(expr) do { \
|
|
if (!(expr)) { \
|
|
fprintf(stderr, "CHECK failed at %s:%d: %s\n", __FILE__, __LINE__, #expr); \
|
|
return 1; \
|
|
} \
|
|
} while (0)
|
|
|
|
static int check_general_errno(void)
|
|
{
|
|
GeneralMsg_s genMsg;
|
|
|
|
genMsg.errStatus = zOK;
|
|
genMsg.errStatusSetter = NULL;
|
|
|
|
LB_SetErrno(&genMsg, zERR_FAILURE, "first");
|
|
CHECK(genMsg.errStatus == zERR_FAILURE);
|
|
CHECK(genMsg.errStatusSetter != NULL);
|
|
|
|
LB_SetErrno(&genMsg, zERR_NO_MEMORY, "oom");
|
|
CHECK(genMsg.errStatus == zERR_NO_MEMORY);
|
|
|
|
LB_SetErrno(&genMsg, zERR_FAILURE, "ignored");
|
|
CHECK(genMsg.errStatus == zERR_NO_MEMORY);
|
|
|
|
LB_ForceSetErrnoWithWhere(&genMsg, zERR_FAILURE, "forced");
|
|
CHECK(genMsg.errStatus == zERR_FAILURE);
|
|
CHECK(genMsg.errStatusSetter != NULL);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int check_msg_status(void)
|
|
{
|
|
Msg_s msg;
|
|
|
|
msg.sys.status = zOK;
|
|
msg.sys.where = 0;
|
|
|
|
MSG_SetStatus(&msg, zERR_FAILURE, "first");
|
|
CHECK(msg.sys.status == zERR_FAILURE);
|
|
CHECK(msg.sys.where != 0);
|
|
|
|
MSG_SetStatus(&msg, zERR_OUT_OF_SPACE, "space");
|
|
CHECK(msg.sys.status == zERR_OUT_OF_SPACE);
|
|
|
|
MSG_SetStatus(&msg, zERR_FAILURE, "ignored");
|
|
CHECK(msg.sys.status == zERR_OUT_OF_SPACE);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
if (check_general_errno() != 0) {
|
|
return 1;
|
|
}
|
|
if (check_msg_status() != 0) {
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|