Fix #1616 - randomize mqtt will and client id for parallel test

This commit is contained in:
Sergey Lyubka committed 2022-07-04 11:00:06 +01:00
1 parent 432452ea9a
commit 81ffcd8ee9
6 files changed
+52 -3

No files matched your search

+13
View File
@@ -21,6 +21,19 @@ void mg_random(void *buf, size_t len) {
}
#endif
char *mg_random_str(char *buf, size_t len) {
size_t i;
mg_random(buf, len);
for (i = 0; i < len; i++) {
uint8_t c = ((uint8_t *) buf)[i] % 62;
buf[i] = i == len - 1 ? '\0' // 0-terminate last byte
: c < 26 ? (char) ('a' + c) // lowercase
: c < 52 ? (char) ('A' + c - 26) // uppercase
: (char) ('0' + c - 52); // numeric
}
return buf;
}
uint32_t mg_ntohl(uint32_t net) {
uint8_t data[4] = {0, 0, 0, 0};
memcpy(&data, &net, sizeof(data));
+1
View File
@@ -5,6 +5,7 @@
#include "str.h"
void mg_random(void *buf, size_t len);
char *mg_random_str(char *buf, size_t len);
uint16_t mg_ntohs(uint16_t net);
uint32_t mg_ntohl(uint32_t net);
uint32_t mg_crc32(uint32_t crc, const char *buf, size_t len);