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
-68
View File
@@ -161,71 +161,3 @@ int ihave_decode_apdu(
return len;
}
#endif
#ifdef BAC_TEST
#include <assert.h>
#include <string.h>
#include "ctest.h"
void testIHaveData(Test *pTest, BACNET_I_HAVE_DATA *data)
{
uint8_t apdu[480] = { 0 };
int len = 0;
int apdu_len = 0;
BACNET_I_HAVE_DATA test_data;
len = ihave_encode_apdu(&apdu[0], data);
ct_test(pTest, len != 0);
apdu_len = len;
len = ihave_decode_apdu(&apdu[0], apdu_len, &test_data);
ct_test(pTest, len != -1);
ct_test(pTest, test_data.device_id.type == data->device_id.type);
ct_test(pTest, test_data.device_id.instance == data->device_id.instance);
ct_test(pTest, test_data.object_id.type == data->object_id.type);
ct_test(pTest, test_data.object_id.instance == data->object_id.instance);
ct_test(pTest,
characterstring_same(&test_data.object_name, &data->object_name));
}
void testIHave(Test *pTest)
{
BACNET_I_HAVE_DATA data;
characterstring_init_ansi(&data.object_name, "Patricia - my love!");
data.device_id.type = OBJECT_DEVICE;
for (data.device_id.instance = 1;
data.device_id.instance <= BACNET_MAX_INSTANCE;
data.device_id.instance <<= 1) {
for (data.object_id.type = OBJECT_ANALOG_INPUT;
data.object_id.type < MAX_BACNET_OBJECT_TYPE;
data.object_id.type++) {
for (data.object_id.instance = 1;
data.object_id.instance <= BACNET_MAX_INSTANCE;
data.object_id.instance <<= 1) {
testIHaveData(pTest, &data);
}
}
}
}
#ifdef TEST_I_HAVE
int main(void)
{
Test *pTest;
bool rc;
pTest = ct_create("BACnet I-Have", NULL);
/* individual tests */
rc = ct_addTestFunction(pTest, testIHave);
assert(rc);
ct_setStream(pTest, stdout);
ct_run(pTest);
(void)ct_report(pTest);
ct_destroy(pTest);
return 0;
}
#endif /* TEST_WHOIS */
#endif /* BAC_TEST */