Add test CI
This commit is contained in:
parent
f800caaef5
commit
eac2029d00
|
|
@ -2,6 +2,7 @@ image: registry.es.av.it.pt/its/it2s-docker/archlinux-maker
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- build
|
- build
|
||||||
|
- test
|
||||||
- deploy release
|
- deploy release
|
||||||
- deploy debug
|
- deploy debug
|
||||||
|
|
||||||
|
|
@ -18,6 +19,13 @@ build:
|
||||||
- ./build/src/it2s-itss-facilities
|
- ./build/src/it2s-itss-facilities
|
||||||
expire_in: 1 hour
|
expire_in: 1 hour
|
||||||
|
|
||||||
|
test:
|
||||||
|
stage: test
|
||||||
|
extends: .dependencies
|
||||||
|
script:
|
||||||
|
- cd test
|
||||||
|
- sh spawn.sh
|
||||||
|
|
||||||
deploy release:
|
deploy release:
|
||||||
stage: deploy release
|
stage: deploy release
|
||||||
script:
|
script:
|
||||||
|
|
|
||||||
|
|
@ -6,3 +6,4 @@ SET(BUILD_SHARED_LIBS ON)
|
||||||
SET(CMAKE_INSTALL_PREFIX "/usr")
|
SET(CMAKE_INSTALL_PREFIX "/usr")
|
||||||
|
|
||||||
ADD_SUBDIRECTORY(src)
|
ADD_SUBDIRECTORY(src)
|
||||||
|
ADD_SUBDIRECTORY(test)
|
||||||
|
|
|
||||||
136
test/tester.c
136
test/tester.c
|
|
@ -2,6 +2,8 @@
|
||||||
#include <itss-transport/BTPDataIndication.h>
|
#include <itss-transport/BTPDataIndication.h>
|
||||||
#include <itss-facilities/FacilitiesDataIndication.h>
|
#include <itss-facilities/FacilitiesDataIndication.h>
|
||||||
#include <itss-facilities/FacilitiesDataRequest.h>
|
#include <itss-facilities/FacilitiesDataRequest.h>
|
||||||
|
#include <itss-management/ManagementRequest.h>
|
||||||
|
#include <itss-management/ManagementReply.h>
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <zmq.h>
|
#include <zmq.h>
|
||||||
|
|
@ -18,7 +20,133 @@ void hex2bin(char* hex, uint8_t** bin, uint16_t* bin_len) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int decap(void* ctx) {
|
int init(void* ctx) {
|
||||||
|
printf("Initializing management simulator \n");
|
||||||
|
|
||||||
|
void* management_socket = zmq_socket(ctx, ZMQ_REP);
|
||||||
|
zmq_bind(management_socket, "ipc:///tmp/itss/management");
|
||||||
|
uint8_t buffer[2048];
|
||||||
|
|
||||||
|
// Ignore first request (set)
|
||||||
|
zmq_recv(management_socket, buffer, 2048, 0);
|
||||||
|
int code = 0;
|
||||||
|
zmq_send(management_socket, buffer, 2048, 0);
|
||||||
|
|
||||||
|
// Request get
|
||||||
|
zmq_recv(management_socket, buffer, 2048, 0);
|
||||||
|
int rv = 0;
|
||||||
|
|
||||||
|
ManagementRequest_t* mreq = NULL;
|
||||||
|
asn_dec_rval_t dec = asn_decode(NULL, ATS_CANONICAL_OER, &asn_DEF_ManagementRequest, (void**) &mreq, buffer, 2048);
|
||||||
|
if (dec.code) {
|
||||||
|
rv = 1;
|
||||||
|
printf(" FAIL: MREQ decode error\n");
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
printf(" - Received MREQ\n");
|
||||||
|
|
||||||
|
ManagementReply_t* mrep = calloc(1, sizeof(ManagementReply_t));
|
||||||
|
switch (mreq->present) {
|
||||||
|
case ManagementRequest_PR_get:
|
||||||
|
mrep->returnCode = ManagementReplyReturnCode_accepted;
|
||||||
|
mrep->attributes = calloc(1, sizeof(ManagementReplyAttributes_t));
|
||||||
|
|
||||||
|
if (mreq->choice.get.stationId) {
|
||||||
|
mrep->attributes->stationId = malloc(sizeof(long));
|
||||||
|
*mrep->attributes->stationId = 78;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mreq->choice.get.gpsType) {
|
||||||
|
mrep->attributes->gpsType = malloc(sizeof(long));
|
||||||
|
*mrep->attributes->gpsType = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mreq->choice.get.clockType) {
|
||||||
|
mrep->attributes->clockType = malloc(sizeof(long));
|
||||||
|
*mrep->attributes->clockType = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mreq->choice.get.clock) {
|
||||||
|
mrep->attributes->clock = calloc(1, sizeof(TimestampIts_t));
|
||||||
|
asn_ulong2INTEGER(mrep->attributes->clock, 666);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mreq->choice.get.clockOffset) {
|
||||||
|
mrep->attributes->clockOffset = calloc(1, sizeof(TimestampIts_t));
|
||||||
|
asn_ulong2INTEGER(mrep->attributes->clockOffset, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mreq->choice.get.coordinates) {
|
||||||
|
mrep->attributes->coordinates = calloc(1, sizeof(WGS84Coordinates_t));
|
||||||
|
mrep->attributes->coordinates->latitude = 0;
|
||||||
|
mrep->attributes->coordinates->longitude = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mreq->choice.get.altitude) {
|
||||||
|
mrep->attributes->altitude = calloc(1, sizeof(Altitude_t));
|
||||||
|
mrep->attributes->altitude->altitudeValue = 0;
|
||||||
|
mrep->attributes->altitude->altitudeConfidence = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mreq->choice.get.speed) {
|
||||||
|
mrep->attributes->speed = calloc(1, sizeof(Speed_t));
|
||||||
|
mrep->attributes->speed->speedValue = 0;
|
||||||
|
mrep->attributes->speed->speedConfidence = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mreq->choice.get.heading) {
|
||||||
|
mrep->attributes->heading = calloc(1, sizeof(Heading_t));
|
||||||
|
mrep->attributes->heading->headingValue = 0;
|
||||||
|
mrep->attributes->heading->headingConfidence = 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ManagementRequest_PR_set:
|
||||||
|
default:
|
||||||
|
rv = 1;
|
||||||
|
printf(" FAIL: MREQ. not GET (%d)\n", mreq->present);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
asn_enc_rval_t enc = oer_encode_to_buffer(&asn_DEF_ManagementReply, NULL, mrep, buffer, 256);
|
||||||
|
zmq_send(management_socket, buffer, enc.encoded, 0);
|
||||||
|
|
||||||
|
printf(" OK\n");
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
ASN_STRUCT_FREE(asn_DEF_ManagementRequest, mreq);
|
||||||
|
ASN_STRUCT_FREE(asn_DEF_ManagementReply, mrep);
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
int cam_gen(void* ctx) {
|
||||||
|
printf("Testing CAM generation:\n");
|
||||||
|
|
||||||
|
void* transport_socket = zmq_socket(ctx, ZMQ_REP);
|
||||||
|
|
||||||
|
zmq_bind(transport_socket, "ipc:///tmp/itss/transport");
|
||||||
|
uint8_t buffer[2048];
|
||||||
|
zmq_recv(transport_socket, buffer, 2048, 0);
|
||||||
|
int code = 0;
|
||||||
|
zmq_send(transport_socket, &code, 1, 0);
|
||||||
|
|
||||||
|
zmq_close(transport_socket);
|
||||||
|
|
||||||
|
BTPDataRequest_t* bdr = NULL;
|
||||||
|
asn_dec_rval_t dec = asn_decode(NULL, ATS_CANONICAL_OER, &asn_DEF_BTPDataRequest, (void**) &bdr, buffer+1, 2047);
|
||||||
|
if (dec.code) {
|
||||||
|
printf(" FAIL\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
printf(" - Received CAM BDR (%ldB)\n", bdr->data.size);
|
||||||
|
|
||||||
|
if (bdr->destinationPort == Port_cam) {
|
||||||
|
printf(" OK\n");
|
||||||
|
} else {
|
||||||
|
printf(" FAIL\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -38,6 +166,7 @@ int forward_up(void* ctx) {
|
||||||
bdi->data.size = cam_len;
|
bdi->data.size = cam_len;
|
||||||
bdi->gnDestinationAddress.buf = calloc(1, 6);
|
bdi->gnDestinationAddress.buf = calloc(1, 6);
|
||||||
bdi->gnDestinationAddress.size = 6;
|
bdi->gnDestinationAddress.size = 6;
|
||||||
|
bdi->destinationPort = Port_cam;
|
||||||
|
|
||||||
uint8_t b_bdi_cam[512];
|
uint8_t b_bdi_cam[512];
|
||||||
b_bdi_cam[0] = 3;
|
b_bdi_cam[0] = 3;
|
||||||
|
|
@ -93,8 +222,11 @@ int main() {
|
||||||
|
|
||||||
void* ctx = zmq_ctx_new();
|
void* ctx = zmq_ctx_new();
|
||||||
|
|
||||||
|
rv += init(ctx);
|
||||||
|
if (rv) return 1;
|
||||||
|
|
||||||
rv += forward_up(ctx);
|
rv += forward_up(ctx);
|
||||||
rv += decap(ctx);
|
rv += cam_gen(ctx);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue