54 lines
1.7 KiB
C
54 lines
1.7 KiB
C
#include "sph_worker_reports.h"
|
|
#include "sph_worker_protocol.h"
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
static int fail(const char *message)
|
|
{
|
|
fprintf(stderr, "%s\n", message);
|
|
return 1;
|
|
}
|
|
|
|
static int contains(const char *text, const char *needle)
|
|
{
|
|
return strstr(text, needle) != 0;
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
char record[512];
|
|
if (strcmp(sphlite_worker_report_filename(SPHLITE_WORKER_REPORT_LOG),
|
|
"sphlite_cclite_worker.log") != 0) {
|
|
return fail("worker log filename mismatch");
|
|
}
|
|
if (!contains(sphlite_worker_report_header(SPHLITE_WORKER_REPORT_LOG),
|
|
"command_block") ||
|
|
!contains(sphlite_worker_report_header(SPHLITE_WORKER_REPORT_LOG),
|
|
"ack_sequence") ||
|
|
!contains(sphlite_worker_report_header(SPHLITE_WORKER_REPORT_PARTICLE),
|
|
"external_id") ||
|
|
!contains(sphlite_worker_report_header(SPHLITE_WORKER_REPORT_FORCE),
|
|
"reject_reason")) {
|
|
return fail("worker report header mismatch");
|
|
}
|
|
if (!sphlite_worker_report_vtk_supported()) {
|
|
return fail("VTU/PVD support was not advertised");
|
|
}
|
|
if (sphlite_worker_format_log_record(record, (int)sizeof(record), "SPH",
|
|
"cmd", "data", SPHLITE_WORKER_COMMAND_ADVANCE, 12, 44,
|
|
SPHLITE_WORKER_STATE_DONE, 3, 4, 5, 0, "ok") != 0) {
|
|
return fail("log record formatting failed");
|
|
}
|
|
if (!contains(record, "SPH,cmd,data") ||
|
|
!contains(record, ",44,DONE,") ||
|
|
!contains(record, ",3,4,5,0,ok")) {
|
|
return fail("log record content mismatch");
|
|
}
|
|
if (sphlite_worker_format_log_record(record, 8, "SPH", "cmd", "data",
|
|
1, 2, 3, SPHLITE_WORKER_STATE_DONE, 4, 5, 6, 0, "too-long") == 0) {
|
|
return fail("small log record buffer was accepted");
|
|
}
|
|
return 0;
|
|
}
|