test: Apply semantic patch file ztest_strcmp.cocci
This patch file updates the use of assertion macros comparing strings. Command line used: ``` ./scripts/coccicheck --mode=patch \ --cocci=scripts/coccinelle/ztest_strcmp.cocci tests/ ``` Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
This commit is contained in:
parent
470a0fcaa5
commit
8799ab1ec2
33 changed files with 227 additions and 268 deletions
|
@ -80,7 +80,7 @@ static int dummy_sensor_init(const struct device *dev)
|
||||||
const struct device *i2c = device_get_binding(config->i2c_name);
|
const struct device *i2c = device_get_binding(config->i2c_name);
|
||||||
|
|
||||||
/* Bus and address should be configured. */
|
/* Bus and address should be configured. */
|
||||||
zassert_equal(strcmp(config->i2c_name, "dummy I2C"), 0);
|
zassert_str_equal(config->i2c_name, "dummy I2C");
|
||||||
zassert_equal(config->i2c_address, 123);
|
zassert_equal(config->i2c_address, 123);
|
||||||
|
|
||||||
if (i2c != NULL) {
|
if (i2c != NULL) {
|
||||||
|
|
|
@ -220,7 +220,7 @@ ZTEST(printk, test_printk)
|
||||||
pk_console[pos] = '\0';
|
pk_console[pos] = '\0';
|
||||||
__printk_hook_install(_old_char_out);
|
__printk_hook_install(_old_char_out);
|
||||||
printk("expected '%s'\n", expected);
|
printk("expected '%s'\n", expected);
|
||||||
zassert_true((strcmp(pk_console, expected) == 0), "printk failed");
|
zassert_str_equal(pk_console, expected, "printk failed");
|
||||||
|
|
||||||
(void)memset(pk_console, 0, sizeof(pk_console));
|
(void)memset(pk_console, 0, sizeof(pk_console));
|
||||||
count = 0;
|
count = 0;
|
||||||
|
@ -251,7 +251,7 @@ ZTEST(printk, test_printk)
|
||||||
count += snprintk(pk_console + count, sizeof(pk_console) - count,
|
count += snprintk(pk_console + count, sizeof(pk_console) - count,
|
||||||
"0x%x %p %-2p\n", hex, ptr, (char *)42);
|
"0x%x %p %-2p\n", hex, ptr, (char *)42);
|
||||||
pk_console[count] = '\0';
|
pk_console[count] = '\0';
|
||||||
zassert_true((strcmp(pk_console, expected) == 0), "snprintk failed");
|
zassert_str_equal(pk_console, expected, "snprintk failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void *common_setup(void);
|
extern void *common_setup(void);
|
||||||
|
|
|
@ -228,44 +228,44 @@ ZTEST(threads_lifecycle_1cpu, test_k_thread_state_str)
|
||||||
|
|
||||||
tid->base.thread_state = 0;
|
tid->base.thread_state = 0;
|
||||||
str = k_thread_state_str(tid, state_str, sizeof(state_str));
|
str = k_thread_state_str(tid, state_str, sizeof(state_str));
|
||||||
zassert_true(strcmp(str, "") == 0);
|
zassert_str_equal(str, "");
|
||||||
|
|
||||||
tid->base.thread_state = _THREAD_DUMMY;
|
tid->base.thread_state = _THREAD_DUMMY;
|
||||||
|
|
||||||
str = k_thread_state_str(tid, NULL, sizeof(state_str));
|
str = k_thread_state_str(tid, NULL, sizeof(state_str));
|
||||||
zassert_true(strcmp(str, "") == 0);
|
zassert_str_equal(str, "");
|
||||||
|
|
||||||
str = k_thread_state_str(tid, state_str, 0);
|
str = k_thread_state_str(tid, state_str, 0);
|
||||||
zassert_true(strcmp(str, "") == 0);
|
zassert_str_equal(str, "");
|
||||||
|
|
||||||
str = k_thread_state_str(tid, state_str, sizeof(state_str));
|
str = k_thread_state_str(tid, state_str, sizeof(state_str));
|
||||||
zassert_true(strcmp(str, "dummy") == 0);
|
zassert_str_equal(str, "dummy");
|
||||||
|
|
||||||
tid->base.thread_state = _THREAD_PENDING;
|
tid->base.thread_state = _THREAD_PENDING;
|
||||||
str = k_thread_state_str(tid, state_str, sizeof(state_str));
|
str = k_thread_state_str(tid, state_str, sizeof(state_str));
|
||||||
zassert_true(strcmp(str, "pending") == 0);
|
zassert_str_equal(str, "pending");
|
||||||
|
|
||||||
tid->base.thread_state = _THREAD_PRESTART;
|
tid->base.thread_state = _THREAD_PRESTART;
|
||||||
str = k_thread_state_str(tid, state_str, sizeof(state_str));
|
str = k_thread_state_str(tid, state_str, sizeof(state_str));
|
||||||
zassert_true(strcmp(str, "prestart") == 0);
|
zassert_str_equal(str, "prestart");
|
||||||
|
|
||||||
tid->base.thread_state = _THREAD_DEAD;
|
tid->base.thread_state = _THREAD_DEAD;
|
||||||
str = k_thread_state_str(tid, state_str, sizeof(state_str));
|
str = k_thread_state_str(tid, state_str, sizeof(state_str));
|
||||||
zassert_true(strcmp(str, "dead") == 0);
|
zassert_str_equal(str, "dead");
|
||||||
|
|
||||||
tid->base.thread_state = _THREAD_SUSPENDED;
|
tid->base.thread_state = _THREAD_SUSPENDED;
|
||||||
str = k_thread_state_str(tid, state_str, sizeof(state_str));
|
str = k_thread_state_str(tid, state_str, sizeof(state_str));
|
||||||
zassert_true(strcmp(str, "suspended") == 0);
|
zassert_str_equal(str, "suspended");
|
||||||
|
|
||||||
tid->base.thread_state = _THREAD_ABORTING;
|
tid->base.thread_state = _THREAD_ABORTING;
|
||||||
str = k_thread_state_str(tid, state_str, sizeof(state_str));
|
str = k_thread_state_str(tid, state_str, sizeof(state_str));
|
||||||
zassert_true(strcmp(str, "aborting") == 0);
|
zassert_str_equal(str, "aborting");
|
||||||
|
|
||||||
tid->base.thread_state = _THREAD_QUEUED;
|
tid->base.thread_state = _THREAD_QUEUED;
|
||||||
str = k_thread_state_str(tid, state_str, sizeof(state_str));
|
str = k_thread_state_str(tid, state_str, sizeof(state_str));
|
||||||
zassert_true(strcmp(str, "queued") == 0);
|
zassert_str_equal(str, "queued");
|
||||||
|
|
||||||
tid->base.thread_state = _THREAD_PENDING | _THREAD_SUSPENDED;
|
tid->base.thread_state = _THREAD_PENDING | _THREAD_SUSPENDED;
|
||||||
str = k_thread_state_str(tid, state_str, sizeof(state_str));
|
str = k_thread_state_str(tid, state_str, sizeof(state_str));
|
||||||
zassert_true(strcmp(str, "pending+suspended") == 0);
|
zassert_str_equal(str, "pending+suspended");
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,19 +165,19 @@ ZTEST(threads_lifecycle, test_resume_unsuspend_thread)
|
||||||
|
|
||||||
/* Resume an unsuspend thread will not change the thread state. */
|
/* Resume an unsuspend thread will not change the thread state. */
|
||||||
str = k_thread_state_str(tid, buffer, sizeof(buffer));
|
str = k_thread_state_str(tid, buffer, sizeof(buffer));
|
||||||
zassert_true(strcmp(str, "queued") == 0);
|
zassert_str_equal(str, "queued");
|
||||||
k_thread_resume(tid);
|
k_thread_resume(tid);
|
||||||
str = k_thread_state_str(tid, buffer, sizeof(buffer));
|
str = k_thread_state_str(tid, buffer, sizeof(buffer));
|
||||||
zassert_true(strcmp(str, "queued") == 0);
|
zassert_str_equal(str, "queued");
|
||||||
|
|
||||||
/* suspend created thread */
|
/* suspend created thread */
|
||||||
k_thread_suspend(tid);
|
k_thread_suspend(tid);
|
||||||
str = k_thread_state_str(tid, buffer, sizeof(buffer));
|
str = k_thread_state_str(tid, buffer, sizeof(buffer));
|
||||||
zassert_true(strcmp(str, "suspended") == 0);
|
zassert_str_equal(str, "suspended");
|
||||||
|
|
||||||
/* Resume an suspend thread will make it to be next eligible.*/
|
/* Resume an suspend thread will make it to be next eligible.*/
|
||||||
k_thread_resume(tid);
|
k_thread_resume(tid);
|
||||||
str = k_thread_state_str(tid, buffer, sizeof(buffer));
|
str = k_thread_state_str(tid, buffer, sizeof(buffer));
|
||||||
zassert_true(strcmp(str, "queued") == 0);
|
zassert_str_equal(str, "queued");
|
||||||
k_thread_abort(tid);
|
k_thread_abort(tid);
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,7 +237,7 @@ static void test_queue_start(void)
|
||||||
|
|
||||||
zassert_true(tn != cfg.name);
|
zassert_true(tn != cfg.name);
|
||||||
zassert_true(tn != NULL);
|
zassert_true(tn != NULL);
|
||||||
zassert_equal(strcmp(tn, cfg.name), 0);
|
zassert_str_equal(tn, cfg.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg.name = NULL;
|
cfg.name = NULL;
|
||||||
|
@ -251,7 +251,7 @@ static void test_queue_start(void)
|
||||||
|
|
||||||
zassert_true(tn != cfg.name);
|
zassert_true(tn != cfg.name);
|
||||||
zassert_true(tn != NULL);
|
zassert_true(tn != NULL);
|
||||||
zassert_equal(strcmp(tn, ""), 0);
|
zassert_str_equal(tn, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg.name = "wq.coophi";
|
cfg.name = "wq.coophi";
|
||||||
|
|
|
@ -230,7 +230,7 @@ ZTEST(libc_common, test_strcmp)
|
||||||
char test = 0;
|
char test = 0;
|
||||||
|
|
||||||
zassert_true((strcmp(buffer, "fffff") < 0), "strcmp less ...");
|
zassert_true((strcmp(buffer, "fffff") < 0), "strcmp less ...");
|
||||||
zassert_true((strcmp(buffer, "eeeee") == 0), "strcmp equal ...");
|
zassert_str_equal(buffer, "eeeee", "strcmp equal ...");
|
||||||
zassert_true((strcmp(buffer, "ddddd") > 0), "strcmp greater ...");
|
zassert_true((strcmp(buffer, "ddddd") > 0), "strcmp greater ...");
|
||||||
|
|
||||||
zassert_true((strncasecmp(buffer, "FFFFF", 3) < 0), "strncasecmp less ...");
|
zassert_true((strncasecmp(buffer, "FFFFF", 3) < 0), "strncasecmp less ...");
|
||||||
|
@ -277,7 +277,7 @@ ZTEST(libc_common, test_strcpy)
|
||||||
(void)memset(buffer, '\0', BUFSIZE);
|
(void)memset(buffer, '\0', BUFSIZE);
|
||||||
strcpy(buffer, "10 chars!\0");
|
strcpy(buffer, "10 chars!\0");
|
||||||
|
|
||||||
zassert_true((strcmp(buffer, "10 chars!\0") == 0), "strcpy");
|
zassert_str_equal(buffer, "10 chars!\0", "strcpy");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -467,7 +467,7 @@ ZTEST(libc_common, test_checktype)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
zassert_equal(strcmp(buf, exp_alnum), 0, "isalnum error");
|
zassert_str_equal(buf, exp_alnum, "isalnum error");
|
||||||
|
|
||||||
ptr = buf;
|
ptr = buf;
|
||||||
for (int i = 0; i < 128; i++) {
|
for (int i = 0; i < 128; i++) {
|
||||||
|
@ -476,7 +476,7 @@ ZTEST(libc_common, test_checktype)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
zassert_equal(strcmp(buf, exp_alpha), 0, "isalpha error");
|
zassert_str_equal(buf, exp_alpha, "isalpha error");
|
||||||
|
|
||||||
ptr = buf;
|
ptr = buf;
|
||||||
for (int i = 0; i < 128; i++) {
|
for (int i = 0; i < 128; i++) {
|
||||||
|
@ -485,7 +485,7 @@ ZTEST(libc_common, test_checktype)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
zassert_equal(strcmp(buf, exp_digit), 0, "isdigit error");
|
zassert_str_equal(buf, exp_digit, "isdigit error");
|
||||||
|
|
||||||
ptr = buf;
|
ptr = buf;
|
||||||
for (int i = 0; i < 128; i++) {
|
for (int i = 0; i < 128; i++) {
|
||||||
|
@ -494,7 +494,7 @@ ZTEST(libc_common, test_checktype)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
zassert_equal(strcmp(buf, exp_graph), 0, "isgraph error");
|
zassert_str_equal(buf, exp_graph, "isgraph error");
|
||||||
|
|
||||||
ptr = buf;
|
ptr = buf;
|
||||||
for (int i = 0; i < 128; i++) {
|
for (int i = 0; i < 128; i++) {
|
||||||
|
@ -503,7 +503,7 @@ ZTEST(libc_common, test_checktype)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
zassert_equal(strcmp(buf, exp_print), 0, "isprint error");
|
zassert_str_equal(buf, exp_print, "isprint error");
|
||||||
|
|
||||||
ptr = buf;
|
ptr = buf;
|
||||||
for (int i = 0; i < 128; i++) {
|
for (int i = 0; i < 128; i++) {
|
||||||
|
@ -512,7 +512,7 @@ ZTEST(libc_common, test_checktype)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
zassert_equal(strcmp(buf, exp_upper), 0, "isupper error");
|
zassert_str_equal(buf, exp_upper, "isupper error");
|
||||||
|
|
||||||
ptr = buf;
|
ptr = buf;
|
||||||
for (int i = 0; i < 128; i++) {
|
for (int i = 0; i < 128; i++) {
|
||||||
|
@ -521,7 +521,7 @@ ZTEST(libc_common, test_checktype)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
zassert_equal(strcmp(buf, exp_space), 0, "isspace error");
|
zassert_str_equal(buf, exp_space, "isspace error");
|
||||||
|
|
||||||
ptr = buf;
|
ptr = buf;
|
||||||
for (int i = 0; i < 128; i++) {
|
for (int i = 0; i < 128; i++) {
|
||||||
|
@ -530,7 +530,7 @@ ZTEST(libc_common, test_checktype)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
zassert_equal(strcmp(buf, exp_xdigit), 0, "isxdigit error");
|
zassert_str_equal(buf, exp_xdigit, "isxdigit error");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -642,7 +642,7 @@ ZTEST(libc_common, test_str_operate)
|
||||||
char *ptr;
|
char *ptr;
|
||||||
|
|
||||||
zassert_not_null(strcat(str1, str3), "strcat false");
|
zassert_not_null(strcat(str1, str3), "strcat false");
|
||||||
zassert_equal(strcmp(str1, "aabbccd"), 0, "test strcat failed");
|
zassert_str_equal(str1, "aabbccd", "test strcat failed");
|
||||||
|
|
||||||
ret = strcspn(str1, str2);
|
ret = strcspn(str1, str2);
|
||||||
zassert_equal(ret, 2, "strcspn failed");
|
zassert_equal(ret, 2, "strcspn failed");
|
||||||
|
@ -659,12 +659,12 @@ ZTEST(libc_common, test_str_operate)
|
||||||
#if defined(__GNUC__) && __GNUC__ >= 7
|
#if defined(__GNUC__) && __GNUC__ >= 7
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
zassert_equal(strcmp(ncat, "ddeeaa"), 0, "strncat failed");
|
zassert_str_equal(ncat, "ddeeaa", "strncat failed");
|
||||||
|
|
||||||
zassert_is_null(strrchr(ncat, 'z'),
|
zassert_is_null(strrchr(ncat, 'z'),
|
||||||
"strrchr not found this word. failed");
|
"strrchr not found this word. failed");
|
||||||
ptr = strrchr(ncat, 'e');
|
ptr = strrchr(ncat, 'e');
|
||||||
zassert_equal(strcmp(ptr, "eaa"), 0, "strrchr failed");
|
zassert_str_equal(ptr, "eaa", "strrchr failed");
|
||||||
|
|
||||||
zassert_is_null(strstr(str1, "ayz"), "strstr aabbccd with ayz failed");
|
zassert_is_null(strstr(str1, "ayz"), "strstr aabbccd with ayz failed");
|
||||||
zassert_not_null(strstr(str1, str2), "strstr aabbccd with b succeed");
|
zassert_not_null(strstr(str1, str2), "strstr aabbccd with b succeed");
|
||||||
|
@ -728,13 +728,11 @@ ZTEST(libc_common, test_strtol)
|
||||||
|
|
||||||
ret = strtol(str_normal, &stop, 10);
|
ret = strtol(str_normal, &stop, 10);
|
||||||
zassert_equal(ret, -1011, "strtol base = 10 failed");
|
zassert_equal(ret, -1011, "strtol base = 10 failed");
|
||||||
zassert_true((strcmp(stop, " This stopped it") == 0),
|
zassert_str_equal(stop, " This stopped it", "strtol get stop failed");
|
||||||
"strtol get stop failed");
|
|
||||||
|
|
||||||
ret = strtol(str_abnormal, &stop, 0);
|
ret = strtol(str_abnormal, &stop, 0);
|
||||||
zassert_equal(ret, 0, "strtol base = 0 failed");
|
zassert_equal(ret, 0, "strtol base = 0 failed");
|
||||||
zassert_true((strcmp(stop, "ABCDEFGH") == 0),
|
zassert_str_equal(stop, "ABCDEFGH", "strtol get stop failed");
|
||||||
"strtol get stop failed");
|
|
||||||
|
|
||||||
#if LONG_MAX > 2147483647
|
#if LONG_MAX > 2147483647
|
||||||
char border1[] = "-9223372036854775809";
|
char border1[] = "-9223372036854775809";
|
||||||
|
@ -817,13 +815,11 @@ ZTEST(libc_common, test_strtoul)
|
||||||
|
|
||||||
ret = strtoul(str_normal, &stop, 10);
|
ret = strtoul(str_normal, &stop, 10);
|
||||||
zassert_equal(ret, -1011, "strtol base = 10 failed");
|
zassert_equal(ret, -1011, "strtol base = 10 failed");
|
||||||
zassert_true((strcmp(stop, " This stopped it") == 0),
|
zassert_str_equal(stop, " This stopped it", "strtol get stop failed");
|
||||||
"strtol get stop failed");
|
|
||||||
|
|
||||||
ret = strtoul(str_abnormal, &stop, 0);
|
ret = strtoul(str_abnormal, &stop, 0);
|
||||||
zassert_equal(ret, 0, "strtol base = 0 failed");
|
zassert_equal(ret, 0, "strtol base = 0 failed");
|
||||||
zassert_true((strcmp(stop, "ABCDEFGH") == 0),
|
zassert_str_equal(stop, "ABCDEFGH", "strtol get stop failed");
|
||||||
"strtol get stop failed");
|
|
||||||
|
|
||||||
#if LONG_MAX > 2147483647
|
#if LONG_MAX > 2147483647
|
||||||
char border1[] = "18446744073709551615";
|
char border1[] = "18446744073709551615";
|
||||||
|
@ -901,11 +897,11 @@ void test_strtoll(void)
|
||||||
|
|
||||||
ret = strtoll(str_normal, &stop, 10);
|
ret = strtoll(str_normal, &stop, 10);
|
||||||
zassert_equal(ret, -1011, "strtoll base = 10 failed");
|
zassert_equal(ret, -1011, "strtoll base = 10 failed");
|
||||||
zassert_true((strcmp(stop, " This stopped it") == 0), "strtoll get stop failed");
|
zassert_str_equal(stop, " This stopped it", "strtoll get stop failed");
|
||||||
|
|
||||||
ret = strtoll(str_abnormal, &stop, 0);
|
ret = strtoll(str_abnormal, &stop, 0);
|
||||||
zassert_equal(ret, 0, "strtoll base = 0 failed");
|
zassert_equal(ret, 0, "strtoll base = 0 failed");
|
||||||
zassert_true((strcmp(stop, "ABCDEFGH") == 0), "strtoll get stop failed");
|
zassert_str_equal(stop, "ABCDEFGH", "strtoll get stop failed");
|
||||||
|
|
||||||
char border1[] = "-9223372036854775808";
|
char border1[] = "-9223372036854775808";
|
||||||
char border2[] = "+9223372036854775807";
|
char border2[] = "+9223372036854775807";
|
||||||
|
@ -981,11 +977,12 @@ void test_strtoull(void)
|
||||||
|
|
||||||
ret = strtoull(str_normal, &stop, 10);
|
ret = strtoull(str_normal, &stop, 10);
|
||||||
zassert_equal(ret, -1011, "strtoull base = 10 failed");
|
zassert_equal(ret, -1011, "strtoull base = 10 failed");
|
||||||
zassert_true((strcmp(stop, " This stopped it") == 0), "strtoull get stop failed");
|
zassert_str_equal(stop, " This stopped it",
|
||||||
|
"strtoull get stop failed");
|
||||||
|
|
||||||
ret = strtoull(str_abnormal, &stop, 0);
|
ret = strtoull(str_abnormal, &stop, 0);
|
||||||
zassert_equal(ret, 0, "strtoull base = 0 failed");
|
zassert_equal(ret, 0, "strtoull base = 0 failed");
|
||||||
zassert_true((strcmp(stop, "ABCDEFGH") == 0), "strtoull get stop failed");
|
zassert_str_equal(stop, "ABCDEFGH", "strtoull get stop failed");
|
||||||
|
|
||||||
char border1[] = "+18446744073709551615";
|
char border1[] = "+18446744073709551615";
|
||||||
char border2[] = "-18446744073709551615000";
|
char border2[] = "-18446744073709551615000";
|
||||||
|
@ -1028,8 +1025,8 @@ ZTEST(libc_common, test_tolower_toupper)
|
||||||
}
|
}
|
||||||
lw[i] = up[i] = '\0';
|
lw[i] = up[i] = '\0';
|
||||||
|
|
||||||
zassert_equal(strcmp(up, toup), 0, "toupper error");
|
zassert_str_equal(up, toup, "toupper error");
|
||||||
zassert_equal(strcmp(lw, tolw), 0, "tolower error");
|
zassert_str_equal(lw, tolw, "tolower error");
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_strtok_r_do(char *str, char *sep, int tlen,
|
void test_strtok_r_do(char *str, char *sep, int tlen,
|
||||||
|
|
|
@ -289,11 +289,11 @@ ZTEST(cbprintf_package, test_cbprintf_fsc_package)
|
||||||
/* Get pointer to the first string in the package. */
|
/* Get pointer to the first string in the package. */
|
||||||
addr = (char *)&fsc_package[desc->desc.len * sizeof(int) + 1];
|
addr = (char *)&fsc_package[desc->desc.len * sizeof(int) + 1];
|
||||||
|
|
||||||
zassert_equal(strcmp(test_str, addr), 0);
|
zassert_str_equal(test_str, addr);
|
||||||
|
|
||||||
/* Get address of the second string. */
|
/* Get address of the second string. */
|
||||||
addr += strlen(addr) + 2;
|
addr += strlen(addr) + 2;
|
||||||
zassert_equal(strcmp(test_str1, addr), 0);
|
zassert_str_equal(test_str1, addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void check_package(void *package, size_t len, const char *exp_str)
|
static void check_package(void *package, size_t len, const char *exp_str)
|
||||||
|
|
|
@ -255,7 +255,7 @@ ZTEST(lib_json_test, test_json_decoding)
|
||||||
zassert_equal(ret, (1 << ARRAY_SIZE(test_descr)) - 1,
|
zassert_equal(ret, (1 << ARRAY_SIZE(test_descr)) - 1,
|
||||||
"Not all fields decoded correctly");
|
"Not all fields decoded correctly");
|
||||||
|
|
||||||
zassert_true(!strcmp(ts.some_string, "zephyr 123\\uABCD456"),
|
zassert_str_equal(ts.some_string, "zephyr 123\\uABCD456",
|
||||||
"String not decoded correctly");
|
"String not decoded correctly");
|
||||||
zassert_equal(ts.some_int, 42, "Positive integer not decoded correctly");
|
zassert_equal(ts.some_int, 42, "Positive integer not decoded correctly");
|
||||||
zassert_equal(ts.some_bool, true, "Boolean not decoded correctly");
|
zassert_equal(ts.some_bool, true, "Boolean not decoded correctly");
|
||||||
|
@ -263,8 +263,8 @@ ZTEST(lib_json_test, test_json_decoding)
|
||||||
"Nested negative integer not decoded correctly");
|
"Nested negative integer not decoded correctly");
|
||||||
zassert_equal(ts.some_nested_struct.nested_bool, false,
|
zassert_equal(ts.some_nested_struct.nested_bool, false,
|
||||||
"Nested boolean value not decoded correctly");
|
"Nested boolean value not decoded correctly");
|
||||||
zassert_true(!strcmp(ts.some_nested_struct.nested_string,
|
zassert_str_equal(ts.some_nested_struct.nested_string,
|
||||||
"this should be escaped: \\t"),
|
"this should be escaped: \\t",
|
||||||
"Nested string not decoded correctly");
|
"Nested string not decoded correctly");
|
||||||
zassert_equal(ts.some_array_len, 5,
|
zassert_equal(ts.some_array_len, 5,
|
||||||
"Array doesn't have correct number of items");
|
"Array doesn't have correct number of items");
|
||||||
|
@ -284,8 +284,8 @@ ZTEST(lib_json_test, test_json_decoding)
|
||||||
"Named nested integer not decoded correctly");
|
"Named nested integer not decoded correctly");
|
||||||
zassert_equal(ts.xnother_nexx.nested_bool, true,
|
zassert_equal(ts.xnother_nexx.nested_bool, true,
|
||||||
"Named nested boolean not decoded correctly");
|
"Named nested boolean not decoded correctly");
|
||||||
zassert_true(!strcmp(ts.xnother_nexx.nested_string,
|
zassert_str_equal(ts.xnother_nexx.nested_string,
|
||||||
"no escape necessary"),
|
"no escape necessary",
|
||||||
"Named nested string not decoded correctly");
|
"Named nested string not decoded correctly");
|
||||||
zassert_equal(ts.obj_array_len, 2,
|
zassert_equal(ts.obj_array_len, 2,
|
||||||
"Array of objects does not have correct number of items");
|
"Array of objects does not have correct number of items");
|
||||||
|
@ -293,13 +293,13 @@ ZTEST(lib_json_test, test_json_decoding)
|
||||||
"Integer in first object array element not decoded correctly");
|
"Integer in first object array element not decoded correctly");
|
||||||
zassert_equal(ts.nested_obj_array[0].nested_bool, true,
|
zassert_equal(ts.nested_obj_array[0].nested_bool, true,
|
||||||
"Boolean value in first object array element not decoded correctly");
|
"Boolean value in first object array element not decoded correctly");
|
||||||
zassert_true(!strcmp(ts.nested_obj_array[0].nested_string, "true"),
|
zassert_str_equal(ts.nested_obj_array[0].nested_string, "true",
|
||||||
"String in first object array element not decoded correctly");
|
"String in first object array element not decoded correctly");
|
||||||
zassert_equal(ts.nested_obj_array[1].nested_int, 0,
|
zassert_equal(ts.nested_obj_array[1].nested_int, 0,
|
||||||
"Integer in second object array element not decoded correctly");
|
"Integer in second object array element not decoded correctly");
|
||||||
zassert_equal(ts.nested_obj_array[1].nested_bool, false,
|
zassert_equal(ts.nested_obj_array[1].nested_bool, false,
|
||||||
"Boolean value in second object array element not decoded correctly");
|
"Boolean value in second object array element not decoded correctly");
|
||||||
zassert_true(!strcmp(ts.nested_obj_array[1].nested_string, "false"),
|
zassert_str_equal(ts.nested_obj_array[1].nested_string, "false",
|
||||||
"String in second object array element not decoded correctly");
|
"String in second object array element not decoded correctly");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,7 +325,8 @@ ZTEST(lib_json_test, test_json_limits)
|
||||||
ret = json_obj_parse(encoded, sizeof(encoded) - 1, obj_limits_descr,
|
ret = json_obj_parse(encoded, sizeof(encoded) - 1, obj_limits_descr,
|
||||||
ARRAY_SIZE(obj_limits_descr), &limits_decoded);
|
ARRAY_SIZE(obj_limits_descr), &limits_decoded);
|
||||||
|
|
||||||
zassert_true(!strcmp(encoded, buffer), "Integer limits not encoded correctly");
|
zassert_str_equal(encoded, buffer,
|
||||||
|
"Integer limits not encoded correctly");
|
||||||
zassert_true(!memcmp(&limits, &limits_decoded, sizeof(limits)),
|
zassert_true(!memcmp(&limits, &limits_decoded, sizeof(limits)),
|
||||||
"Integer limits not decoded correctly");
|
"Integer limits not decoded correctly");
|
||||||
}
|
}
|
||||||
|
@ -351,7 +352,7 @@ ZTEST(lib_json_test, test_json_encoding_array_array)
|
||||||
ret = json_obj_encode_buf(array_array_descr, ARRAY_SIZE(array_array_descr),
|
ret = json_obj_encode_buf(array_array_descr, ARRAY_SIZE(array_array_descr),
|
||||||
&obj_array_array_ts, buffer, sizeof(buffer));
|
&obj_array_array_ts, buffer, sizeof(buffer));
|
||||||
zassert_equal(ret, 0, "Encoding array returned error");
|
zassert_equal(ret, 0, "Encoding array returned error");
|
||||||
zassert_true(!strcmp(buffer, encoded),
|
zassert_str_equal(buffer, encoded,
|
||||||
"Encoded array of objects is not consistent");
|
"Encoded array of objects is not consistent");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,18 +375,19 @@ ZTEST(lib_json_test, test_json_decoding_array_array)
|
||||||
zassert_equal(obj_array_array_ts.objects_array_len, 3,
|
zassert_equal(obj_array_array_ts.objects_array_len, 3,
|
||||||
"Array doesn't have correct number of items");
|
"Array doesn't have correct number of items");
|
||||||
|
|
||||||
zassert_true(!strcmp(obj_array_array_ts.objects_array[0].objects.name,
|
zassert_str_equal(obj_array_array_ts.objects_array[0].objects.name,
|
||||||
"Sim\303\263n Bol\303\255var"), "String not decoded correctly");
|
"Sim\303\263n Bol\303\255var",
|
||||||
|
"String not decoded correctly");
|
||||||
zassert_equal(obj_array_array_ts.objects_array[0].objects.height, 168,
|
zassert_equal(obj_array_array_ts.objects_array[0].objects.height, 168,
|
||||||
"Sim\303\263n Bol\303\255var height not decoded correctly");
|
"Sim\303\263n Bol\303\255var height not decoded correctly");
|
||||||
|
|
||||||
zassert_true(!strcmp(obj_array_array_ts.objects_array[1].objects.name,
|
zassert_str_equal(obj_array_array_ts.objects_array[1].objects.name,
|
||||||
"Pel\303\251"), "String not decoded correctly");
|
"Pel\303\251", "String not decoded correctly");
|
||||||
zassert_equal(obj_array_array_ts.objects_array[1].objects.height, 173,
|
zassert_equal(obj_array_array_ts.objects_array[1].objects.height, 173,
|
||||||
"Pel\303\251 height not decoded correctly");
|
"Pel\303\251 height not decoded correctly");
|
||||||
|
|
||||||
zassert_true(!strcmp(obj_array_array_ts.objects_array[2].objects.name,
|
zassert_str_equal(obj_array_array_ts.objects_array[2].objects.name,
|
||||||
"Usain Bolt"), "String not decoded correctly");
|
"Usain Bolt", "String not decoded correctly");
|
||||||
zassert_equal(obj_array_array_ts.objects_array[2].objects.height, 195,
|
zassert_equal(obj_array_array_ts.objects_array[2].objects.height, 195,
|
||||||
"Usain Bolt height not decoded correctly");
|
"Usain Bolt height not decoded correctly");
|
||||||
}
|
}
|
||||||
|
@ -425,7 +427,7 @@ ZTEST(lib_json_test, test_json_obj_arr_encoding)
|
||||||
ret = json_obj_encode_buf(obj_array_descr, ARRAY_SIZE(obj_array_descr),
|
ret = json_obj_encode_buf(obj_array_descr, ARRAY_SIZE(obj_array_descr),
|
||||||
&oa, buffer, sizeof(buffer));
|
&oa, buffer, sizeof(buffer));
|
||||||
zassert_equal(ret, 0, "Encoding array of object returned error");
|
zassert_equal(ret, 0, "Encoding array of object returned error");
|
||||||
zassert_true(!strcmp(buffer, encoded),
|
zassert_str_equal(buffer, encoded,
|
||||||
"Encoded array of objects is not consistent");
|
"Encoded array of objects is not consistent");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,18 +448,19 @@ ZTEST(lib_json_test, test_json_arr_obj_decoding)
|
||||||
zassert_equal(obj_array_array_ts.num_elements, 3,
|
zassert_equal(obj_array_array_ts.num_elements, 3,
|
||||||
"Array doesn't have correct number of items");
|
"Array doesn't have correct number of items");
|
||||||
|
|
||||||
zassert_true(!strcmp(obj_array_array_ts.elements[0].name,
|
zassert_str_equal(obj_array_array_ts.elements[0].name,
|
||||||
"Sim\303\263n Bol\303\255var"), "String not decoded correctly");
|
"Sim\303\263n Bol\303\255var",
|
||||||
|
"String not decoded correctly");
|
||||||
zassert_equal(obj_array_array_ts.elements[0].height, 168,
|
zassert_equal(obj_array_array_ts.elements[0].height, 168,
|
||||||
"Sim\303\263n Bol\303\255var height not decoded correctly");
|
"Sim\303\263n Bol\303\255var height not decoded correctly");
|
||||||
|
|
||||||
zassert_true(!strcmp(obj_array_array_ts.elements[1].name,
|
zassert_str_equal(obj_array_array_ts.elements[1].name, "Pel\303\251",
|
||||||
"Pel\303\251"), "String not decoded correctly");
|
"String not decoded correctly");
|
||||||
zassert_equal(obj_array_array_ts.elements[1].height, 173,
|
zassert_equal(obj_array_array_ts.elements[1].height, 173,
|
||||||
"Pel\303\251 height not decoded correctly");
|
"Pel\303\251 height not decoded correctly");
|
||||||
|
|
||||||
zassert_true(!strcmp(obj_array_array_ts.elements[2].name,
|
zassert_str_equal(obj_array_array_ts.elements[2].name, "Usain Bolt",
|
||||||
"Usain Bolt"), "String not decoded correctly");
|
"String not decoded correctly");
|
||||||
zassert_equal(obj_array_array_ts.elements[2].height, 195,
|
zassert_equal(obj_array_array_ts.elements[2].height, 195,
|
||||||
"Usain Bolt height not decoded correctly");
|
"Usain Bolt height not decoded correctly");
|
||||||
}
|
}
|
||||||
|
@ -500,7 +503,7 @@ ZTEST(lib_json_test, test_json_arr_obj_encoding)
|
||||||
|
|
||||||
ret = json_arr_encode_buf(obj_array_descr, &oa, buffer, sizeof(buffer));
|
ret = json_arr_encode_buf(obj_array_descr, &oa, buffer, sizeof(buffer));
|
||||||
zassert_equal(ret, 0, "Encoding array of object returned error %d", ret);
|
zassert_equal(ret, 0, "Encoding array of object returned error %d", ret);
|
||||||
zassert_true(!strcmp(buffer, encoded),
|
zassert_str_equal(buffer, encoded,
|
||||||
"Encoded array of objects is not consistent");
|
"Encoded array of objects is not consistent");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -629,7 +632,7 @@ ZTEST(lib_json_test, test_json_2dim_arr_obj_encoding)
|
||||||
ret = json_obj_encode_buf(array_2dim_descr, ARRAY_SIZE(array_2dim_descr),
|
ret = json_obj_encode_buf(array_2dim_descr, ARRAY_SIZE(array_2dim_descr),
|
||||||
&obj_array_array_ts, buffer, sizeof(buffer));
|
&obj_array_array_ts, buffer, sizeof(buffer));
|
||||||
zassert_equal(ret, 0, "Encoding two-dimensional array returned error");
|
zassert_equal(ret, 0, "Encoding two-dimensional array returned error");
|
||||||
zassert_true(!strcmp(buffer, encoded),
|
zassert_str_equal(buffer, encoded,
|
||||||
"Encoded two-dimensional array is not consistent");
|
"Encoded two-dimensional array is not consistent");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -712,7 +715,7 @@ ZTEST(lib_json_test, test_json_2dim_arr_extra_obj_encoding)
|
||||||
ret = json_obj_encode_buf(array_2dim_extra_descr, ARRAY_SIZE(array_2dim_extra_descr),
|
ret = json_obj_encode_buf(array_2dim_extra_descr, ARRAY_SIZE(array_2dim_extra_descr),
|
||||||
&obj_array_2dim_extra_ts, buffer, sizeof(buffer));
|
&obj_array_2dim_extra_ts, buffer, sizeof(buffer));
|
||||||
zassert_equal(ret, 0, "Encoding two-dimensional extra array returned error");
|
zassert_equal(ret, 0, "Encoding two-dimensional extra array returned error");
|
||||||
zassert_true(!strcmp(buffer, encoded),
|
zassert_str_equal(buffer, encoded,
|
||||||
"Encoded two-dimensional extra array is not consistent");
|
"Encoded two-dimensional extra array is not consistent");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -796,7 +799,7 @@ ZTEST(lib_json_test, test_json_2dim_arr_extra_named_obj_encoding)
|
||||||
ARRAY_SIZE(array_2dim_extra_named_descr),
|
ARRAY_SIZE(array_2dim_extra_named_descr),
|
||||||
&obj_array_2dim_extra_ts, buffer, sizeof(buffer));
|
&obj_array_2dim_extra_ts, buffer, sizeof(buffer));
|
||||||
zassert_equal(ret, 0, "Encoding two-dimensional extra named array returned error");
|
zassert_equal(ret, 0, "Encoding two-dimensional extra named array returned error");
|
||||||
zassert_true(!strcmp(buffer, encoded),
|
zassert_str_equal(buffer, encoded,
|
||||||
"Encoded two-dimensional extra named array is not consistent");
|
"Encoded two-dimensional extra named array is not consistent");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1033,8 +1036,7 @@ ZTEST(lib_json_test, test_json_escape)
|
||||||
zassert_equal(ret, 0, "Escape did not succeed");
|
zassert_equal(ret, 0, "Escape did not succeed");
|
||||||
zassert_equal(len, sizeof(buf) - 1,
|
zassert_equal(len, sizeof(buf) - 1,
|
||||||
"Escaped length not computed correctly");
|
"Escaped length not computed correctly");
|
||||||
zassert_true(!strcmp(buf, expected),
|
zassert_str_equal(buf, expected, "Escaped value is not correct");
|
||||||
"Escaped value is not correct");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Edge case: only one character, which must be escaped. */
|
/* Edge case: only one character, which must be escaped. */
|
||||||
|
@ -1050,8 +1052,7 @@ ZTEST(lib_json_test, test_json_escape_one)
|
||||||
"Escaping one character did not succeed");
|
"Escaping one character did not succeed");
|
||||||
zassert_equal(len, sizeof(buf) - 1,
|
zassert_equal(len, sizeof(buf) - 1,
|
||||||
"Escaping one character length is not correct");
|
"Escaping one character length is not correct");
|
||||||
zassert_true(!strcmp(buf, expected),
|
zassert_str_equal(buf, expected, "Escaped value is not correct");
|
||||||
"Escaped value is not correct");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ZTEST(lib_json_test, test_json_escape_empty)
|
ZTEST(lib_json_test, test_json_escape_empty)
|
||||||
|
@ -1077,7 +1078,7 @@ ZTEST(lib_json_test, test_json_escape_no_op)
|
||||||
zassert_equal(ret, 0, "Escape no-op not handled correctly");
|
zassert_equal(ret, 0, "Escape no-op not handled correctly");
|
||||||
zassert_equal(len, sizeof(nothing_to_escape) - 1,
|
zassert_equal(len, sizeof(nothing_to_escape) - 1,
|
||||||
"Changed length of already escaped string");
|
"Changed length of already escaped string");
|
||||||
zassert_true(!strcmp(nothing_to_escape, expected),
|
zassert_str_equal(nothing_to_escape, expected,
|
||||||
"Altered string with nothing to escape");
|
"Altered string with nothing to escape");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -754,7 +754,7 @@ ZTEST(sprintf, test_sprintf_string)
|
||||||
"Expected 'short string', got '%s'\n", buffer);
|
"Expected 'short string', got '%s'\n", buffer);
|
||||||
|
|
||||||
sprintf(buffer, "%s", REALLY_LONG_STRING);
|
sprintf(buffer, "%s", REALLY_LONG_STRING);
|
||||||
zassert_true((strcmp(buffer, REALLY_LONG_STRING) == 0),
|
zassert_str_equal(buffer, REALLY_LONG_STRING,
|
||||||
"sprintf(%%s) of REALLY_LONG_STRING doesn't match!\n");
|
"sprintf(%%s) of REALLY_LONG_STRING doesn't match!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ ZTEST(nanopb_tests, test_nanopb_nested)
|
||||||
|
|
||||||
zassert_equal(42, msg.nested.id);
|
zassert_equal(42, msg.nested.id);
|
||||||
zassert_true(msg.has_nested);
|
zassert_true(msg.has_nested);
|
||||||
zassert_equal(0, strcmp(msg.nested.name, "Test name"));
|
zassert_str_equal(msg.nested.name, "Test name");
|
||||||
}
|
}
|
||||||
|
|
||||||
ZTEST(nanopb_tests, test_nanopb_lib)
|
ZTEST(nanopb_tests, test_nanopb_lib)
|
||||||
|
|
|
@ -639,7 +639,8 @@ ZTEST(conn_mgr_conn, test_conn_opt)
|
||||||
0, "conn_mgr_if_get_opt should succeed for valid parameters");
|
0, "conn_mgr_if_get_opt should succeed for valid parameters");
|
||||||
printk("%d, %d", buf_len, strlen(buf) + 1);
|
printk("%d, %d", buf_len, strlen(buf) + 1);
|
||||||
zassert_equal(buf_len, strlen(buf) + 1, "conn_mgr_if_get_opt should return valid optlen");
|
zassert_equal(buf_len, strlen(buf) + 1, "conn_mgr_if_get_opt should return valid optlen");
|
||||||
zassert_equal(strcmp(buf, "A"), 0, "conn_mgr_if_get_opt should retrieve \"A\"");
|
zassert_str_equal(buf, "A",
|
||||||
|
"conn_mgr_if_get_opt should retrieve \"A\"");
|
||||||
|
|
||||||
/* Verify that ifa1->Y was not affected */
|
/* Verify that ifa1->Y was not affected */
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
|
@ -668,7 +669,8 @@ ZTEST(conn_mgr_conn, test_conn_opt)
|
||||||
zassert_equal(conn_mgr_if_get_opt(ifa1, TEST_CONN_OPT_Y, &buf, &buf_len),
|
zassert_equal(conn_mgr_if_get_opt(ifa1, TEST_CONN_OPT_Y, &buf, &buf_len),
|
||||||
0, "conn_mgr_if_get_opt should succeed for valid parameters");
|
0, "conn_mgr_if_get_opt should succeed for valid parameters");
|
||||||
zassert_equal(buf_len, strlen(buf) + 1, "conn_mgr_if_get_opt should return valid optlen");
|
zassert_equal(buf_len, strlen(buf) + 1, "conn_mgr_if_get_opt should return valid optlen");
|
||||||
zassert_equal(strcmp(buf, "ABC"), 0, "conn_mgr_if_get_opt should retrieve \"ABC\"");
|
zassert_str_equal(buf, "ABC",
|
||||||
|
"conn_mgr_if_get_opt should retrieve \"ABC\"");
|
||||||
|
|
||||||
/* Verify that ifa1->X was not affected */
|
/* Verify that ifa1->X was not affected */
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
|
@ -676,7 +678,8 @@ ZTEST(conn_mgr_conn, test_conn_opt)
|
||||||
zassert_equal(conn_mgr_if_get_opt(ifa1, TEST_CONN_OPT_X, &buf, &buf_len),
|
zassert_equal(conn_mgr_if_get_opt(ifa1, TEST_CONN_OPT_X, &buf, &buf_len),
|
||||||
0, "conn_mgr_if_get_opt should succeed for valid parameters");
|
0, "conn_mgr_if_get_opt should succeed for valid parameters");
|
||||||
zassert_equal(buf_len, strlen(buf) + 1, "conn_mgr_if_get_opt should return valid optlen");
|
zassert_equal(buf_len, strlen(buf) + 1, "conn_mgr_if_get_opt should return valid optlen");
|
||||||
zassert_equal(strcmp(buf, "A"), 0, "conn_mgr_if_get_opt should retrieve \"A\"");
|
zassert_str_equal(buf, "A",
|
||||||
|
"conn_mgr_if_get_opt should retrieve \"A\"");
|
||||||
|
|
||||||
/* Next, we pass some buffers that are too large or too small.
|
/* Next, we pass some buffers that are too large or too small.
|
||||||
* This is an indirect way of verifying that buf_len is passed correctly.
|
* This is an indirect way of verifying that buf_len is passed correctly.
|
||||||
|
|
|
@ -319,26 +319,26 @@ ZTEST(server_function_tests, test_http_server_start_stop)
|
||||||
|
|
||||||
ZTEST(server_function_tests, test_get_frame_type_name)
|
ZTEST(server_function_tests, test_get_frame_type_name)
|
||||||
{
|
{
|
||||||
zassert_equal(strcmp(get_frame_type_name(HTTP_SERVER_DATA_FRAME), "DATA"), 0,
|
zassert_str_equal(get_frame_type_name(HTTP_SERVER_DATA_FRAME), "DATA",
|
||||||
"Unexpected frame type");
|
"Unexpected frame type");
|
||||||
zassert_equal(strcmp(get_frame_type_name(HTTP_SERVER_HEADERS_FRAME), "HEADERS"), 0,
|
zassert_str_equal(get_frame_type_name(HTTP_SERVER_HEADERS_FRAME),
|
||||||
|
"HEADERS", "Unexpected frame type");
|
||||||
|
zassert_str_equal(get_frame_type_name(HTTP_SERVER_PRIORITY_FRAME),
|
||||||
|
"PRIORITY", "Unexpected frame type");
|
||||||
|
zassert_str_equal(get_frame_type_name(HTTP_SERVER_RST_STREAM_FRAME),
|
||||||
|
"RST_STREAM", "Unexpected frame type");
|
||||||
|
zassert_str_equal(get_frame_type_name(HTTP_SERVER_SETTINGS_FRAME),
|
||||||
|
"SETTINGS", "Unexpected frame type");
|
||||||
|
zassert_str_equal(get_frame_type_name(HTTP_SERVER_PUSH_PROMISE_FRAME),
|
||||||
|
"PUSH_PROMISE", "Unexpected frame type");
|
||||||
|
zassert_str_equal(get_frame_type_name(HTTP_SERVER_PING_FRAME), "PING",
|
||||||
"Unexpected frame type");
|
"Unexpected frame type");
|
||||||
zassert_equal(strcmp(get_frame_type_name(HTTP_SERVER_PRIORITY_FRAME), "PRIORITY"), 0,
|
zassert_str_equal(get_frame_type_name(HTTP_SERVER_GOAWAY_FRAME),
|
||||||
"Unexpected frame type");
|
"GOAWAY", "Unexpected frame type");
|
||||||
zassert_equal(strcmp(get_frame_type_name(HTTP_SERVER_RST_STREAM_FRAME), "RST_STREAM"), 0,
|
zassert_str_equal(get_frame_type_name(HTTP_SERVER_WINDOW_UPDATE_FRAME),
|
||||||
"Unexpected frame type");
|
"WINDOW_UPDATE", "Unexpected frame type");
|
||||||
zassert_equal(strcmp(get_frame_type_name(HTTP_SERVER_SETTINGS_FRAME), "SETTINGS"), 0,
|
zassert_str_equal(get_frame_type_name(HTTP_SERVER_CONTINUATION_FRAME),
|
||||||
"Unexpected frame type");
|
"CONTINUATION", "Unexpected frame type");
|
||||||
zassert_equal(strcmp(get_frame_type_name(HTTP_SERVER_PUSH_PROMISE_FRAME), "PUSH_PROMISE"),
|
|
||||||
0, "Unexpected frame type");
|
|
||||||
zassert_equal(strcmp(get_frame_type_name(HTTP_SERVER_PING_FRAME), "PING"), 0,
|
|
||||||
"Unexpected frame type");
|
|
||||||
zassert_equal(strcmp(get_frame_type_name(HTTP_SERVER_GOAWAY_FRAME), "GOAWAY"), 0,
|
|
||||||
"Unexpected frame type");
|
|
||||||
zassert_equal(strcmp(get_frame_type_name(HTTP_SERVER_WINDOW_UPDATE_FRAME), "WINDOW_UPDATE"),
|
|
||||||
0, "Unexpected frame type");
|
|
||||||
zassert_equal(strcmp(get_frame_type_name(HTTP_SERVER_CONTINUATION_FRAME), "CONTINUATION"),
|
|
||||||
0, "Unexpected frame type");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ZTEST(server_function_tests, test_parse_http_frames)
|
ZTEST(server_function_tests, test_parse_http_frames)
|
||||||
|
|
|
@ -181,7 +181,7 @@ ZTEST(lwm2m_registry, test_get_set)
|
||||||
|
|
||||||
zassert_equal(b, true);
|
zassert_equal(b, true);
|
||||||
zassert_equal(memcmp(opaque, &(uint8_t[6]) {0xde, 0xad, 0xbe, 0xff, 0, 0}, l), 0);
|
zassert_equal(memcmp(opaque, &(uint8_t[6]) {0xde, 0xad, 0xbe, 0xff, 0, 0}, l), 0);
|
||||||
zassert_equal(strcmp(string, "Hello"), 0);
|
zassert_str_equal(string, "Hello");
|
||||||
zassert_equal(u8, 8);
|
zassert_equal(u8, 8);
|
||||||
zassert_equal(s8, -8);
|
zassert_equal(s8, -8);
|
||||||
zassert_equal(u16, 16);
|
zassert_equal(u16, 16);
|
||||||
|
@ -465,7 +465,7 @@ ZTEST(lwm2m_registry, test_deprecated_functions)
|
||||||
|
|
||||||
zassert_equal(b, true);
|
zassert_equal(b, true);
|
||||||
zassert_equal(memcmp(opaque, &(uint8_t[6]) {0xde, 0xad, 0xbe, 0xff, 0, 0}, l), 0);
|
zassert_equal(memcmp(opaque, &(uint8_t[6]) {0xde, 0xad, 0xbe, 0xff, 0, 0}, l), 0);
|
||||||
zassert_equal(strcmp(string, "Hello"), 0);
|
zassert_str_equal(string, "Hello");
|
||||||
zassert_equal(u8, 8);
|
zassert_equal(u8, 8);
|
||||||
zassert_equal(s8, -8);
|
zassert_equal(s8, -8);
|
||||||
zassert_equal(u16, 16);
|
zassert_equal(u16, 16);
|
||||||
|
@ -681,7 +681,7 @@ ZTEST(lwm2m_registry, test_set_bulk)
|
||||||
zassert_equal(b, true);
|
zassert_equal(b, true);
|
||||||
zassert_equal(memcmp(opaque, &(uint8_t[6]) {0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff},
|
zassert_equal(memcmp(opaque, &(uint8_t[6]) {0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff},
|
||||||
sizeof(opaque)), 0);
|
sizeof(opaque)), 0);
|
||||||
zassert_equal(strcmp(string, "Hello world"), 0);
|
zassert_str_equal(string, "Hello world");
|
||||||
zassert_equal(u8, 80);
|
zassert_equal(u8, 80);
|
||||||
zassert_equal(s8, -80);
|
zassert_equal(s8, -80);
|
||||||
zassert_equal(u16, 160);
|
zassert_equal(u16, 160);
|
||||||
|
|
|
@ -37,21 +37,21 @@ ZTEST(test_symtab, test_symtab_find_symbol_name)
|
||||||
/* Find the name of functions with `symtab_find_symbol_name()` */
|
/* Find the name of functions with `symtab_find_symbol_name()` */
|
||||||
offset = -1;
|
offset = -1;
|
||||||
symbol_name = symtab_find_symbol_name((uintptr_t)main, &offset);
|
symbol_name = symtab_find_symbol_name((uintptr_t)main, &offset);
|
||||||
zassert_equal(strcmp(symbol_name, "main"), 0);
|
zassert_str_equal(symbol_name, "main");
|
||||||
zassert_equal(offset, 0);
|
zassert_equal(offset, 0);
|
||||||
|
|
||||||
/* Do a few more just for fun */
|
/* Do a few more just for fun */
|
||||||
symbol_name = symtab_find_symbol_name((uintptr_t)strcmp, NULL);
|
symbol_name = symtab_find_symbol_name((uintptr_t)strcmp, NULL);
|
||||||
zassert_equal(strcmp(symbol_name, "strcmp"), 0);
|
zassert_str_equal(symbol_name, "strcmp");
|
||||||
|
|
||||||
symbol_name = symtab_find_symbol_name((uintptr_t)symtab_find_symbol_name, NULL);
|
symbol_name = symtab_find_symbol_name((uintptr_t)symtab_find_symbol_name, NULL);
|
||||||
zassert_equal(strcmp(symbol_name, "symtab_find_symbol_name"), 0);
|
zassert_str_equal(symbol_name, "symtab_find_symbol_name");
|
||||||
|
|
||||||
symbol_name = symtab_find_symbol_name((uintptr_t)test_main, NULL);
|
symbol_name = symtab_find_symbol_name((uintptr_t)test_main, NULL);
|
||||||
zassert_equal(strcmp(symbol_name, "test_main"), 0);
|
zassert_str_equal(symbol_name, "test_main");
|
||||||
|
|
||||||
symbol_name = symtab_find_symbol_name((uintptr_t)setup, NULL);
|
symbol_name = symtab_find_symbol_name((uintptr_t)setup, NULL);
|
||||||
zassert_equal(strcmp(symbol_name, "setup"), 0);
|
zassert_str_equal(symbol_name, "setup");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,7 +83,7 @@ ZTEST(test_symtab, test_before_first)
|
||||||
if (first_addr > 0) {
|
if (first_addr > 0) {
|
||||||
offset = -1;
|
offset = -1;
|
||||||
symbol_name = symtab_find_symbol_name(first_addr - 1, &offset);
|
symbol_name = symtab_find_symbol_name(first_addr - 1, &offset);
|
||||||
zassert_equal(strcmp(symbol_name, "?"), 0);
|
zassert_str_equal(symbol_name, "?");
|
||||||
zassert_equal(offset, 0);
|
zassert_equal(offset, 0);
|
||||||
} else {
|
} else {
|
||||||
ztest_test_skip();
|
ztest_test_skip();
|
||||||
|
@ -98,13 +98,13 @@ ZTEST(test_symtab, test_first)
|
||||||
|
|
||||||
offset = -1;
|
offset = -1;
|
||||||
symbol_name = symtab_find_symbol_name(first_addr, &offset);
|
symbol_name = symtab_find_symbol_name(first_addr, &offset);
|
||||||
zassert_equal(strcmp(symbol_name, symtab->entries[0].name), 0);
|
zassert_str_equal(symbol_name, symtab->entries[0].name);
|
||||||
zassert_equal(offset, 0);
|
zassert_equal(offset, 0);
|
||||||
|
|
||||||
if ((symtab->entries[0].offset + 1) != symtab->entries[1].offset) {
|
if ((symtab->entries[0].offset + 1) != symtab->entries[1].offset) {
|
||||||
offset = -1;
|
offset = -1;
|
||||||
symbol_name = symtab_find_symbol_name(first_addr + 1, &offset);
|
symbol_name = symtab_find_symbol_name(first_addr + 1, &offset);
|
||||||
zassert_equal(strcmp(symbol_name, symtab->entries[0].name), 0);
|
zassert_str_equal(symbol_name, symtab->entries[0].name);
|
||||||
zassert_equal(offset, 1);
|
zassert_equal(offset, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ ZTEST(test_symtab, test_last)
|
||||||
|
|
||||||
offset = -1;
|
offset = -1;
|
||||||
symbol_name = symtab_find_symbol_name(last_addr, &offset);
|
symbol_name = symtab_find_symbol_name(last_addr, &offset);
|
||||||
zassert_equal(strcmp(symbol_name, symtab->entries[last_idx].name), 0);
|
zassert_str_equal(symbol_name, symtab->entries[last_idx].name);
|
||||||
zassert_equal(offset, 0);
|
zassert_equal(offset, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +135,8 @@ ZTEST(test_symtab, test_after_last)
|
||||||
if (last_offset + 0x1 != symtab->entries[symtab->length].offset) {
|
if (last_offset + 0x1 != symtab->entries[symtab->length].offset) {
|
||||||
offset = -1;
|
offset = -1;
|
||||||
symbol_name = symtab_find_symbol_name(last_addr + 0x1, &offset);
|
symbol_name = symtab_find_symbol_name(last_addr + 0x1, &offset);
|
||||||
zassert_equal(strcmp(symbol_name, symtab->entries[symtab->length - 1].name), 0);
|
zassert_str_equal(symbol_name,
|
||||||
|
symtab->entries[symtab->length - 1].name);
|
||||||
zassert_equal(offset, 0x1);
|
zassert_equal(offset, 0x1);
|
||||||
} else {
|
} else {
|
||||||
ztest_test_skip();
|
ztest_test_skip();
|
||||||
|
@ -153,6 +154,6 @@ ZTEST(test_symtab, test_after_dummy)
|
||||||
/* Test `offset` output with dummy symbol (after last dymbol) */
|
/* Test `offset` output with dummy symbol (after last dymbol) */
|
||||||
offset = -1;
|
offset = -1;
|
||||||
symbol_name = symtab_find_symbol_name(last_dummy_addr + 0x42, &offset);
|
symbol_name = symtab_find_symbol_name(last_dummy_addr + 0x42, &offset);
|
||||||
zassert_equal(strcmp(symbol_name, "?"), 0);
|
zassert_str_equal(symbol_name, "?");
|
||||||
zassert_equal(offset, 0);
|
zassert_equal(offset, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,8 +43,7 @@ static int create_write_hello(const struct fs_mount_t *mp)
|
||||||
|
|
||||||
zassert_equal(stat.type, FS_DIR_ENTRY_FILE,
|
zassert_equal(stat.type, FS_DIR_ENTRY_FILE,
|
||||||
"stat new hello not file");
|
"stat new hello not file");
|
||||||
zassert_equal(strcmp(stat.name, HELLO), 0,
|
zassert_str_equal(stat.name, HELLO, "stat new hello not hello");
|
||||||
"stat new hello not hello");
|
|
||||||
zassert_equal(stat.size, 0,
|
zassert_equal(stat.size, 0,
|
||||||
"stat new hello not empty");
|
"stat new hello not empty");
|
||||||
|
|
||||||
|
@ -58,8 +57,7 @@ static int create_write_hello(const struct fs_mount_t *mp)
|
||||||
|
|
||||||
zassert_equal(stat.type, FS_DIR_ENTRY_FILE,
|
zassert_equal(stat.type, FS_DIR_ENTRY_FILE,
|
||||||
"stat written hello not file");
|
"stat written hello not file");
|
||||||
zassert_equal(strcmp(stat.name, HELLO), 0,
|
zassert_str_equal(stat.name, HELLO, "stat written hello not hello");
|
||||||
"stat written hello not hello");
|
|
||||||
|
|
||||||
/* Anomalous behavior requiring upstream response */
|
/* Anomalous behavior requiring upstream response */
|
||||||
if (mp->type == FS_LITTLEFS) {
|
if (mp->type == FS_LITTLEFS) {
|
||||||
|
@ -79,8 +77,7 @@ static int create_write_hello(const struct fs_mount_t *mp)
|
||||||
|
|
||||||
zassert_equal(stat.type, FS_DIR_ENTRY_FILE,
|
zassert_equal(stat.type, FS_DIR_ENTRY_FILE,
|
||||||
"stat closed hello not file");
|
"stat closed hello not file");
|
||||||
zassert_equal(strcmp(stat.name, HELLO), 0,
|
zassert_str_equal(stat.name, HELLO, "stat closed hello not hello");
|
||||||
"stat closed hello not hello");
|
|
||||||
zassert_equal(stat.size, TESTFS_BUFFER_SIZE,
|
zassert_equal(stat.size, TESTFS_BUFFER_SIZE,
|
||||||
"stat closed hello badsize");
|
"stat closed hello badsize");
|
||||||
|
|
||||||
|
|
|
@ -700,7 +700,7 @@ void test_file_read(void)
|
||||||
read_buff[brw] = 0;
|
read_buff[brw] = 0;
|
||||||
TC_PRINT("Data read:\"%s\"\n\n", read_buff);
|
TC_PRINT("Data read:\"%s\"\n\n", read_buff);
|
||||||
|
|
||||||
zassert_true(strcmp(test_str, read_buff) == 0,
|
zassert_str_equal(test_str, read_buff,
|
||||||
"Error - Data read does not match data written");
|
"Error - Data read does not match data written");
|
||||||
|
|
||||||
TC_PRINT("Data read matches data written\n");
|
TC_PRINT("Data read matches data written\n");
|
||||||
|
|
|
@ -31,12 +31,12 @@ ZTEST(littlefs, test_util_path_init_base)
|
||||||
zassert_equal(testfs_path_init(&path, NULL, TESTFS_PATH_END),
|
zassert_equal(testfs_path_init(&path, NULL, TESTFS_PATH_END),
|
||||||
path.path,
|
path.path,
|
||||||
"bad root init return");
|
"bad root init return");
|
||||||
zassert_equal(strcmp(path.path, "/"), 0, "bad root init path");
|
zassert_str_equal(path.path, "/", "bad root init path");
|
||||||
|
|
||||||
zassert_equal(testfs_path_init(&path, &mnt, TESTFS_PATH_END),
|
zassert_equal(testfs_path_init(&path, &mnt, TESTFS_PATH_END),
|
||||||
path.path,
|
path.path,
|
||||||
"bad mnt init return");
|
"bad mnt init return");
|
||||||
zassert_equal(strcmp(path.path, mnt.mnt_point), 0, "bad mnt init path");
|
zassert_str_equal(path.path, mnt.mnt_point, "bad mnt init path");
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_DEBUG)) {
|
if (IS_ENABLED(CONFIG_DEBUG)) {
|
||||||
struct fs_mount_t invalid = {
|
struct fs_mount_t invalid = {
|
||||||
|
@ -76,71 +76,35 @@ ZTEST(littlefs, test_util_path_init_overrun)
|
||||||
|
|
||||||
ZTEST(littlefs, test_util_path_init_extended)
|
ZTEST(littlefs, test_util_path_init_extended)
|
||||||
{
|
{
|
||||||
zassert_equal(strcmp(testfs_path_init(&path, &mnt,
|
zassert_str_equal(testfs_path_init(&path, &mnt, ELT1, TESTFS_PATH_END),
|
||||||
ELT1,
|
MNT "/" ELT1, "bad mnt init elt1");
|
||||||
TESTFS_PATH_END),
|
|
||||||
MNT "/" ELT1),
|
|
||||||
0,
|
|
||||||
"bad mnt init elt1");
|
|
||||||
|
|
||||||
zassert_equal(strcmp(testfs_path_init(&path, &mnt,
|
zassert_str_equal(testfs_path_init(&path, &mnt, ELT1, ELT2, TESTFS_PATH_END),
|
||||||
ELT1,
|
MNT "/" ELT1 "/" ELT2, "bad mnt init elt1 elt2");
|
||||||
ELT2,
|
|
||||||
TESTFS_PATH_END),
|
|
||||||
MNT "/" ELT1 "/" ELT2),
|
|
||||||
0,
|
|
||||||
"bad mnt init elt1 elt2");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ZTEST(littlefs, test_util_path_extend)
|
ZTEST(littlefs, test_util_path_extend)
|
||||||
{
|
{
|
||||||
zassert_equal(strcmp(testfs_path_extend(reset_path(),
|
zassert_str_equal(testfs_path_extend(reset_path(), TESTFS_PATH_END),
|
||||||
TESTFS_PATH_END),
|
MNT, "empty extend failed");
|
||||||
MNT),
|
|
||||||
0,
|
|
||||||
"empty extend failed");
|
|
||||||
|
|
||||||
zassert_equal(strcmp(testfs_path_extend(reset_path(),
|
zassert_str_equal(testfs_path_extend(reset_path(), ELT2, TESTFS_PATH_END),
|
||||||
ELT2,
|
MNT "/" ELT2, "elt extend failed");
|
||||||
TESTFS_PATH_END),
|
|
||||||
MNT "/" ELT2),
|
|
||||||
0,
|
|
||||||
"elt extend failed");
|
|
||||||
|
|
||||||
zassert_equal(strcmp(testfs_path_extend(reset_path(),
|
zassert_str_equal(testfs_path_extend(reset_path(), ELT1, ELT2, TESTFS_PATH_END),
|
||||||
ELT1,
|
MNT "/" ELT1 "/" ELT2, "elt1 elt2 extend failed");
|
||||||
ELT2,
|
|
||||||
TESTFS_PATH_END),
|
|
||||||
MNT "/" ELT1 "/" ELT2),
|
|
||||||
0,
|
|
||||||
"elt1 elt2 extend failed");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ZTEST(littlefs, test_util_path_extend_up)
|
ZTEST(littlefs, test_util_path_extend_up)
|
||||||
{
|
{
|
||||||
zassert_equal(strcmp(testfs_path_extend(reset_path(),
|
zassert_str_equal(testfs_path_extend(reset_path(), ELT2, "..", ELT1, TESTFS_PATH_END),
|
||||||
ELT2,
|
MNT "/" ELT1, "elt elt2, up, elt1 failed");
|
||||||
"..",
|
|
||||||
ELT1,
|
|
||||||
TESTFS_PATH_END),
|
|
||||||
MNT "/" ELT1),
|
|
||||||
0,
|
|
||||||
"elt elt2, up, elt1 failed");
|
|
||||||
|
|
||||||
zassert_equal(strcmp(testfs_path_extend(reset_path(),
|
zassert_str_equal(testfs_path_extend(reset_path(), "..", TESTFS_PATH_END),
|
||||||
"..",
|
"/", "up strip mnt failed");
|
||||||
TESTFS_PATH_END),
|
|
||||||
"/"),
|
|
||||||
0,
|
|
||||||
"up strip mnt failed");
|
|
||||||
|
|
||||||
zassert_equal(strcmp(testfs_path_extend(reset_path(),
|
zassert_str_equal(testfs_path_extend(reset_path(), "..", "..", TESTFS_PATH_END),
|
||||||
"..",
|
"/", "up from root failed");
|
||||||
"..",
|
|
||||||
TESTFS_PATH_END),
|
|
||||||
"/"),
|
|
||||||
0,
|
|
||||||
"up from root failed");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ZTEST(littlefs, test_util_path_extend_overrun)
|
ZTEST(littlefs, test_util_path_extend_overrun)
|
||||||
|
@ -150,11 +114,6 @@ ZTEST(littlefs, test_util_path_extend_overrun)
|
||||||
memset(long_elt, 'a', sizeof(long_elt) - 1);
|
memset(long_elt, 'a', sizeof(long_elt) - 1);
|
||||||
long_elt[sizeof(long_elt) - 1] = '\0';
|
long_elt[sizeof(long_elt) - 1] = '\0';
|
||||||
|
|
||||||
zassert_equal(strcmp(testfs_path_extend(reset_path(),
|
zassert_str_equal(testfs_path_extend(reset_path(), long_elt, ELT1, TESTFS_PATH_END),
|
||||||
long_elt,
|
MNT, "stop at overrun failed");
|
||||||
ELT1,
|
|
||||||
TESTFS_PATH_END),
|
|
||||||
MNT),
|
|
||||||
0,
|
|
||||||
"stop at overrun failed");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,7 +211,7 @@ ZTEST(log_links, test_log_runtime_level_set)
|
||||||
|
|
||||||
ZTEST(log_links, test_log_domain_name_get)
|
ZTEST(log_links, test_log_domain_name_get)
|
||||||
{
|
{
|
||||||
zassert_equal(strcmp(log_domain_name_get(0), ""), 0,
|
zassert_str_equal(log_domain_name_get(0), "",
|
||||||
"Unexpected domain name");
|
"Unexpected domain name");
|
||||||
zassert_equal(strcmp(log_domain_name_get(1), "domain1"), 0,
|
zassert_equal(strcmp(log_domain_name_get(1), "domain1"), 0,
|
||||||
"Unexpected domain name (%s)", log_domain_name_get(1));
|
"Unexpected domain name (%s)", log_domain_name_get(1));
|
||||||
|
|
|
@ -57,7 +57,7 @@ ZTEST(test_log_output, test_no_flags)
|
||||||
log_output_process(&log_output, 0, NULL, SNAME, NULL, LOG_LEVEL_INF, package, NULL, 0, 0);
|
log_output_process(&log_output, 0, NULL, SNAME, NULL, LOG_LEVEL_INF, package, NULL, 0, 0);
|
||||||
|
|
||||||
mock_buffer[mock_len] = '\0';
|
mock_buffer[mock_len] = '\0';
|
||||||
zassert_equal(strcmp(exp_str, mock_buffer), 0);
|
zassert_str_equal(exp_str, mock_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZTEST(test_log_output, test_raw)
|
ZTEST(test_log_output, test_raw)
|
||||||
|
@ -73,7 +73,7 @@ ZTEST(test_log_output, test_raw)
|
||||||
package, NULL, 0, 0);
|
package, NULL, 0, 0);
|
||||||
|
|
||||||
mock_buffer[mock_len] = '\0';
|
mock_buffer[mock_len] = '\0';
|
||||||
zassert_equal(strcmp(exp_str, mock_buffer), 0);
|
zassert_str_equal(exp_str, mock_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZTEST(test_log_output, test_no_flags_dname)
|
ZTEST(test_log_output, test_no_flags_dname)
|
||||||
|
@ -88,7 +88,7 @@ ZTEST(test_log_output, test_no_flags_dname)
|
||||||
log_output_process(&log_output, 0, DNAME, SNAME, NULL, LOG_LEVEL_INF, package, NULL, 0, 0);
|
log_output_process(&log_output, 0, DNAME, SNAME, NULL, LOG_LEVEL_INF, package, NULL, 0, 0);
|
||||||
|
|
||||||
mock_buffer[mock_len] = '\0';
|
mock_buffer[mock_len] = '\0';
|
||||||
zassert_equal(strcmp(exp_str, mock_buffer), 0);
|
zassert_str_equal(exp_str, mock_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZTEST(test_log_output, test_level_flag)
|
ZTEST(test_log_output, test_level_flag)
|
||||||
|
@ -105,7 +105,7 @@ ZTEST(test_log_output, test_level_flag)
|
||||||
package, NULL, 0, flags);
|
package, NULL, 0, flags);
|
||||||
|
|
||||||
mock_buffer[mock_len] = '\0';
|
mock_buffer[mock_len] = '\0';
|
||||||
zassert_equal(strcmp(exp_str, mock_buffer), 0);
|
zassert_str_equal(exp_str, mock_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZTEST(test_log_output, test_ts_flag)
|
ZTEST(test_log_output, test_ts_flag)
|
||||||
|
@ -124,7 +124,7 @@ ZTEST(test_log_output, test_ts_flag)
|
||||||
package, NULL, 0, flags);
|
package, NULL, 0, flags);
|
||||||
|
|
||||||
mock_buffer[mock_len] = '\0';
|
mock_buffer[mock_len] = '\0';
|
||||||
zassert_equal(strcmp(exp_str, mock_buffer), 0);
|
zassert_str_equal(exp_str, mock_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZTEST(test_log_output, test_format_ts)
|
ZTEST(test_log_output, test_format_ts)
|
||||||
|
@ -145,7 +145,7 @@ ZTEST(test_log_output, test_format_ts)
|
||||||
|
|
||||||
mock_buffer[mock_len] = '\0';
|
mock_buffer[mock_len] = '\0';
|
||||||
printk("%s", mock_buffer);
|
printk("%s", mock_buffer);
|
||||||
zassert_equal(strcmp(exp_str, mock_buffer), 0);
|
zassert_str_equal(exp_str, mock_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZTEST(test_log_output, test_ts_to_us)
|
ZTEST(test_log_output, test_ts_to_us)
|
||||||
|
@ -182,7 +182,7 @@ ZTEST(test_log_output, test_levels)
|
||||||
package, NULL, 0, flags);
|
package, NULL, 0, flags);
|
||||||
|
|
||||||
mock_buffer[mock_len] = '\0';
|
mock_buffer[mock_len] = '\0';
|
||||||
zassert_equal(strcmp(exp_strs[i], mock_buffer), 0);
|
zassert_str_equal(exp_strs[i], mock_buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ ZTEST(test_log_output, test_colors)
|
||||||
package, NULL, 0, flags);
|
package, NULL, 0, flags);
|
||||||
|
|
||||||
mock_buffer[mock_len] = '\0';
|
mock_buffer[mock_len] = '\0';
|
||||||
zassert_equal(strcmp(exp_strs[i], mock_buffer), 0);
|
zassert_str_equal(exp_strs[i], mock_buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ ZTEST(test_log_output, test_thread_id)
|
||||||
|
|
||||||
mock_buffer[mock_len] = '\0';
|
mock_buffer[mock_len] = '\0';
|
||||||
printk("%s", mock_buffer);
|
printk("%s", mock_buffer);
|
||||||
zassert_equal(strcmp(exp_str, mock_buffer), 0);
|
zassert_str_equal(exp_str, mock_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZTEST(test_log_output, test_skip_src)
|
ZTEST(test_log_output, test_skip_src)
|
||||||
|
@ -262,7 +262,7 @@ ZTEST(test_log_output, test_skip_src)
|
||||||
package, NULL, 0, flags);
|
package, NULL, 0, flags);
|
||||||
|
|
||||||
mock_buffer[mock_len] = '\0';
|
mock_buffer[mock_len] = '\0';
|
||||||
zassert_equal(strcmp(exp_str, mock_buffer), 0);
|
zassert_str_equal(exp_str, mock_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void before(void *notused)
|
static void before(void *notused)
|
||||||
|
|
|
@ -75,7 +75,7 @@ ZTEST(test_timestamp, test_custom_timestamp)
|
||||||
package, NULL, 0, flags);
|
package, NULL, 0, flags);
|
||||||
|
|
||||||
mock_buffer[mock_len] = '\0';
|
mock_buffer[mock_len] = '\0';
|
||||||
zassert_equal(strcmp(exp_str, mock_buffer), 0);
|
zassert_str_equal(exp_str, mock_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void before(void *notused)
|
static void before(void *notused)
|
||||||
|
|
|
@ -26,15 +26,15 @@ ZTEST(mem_attr, test_mem_attr)
|
||||||
zassert_equal(region[idx].dt_attr, DT_MEM_ARM_MPU_FLASH |
|
zassert_equal(region[idx].dt_attr, DT_MEM_ARM_MPU_FLASH |
|
||||||
DT_MEM_NON_VOLATILE,
|
DT_MEM_NON_VOLATILE,
|
||||||
"Wrong region address");
|
"Wrong region address");
|
||||||
zassert_true((strcmp(region[idx].dt_name, "memory@10000000") == 0),
|
zassert_str_equal(region[idx].dt_name,
|
||||||
"Wrong name");
|
"memory@10000000", "Wrong name");
|
||||||
} else {
|
} else {
|
||||||
zassert_equal(region[idx].dt_addr, 0x20000000, "Wrong region address");
|
zassert_equal(region[idx].dt_addr, 0x20000000, "Wrong region address");
|
||||||
zassert_equal(region[idx].dt_size, 0x2000, "Wrong region size");
|
zassert_equal(region[idx].dt_size, 0x2000, "Wrong region size");
|
||||||
zassert_equal(region[idx].dt_attr, DT_MEM_ARM_MPU_RAM_NOCACHE,
|
zassert_equal(region[idx].dt_attr, DT_MEM_ARM_MPU_RAM_NOCACHE,
|
||||||
"Wrong region address");
|
"Wrong region address");
|
||||||
zassert_true((strcmp(region[idx].dt_name, "memory@20000000") == 0),
|
zassert_str_equal(region[idx].dt_name,
|
||||||
"Wrong name");
|
"memory@20000000", "Wrong name");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -521,11 +521,16 @@ ZTEST(modem_chat, test_script_with_partial_matches)
|
||||||
MODEM_CHAT_UTEST_ON_CMGL_PARTIAL_CALLED_BIT);
|
MODEM_CHAT_UTEST_ON_CMGL_PARTIAL_CALLED_BIT);
|
||||||
zassert_equal(called, true, "Match callback not called");
|
zassert_equal(called, true, "Match callback not called");
|
||||||
zassert_equal(argc_buffers, 5, "Incorrect number of args");
|
zassert_equal(argc_buffers, 5, "Incorrect number of args");
|
||||||
zassert_equal(strcmp(argv_buffers[0], "+CMGL: "), 0, "Incorrect argv received");
|
zassert_str_equal(argv_buffers[0], "+CMGL: ",
|
||||||
zassert_equal(strcmp(argv_buffers[1], "1"), 0, "Incorrect argv received");
|
"Incorrect argv received");
|
||||||
zassert_equal(strcmp(argv_buffers[2], "1"), 0, "Incorrect argv received");
|
zassert_str_equal(argv_buffers[1], "1",
|
||||||
zassert_equal(strcmp(argv_buffers[3], ""), 0, "Incorrect argv received");
|
"Incorrect argv received");
|
||||||
zassert_equal(strcmp(argv_buffers[4], "50"), 0, "Incorrect argv received");
|
zassert_str_equal(argv_buffers[2], "1",
|
||||||
|
"Incorrect argv received");
|
||||||
|
zassert_str_equal(argv_buffers[3], "",
|
||||||
|
"Incorrect argv received");
|
||||||
|
zassert_str_equal(argv_buffers[4], "50",
|
||||||
|
"Incorrect argv received");
|
||||||
|
|
||||||
atomic_set(&callback_called, 0);
|
atomic_set(&callback_called, 0);
|
||||||
modem_backend_mock_put(&mock, cmgl_response_1, sizeof(cmgl_response_1) - 1);
|
modem_backend_mock_put(&mock, cmgl_response_1, sizeof(cmgl_response_1) - 1);
|
||||||
|
@ -535,8 +540,10 @@ ZTEST(modem_chat, test_script_with_partial_matches)
|
||||||
MODEM_CHAT_UTEST_ON_CMGL_PARTIAL_ANY_CALLED_BIT);
|
MODEM_CHAT_UTEST_ON_CMGL_PARTIAL_ANY_CALLED_BIT);
|
||||||
zassert_equal(called, true, "Match callback not called");
|
zassert_equal(called, true, "Match callback not called");
|
||||||
zassert_equal(argc_buffers, 2, "Incorrect number of args");
|
zassert_equal(argc_buffers, 2, "Incorrect number of args");
|
||||||
zassert_equal(strcmp(argv_buffers[0], ""), 0, "Incorrect argv received");
|
zassert_str_equal(argv_buffers[0], "",
|
||||||
zassert_equal(strcmp(argv_buffers[1], "07911326060032F064A9542954"), 0,
|
"Incorrect argv received");
|
||||||
|
zassert_str_equal(argv_buffers[1],
|
||||||
|
"07911326060032F064A9542954",
|
||||||
"Incorrect argv received");
|
"Incorrect argv received");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,25 +33,29 @@ ZTEST(device_driver_init, test_device_driver_init)
|
||||||
enum pm_device_state state;
|
enum pm_device_state state;
|
||||||
int rc;
|
int rc;
|
||||||
state = -1;
|
state = -1;
|
||||||
zassert_equal(strcmp("", pm_device_state_str(state)), 0, "Invalid device state");
|
zassert_str_equal("", pm_device_state_str(state),
|
||||||
|
"Invalid device state");
|
||||||
/* No device runtime PM, starts on */
|
/* No device runtime PM, starts on */
|
||||||
DEVICE_STATE_IS(DT_NODELABEL(test_reg), PM_DEVICE_STATE_ACTIVE);
|
DEVICE_STATE_IS(DT_NODELABEL(test_reg), PM_DEVICE_STATE_ACTIVE);
|
||||||
DEVICE_STATE_IS(DT_NODELABEL(test_reg_chained), PM_DEVICE_STATE_ACTIVE);
|
DEVICE_STATE_IS(DT_NODELABEL(test_reg_chained), PM_DEVICE_STATE_ACTIVE);
|
||||||
POWER_GPIO_CONFIG_IS(DT_NODELABEL(test_reg), GPIO_OUTPUT_HIGH);
|
POWER_GPIO_CONFIG_IS(DT_NODELABEL(test_reg), GPIO_OUTPUT_HIGH);
|
||||||
POWER_GPIO_CONFIG_IS(DT_NODELABEL(test_reg_chained), GPIO_OUTPUT_HIGH);
|
POWER_GPIO_CONFIG_IS(DT_NODELABEL(test_reg_chained), GPIO_OUTPUT_HIGH);
|
||||||
zassert_equal(strcmp("active", pm_device_state_str(state)), 0, "Invalid device state");
|
zassert_str_equal("active", pm_device_state_str(state),
|
||||||
|
"Invalid device state");
|
||||||
/* Device powered, zephyr,pm-device-runtime-auto, starts suspended */
|
/* Device powered, zephyr,pm-device-runtime-auto, starts suspended */
|
||||||
DEVICE_STATE_IS(DT_NODELABEL(test_reg_chained_auto), PM_DEVICE_STATE_SUSPENDED);
|
DEVICE_STATE_IS(DT_NODELABEL(test_reg_chained_auto), PM_DEVICE_STATE_SUSPENDED);
|
||||||
DEVICE_STATE_IS(DT_NODELABEL(test_reg_auto), PM_DEVICE_STATE_SUSPENDED);
|
DEVICE_STATE_IS(DT_NODELABEL(test_reg_auto), PM_DEVICE_STATE_SUSPENDED);
|
||||||
POWER_GPIO_CONFIG_IS(DT_NODELABEL(test_reg_chained_auto), GPIO_OUTPUT_LOW);
|
POWER_GPIO_CONFIG_IS(DT_NODELABEL(test_reg_chained_auto), GPIO_OUTPUT_LOW);
|
||||||
POWER_GPIO_CONFIG_IS(DT_NODELABEL(test_reg_auto), GPIO_OUTPUT_LOW);
|
POWER_GPIO_CONFIG_IS(DT_NODELABEL(test_reg_auto), GPIO_OUTPUT_LOW);
|
||||||
zassert_equal(strcmp("suspended", pm_device_state_str(state)), 0, "Invalid device state");
|
zassert_str_equal("suspended", pm_device_state_str(state),
|
||||||
|
"Invalid device state");
|
||||||
/* Device not powered, starts off */
|
/* Device not powered, starts off */
|
||||||
DEVICE_STATE_IS(DT_NODELABEL(test_reg_auto_chained), PM_DEVICE_STATE_OFF);
|
DEVICE_STATE_IS(DT_NODELABEL(test_reg_auto_chained), PM_DEVICE_STATE_OFF);
|
||||||
DEVICE_STATE_IS(DT_NODELABEL(test_reg_auto_chained_auto), PM_DEVICE_STATE_OFF);
|
DEVICE_STATE_IS(DT_NODELABEL(test_reg_auto_chained_auto), PM_DEVICE_STATE_OFF);
|
||||||
POWER_GPIO_CONFIG_IS(DT_NODELABEL(test_reg_auto_chained), GPIO_DISCONNECTED);
|
POWER_GPIO_CONFIG_IS(DT_NODELABEL(test_reg_auto_chained), GPIO_DISCONNECTED);
|
||||||
POWER_GPIO_CONFIG_IS(DT_NODELABEL(test_reg_auto_chained_auto), GPIO_DISCONNECTED);
|
POWER_GPIO_CONFIG_IS(DT_NODELABEL(test_reg_auto_chained_auto), GPIO_DISCONNECTED);
|
||||||
zassert_equal(strcmp("off", pm_device_state_str(state)), 0, "Invalid device state");
|
zassert_str_equal("off", pm_device_state_str(state),
|
||||||
|
"Invalid device state");
|
||||||
#else
|
#else
|
||||||
/* Every regulator should be in "active" mode automatically.
|
/* Every regulator should be in "active" mode automatically.
|
||||||
* State checking via GPIO as PM API is disabled.
|
* State checking via GPIO as PM API is disabled.
|
||||||
|
|
|
@ -81,7 +81,7 @@ void test_event_flags_no_wait_timeout(void)
|
||||||
"Invalid event Flags ID is unexpectedly working!");
|
"Invalid event Flags ID is unexpectedly working!");
|
||||||
|
|
||||||
name = osEventFlagsGetName(evt_id);
|
name = osEventFlagsGetName(evt_id);
|
||||||
zassert_true(strcmp(event_flags_attrs.name, name) == 0,
|
zassert_str_equal(event_flags_attrs.name, name,
|
||||||
"Error getting event_flags object name");
|
"Error getting event_flags object name");
|
||||||
|
|
||||||
id1 = osThreadNew(thread1, evt_id, &thread1_attr);
|
id1 = osThreadNew(thread1, evt_id, &thread1_attr);
|
||||||
|
|
|
@ -78,7 +78,7 @@ ZTEST(cmsis_kernel, test_kernel_apis)
|
||||||
irq_offload(get_version_check, (const void *)&version_irq);
|
irq_offload(get_version_check, (const void *)&version_irq);
|
||||||
|
|
||||||
/* Check if the version value retrieved in ISR and thread is same */
|
/* Check if the version value retrieved in ISR and thread is same */
|
||||||
zassert_equal(strcmp(version.info, version_irq.info), 0);
|
zassert_str_equal(version.info, version_irq.info);
|
||||||
zassert_equal(version.os_info.api, version_irq.os_info.api);
|
zassert_equal(version.os_info.api, version_irq.os_info.api);
|
||||||
zassert_equal(version.os_info.kernel, version_irq.os_info.kernel);
|
zassert_equal(version.os_info.kernel, version_irq.os_info.kernel);
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,7 @@ static void mempool_common_tests(osMemoryPoolId_t mp_id,
|
||||||
"Something's wrong with osMemoryPoolGetName!");
|
"Something's wrong with osMemoryPoolGetName!");
|
||||||
|
|
||||||
name = osMemoryPoolGetName(mp_id);
|
name = osMemoryPoolGetName(mp_id);
|
||||||
zassert_true(strcmp(expected_name, name) == 0,
|
zassert_str_equal(expected_name, name, "Error getting mempool name");
|
||||||
"Error getting mempool name");
|
|
||||||
|
|
||||||
zassert_equal(osMemoryPoolGetCapacity(dummy_id), 0,
|
zassert_equal(osMemoryPoolGetCapacity(dummy_id), 0,
|
||||||
"Something's wrong with osMemoryPoolGetCapacity!");
|
"Something's wrong with osMemoryPoolGetCapacity!");
|
||||||
|
|
|
@ -66,8 +66,7 @@ ZTEST(cmsis_mutex, test_mutex)
|
||||||
zassert_true(mutex_id != NULL, "Mutex1 creation failed");
|
zassert_true(mutex_id != NULL, "Mutex1 creation failed");
|
||||||
|
|
||||||
name = osMutexGetName(mutex_id);
|
name = osMutexGetName(mutex_id);
|
||||||
zassert_true(strcmp(mutex_attr.name, name) == 0,
|
zassert_str_equal(mutex_attr.name, name, "Error getting Mutex name");
|
||||||
"Error getting Mutex name");
|
|
||||||
|
|
||||||
/* Try to release mutex without obtaining it */
|
/* Try to release mutex without obtaining it */
|
||||||
status = osMutexRelease(mutex_id);
|
status = osMutexRelease(mutex_id);
|
||||||
|
|
|
@ -78,7 +78,7 @@ ZTEST(cmsis_semaphore, test_semaphore)
|
||||||
zassert_true(semaphore_id != NULL, "semaphore creation failed");
|
zassert_true(semaphore_id != NULL, "semaphore creation failed");
|
||||||
|
|
||||||
name = osSemaphoreGetName(semaphore_id);
|
name = osSemaphoreGetName(semaphore_id);
|
||||||
zassert_true(strcmp(sema_attr.name, name) == 0,
|
zassert_str_equal(sema_attr.name, name,
|
||||||
"Error getting Semaphore name");
|
"Error getting Semaphore name");
|
||||||
|
|
||||||
id = osThreadNew(thread_sema, semaphore_id, &thread_attr);
|
id = osThreadNew(thread_sema, semaphore_id, &thread_attr);
|
||||||
|
|
|
@ -46,8 +46,7 @@ static void thread1(void *argument)
|
||||||
zassert_true(thread_id != NULL, "Failed getting Thread ID");
|
zassert_true(thread_id != NULL, "Failed getting Thread ID");
|
||||||
|
|
||||||
name = osThreadGetName(thread_id);
|
name = osThreadGetName(thread_id);
|
||||||
zassert_true(strcmp(args->name, name) == 0,
|
zassert_str_equal(args->name, name, "Failed getting Thread name");
|
||||||
"Failed getting Thread name");
|
|
||||||
|
|
||||||
/* This thread starts off at a high priority (same as thread2) */
|
/* This thread starts off at a high priority (same as thread2) */
|
||||||
(*args->yield_check)++;
|
(*args->yield_check)++;
|
||||||
|
|
|
@ -55,8 +55,7 @@ ZTEST(cmsis_timer, test_timer)
|
||||||
zassert_true(id1 != NULL, "error creating one-shot timer");
|
zassert_true(id1 != NULL, "error creating one-shot timer");
|
||||||
|
|
||||||
name = osTimerGetName(id1);
|
name = osTimerGetName(id1);
|
||||||
zassert_true(strcmp(timer_attr.name, name) == 0,
|
zassert_str_equal(timer_attr.name, name, "Error getting Timer name");
|
||||||
"Error getting Timer name");
|
|
||||||
|
|
||||||
/* Stop the timer before start */
|
/* Stop the timer before start */
|
||||||
status = osTimerStop(id1);
|
status = osTimerStop(id1);
|
||||||
|
|
|
@ -56,8 +56,7 @@ ZTEST(settings_config_fcb, test_config_save_2_fcb)
|
||||||
rc = settings_load();
|
rc = settings_load();
|
||||||
zassert_true(rc == 0, "fcb read error");
|
zassert_true(rc == 0, "fcb read error");
|
||||||
zassert_true(val8 == 42U, "bad value read");
|
zassert_true(val8 == 42U, "bad value read");
|
||||||
zassert_true(!strcmp(val_string[0], test_ref_value[0]),
|
zassert_str_equal(val_string[0], test_ref_value[0], "bad value read");
|
||||||
"bad value read");
|
|
||||||
test_export_block = 1;
|
test_export_block = 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1306,14 +1306,14 @@ ZTEST(prf, test_cbprintf_fsc_package)
|
||||||
cbpprintf(fsc_package_cb, &pout, package);
|
cbpprintf(fsc_package_cb, &pout, package);
|
||||||
*pout = '\0';
|
*pout = '\0';
|
||||||
|
|
||||||
zassert_equal(strcmp(out_str, exp_str1), 0);
|
zassert_str_equal(out_str, exp_str1);
|
||||||
zassert_true(strcmp(exp_str0, exp_str1) != 0);
|
zassert_true(strcmp(exp_str0, exp_str1) != 0);
|
||||||
|
|
||||||
/* FSC package contains original content. */
|
/* FSC package contains original content. */
|
||||||
pout = out_str;
|
pout = out_str;
|
||||||
cbpprintf(fsc_package_cb, &pout, fsc_package);
|
cbpprintf(fsc_package_cb, &pout, fsc_package);
|
||||||
*pout = '\0';
|
*pout = '\0';
|
||||||
zassert_equal(strcmp(out_str, exp_str0), 0);
|
zassert_str_equal(out_str, exp_str0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZTEST(prf, test_cbpprintf)
|
ZTEST(prf, test_cbpprintf)
|
||||||
|
|
|
@ -14,48 +14,43 @@ ZTEST(util, test_u8_to_dec) {
|
||||||
|
|
||||||
len = u8_to_dec(text, sizeof(text), 0);
|
len = u8_to_dec(text, sizeof(text), 0);
|
||||||
zassert_equal(len, 1, "Length of 0 is not 1");
|
zassert_equal(len, 1, "Length of 0 is not 1");
|
||||||
zassert_equal(strcmp(text, "0"), 0,
|
zassert_str_equal(text, "0", "Value=0 is not converted to \"0\"");
|
||||||
"Value=0 is not converted to \"0\"");
|
|
||||||
|
|
||||||
len = u8_to_dec(text, sizeof(text), 1);
|
len = u8_to_dec(text, sizeof(text), 1);
|
||||||
zassert_equal(len, 1, "Length of 1 is not 1");
|
zassert_equal(len, 1, "Length of 1 is not 1");
|
||||||
zassert_equal(strcmp(text, "1"), 0,
|
zassert_str_equal(text, "1", "Value=1 is not converted to \"1\"");
|
||||||
"Value=1 is not converted to \"1\"");
|
|
||||||
|
|
||||||
len = u8_to_dec(text, sizeof(text), 11);
|
len = u8_to_dec(text, sizeof(text), 11);
|
||||||
zassert_equal(len, 2, "Length of 11 is not 2");
|
zassert_equal(len, 2, "Length of 11 is not 2");
|
||||||
zassert_equal(strcmp(text, "11"), 0,
|
zassert_str_equal(text, "11", "Value=10 is not converted to \"11\"");
|
||||||
"Value=10 is not converted to \"11\"");
|
|
||||||
|
|
||||||
len = u8_to_dec(text, sizeof(text), 100);
|
len = u8_to_dec(text, sizeof(text), 100);
|
||||||
zassert_equal(len, 3, "Length of 100 is not 3");
|
zassert_equal(len, 3, "Length of 100 is not 3");
|
||||||
zassert_equal(strcmp(text, "100"), 0,
|
zassert_str_equal(text, "100",
|
||||||
"Value=100 is not converted to \"100\"");
|
"Value=100 is not converted to \"100\"");
|
||||||
|
|
||||||
len = u8_to_dec(text, sizeof(text), 101);
|
len = u8_to_dec(text, sizeof(text), 101);
|
||||||
zassert_equal(len, 3, "Length of 101 is not 3");
|
zassert_equal(len, 3, "Length of 101 is not 3");
|
||||||
zassert_equal(strcmp(text, "101"), 0,
|
zassert_str_equal(text, "101",
|
||||||
"Value=101 is not converted to \"101\"");
|
"Value=101 is not converted to \"101\"");
|
||||||
|
|
||||||
len = u8_to_dec(text, sizeof(text), 255);
|
len = u8_to_dec(text, sizeof(text), 255);
|
||||||
zassert_equal(len, 3, "Length of 255 is not 3");
|
zassert_equal(len, 3, "Length of 255 is not 3");
|
||||||
zassert_equal(strcmp(text, "255"), 0,
|
zassert_str_equal(text, "255",
|
||||||
"Value=255 is not converted to \"255\"");
|
"Value=255 is not converted to \"255\"");
|
||||||
|
|
||||||
memset(text, 0, sizeof(text));
|
memset(text, 0, sizeof(text));
|
||||||
len = u8_to_dec(text, 2, 123);
|
len = u8_to_dec(text, 2, 123);
|
||||||
zassert_equal(len, 2,
|
zassert_equal(len, 2,
|
||||||
"Length of converted value using 2 byte buffer isn't 2");
|
"Length of converted value using 2 byte buffer isn't 2");
|
||||||
zassert_equal(
|
zassert_str_equal(text, "12",
|
||||||
strcmp(text, "12"), 0,
|
|
||||||
"Value=123 is not converted to \"12\" using 2-byte buffer");
|
"Value=123 is not converted to \"12\" using 2-byte buffer");
|
||||||
|
|
||||||
memset(text, 0, sizeof(text));
|
memset(text, 0, sizeof(text));
|
||||||
len = u8_to_dec(text, 1, 123);
|
len = u8_to_dec(text, 1, 123);
|
||||||
zassert_equal(len, 1,
|
zassert_equal(len, 1,
|
||||||
"Length of converted value using 1 byte buffer isn't 1");
|
"Length of converted value using 1 byte buffer isn't 1");
|
||||||
zassert_equal(
|
zassert_str_equal(text, "1",
|
||||||
strcmp(text, "1"), 0,
|
|
||||||
"Value=123 is not converted to \"1\" using 1-byte buffer");
|
"Value=123 is not converted to \"1\" using 1-byte buffer");
|
||||||
|
|
||||||
memset(text, 0, sizeof(text));
|
memset(text, 0, sizeof(text));
|
||||||
|
@ -419,9 +414,9 @@ ZTEST(util, test_LIST_DROP_EMPTY) {
|
||||||
};
|
};
|
||||||
|
|
||||||
zassert_equal(ARRAY_SIZE(arr), 3, "Failed to cleanup list");
|
zassert_equal(ARRAY_SIZE(arr), 3, "Failed to cleanup list");
|
||||||
zassert_equal(strcmp(arr[0], "Henry"), 0, "Failed at 0");
|
zassert_str_equal(arr[0], "Henry", "Failed at 0");
|
||||||
zassert_equal(strcmp(arr[1], "Dorsett"), 0, "Failed at 1");
|
zassert_str_equal(arr[1], "Dorsett", "Failed at 1");
|
||||||
zassert_equal(strcmp(arr[2], "Case"), 0, "Failed at 0");
|
zassert_str_equal(arr[2], "Case", "Failed at 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
ZTEST(util, test_nested_FOR_EACH) {
|
ZTEST(util, test_nested_FOR_EACH) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue