mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-28 01:27:09 +03:00
testdriver.c: unit tests failures do not error on exit
Unfortunately tests/testdriver always exited with 0, even if there was a test suite error. This meant that CI tests were not picking up any issues. tests/testdriver now exits with a value of 1 if there is a test suite issue. Errors corrected in/for the test suite.
This commit is contained in:
1 parent
c816bf7fcf
commit
9d228feff0
3 files changed
+26
-18
No files matched your search
@@ -3092,7 +3092,19 @@ coap_new_error_response(const coap_pdu_t *request, coap_pdu_code_t code,
|
||||
first = 0;
|
||||
}
|
||||
coap_add_data(response, (size_t)strlen(buf), (const uint8_t *)buf);
|
||||
} else if (opts && opts->mask) {
|
||||
coap_opt_t *option;
|
||||
|
||||
/* copy all options */
|
||||
coap_option_iterator_init(request, &opt_iter, opts);
|
||||
while ((option = coap_option_next(&opt_iter))) {
|
||||
coap_add_option_internal(response, opt_iter.number,
|
||||
coap_opt_length(option),
|
||||
coap_opt_value(option));
|
||||
}
|
||||
#if COAP_ERROR_PHRASE_LENGTH > 0
|
||||
if (phrase)
|
||||
coap_add_data(response, (size_t)strlen(phrase), (const uint8_t *)phrase);
|
||||
} else {
|
||||
/* note that diagnostic messages do not need a Content-Format option. */
|
||||
if (phrase)
|
||||
|
||||
+10
-17
@@ -91,8 +91,8 @@ t_error_response3(void) {
|
||||
const uint8_t code = COAP_RESPONSE_CODE(402);
|
||||
uint8_t teststr[] = {
|
||||
0x65, code, 0x00, 0x00, 't', 'o', 'k', 'e',
|
||||
'n', 0xd0, 0x0c, 0xff, 'B', 'a', 'd', ' ', 'O',
|
||||
'p', 't', 'i', 'o', 'n'
|
||||
'n', 0xff, 'B', 'a', 'd', ' ', 'O',
|
||||
'p', 't', 'i', 'o', 'n', ' ', '2', '5'
|
||||
};
|
||||
coap_pdu_t *response;
|
||||
|
||||
@@ -128,10 +128,9 @@ t_error_response4(void) {
|
||||
};
|
||||
uint8_t teststr[] = {
|
||||
0x65, code, 0x00, 0x00, 't', 'o', 'k', 'e',
|
||||
'n', 0xdc, 0x0c, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
|
||||
0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0xff, 'B',
|
||||
'n', 0xff, 'B',
|
||||
'a', 'd', ' ', 'O', 'p', 't', 'i', 'o',
|
||||
'n'
|
||||
'n', ' ', '2', '5'
|
||||
};
|
||||
coap_pdu_t *response;
|
||||
|
||||
@@ -168,11 +167,9 @@ t_error_response5(void) {
|
||||
};
|
||||
uint8_t teststr[] = {
|
||||
0x65, code, 0x00, 0x00, 't', 'o', 'k', 'e',
|
||||
'n', 0xdd, 0x0c, 0x06, 0x00, 0x01, 0x02, 0x03, 0x04,
|
||||
0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,
|
||||
0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0xff, 'B',
|
||||
'n', 0xff, 'B',
|
||||
'a', 'd', ' ', 'O', 'p', 't', 'i', 'o',
|
||||
'n'
|
||||
'n', ' ', '2', '5'
|
||||
};
|
||||
coap_pdu_t *response;
|
||||
|
||||
@@ -209,11 +206,9 @@ t_error_response6(void) {
|
||||
};
|
||||
uint8_t teststr[] = {
|
||||
0x65, code, 0x00, 0x00, 't', 'o', 'k', 'e',
|
||||
'n', 0xdd, 0x0a, 0x06, 0x00, 0x01, 0x02, 0x03,
|
||||
0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
|
||||
0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0xff,
|
||||
'n', 0xff,
|
||||
'B', 'a', 'd', ' ', 'O', 'p', 't', 'i',
|
||||
'o', 'n'
|
||||
'o', 'n', ' ', '2', '3'
|
||||
};
|
||||
coap_pdu_t *response;
|
||||
|
||||
@@ -250,11 +245,9 @@ t_error_response7(void) {
|
||||
};
|
||||
uint8_t teststr[] = {
|
||||
0x65, code, 0x00, 0x00, 't', 'o', 'k', 'e',
|
||||
'n', 0xdd, 0x0a, 0x06, 0x00, 0x01, 0x02, 0x03,
|
||||
0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
|
||||
0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0xff,
|
||||
'n', 0xff,
|
||||
'B', 'a', 'd', ' ', 'O', 'p', 't', 'i',
|
||||
'o', 'n'
|
||||
'o', 'n', ' ', '2', '3'
|
||||
};
|
||||
coap_pdu_t *response;
|
||||
|
||||
|
||||
+4
-1
@@ -31,6 +31,7 @@ int
|
||||
main(int argc COAP_UNUSED, char **argv COAP_UNUSED) {
|
||||
CU_ErrorCode result;
|
||||
CU_BasicRunMode run_mode = CU_BRM_VERBOSE;
|
||||
unsigned int failed;
|
||||
|
||||
if (CU_initialize_registry() != CUE_SUCCESS) {
|
||||
fprintf(stderr, "E: test framework initialization failed\n");
|
||||
@@ -57,9 +58,11 @@ main(int argc COAP_UNUSED, char **argv COAP_UNUSED) {
|
||||
|
||||
CU_basic_set_mode(run_mode);
|
||||
result = CU_basic_run_tests();
|
||||
|
||||
failed = CU_get_number_of_failures();
|
||||
CU_cleanup_registry();
|
||||
coap_cleanup();
|
||||
|
||||
if (failed)
|
||||
exit(1);
|
||||
return result;
|
||||
}
|
||||
Reference in new issue
Block a user