Push test results for health dashboard

This commit is contained in:
Sergio R. Caprile committed 2025-09-01 14:52:37 -03:00
1 parent bf4dd15317
commit 3baabebb34
4 files changed
+99 -17

No files matched your search

+3 -1
View File
@@ -1,4 +1,6 @@
#!/usr/bin/awk -f
#!/usr/bin/env -S gawk -f
# gawk used to avoid "towc" errors seen on MacOS. env used to circumvent brew installing it wherever they like
BEGIN {
FS="\t"
print "{"
+35 -9
View File
@@ -82,7 +82,12 @@ static const char *s_ca_cert =
static char *host_ip;
static int s_num_tests = 0;
static bool s_error = false;
#ifdef NO_ABORT
static int s_abort = 0;
#define ABORT() ++s_abort, s_error = true
#else
#ifdef NO_SLEEP_ABORT
#define ABORT() abort()
#else
@@ -90,6 +95,7 @@ static int s_num_tests = 0;
sleep(2); /* 2s, GH print reason */ \
abort();
#endif
#endif
#define ASSERT(expr) \
do { \
@@ -101,6 +107,7 @@ static int s_num_tests = 0;
} \
} while (0)
static struct mg_http_message gethm(const char *buf) {
struct mg_http_message hm;
memset(&hm, 0, sizeof(hm));
@@ -531,22 +538,41 @@ int main(void) {
usleep(10000); // 10 ms
}
#define DASHBOARD(x) printf("HEALTH_DASHBOARD\t\"%s\": %s,\n", x, s_error ? "false":"true");
// RUN TESTS
usleep(500000); // 500 ms
s_error = false;
test_http_client(&mgr);
usleep(500000); // 500 ms
test_http_server(&mgr);
usleep(500000); // 500 ms
test_tls(&mgr);
usleep(500000); // 500 ms
test_mqtt_connsubpub(&mgr);
usleep(500000); // 500 ms
DASHBOARD("http_client");
printf("SUCCESS. Total tests: %d\n", s_num_tests);
usleep(500000); // 500 ms
s_error = false;
test_http_server(&mgr);
DASHBOARD("http_server");
usleep(500000); // 500 ms
s_error = false;
test_tls(&mgr);
DASHBOARD("tls");
usleep(500000); // 500 ms
s_error = false;
test_mqtt_connsubpub(&mgr);
DASHBOARD("mqtt");
// Clear
s_error = false;
mg_mgr_free(&mgr);
ASSERT(mgr.conns == NULL); // Deconstruction OK
close(fd);
return 0;
printf("HEALTH_DASHBOARD\t\"cleanup\": %s\n", s_error ? "false":"true");
// last entry with no comma
#ifdef NO_ABORT
if (s_abort != 0) return EXIT_FAILURE;
#endif
printf("SUCCESS. Total tests: %d\n", s_num_tests);
return EXIT_SUCCESS;
}
+31 -1
View File
@@ -6,9 +6,14 @@
#include "driver_mock.c"
static int s_num_tests = 0;
static bool s_error = false;
static int s_sent_fragment = 0;
static int s_seg_sent = 0;
#ifdef NO_ABORT
static int s_abort = 0;
#define ABORT() ++s_abort, s_error = true
#else
#ifdef NO_SLEEP_ABORT
#define ABORT() abort()
#else
@@ -16,6 +21,7 @@ static int s_seg_sent = 0;
sleep(2); /* 2s, GH print reason */ \
abort();
#endif
#endif
#define ASSERT(expr) \
do { \
@@ -27,6 +33,7 @@ static int s_seg_sent = 0;
} \
} while (0)
static void test_csum(void) {
uint8_t ip[20] = {0x45, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x28, 0x11,
0x94, 0xcf, 0x7f, 0x00, 0x00, 0x01, 0x7f, 0x00, 0x00, 0x01};
@@ -811,12 +818,35 @@ static void test_tcp(void) {
test_tcp_retransmit();
}
#define DASHBOARD(x) printf("HEALTH_DASHBOARD\t\"%s\": %s,\n", x, s_error ? "false":"true");
int main(void) {
s_error = false;
test_csum();
DASHBOARD("checksum");
s_error = false;
test_statechange();
DASHBOARD("statechange");
s_error = false;
test_poll();
DASHBOARD("poll");
s_error = false;
test_tcp();
DASHBOARD("tcp");
s_error = false;
test_fragmentation();
printf("HEALTH_DASHBOARD\t\"ipfrag\": %s\n", s_error ? "false":"true");
// last entry with no comma
#ifdef NO_ABORT
if (s_abort != 0) return EXIT_FAILURE;
#endif
printf("SUCCESS. Total tests: %d\n", s_num_tests);
return 0;
return EXIT_SUCCESS;
}