Issue 87 execute tests with GitHub ci (#234)

* Enable lcov coverage in unit testing via cmake.

* fix pipeline build error

* add compile options for unit test to silence some warnings

* remove all BAC_TEST unit tests in src/bacnet/ folder. They are now in test/bacnet/ folders using ztest.

* removed key.c - only used for unit test.

* produce XML test result output for parsing

* produce junit XML test result output

* change lint workflow to quality

* update readme badge for quality results

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
Steve Karg
2022-02-28 20:09:46 -06:00
committed by GitHub
parent 585cdb4a7d
commit c3a4c229fe
182 changed files with 231 additions and 16779 deletions
-82
View File
@@ -130,85 +130,3 @@ int rd_decode_service_request(uint8_t *apdu,
return (int)len;
}
#ifdef BAC_TEST
#include <assert.h>
#include <string.h>
#include "ctest.h"
int rd_decode_apdu(uint8_t *apdu,
unsigned apdu_len,
uint8_t *invoke_id,
BACNET_REINITIALIZED_STATE *state,
BACNET_CHARACTER_STRING *password)
{
int len = 0;
unsigned offset = 0;
if (!apdu)
return -1;
/* optional checking - most likely was already done prior to this call */
if (apdu[0] != PDU_TYPE_CONFIRMED_SERVICE_REQUEST)
return -1;
/* apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU); */
*invoke_id = apdu[2]; /* invoke id - filled in by net layer */
if (apdu[3] != SERVICE_CONFIRMED_REINITIALIZE_DEVICE)
return -1;
offset = 4;
if (apdu_len > offset) {
len = rd_decode_service_request(
&apdu[offset], apdu_len - offset, state, password);
}
return len;
}
void test_ReinitializeDevice(Test *pTest)
{
uint8_t apdu[480] = { 0 };
int len = 0;
int apdu_len = 0;
uint8_t invoke_id = 128;
uint8_t test_invoke_id = 0;
BACNET_REINITIALIZED_STATE state;
BACNET_REINITIALIZED_STATE test_state;
BACNET_CHARACTER_STRING password;
BACNET_CHARACTER_STRING test_password;
state = BACNET_REINIT_WARMSTART;
characterstring_init_ansi(&password, "John 3:16");
len = rd_encode_apdu(&apdu[0], invoke_id, state, &password);
ct_test(pTest, len != 0);
apdu_len = len;
len = rd_decode_apdu(
&apdu[0], apdu_len, &test_invoke_id, &test_state, &test_password);
ct_test(pTest, len != -1);
ct_test(pTest, test_invoke_id == invoke_id);
ct_test(pTest, test_state == state);
ct_test(pTest, characterstring_same(&test_password, &password));
return;
}
#ifdef TEST_REINITIALIZE_DEVICE
int main(void)
{
Test *pTest;
bool rc;
pTest = ct_create("BACnet ReinitializeDevice", NULL);
/* individual tests */
rc = ct_addTestFunction(pTest, test_ReinitializeDevice);
assert(rc);
ct_setStream(pTest, stdout);
ct_run(pTest);
(void)ct_report(pTest);
ct_destroy(pTest);
return 0;
}
#endif /* TEST_REINITIALIZE_DEVICE */
#endif /* BAC_TEST */