Fixed load control object and unit test. Added recipe to Makefile for Zephyr OS twister unit testing. (#710)

This commit is contained in:
Steve Karg
2024-08-06 08:28:01 -05:00
committed by GitHub
parent ebfaa5eb2c
commit 61730e3d87
63 changed files with 1191 additions and 684 deletions
+175 -324
View File
@@ -13,6 +13,7 @@
#include <bacnet/bacstr.h>
#include <bacnet/basic/object/ao.h>
#include <bacnet/basic/object/lc.h>
#include <property_test.h>
/* TODO: Refactor basic/object/lc.c to avoid duplication of the following:
*/
@@ -55,7 +56,7 @@ static void
Load_Control_WriteProperty_Request_Shed_Level(int instance, unsigned level)
{
bool status = false;
BACNET_APPLICATION_DATA_VALUE value;
BACNET_APPLICATION_DATA_VALUE value = { 0 };
BACNET_WRITE_PROPERTY_DATA wp_data;
wp_data.object_type = OBJECT_LOAD_CONTROL;
@@ -63,12 +64,11 @@ Load_Control_WriteProperty_Request_Shed_Level(int instance, unsigned level)
wp_data.array_index = BACNET_ARRAY_ALL;
wp_data.priority = BACNET_NO_PRIORITY;
wp_data.object_property = PROP_REQUESTED_SHED_LEVEL;
value.context_specific = true;
value.context_tag = 1;
value.tag = BACNET_APPLICATION_TAG_UNSIGNED_INT;
value.type.Unsigned_Int = level;
wp_data.application_data_len =
bacapp_encode_data(&wp_data.application_data[0], &value);
value.type.Shed_Level.type = BACNET_SHED_TYPE_LEVEL;
value.type.Shed_Level.value.level = level;
wp_data.application_data_len = bacapp_encode_known_property(
&wp_data.application_data[0], &value, wp_data.object_type,
wp_data.object_property);
zassert_true(wp_data.application_data_len > 0, NULL);
status = Load_Control_Write_Property(&wp_data);
zassert_true(status, NULL);
@@ -91,7 +91,7 @@ static void Load_Control_WriteProperty_Enable(int instance, bool enable)
value.tag = BACNET_APPLICATION_TAG_BOOLEAN;
value.type.Boolean = enable;
wp_data.application_data_len =
bacapp_encode_data(&wp_data.application_data[0], &value);
bacapp_encode_application_data(&wp_data.application_data[0], &value);
zassert_true(wp_data.application_data_len > 0, NULL);
status = Load_Control_Write_Property(&wp_data);
zassert_true(status, NULL);
@@ -114,7 +114,7 @@ Load_Control_WriteProperty_Shed_Duration(int instance, unsigned duration)
value.tag = BACNET_APPLICATION_TAG_UNSIGNED_INT;
value.type.Unsigned_Int = duration;
wp_data.application_data_len =
bacapp_encode_data(&wp_data.application_data[0], &value);
bacapp_encode_application_data(&wp_data.application_data[0], &value);
zassert_true(wp_data.application_data_len > 0, NULL);
status = Load_Control_Write_Property(&wp_data);
zassert_true(status, NULL);
@@ -137,7 +137,7 @@ Load_Control_WriteProperty_Duty_Window(int instance, unsigned duration)
value.tag = BACNET_APPLICATION_TAG_UNSIGNED_INT;
value.type.Unsigned_Int = duration;
wp_data.application_data_len =
bacapp_encode_data(&wp_data.application_data[0], &value);
bacapp_encode_application_data(&wp_data.application_data[0], &value);
zassert_true(wp_data.application_data_len > 0, NULL);
status = Load_Control_Write_Property(&wp_data);
zassert_true(status, NULL);
@@ -155,18 +155,12 @@ static void Load_Control_WriteProperty_Start_Time_Wildcards(int instance)
wp_data.array_index = BACNET_ARRAY_ALL;
wp_data.priority = BACNET_NO_PRIORITY;
wp_data.object_property = PROP_START_TIME;
value.context_specific = false;
value.context_tag = 0;
value.tag = BACNET_APPLICATION_TAG_DATE;
datetime_date_wildcard_set(&value.type.Date);
wp_data.application_data_len =
bacapp_encode_data(&wp_data.application_data[0], &value);
zassert_true(wp_data.application_data_len > 0, NULL);
len = wp_data.application_data_len;
value.tag = BACNET_APPLICATION_TAG_TIME;
datetime_time_wildcard_set(&value.type.Time);
wp_data.application_data_len =
bacapp_encode_data(&wp_data.application_data[len], &value);
value.tag = BACNET_APPLICATION_TAG_DATETIME;
datetime_date_wildcard_set(&value.type.Date_Time.date);
datetime_time_wildcard_set(&value.type.Date_Time.time);
wp_data.application_data_len = bacapp_encode_known_property(
&wp_data.application_data[0], &value, wp_data.object_type,
wp_data.object_property);
zassert_true(wp_data.application_data_len > 0, NULL);
wp_data.application_data_len += len;
status = Load_Control_Write_Property(&wp_data);
@@ -193,18 +187,13 @@ static void Load_Control_WriteProperty_Start_Time(
wp_data.array_index = BACNET_ARRAY_ALL;
wp_data.priority = BACNET_NO_PRIORITY;
wp_data.object_property = PROP_START_TIME;
value.context_specific = false;
value.context_tag = 0;
value.tag = BACNET_APPLICATION_TAG_DATE;
datetime_set_date(&value.type.Date, year, month, day);
wp_data.application_data_len =
bacapp_encode_data(&wp_data.application_data[0], &value);
zassert_true(wp_data.application_data_len > 0, NULL);
len = wp_data.application_data_len;
value.tag = BACNET_APPLICATION_TAG_TIME;
datetime_set_time(&value.type.Time, hour, minute, seconds, hundredths);
wp_data.application_data_len =
bacapp_encode_data(&wp_data.application_data[len], &value);
value.tag = BACNET_APPLICATION_TAG_DATETIME;
datetime_set_date(&value.type.Date_Time.date, year, month, day);
datetime_set_time(
&value.type.Date_Time.time, hour, minute, seconds, hundredths);
wp_data.application_data_len = bacapp_encode_known_property(
&wp_data.application_data[0], &value, wp_data.object_type,
wp_data.object_property);
zassert_true(wp_data.application_data_len > 0, NULL);
wp_data.application_data_len += len;
status = Load_Control_Write_Property(&wp_data);
@@ -217,42 +206,45 @@ ZTEST(lc_tests, testLoadControlStateMachine)
static void testLoadControlStateMachine(void)
#endif
{
// TODO: unsigned i = 0, j = 0;
uint8_t level = 0;
unsigned i = 0, j = 0;
float level = 0;
unsigned count = 0;
BACNET_DATE_TIME bdatetime = { 0 };
uint32_t object_instance = 0;
BACNET_OBJECT_PROPERTY_REFERENCE object_property_reference;
bool status;
Analog_Output_Init();
Load_Control_Init();
// TODO: /* validate the triggers for each state change */
// TODO: for (j = 0; j < 20; j++) {
// TODO: Load_Control_State_Machine(0);
// TODO: for (i = 0; i < MAX_LOAD_CONTROLS; i++) {
// TODO: zassert_equal(Load_Control_State[i], SHED_INACTIVE,
// NULL);
// TODO: }
// TODO: }
object_instance = Load_Control_Index_To_Instance(0);
/* validate the triggers for each state change */
for (j = 0; j < 20; j++) {
Load_Control_State_Machine(0, &bdatetime);
count = Load_Control_Count();
for (i = 0; i < count; i++) {
zassert_equal(Load_Control_State(i), SHED_INACTIVE, NULL);
}
}
/* SHED_REQUEST_PENDING */
/* CancelShed - Start time has wildcards */
Load_Control_WriteProperty_Enable(0, true);
Load_Control_WriteProperty_Shed_Duration(0, 60);
Load_Control_WriteProperty_Start_Time_Wildcards(0);
Load_Control_State_Machine(0);
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
// NULL);
Load_Control_State_Machine(0);
// TODO: zassert_equal(Load_Control_State[0], SHED_INACTIVE, NULL);
Load_Control_State_Machine(0, &bdatetime);
zassert_equal(Load_Control_State(0), SHED_REQUEST_PENDING, NULL);
Load_Control_State_Machine(0, &bdatetime);
zassert_equal(Load_Control_State(0), SHED_INACTIVE, NULL);
/* CancelShed - Requested_Shed_Level equal to default value */
Load_Control_Init();
Load_Control_WriteProperty_Request_Shed_Level(0, 0);
Load_Control_WriteProperty_Start_Time(0, 2007, 2, 27, 15, 0, 0, 0);
Load_Control_WriteProperty_Shed_Duration(0, 5);
// TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 15, 0, 0, 0);
Load_Control_State_Machine(0);
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
// NULL);
Load_Control_State_Machine(0);
// TODO: zassert_equal(Load_Control_State[0], SHED_INACTIVE, NULL);
datetime_set_values(&bdatetime, 2007, 2, 27, 15, 0, 0, 0);
Load_Control_State_Machine(0, &bdatetime);
zassert_equal(Load_Control_State(0), SHED_REQUEST_PENDING, NULL);
Load_Control_State_Machine(0, &bdatetime);
zassert_equal(Load_Control_State(0), SHED_INACTIVE, NULL);
/* CancelShed - Non-default values, but Start time is passed */
Load_Control_Init();
@@ -260,12 +252,11 @@ static void testLoadControlStateMachine(void)
Load_Control_WriteProperty_Request_Shed_Level(0, 1);
Load_Control_WriteProperty_Shed_Duration(0, 5);
Load_Control_WriteProperty_Start_Time(0, 2007, 2, 27, 15, 0, 0, 0);
// TODO: datetime_set_values(&Current_Time, 2007, 2, 28, 15, 0, 0, 0);
Load_Control_State_Machine(0);
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
// NULL);
Load_Control_State_Machine(0);
// TODO: zassert_equal(Load_Control_State[0], SHED_INACTIVE, NULL);
datetime_set_values(&bdatetime, 2007, 2, 28, 15, 0, 0, 0);
Load_Control_State_Machine(0, &bdatetime);
zassert_equal(Load_Control_State(0), SHED_REQUEST_PENDING, NULL);
Load_Control_State_Machine(0, &bdatetime);
zassert_equal(Load_Control_State(0), SHED_INACTIVE, NULL);
/* ReconfigurePending - new write received while pending */
Load_Control_Init();
@@ -273,35 +264,27 @@ static void testLoadControlStateMachine(void)
Load_Control_WriteProperty_Request_Shed_Level(0, 1);
Load_Control_WriteProperty_Shed_Duration(0, 5);
Load_Control_WriteProperty_Start_Time(0, 2007, 2, 27, 15, 0, 0, 0);
// TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 5, 0, 0, 0);
Load_Control_State_Machine(0);
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
// NULL);
Load_Control_State_Machine(0);
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
// NULL);
datetime_set_values(&bdatetime, 2007, 2, 27, 5, 0, 0, 0);
Load_Control_State_Machine(0, &bdatetime);
zassert_equal(Load_Control_State(0), SHED_REQUEST_PENDING, NULL);
Load_Control_State_Machine(0, &bdatetime);
zassert_equal(Load_Control_State(0), SHED_REQUEST_PENDING, NULL);
Load_Control_WriteProperty_Request_Shed_Level(0, 2);
Load_Control_State_Machine(0);
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
// NULL);
Load_Control_State_Machine(0, &bdatetime);
zassert_equal(Load_Control_State(0), SHED_REQUEST_PENDING, NULL);
Load_Control_WriteProperty_Shed_Duration(0, 6);
Load_Control_State_Machine(0);
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
// NULL);
Load_Control_State_Machine(0, &bdatetime);
zassert_equal(Load_Control_State(0), SHED_REQUEST_PENDING, NULL);
Load_Control_WriteProperty_Duty_Window(0, 60);
Load_Control_State_Machine(0);
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
// NULL);
Load_Control_State_Machine(0, &bdatetime);
zassert_equal(Load_Control_State(0), SHED_REQUEST_PENDING, NULL);
Load_Control_WriteProperty_Start_Time(0, 2007, 2, 27, 15, 0, 0, 1);
Load_Control_State_Machine(0);
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
// NULL);
Load_Control_State_Machine(0);
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
// NULL);
Load_Control_State_Machine(0);
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
// NULL);
Load_Control_State_Machine(0, &bdatetime);
zassert_equal(Load_Control_State(0), SHED_REQUEST_PENDING, NULL);
Load_Control_State_Machine(0, &bdatetime);
zassert_equal(Load_Control_State(0), SHED_REQUEST_PENDING, NULL);
Load_Control_State_Machine(0, &bdatetime);
zassert_equal(Load_Control_State(0), SHED_REQUEST_PENDING, NULL);
/* CannotMeetShed -> FinishedUnsuccessfulShed */
Load_Control_Init();
@@ -309,24 +292,35 @@ static void testLoadControlStateMachine(void)
Load_Control_WriteProperty_Request_Shed_Level(0, 1);
Load_Control_WriteProperty_Shed_Duration(0, 120);
Load_Control_WriteProperty_Start_Time(0, 2007, 2, 27, 15, 0, 0, 0);
// TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 5, 0, 0, 0);
Load_Control_State_Machine(0);
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
// NULL);
Load_Control_State_Machine(0);
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
// NULL);
datetime_set_values(&bdatetime, 2007, 2, 27, 5, 0, 0, 0);
Load_Control_State_Machine(0, &bdatetime);
zassert_equal(Load_Control_State(0), SHED_REQUEST_PENDING, NULL);
Load_Control_State_Machine(0, &bdatetime);
zassert_equal(Load_Control_State(0), SHED_REQUEST_PENDING, NULL);
/* set to lowest value so we cannot meet the shed level */
// TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 16, 0, 0, 0);
Analog_Output_Present_Value_Set(0, 0, 16);
Load_Control_State_Machine(0);
// TODO: zassert_equal(Load_Control_State[0], SHED_NON_COMPLIANT, NULL);
Load_Control_State_Machine(0);
// TODO: zassert_equal(Load_Control_State[0], SHED_NON_COMPLIANT, NULL);
datetime_set_values(&bdatetime, 2007, 2, 27, 16, 0, 0, 0);
Load_Control_Manipulated_Variable_Reference(
object_instance, &object_property_reference);
if ((object_property_reference.object_identifier.type ==
OBJECT_ANALOG_OUTPUT) &&
(object_property_reference.property_identifier == PROP_PRESENT_VALUE)) {
status = Analog_Output_Present_Value_Set(
object_property_reference.object_identifier.instance, 0.0f,
BACNET_MAX_PRIORITY);
zassert_true(status, NULL);
} else {
zassert_true(false, NULL);
}
Load_Control_State_Machine(0, &bdatetime);
zassert_equal(Load_Control_State(0), SHED_NON_COMPLIANT, NULL);
Load_Control_State_Machine(0, &bdatetime);
zassert_equal(Load_Control_State(0), SHED_NON_COMPLIANT, NULL);
/* FinishedUnsuccessfulShed */
// TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 23, 0, 0, 0);
Load_Control_State_Machine(0);
// TODO: zassert_equal(Load_Control_State[0], SHED_INACTIVE, NULL);
datetime_set_values(&bdatetime, 2007, 2, 27, 23, 0, 0, 0);
Load_Control_State_Machine(0, &bdatetime);
zassert_equal(Load_Control_State(0), SHED_INACTIVE, NULL);
/* CannotMeetShed -> UnsuccessfulShedReconfigured */
Load_Control_Init();
@@ -334,45 +328,78 @@ static void testLoadControlStateMachine(void)
Load_Control_WriteProperty_Request_Shed_Level(0, 1);
Load_Control_WriteProperty_Shed_Duration(0, 120);
Load_Control_WriteProperty_Start_Time(0, 2007, 2, 27, 15, 0, 0, 0);
// TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 5, 0, 0, 0);
Load_Control_State_Machine(0);
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
// NULL);
Load_Control_State_Machine(0);
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
// NULL);
datetime_set_values(&bdatetime, 2007, 2, 27, 5, 0, 0, 0);
Load_Control_State_Machine(0, &bdatetime);
zassert_equal(Load_Control_State(0), SHED_REQUEST_PENDING, NULL);
Load_Control_State_Machine(0, &bdatetime);
zassert_equal(Load_Control_State(0), SHED_REQUEST_PENDING, NULL);
/* set to lowest value so we cannot meet the shed level */
// TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 16, 0, 0, 0);
Analog_Output_Present_Value_Set(0, 0, 16);
Load_Control_State_Machine(0);
// TODO: zassert_equal(Load_Control_State[0], SHED_NON_COMPLIANT, NULL);
Load_Control_State_Machine(0);
// TODO: zassert_equal(Load_Control_State[0], SHED_NON_COMPLIANT, NULL);
datetime_set_values(&bdatetime, 2007, 2, 27, 16, 0, 0, 0);
Load_Control_Manipulated_Variable_Reference(
object_instance, &object_property_reference);
if ((object_property_reference.object_identifier.type ==
OBJECT_ANALOG_OUTPUT) &&
(object_property_reference.property_identifier == PROP_PRESENT_VALUE)) {
status = Analog_Output_Present_Value_Set(
object_property_reference.object_identifier.instance, 0.0f,
BACNET_MAX_PRIORITY);
zassert_true(status, NULL);
} else {
zassert_true(false, NULL);
}
Load_Control_State_Machine(0, &bdatetime);
zassert_equal(Load_Control_State(0), SHED_NON_COMPLIANT, NULL);
Load_Control_State_Machine(0, &bdatetime);
zassert_equal(Load_Control_State(0), SHED_NON_COMPLIANT, NULL);
/* FinishedUnsuccessfulShed */
Load_Control_WriteProperty_Start_Time(0, 2007, 2, 27, 16, 0, 0, 0);
Load_Control_State_Machine(0);
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
// NULL);
Load_Control_State_Machine(0);
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
// NULL);
// TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 16, 0, 1, 0);
Load_Control_State_Machine(0);
// TODO: zassert_equal(Load_Control_State[0], SHED_NON_COMPLIANT, NULL);
Load_Control_State_Machine(0, &bdatetime);
zassert_equal(Load_Control_State(0), SHED_REQUEST_PENDING, NULL);
Load_Control_State_Machine(0, &bdatetime);
zassert_equal(Load_Control_State(0), SHED_REQUEST_PENDING, NULL);
datetime_set_values(&bdatetime, 2007, 2, 27, 16, 0, 1, 0);
Load_Control_State_Machine(0, &bdatetime);
zassert_equal(Load_Control_State(0), SHED_NON_COMPLIANT, NULL);
/* CanNowComplyWithShed */
Analog_Output_Present_Value_Set(0, 100, 16);
// TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 16, 0, 2, 0);
Load_Control_State_Machine(0);
// TODO: zassert_equal(Load_Control_State[0], SHED_COMPLIANT, NULL);
level = Analog_Output_Present_Value(0);
// TODO: Fails: zassert_equal(level, 90, NULL);
Load_Control_Manipulated_Variable_Reference(
object_instance, &object_property_reference);
if ((object_property_reference.object_identifier.type ==
OBJECT_ANALOG_OUTPUT) &&
(object_property_reference.property_identifier == PROP_PRESENT_VALUE)) {
status = Analog_Output_Present_Value_Set(
object_property_reference.object_identifier.instance, 100.0f,
BACNET_MAX_PRIORITY);
zassert_true(status, NULL);
} else {
zassert_true(false, NULL);
}
datetime_set_values(&bdatetime, 2007, 2, 27, 16, 0, 2, 0);
Load_Control_State_Machine(0, &bdatetime);
zassert_equal(Load_Control_State(0), SHED_COMPLIANT, NULL);
Load_Control_Manipulated_Variable_Reference(
object_instance, &object_property_reference);
if ((object_property_reference.object_identifier.type ==
OBJECT_ANALOG_OUTPUT) &&
(object_property_reference.property_identifier == PROP_PRESENT_VALUE)) {
level = Analog_Output_Present_Value(
object_property_reference.object_identifier.instance);
} else {
zassert_true(false, NULL);
}
zassert_false(islessgreater(90.0f, level), "AO Present Value = %f", level);
/* FinishedSuccessfulShed */
// TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 23, 0, 0, 0);
Load_Control_State_Machine(0);
// TODO: zassert_equal(Load_Control_State[0], SHED_INACTIVE, NULL);
level = Analog_Output_Present_Value(0);
// TODO: Fails: zassert_equal(level, 100, NULL);
(void)level; // TODO: remove when level will be checked
datetime_set_values(&bdatetime, 2007, 2, 27, 23, 0, 0, 0);
Load_Control_State_Machine(0, &bdatetime);
zassert_equal(Load_Control_State(0), SHED_INACTIVE, NULL);
if ((object_property_reference.object_identifier.type ==
OBJECT_ANALOG_OUTPUT) &&
(object_property_reference.property_identifier == PROP_PRESENT_VALUE)) {
level = Analog_Output_Present_Value(
object_property_reference.object_identifier.instance);
} else {
zassert_true(false, NULL);
}
zassert_false(islessgreater(100.0f, level), "AO Present Value = %f", level);
}
#ifndef MAX_LOAD_CONTROLS
@@ -421,56 +448,21 @@ ZTEST(lc_tests, test_Load_Control_Read_Write_Property)
static void test_Load_Control_Read_Write_Property(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;
bool status = false;
unsigned count = 0;
uint32_t object_instance = 0;
zassert_equal(Load_Control_Read_Property(NULL), 0, NULL);
zassert_false(Load_Control_Write_Property(NULL), NULL);
uint32_t object_instance = BACNET_MAX_INSTANCE, test_object_instance = 0;
const int skip_fail_property_list[] = { -1 };
object_instance = Load_Control_Index_To_Instance(0);
Load_Control_Init();
count = Load_Control_Count();
zassert_true(count > 0, NULL);
rpdata.application_data = &apdu[0];
rpdata.application_data_len = sizeof(apdu);
rpdata.object_type = OBJECT_LOAD_CONTROL;
rpdata.object_instance = object_instance;
Load_Control_Property_Lists(&pRequired, &pOptional, &pProprietary);
while ((*pRequired) != -1) {
rpdata.object_property = *pRequired;
rpdata.array_index = BACNET_ARRAY_ALL;
len = Load_Control_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 = Load_Control_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++;
}
test_object_instance = Load_Control_Index_To_Instance(0);
zassert_equal(object_instance, test_object_instance, NULL);
bacnet_object_properties_read_write_test(
OBJECT_LOAD_CONTROL, object_instance, Load_Control_Property_Lists,
Load_Control_Read_Property, Load_Control_Write_Property,
skip_fail_property_list);
}
static bool init_wp_data_and_value(
@@ -529,136 +521,6 @@ static void test_ShedInactive_gets_RcvShedRequests(void)
zassert_false(Load_Control_Write_Property(&wp_data), NULL);
zassert_equal(wp_data.error_class, ERROR_CLASS_PROPERTY, NULL);
zassert_equal(wp_data.error_code, ERROR_CODE_VALUE_OUT_OF_RANGE, NULL);
/* Verify calls to dependencies are properly made */
// object_property == PROP_REQUESTED_SHED_LEVEL calls
// bacapp_decode_context_data() object_property == PROP_START_TIME calls
// bacapp_decode_application_data() object_property == PROP_SHED_DURATION
// calls nothing object_property == PROP_DUTY_WINDOW calls nothing
// object_property == PROP_SHED_LEVELS calls nothing
// object_property == PROP_ENABLE calls nothing
// default returns error
}
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST(lc_tests, test_ShedReqPending_gets_ReconfigPending)
#else
static void test_ShedReqPending_gets_ReconfigPending(void)
#endif
{
#ifndef UNIT_TESTING
ztest_test_skip();
#endif
}
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST(lc_tests, test_ShedReqPending_gets_CancelShed)
#else
static void test_ShedReqPending_gets_CancelShed(void)
#endif
{
#ifndef UNIT_TESTING
ztest_test_skip();
#endif
}
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST(lc_tests, test_ShedReqPending_gets_CannotMeetShed)
#else
static void test_ShedReqPending_gets_CannotMeetShed(void)
#endif
{
#ifndef UNIT_TESTING
ztest_test_skip();
#endif
}
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST(lc_tests, test_ShedReqPending_gets_PrepareToShed)
#else
static void test_ShedReqPending_gets_PrepareToShed(void)
#endif
{
#ifndef UNIT_TESTING
ztest_test_skip();
#endif
}
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST(lc_tests, test_ShedReqPending_gets_AbleToMeetShed)
#else
static void test_ShedReqPending_gets_AbleToMeetShed(void)
#endif
{
#ifndef UNIT_TESTING
ztest_test_skip();
#endif
}
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST(lc_tests, test_ShedNonCommpliant_gets_UnsuccessfulShedReconfig)
#else
static void test_ShedNonCommpliant_gets_UnsuccessfulShedReconfig(void)
#endif
{
#ifndef UNIT_TESTING
ztest_test_skip();
#endif
}
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST(lc_tests, test_ShedNonCommpliant_gets_FinishedUnsuccessfulShed)
#else
static void test_ShedNonCommpliant_gets_FinishedUnsuccessfulShed(void)
#endif
{
#ifndef UNIT_TESTING
ztest_test_skip();
#endif
}
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST(lc_tests, test_ShedNonCommpliant_gets_CanNowComplyWithShed)
#else
static void test_ShedNonCommpliant_gets_CanNowComplyWithShed(void)
#endif
{
#ifndef UNIT_TESTING
ztest_test_skip();
#endif
}
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST(lc_tests, test_ShedCommpliant_gets_FinishedSuccessfulShed)
#else
static void test_ShedCommpliant_gets_FinishedSuccessfulShed(void)
#endif
{
#ifndef UNIT_TESTING
ztest_test_skip();
#endif
}
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST(lc_tests, test_ShedCommpliant_gets_SuccessfulShedReconfig)
#else
static void test_ShedCommpliant_gets_SuccessfulShedReconfig(void)
#endif
{
#ifndef UNIT_TESTING
ztest_test_skip();
#endif
}
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST(lc_tests, test_ShedCommpliant_gets_CanNoLongerComplyWithShed)
#else
static void test_ShedCommpliant_gets_CanNoLongerComplyWithShed(void)
#endif
{
#ifndef UNIT_TESTING
ztest_test_skip();
#endif
}
/**
@@ -675,18 +537,7 @@ void test_main(void)
ztest_unit_test(test_Load_Control_Count),
ztest_unit_test(test_Load_Control_Read_Write_Property),
ztest_unit_test(testLoadControlStateMachine),
ztest_unit_test(test_ShedInactive_gets_RcvShedRequests),
ztest_unit_test(test_ShedReqPending_gets_ReconfigPending),
ztest_unit_test(test_ShedReqPending_gets_CancelShed),
ztest_unit_test(test_ShedReqPending_gets_CannotMeetShed),
ztest_unit_test(test_ShedReqPending_gets_PrepareToShed),
ztest_unit_test(test_ShedReqPending_gets_AbleToMeetShed),
ztest_unit_test(test_ShedNonCommpliant_gets_UnsuccessfulShedReconfig),
ztest_unit_test(test_ShedNonCommpliant_gets_FinishedUnsuccessfulShed),
ztest_unit_test(test_ShedNonCommpliant_gets_CanNowComplyWithShed),
ztest_unit_test(test_ShedCommpliant_gets_FinishedSuccessfulShed),
ztest_unit_test(test_ShedCommpliant_gets_SuccessfulShedReconfig),
ztest_unit_test(test_ShedCommpliant_gets_CanNoLongerComplyWithShed));
ztest_unit_test(test_ShedInactive_gets_RcvShedRequests));
ztest_run_test_suite(lc_tests);
}