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
-75
View File
@@ -163,78 +163,3 @@ int iam_decode_service_request(uint8_t *apdu,
return apdu_len;
}
#ifdef BAC_TEST
#include <assert.h>
#include <string.h>
#include "ctest.h"
int iam_decode_apdu(uint8_t *apdu,
uint32_t *pDevice_id,
unsigned *pMax_apdu,
int *pSegmentation,
uint16_t *pVendor_id)
{
int apdu_len = 0; /* total length of the apdu, return value */
/* valid data? */
if (!apdu)
return -1;
/* optional checking - most likely was already done prior to this call */
if (apdu[0] != PDU_TYPE_UNCONFIRMED_SERVICE_REQUEST)
return -1;
if (apdu[1] != SERVICE_UNCONFIRMED_I_AM)
return -1;
apdu_len = iam_decode_service_request(
&apdu[2], pDevice_id, pMax_apdu, pSegmentation, pVendor_id);
return apdu_len;
}
void testIAm(Test *pTest)
{
uint8_t apdu[480] = { 0 };
int len = 0;
uint32_t device_id = 42;
unsigned max_apdu = 480;
int segmentation = SEGMENTATION_NONE;
uint16_t vendor_id = 42;
uint32_t test_device_id = 0;
unsigned test_max_apdu = 0;
int test_segmentation = 0;
uint16_t test_vendor_id = 0;
len =
iam_encode_apdu(&apdu[0], device_id, max_apdu, segmentation, vendor_id);
ct_test(pTest, len != 0);
len = iam_decode_apdu(&apdu[0], &test_device_id, &test_max_apdu,
&test_segmentation, &test_vendor_id);
ct_test(pTest, len != -1);
ct_test(pTest, test_device_id == device_id);
ct_test(pTest, test_vendor_id == vendor_id);
ct_test(pTest, test_max_apdu == max_apdu);
ct_test(pTest, test_segmentation == segmentation);
}
#ifdef TEST_IAM
int main(void)
{
Test *pTest;
bool rc;
pTest = ct_create("BACnet I-Am", NULL);
/* individual tests */
rc = ct_addTestFunction(pTest, testIAm);
assert(rc);
ct_setStream(pTest, stdout);
ct_run(pTest);
(void)ct_report(pTest);
ct_destroy(pTest);
return 0;
}
#endif /* TEST_IAM */
#endif /* BAC_TEST */