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
-92
View File
@@ -2427,95 +2427,3 @@ void Network_Port_Init(void)
{
/* do something interesting */
}
#ifdef BACNET_UNIT_TEST
#include <assert.h>
#include <string.h>
#include "ctest.h"
void test_network_port(Test *pTest)
{
uint8_t apdu[MAX_APDU] = { 0 };
int len = 0;
int test_len = 0;
BACNET_READ_PROPERTY_DATA rpdata;
/* for decode value data */
BACNET_APPLICATION_DATA_VALUE value;
const int *pRequired = NULL;
const int *pOptional = NULL;
const int *pProprietary = NULL;
unsigned port = 0;
unsigned count = 0;
uint32_t object_instance = 0;
bool status = false;
uint8_t port_type[] = { PORT_TYPE_ETHERNET, PORT_TYPE_ARCNET,
PORT_TYPE_MSTP, PORT_TYPE_PTP, PORT_TYPE_LONTALK, PORT_TYPE_BIP,
PORT_TYPE_ZIGBEE, PORT_TYPE_VIRTUAL, PORT_TYPE_NON_BACNET,
PORT_TYPE_BIP6, PORT_TYPE_MAX };
while (port_type[port] != PORT_TYPE_MAX) {
object_instance = 1234;
status = Network_Port_Object_Instance_Number_Set(0, object_instance);
ct_test(pTest, status);
status = Network_Port_Type_Set(object_instance, port_type[port]);
ct_test(pTest, status);
Network_Port_Init();
count = Network_Port_Count();
ct_test(pTest, count > 0);
rpdata.application_data = &apdu[0];
rpdata.application_data_len = sizeof(apdu);
rpdata.object_type = OBJECT_NETWORK_PORT;
rpdata.object_instance = object_instance;
Network_Port_Property_Lists(&pRequired, &pOptional, &pProprietary);
while ((*pRequired) != -1) {
rpdata.object_property = *pRequired;
rpdata.array_index = BACNET_ARRAY_ALL;
len = Network_Port_Read_Property(&rpdata);
ct_test(pTest, len != 0);
test_len = bacapp_decode_application_data(rpdata.application_data,
(uint8_t)rpdata.application_data_len, &value);
ct_test(pTest, test_len >= 0);
if (test_len < 0) {
printf("<decode failed!>\n");
}
pRequired++;
}
while ((*pOptional) != -1) {
rpdata.object_property = *pOptional;
rpdata.array_index = BACNET_ARRAY_ALL;
len = Network_Port_Read_Property(&rpdata);
ct_test(pTest, len != 0);
test_len = bacapp_decode_application_data(rpdata.application_data,
(uint8_t)rpdata.application_data_len, &value);
ct_test(pTest, test_len >= 0);
if (test_len < 0) {
printf("<decode failed!>\n");
}
pOptional++;
}
port++;
}
return;
}
#ifdef TEST_NETWORK_PORT
int main(void)
{
Test *pTest;
bool rc;
pTest = ct_create("BACnet Network Port", NULL);
/* individual tests */
rc = ct_addTestFunction(pTest, test_network_port);
assert(rc);
ct_setStream(pTest, stdout);
ct_run(pTest);
(void)ct_report(pTest);
ct_destroy(pTest);
return 0;
}
#endif
#endif /* BAC_TEST */