Issue 187 enable skipped ztest suites (#189)
* Fix some ztests that were skipped * Expose bacapp_same_value() * Fix bacapp, ptransfer tests * Fix bugs in Load_Control object & tests * refactor days functions from datetime module * fix legacy ctests * Add bacnet/basic/sys/days.[ch] to Zephyr build * Update ztest to match from Zephyr v2.6.0; update ringbuf, datetime to build * Fixup ztest test for object/acc * Fix bvlc_address_from_ascii; enable/fix bvlc test * Comment cleanup * test/bacnet/basic/object/lc partially enabled * Fix bacapp_decode_data_len return status on erroneous input * fix ztest include fatal error * fix ztest strsignal reference fatal error * fix zassert_mem_equal reference syntax error * fix zassert_mem_equal reference syntax error Co-authored-by: Gregory Shue <gregory.shue@legrand.us> Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
@@ -43,6 +43,7 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/bactext.c
|
||||
${SRC_DIR}/bacnet/basic/sys/bigend.c
|
||||
${SRC_DIR}/bacnet/datetime.c
|
||||
${SRC_DIR}/bacnet/basic/sys/days.c
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/* @file
|
||||
* @brief test BACnet integer encode/decode APIs
|
||||
* @brief test BACnet command object APIs
|
||||
*/
|
||||
|
||||
#include <ztest.h>
|
||||
@@ -19,66 +19,59 @@
|
||||
/**
|
||||
* @brief Test
|
||||
*/
|
||||
static void testCommand(void)
|
||||
static void test_object_command(void)
|
||||
{
|
||||
#if 0 /*TODO: Test does not pass */
|
||||
uint8_t apdu[MAX_APDU] = { 0 };
|
||||
int len = 0;
|
||||
uint32_t len_value = 0;
|
||||
uint8_t tag_number = 0;
|
||||
uint32_t decoded_instance = 0;
|
||||
BACNET_OBJECT_TYPE decoded_type = 0;
|
||||
int test_len = 0;
|
||||
BACNET_READ_PROPERTY_DATA rpdata;
|
||||
BACNET_ACTION_LIST clist, clist_test;
|
||||
/* 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;
|
||||
|
||||
object_instance = Command_Index_To_Instance(0);
|
||||
Command_Init();
|
||||
count = Command_Count();
|
||||
zassert_true(count > 0, NULL);
|
||||
rpdata.application_data = &apdu[0];
|
||||
rpdata.application_data_len = sizeof(apdu);
|
||||
rpdata.object_type = OBJECT_COMMAND;
|
||||
rpdata.object_instance = 1;
|
||||
rpdata.object_property = PROP_OBJECT_IDENTIFIER;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Command_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, 0, NULL);
|
||||
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
||||
zassert_equal(tag_number, BACNET_APPLICATION_TAG_OBJECT_ID, NULL);
|
||||
len = decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
||||
zassert_equal(decoded_type, rpdata.object_type, NULL);
|
||||
zassert_equal(decoded_instance, rpdata.object_instance, NULL);
|
||||
memset(&clist, 0, sizeof(BACNET_ACTION_LIST));
|
||||
memset(&clist_test, 0, sizeof(BACNET_ACTION_LIST));
|
||||
clist.Device_Id.type = OBJECT_DEVICE;
|
||||
clist.Device_Id.instance = 3389;
|
||||
clist.Object_Id.type = OBJECT_ANALOG_VALUE;
|
||||
clist.Object_Id.instance = 42;
|
||||
clist.Property_Identifier = PROP_PRESENT_VALUE;
|
||||
clist.Property_Array_Index = BACNET_ARRAY_ALL;
|
||||
clist.Value.tag = BACNET_APPLICATION_TAG_REAL;
|
||||
clist.Value.type.Real = 39.0f;
|
||||
clist.Priority = 4;
|
||||
clist.Post_Delay = 0xFFFFFFFFU;
|
||||
clist.Quit_On_Failure = true;
|
||||
clist.Write_Successful = false;
|
||||
clist.next = NULL;
|
||||
len = cl_encode_apdu(apdu, &clist);
|
||||
zassert_true(len > 0, NULL);
|
||||
len = cl_decode_apdu(apdu, len, BACNET_APPLICATION_TAG_REAL, &clist_test);
|
||||
zassert_true(len > 0, NULL);
|
||||
zassert_equal(clist.Device_Id.type, clist_test.Device_Id.type, NULL);
|
||||
zassert_equal(clist.Device_Id.instance, clist_test.Device_Id.instance, NULL);
|
||||
zassert_equal(clist.Object_Id.type, clist_test.Object_Id.type, NULL);
|
||||
zassert_equal(clist.Object_Id.instance, clist_test.Object_Id.instance, NULL);
|
||||
zassert_equal(clist.Property_Identifier, clist_test.Property_Identifier, NULL);
|
||||
zassert_equal(clist.Property_Array_Index, clist_test.Property_Array_Index, NULL);
|
||||
zassert_equal(clist.Value.tag, clist_test.Value.tag, NULL);
|
||||
zassert_equal(clist.Value.type.Real, clist_test.Value.type.Real, NULL);
|
||||
zassert_equal(clist.Priority, clist_test.Priority, NULL);
|
||||
zassert_equal(clist.Post_Delay, clist_test.Post_Delay, NULL);
|
||||
zassert_equal(clist.Quit_On_Failure, clist_test.Quit_On_Failure, NULL);
|
||||
zassert_equal(clist.Write_Successful, clist_test.Write_Successful, NULL);
|
||||
rpdata.object_instance = object_instance;
|
||||
Command_Property_Lists(&pRequired, &pOptional, &pProprietary);
|
||||
while ((*pRequired) != -1) {
|
||||
rpdata.object_property = *pRequired;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Command_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR, NULL);
|
||||
if (len > 0) {
|
||||
test_len = bacapp_decode_application_data(
|
||||
rpdata.application_data,
|
||||
(uint8_t)rpdata.application_data_len, &value);
|
||||
zassert_true(test_len >= 0, NULL);
|
||||
}
|
||||
pRequired++;
|
||||
}
|
||||
while ((*pOptional) != -1) {
|
||||
rpdata.object_property = *pOptional;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Command_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR, NULL);
|
||||
if (len > 0) {
|
||||
test_len = bacapp_decode_application_data(
|
||||
rpdata.application_data,
|
||||
(uint8_t)rpdata.application_data_len, &value);
|
||||
zassert_true(test_len >= 0, NULL);
|
||||
}
|
||||
pOptional++;
|
||||
}
|
||||
port++;
|
||||
|
||||
return;
|
||||
#else
|
||||
ztest_test_skip();
|
||||
#endif
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
@@ -87,9 +80,9 @@ static void testCommand(void)
|
||||
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(command_tests,
|
||||
ztest_unit_test(testCommand)
|
||||
ztest_test_suite(tests_object_command,
|
||||
ztest_unit_test(test_object_command)
|
||||
);
|
||||
|
||||
ztest_run_test_suite(command_tests);
|
||||
ztest_run_test_suite(tests_object_command);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user