Files
Codesys-Library-Atom-Modbus/component-source/tests/test_bridge.c
T

20 lines
1.0 KiB
C

#include "atom_bridge.h"
#include <assert.h>
#include <stdio.h>
#define CALL(cmd,h) ab_call(cmd,h,0x7f000001u,502,1,3,0,2,NULL,0,status,24,100,2000,1000,1000)
int main(void) {
uint32_t status[24],handles[16],old,newh; unsigned i;
assert(ab_call(AB_OPEN,0,0,502,0,0,0,0,NULL,0,status,23,0,0,0,0)==AB_BAD_CAPACITY);
for(i=0;i<16;i++) { assert(CALL(AB_OPEN,0)==0); handles[i]=status[0]; assert(handles[i]); }
assert(CALL(AB_OPEN,0)==AB_POOL_FULL);
old=handles[0]; assert(CALL(AB_CLOSE,old)==0); assert(CALL(AB_TICK,old)==AB_BAD_HANDLE);
assert(CALL(AB_OPEN,0)==0); newh=status[0]; assert(newh!=old);
assert(CALL(AB_CONFIGURE,newh)==0); assert(CALL(AB_ENABLE,newh)==0);
assert(CALL(AB_REQUEST_TIMEOUT,newh)==0); assert(status[22]==1000);
assert(CALL(AB_CONFIGURE,newh)==2); assert(CALL(AB_SUBMIT,newh)==3);
assert(CALL(AB_DISABLE,newh)==0); assert(CALL(AB_COPY_READ,newh)==1);
ab_shutdown(); assert(CALL(AB_TICK,newh)==AB_BAD_HANDLE);
puts("PASS bridge: capacity, pool limit, stale handles, configure, offline submission, shutdown");
return 0;
}