Bugfix/bacapp deprecation fixes (#578)

* Secured bacapp_decode_application_data_safe(), bacapp_decode_application_data_len(), bacapp_decode_context_data(), bacapp_decode_known_property() for timestamp, bacapp_decode_context_data_len(), and bacapp_data_len() functions.

* Fixed Command, Credential Data Input, and Schedule objects unit test
This commit is contained in:
Steve Karg
2024-02-27 14:03:14 -06:00
committed by GitHub
parent 33c7df249a
commit dfef5208d1
21 changed files with 698 additions and 548 deletions
+12 -60
View File
@@ -9,7 +9,7 @@
#include <zephyr/ztest.h>
#include <bacnet/basic/object/schedule.h>
#include <bacnet/bactext.h>
#include <property_test.h>
/**
* @addtogroup bacnet_tests
@@ -25,70 +25,22 @@ ZTEST(schedule_tests, testSchedule)
static void testSchedule(void)
#endif
{
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 count = 0;
bool status = false;
uint32_t object_instance = 0;
const int skip_fail_property_list[] = {
PROP_LIST_OF_OBJECT_PROPERTY_REFERENCES, -1 };
Schedule_Init();
count = Schedule_Count();
zassert_true(count > 0, NULL);
rpdata.application_data = &apdu[0];
rpdata.application_data_len = sizeof(apdu);
rpdata.object_type = OBJECT_SCHEDULE;
rpdata.object_instance = Schedule_Index_To_Instance(0);;
status = Schedule_Valid_Instance(rpdata.object_instance);
zassert_true(status, NULL);
Schedule_Property_Lists(&pRequired, &pOptional, &pProprietary);
while ((*pRequired) != -1) {
rpdata.object_property = *pRequired;
rpdata.array_index = BACNET_ARRAY_ALL;
len = Schedule_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);
if (len != test_len) {
printf("property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
}
if (rpdata.object_property == PROP_PRIORITY_ARRAY) {
/* FIXME: known fail to decode */
len = test_len;
}
zassert_true(test_len >= 0, NULL);
} else {
printf("property '%s': failed to read!\n",
bactext_property_name(rpdata.object_property));
}
pRequired++;
}
while ((*pOptional) != -1) {
rpdata.object_property = *pOptional;
rpdata.array_index = BACNET_ARRAY_ALL;
len = Schedule_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);
if (len != test_len) {
printf("property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
}
zassert_true(test_len >= 0, NULL);
} else {
printf("property '%s': failed to read!\n",
bactext_property_name(rpdata.object_property));
}
pOptional++;
}
object_instance = Schedule_Index_To_Instance(0);
bacnet_object_properties_read_write_test(
OBJECT_SCHEDULE,
object_instance,
Schedule_Property_Lists,
Schedule_Read_Property,
Schedule_Write_Property,
skip_fail_property_list);
}
/**
* @}