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:
Greg Shue
2021-08-16 15:29:40 -07:00
committed by GitHub
parent 541f4024fb
commit 8b8ef8f338
102 changed files with 3178 additions and 1208 deletions
+37 -1
View File
@@ -40,6 +40,16 @@
#include "bacnet/wp.h"
#include "bacnet/basic/services.h"
#ifndef LOAD_CONTROL_DEBUG
#define LOAD_CONTROL_DEBUG 0
#endif
#if LOAD_CONTROL_DEBUG
#include <sys/PRINTF.h>
#define PRINTF(...) printk(__VA_ARGS__)
#else
#define PRINTF(...)
#endif
/* number of demo objects */
#ifndef MAX_LOAD_CONTROLS
#define MAX_LOAD_CONTROLS 4
@@ -212,7 +222,10 @@ unsigned Load_Control_Count(void)
/* that correlates to the correct index */
uint32_t Load_Control_Index_To_Instance(unsigned index)
{
return index;
if (index < MAX_LOAD_CONTROLS) {
return index;
}
return MAX_LOAD_CONTROLS;
}
/* we simply have 0-n object instances. Yours might be */
@@ -857,11 +870,25 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
BACNET_DATE
TempDate; /* build here in case of error in time half of datetime */
PRINTF("Load_Control_Write_Property(wp_data=%p)\n", wp_data);
if (wp_data == NULL) {
PRINTF("Load_Control_Write_Property() failure detected point A\n");
return false;
}
if (wp_data->application_data_len < 0) {
PRINTF("Load_Control_Write_Property() failure detected point A.2\n");
/* error while decoding - a smaller larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
/* decode the some of the request */
len = bacapp_decode_application_data(
wp_data->application_data, wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */
if (len < 0) {
PRINTF("Load_Control_Write_Property() failure detected point B\n");
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
@@ -870,6 +897,7 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
/* only array properties can have array options */
if ((wp_data->object_property != PROP_SHED_LEVELS) &&
(wp_data->array_index != BACNET_ARRAY_ALL)) {
PRINTF("Load_Control_Write_Property() failure detected point C\n");
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
return false;
@@ -881,6 +909,7 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
wp_data->application_data_len, &value,
PROP_REQUESTED_SHED_LEVEL);
if (len == BACNET_STATUS_ERROR) {
PRINTF("Load_Control_Write_Property() failure detected point D\n");
/* error! */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE;
@@ -906,6 +935,7 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
value.type.Real;
status = true;
} else {
PRINTF("Load_Control_Write_Property() failure detected point E\n");
/* error! */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE;
@@ -919,6 +949,7 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_DATE);
if (!status) {
PRINTF("Load_Control_Write_Property() failure detected point F\n");
/* don't continue if we don't have a valid date */
break;
}
@@ -937,6 +968,7 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
Start_Time_Property_Written[object_index] = true;
}
} else {
PRINTF("Load_Control_Write_Property() failure detected point G\n");
status = false;
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
@@ -949,6 +981,8 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
if (status) {
Shed_Duration[object_index] = value.type.Unsigned_Int;
Load_Control_Request_Written[object_index] = true;
} else {
PRINTF("Load_Control_Write_Property() failure detected point H\n");
}
break;
@@ -993,11 +1027,13 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
break;
default:
PRINTF("Load_Control_Write_Property() failure detected point Z\n");
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
break;
}
PRINTF("Load_Control_Write_Property() returning status=%d\n", status);
return status;
}