Skip to content

Commit 3baabeb

Browse files
committed
Push test results for health dashboard
1 parent bf4dd15 commit 3baabeb

File tree

4 files changed

+94
-12
lines changed

4 files changed

+94
-12
lines changed

.github/workflows/nightly.yml

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,17 @@ jobs:
5959
env:
6060
CC: ${{ matrix.cc }}
6161
SSL: ${{ matrix.ssl }}
62-
TFLAGS: -DMQTT_LOCALHOST
62+
TFLAGS: -DMQTT_LOCALHOST -DNO_ABORT
6363
steps:
6464
- uses: actions/checkout@v4
6565
with: { fetch-depth: 2 }
66-
- run: if [ "${{ matrix.target }}" == "mip_tap_test" ]; then ./test/setup_ga_network.sh ; fi && sudo apt -y update ; sudo apt -y install libmbedtls-dev libwolfssl-dev && make -C test ${{ matrix.target }} IPV6=0
66+
- uses: webfactory/[email protected]
67+
with:
68+
ssh-private-key: ${{ secrets.HEALTH_TESTS_SSH_KEY }}
69+
- run: if [ "${{ matrix.target }}" == "mip_tap_test" ]; then ./test/setup_ga_network.sh ; fi && sudo apt -y update ; sudo apt -y install libmbedtls-dev libwolfssl-dev && make -C test ${{ matrix.target }} IPV6=0 > log
70+
- run: test/health.awk < log > json
71+
- run: scp -o "StrictHostKeyChecking=no" json "[email protected]:/data/downloads/${{ matrix.target }}_${{ matrix.cc }}_${{ matrix.ssl }}_$(date +"%Y%m%d").json"
72+
6773
mip89:
6874
runs-on: ubuntu-latest
6975
strategy:
@@ -156,9 +162,15 @@ jobs:
156162
steps:
157163
- uses: actions/checkout@v4
158164
with: { fetch-depth: 2 }
159-
- run: brew install mbedtls wolfssl mosquitto # jq openssl already pre-installed
165+
- uses: webfactory/[email protected]
166+
with:
167+
ssh-private-key: ${{ secrets.HEALTH_TESTS_SSH_KEY }}
168+
- run: brew install mbedtls wolfssl mosquitto gawk # jq openssl already pre-installed
160169
- run: /opt/homebrew/opt/mosquitto/sbin/mosquitto -c /Users/runner/work/mongoose/mongoose/test/mosquitto.conf.macos &
161-
- run: make -C test test ASAN_OPTIONS= MBEDTLS=$(echo $(brew --cellar)/mbedtls*/*) OPENSSL=$(echo $(brew --cellar)/openssl*/*) WOLFSSL=$(echo $(brew --cellar)/wolfssl*/*)
170+
- run: make -C test test ASAN_OPTIONS= MBEDTLS=$(echo $(brew --cellar)/mbedtls*/*) OPENSSL=$(echo $(brew --cellar)/openssl*/*) WOLFSSL=$(echo $(brew --cellar)/wolfssl*/*) > log
171+
- run: test/health.awk < log > json
172+
- run: scp -o "StrictHostKeyChecking=no" json "[email protected]:/data/downloads/macos_test_cc_${{ matrix.ssl }}_${{ matrix.select }}_$(date +"%Y%m%d").json"
173+
162174
windows:
163175
runs-on: ubuntu-latest
164176
strategy:
@@ -178,7 +190,13 @@ jobs:
178190
steps:
179191
- uses: actions/checkout@v4
180192
with: { fetch-depth: 2 }
181-
- run: ./test/setup_mqtt_server.sh && make -C test ${{ matrix.target }}
193+
- uses: webfactory/[email protected]
194+
with:
195+
ssh-private-key: ${{ secrets.HEALTH_TESTS_SSH_KEY }}
196+
- run: ./test/setup_mqtt_server.sh && make -C test ${{ matrix.target }} > log
197+
- run: test/health.awk < log > json
198+
- run: scp -o "StrictHostKeyChecking=no" json "[email protected]:/data/downloads/windows_${{ matrix.target }}_${{ matrix.cc }}_${{ matrix.ssl }}_${{ matrix.select }}_$(date +"%Y%m%d").json"
199+
182200
arm:
183201
runs-on: ubuntu-latest
184202
strategy:
@@ -209,9 +227,15 @@ jobs:
209227
name: tutorials ${{ matrix.ssl }}
210228
steps:
211229
- uses: actions/checkout@v4
230+
- uses: webfactory/[email protected]
231+
with:
232+
ssh-private-key: ${{ secrets.HEALTH_TESTS_SSH_KEY }}
212233
- run: sudo apt -y install libpcap-dev
213-
- run: make -C test tutorials CFLAGS_EXTRA="${{ matrix.ssl }}"
234+
- run: make -C test tutorials CFLAGS_EXTRA="${{ matrix.ssl }}" > log
235+
- run: test/health.awk < log > json
236+
- run: scp -o "StrictHostKeyChecking=no" json "[email protected]:/data/downloads/tutorials_${{ matrix.ssl }}_$(date +"%Y%m%d").json"
214237
- run: make -C test clean_tutorials
238+
215239
tutorials_win:
216240
runs-on: windows-latest
217241
strategy:

