mirror of
https://github.com/cesanta/mongoose.git
synced 2024-11-23 18:49:01 +08:00
Merge pull request #2914 from cesanta/tests
fixes and improvements for tests
This commit is contained in:
commit
c00962e881
16
.github/workflows/nightly.yml
vendored
16
.github/workflows/nightly.yml
vendored
@ -407,6 +407,7 @@ jobs:
|
||||
- path: stm32/nucleo-f746zg-make-baremetal-builtin-cmsis_driver
|
||||
- path: stm32/nucleo-h563zi-make-baremetal-builtin
|
||||
- path: stm32/nucleo-h563zi-make-freertos-builtin
|
||||
- path: stm32/nucleo-h723zg-make-baremetal-builtin
|
||||
- path: stm32/nucleo-h723zg-make-freertos-builtin
|
||||
- path: stm32/nucleo-h743zi-make-baremetal-builtin
|
||||
- path: stm32/nucleo-h743zi-make-freertos-builtin
|
||||
@ -464,21 +465,6 @@ jobs:
|
||||
# - run: make -C examples/${{ matrix.example.path }} device_dashboard
|
||||
# - run: make -C examples/${{ matrix.example.path }} mqtt_dashboard
|
||||
|
||||
dual_examples_arm:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
example:
|
||||
- path: stm32/nucleo-h723zg-make-baremetal-builtin
|
||||
name: ${{ matrix.example.path }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with: { fetch-depth: 2 }
|
||||
- run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
|
||||
- run: make -C examples/${{ matrix.example.path }} device_dashboard
|
||||
- run: make -C examples/${{ matrix.example.path }} mqtt_dashboard
|
||||
|
||||
cube_examples:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
@ -21,6 +21,49 @@
|
||||
|
||||
#include "driver_mock.c"
|
||||
|
||||
|
||||
#define MQTT_URL "mqtt://broker.hivemq.com:1883" // MQTT broker URL
|
||||
#if MG_TLS == MG_TLS_BUILTIN
|
||||
#define MQTTS_URL "mqtts://mongoose.ws:8883" // HiveMQ does not do TLS1.3
|
||||
#define MQTTS_CA mg_str(s_ca_cert)
|
||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
||||
"emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=\n"
|
||||
"-----END CERTIFICATE-----\n";
|
||||
#elif MG_TLS
|
||||
#define MQTTS_URL "mqtts://broker.hivemq.com:8883" // MQTT broker URL
|
||||
#define MQTTS_CA mg_unpacked("/data/ca.pem")
|
||||
#endif
|
||||
|
||||
|
||||
static int s_num_tests = 0;
|
||||
|
||||
#define ASSERT(expr) \
|
||||
@ -28,6 +71,7 @@ static int s_num_tests = 0;
|
||||
s_num_tests++; \
|
||||
if (!(expr)) { \
|
||||
printf("FAILURE %s:%d: %s\n", __FILE__, __LINE__, #expr); \
|
||||
usleep(500000); /* 500 ms, GH print reason */ \
|
||||
abort(); \
|
||||
} \
|
||||
} while (0)
|
||||
@ -162,23 +206,14 @@ static void test_http_client(struct mg_mgr *mgr) {
|
||||
static struct mg_connection *s_conn;
|
||||
static char s_topic[16];
|
||||
|
||||
#define MQTT_URL "mqtt://broker.hivemq.com:1883" // MQTT broker URL
|
||||
#if MG_TLS == MG_TLS_BUILTIN
|
||||
#define MQTTS_URL "mqtts://mongoose.ws:8883" // HiveMQ does not do TLS1.3
|
||||
#define MQTTS_CA mg_str(s_ca_cert)
|
||||
static const char *s_ca_cert;
|
||||
#elif MG_TLS
|
||||
#define MQTTS_URL "mqtts://broker.hivemq.com:8883" // MQTT broker URL
|
||||
#define MQTTS_CA mg_unpacked("/data/ca.pem")
|
||||
#endif
|
||||
|
||||
|
||||
static void mqtt_fn(struct mg_connection *c, int ev, void *ev_data) {
|
||||
if (ev == MG_EV_CONNECT) {
|
||||
MG_DEBUG(("CONNECT"));
|
||||
#if MG_TLS
|
||||
struct mg_tls_opts opts = {.ca = MQTTS_CA,
|
||||
.name = mg_url_host(MQTTS_URL)};
|
||||
struct mg_tls_opts opts;
|
||||
memset(&opts, 0, sizeof(opts));
|
||||
opts.ca = MQTTS_CA;
|
||||
opts.name = mg_url_host(MQTTS_URL);
|
||||
mg_tls_init(c, &opts);
|
||||
#endif
|
||||
} else if (ev == MG_EV_MQTT_OPEN) {
|
||||
@ -345,9 +380,13 @@ int main(void) {
|
||||
#endif
|
||||
|
||||
// RUN TESTS
|
||||
usleep(500000); // 500 ms
|
||||
test_http_client(&mgr);
|
||||
usleep(500000); // 500 ms
|
||||
test_http_server(&mgr, mif.ip);
|
||||
usleep(500000); // 500 ms
|
||||
test_mqtt_connsubpub(&mgr);
|
||||
usleep(500000); // 500 ms
|
||||
|
||||
printf("SUCCESS. Total tests: %d\n", s_num_tests);
|
||||
|
||||
@ -358,39 +397,3 @@ int main(void) {
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#if MG_TLS == MG_TLS_BUILTIN
|
||||
static const char *s_ca_cert =
|
||||
"-----BEGIN CERTIFICATE-----\n"
|
||||
"MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw\n"
|
||||
"TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh\n"
|
||||
"cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4\n"
|
||||
"WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu\n"
|
||||
"ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY\n"
|
||||
"MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc\n"
|
||||
"h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+\n"
|
||||
"0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U\n"
|
||||
"A5/TR5d8mUgjU+g4rk8K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CgdNbOhdjsnvzqvHu7Ur\n"
|
||||
"TkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nxe5AW0wdeRlN8NwdC\n"
|
||||
"jNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZAJzVc\n"
|
||||
"oyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq\n"
|
||||
"4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA\n"
|
||||
"mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d\n"
|
||||
"emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=\n"
|
||||
"-----END CERTIFICATE-----\n";
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user