Change in libosmocore[master]: gsm0408_test: do not return early in test_bearer_cap()
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/28505 ) Change subject: gsm0408_test: do not return early in test_bearer_cap() ...................................................................... gsm0408_test: do not return early in test_bearer_cap() Currently, if one of the testcases fails, test_bearer_cap() would abort and skip the remaining testcases. Also, a msgb would not be free()ed making the LeakSanitizer unhappy. Instead of returning early, jump to the end of loop to ensure that: * the verdict ('passed' or 'failed') is always printed, * all remaining testcases are still executed, * the msgb is free()ed. Change-Id: I39ac801e59ba56dfe3bcd4603b48f6fbf7cfb21c --- M tests/gsm0408/gsm0408_test.c 1 file changed, 10 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/05/28505/1 diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c index 2aceefa..16bc8e8 100644 --- a/tests/gsm0408/gsm0408_test.c +++ b/tests/gsm0408/gsm0408_test.c @@ -84,6 +84,7 @@ for (i = 0; i < ARRAY_SIZE(bcap_tests); i++) { struct msgb *msg = msgb_alloc(100, "test"); + bool pass = false; int lv_len; memset(&bc, 0, sizeof(bc)); @@ -93,7 +94,7 @@ if (rc < 0) { fprintf(stderr, "Error decoding %s\n", bcap_tests[i].name); - return rc; + goto verdict; } if (memcmp(&bc, bcap_tests[i].bc, sizeof(bc))) { fprintf(stderr, "Incorrect decoded result of %s:\n", @@ -102,7 +103,7 @@ osmo_hexdump((uint8_t *) bcap_tests[i].bc, sizeof(bc))); fprintf(stderr, " is: %s\n", osmo_hexdump((uint8_t *) &bc, sizeof(bc))); - return -1; + goto verdict; } /* also test re-encode? */ @@ -110,7 +111,7 @@ if (rc < 0) { fprintf(stderr, "Error encoding %s\n", bcap_tests[i].name); - return rc; + goto verdict; } lv_len = bcap_tests[i].lv[0]+1; if (memcmp(msg->data, bcap_tests[i].lv, lv_len)) { @@ -120,10 +121,14 @@ osmo_hexdump(bcap_tests[i].lv, lv_len)); fprintf(stderr, " is: %s\n", osmo_hexdump(msg->data, msg->len)); - return -1; + goto verdict; } - printf("Test `%s' passed\n", bcap_tests[i].name); + /* all checks passed */ + pass = true; + +verdict: + printf("Test `%s' %sed\n", bcap_tests[i].name, pass ? "pass" : "fail"); msgb_free(msg); } -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/28505 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I39ac801e59ba56dfe3bcd4603b48f6fbf7cfb21c Gerrit-Change-Number: 28505 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de> Gerrit-MessageType: newchange
participants (1)
-
fixeria