test/health.awk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
#!/usr/bin/awk -f
1+
#!/usr/bin/env -S gawk -f
2+
# gawk used to avoid "towc" errors seen on MacOS. env used to circumvent brew installing it wherever they like
3+
24
BEGIN {
35
FS="\t"
46
print "{"

test/mip_tap_test.c

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,20 @@ static const char *s_ca_cert =
8282
static char *host_ip;
8383

8484
static int s_num_tests = 0;
85+
static bool s_error = false;
8586

87+
#ifdef NO_ABORT
88+
static int s_abort = 0;
89+
#define ABORT() ++s_abort, s_error = true
90+
#else
8691
#ifdef NO_SLEEP_ABORT
8792
#define ABORT() abort()
8893
#else
8994
#define ABORT() \
9095
sleep(2); /* 2s, GH print reason */ \
9196
abort();
9297
#endif
98+
#endif
9399

94100
#define ASSERT(expr) \
95101
do { \
@@ -101,6 +107,7 @@ static int s_num_tests = 0;
101107
} \
102108
} while (0)
103109

110+
104111
static struct mg_http_message gethm(const char *buf) {
105112
struct mg_http_message hm;
106113
memset(&hm, 0, sizeof(hm));
@@ -531,22 +538,41 @@ int main(void) {
531538
usleep(10000); // 10 ms
532539
}
533540

541+
#define DASHBOARD(x) printf("HEALTH_DASHBOARD\t\"%s\": %s,\n", x, s_error ? "false":"true");
542+
534543
// RUN TESTS
535544
usleep(500000); // 500 ms
545+
s_error = false;
536546
test_http_client(&mgr);
547+
DASHBOARD("http_client");
548+
537549
usleep(500000); // 500 ms
550+
s_error = false;
538551
test_http_server(&mgr);
552+
DASHBOARD("http_server");
553+
539554
usleep(500000); // 500 ms
555+
s_error = false;
540556
test_tls(&mgr);
557+
DASHBOARD("tls");
558+
541559
usleep(500000); // 500 ms
560+
s_error = false;
542561
test_mqtt_connsubpub(&mgr);
543-
usleep(500000); // 500 ms
544-
545-
printf("SUCCESS. Total tests: %d\n", s_num_tests);
562+
DASHBOARD("mqtt");
546563

547564
// Clear
565+
s_error = false;
548566
mg_mgr_free(&mgr);
549567
ASSERT(mgr.conns == NULL); // Deconstruction OK
550568
close(fd);
551-
return 0;
569+
printf("HEALTH_DASHBOARD\t\"cleanup\": %s\n", s_error ? "false":"true");
570+
// last entry with no comma
571+
572+
#ifdef NO_ABORT
573+
if (s_abort != 0) return EXIT_FAILURE;
574+
#endif
575+
576+
printf("SUCCESS. Total tests: %d\n", s_num_tests);
577+
return EXIT_SUCCESS;
552578
}

test/mip_test.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,22 @@
66
#include "driver_mock.c"
77

88
static int s_num_tests = 0;
9+
static bool s_error = false;
910
static int s_sent_fragment = 0;
1011
static int s_seg_sent = 0;
1112

13+
#ifdef NO_ABORT
14+
static int s_abort = 0;
15+
#define ABORT() ++s_abort, s_error = true
16+
#else
1217
#ifdef NO_SLEEP_ABORT
1318
#define ABORT() abort()
1419
#else
1520
#define ABORT() \
1621
sleep(2); /* 2s, GH print reason */ \
1722
abort();
1823
#endif
24+
#endif
1925

2026
#define ASSERT(expr) \
2127
do { \
@@ -27,6 +33,7 @@ static int s_seg_sent = 0;
2733
} \
2834
} while (0)
2935

36+
3037
static void test_csum(void) {
3138
uint8_t ip[20] = {0x45, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x28, 0x11,
3239
0x94, 0xcf, 0x7f, 0x00, 0x00, 0x01, 0x7f, 0x00, 0x00, 0x01};
@@ -811,12 +818,35 @@ static void test_tcp(void) {
811818
test_tcp_retransmit();
812819
}
813820

821+
822+
#define DASHBOARD(x) printf("HEALTH_DASHBOARD\t\"%s\": %s,\n", x, s_error ? "false":"true");
823+
814824
int main(void) {
825+
s_error = false;
815826
test_csum();
827+
DASHBOARD("checksum");
828+
829+
s_error = false;
816830
test_statechange();
831+
DASHBOARD("statechange");
832+
833+
s_error = false;
817834
test_poll();
835+
DASHBOARD("poll");
836+
837+
s_error = false;
818838
test_tcp();
839+
DASHBOARD("tcp");
840+
841+
s_error = false;
819842
test_fragmentation();
843+
printf("HEALTH_DASHBOARD\t\"ipfrag\": %s\n", s_error ? "false":"true");
844+
// last entry with no comma
845+
846+
#ifdef NO_ABORT
847+
if (s_abort != 0) return EXIT_FAILURE;
848+
#endif
849+
820850
printf("SUCCESS. Total tests: %d\n", s_num_tests);
821-
return 0;
851+
return EXIT_SUCCESS;
822852
}

0 commit comments

Comments
 (0)