Added AlignAfterOpenBracket: AlwaysBreak and BinPackArguments: true to clang-format. Updated test/bacnet c/h files with updated format.

This commit is contained in:
Steve Karg
2024-04-24 09:38:12 -05:00
parent 1aaebe9414
commit 70c54817fd
120 changed files with 2182 additions and 1894 deletions
+11 -12
View File
@@ -29,8 +29,8 @@ static void test_Accumulator(void)
uint8_t apdu[MAX_APDU] = { 0 };
int len = 0;
int test_len = 0;
BACNET_READ_PROPERTY_DATA rpdata = {0};
BACNET_APPLICATION_DATA_VALUE value = {0};
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
BACNET_APPLICATION_DATA_VALUE value = { 0 };
const int *required_property = NULL;
BACNET_UNSIGNED_INTEGER unsigned_value = 1;
@@ -48,14 +48,16 @@ static void test_Accumulator(void)
zassert_true(len >= 0, NULL);
if (len >= 0) {
if (IS_CONTEXT_SPECIFIC(rpdata.application_data[0])) {
test_len = bacapp_decode_context_data(rpdata.application_data,
len, &value, rpdata.object_property);
test_len = bacapp_decode_context_data(
rpdata.application_data, len, &value,
rpdata.object_property);
} else {
test_len = bacapp_decode_application_data(
rpdata.application_data, len, &value);
}
if (len != test_len) {
printf("property '%s': failed to decode!\n",
printf(
"property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
}
zassert_equal(len, test_len, NULL);
@@ -68,10 +70,10 @@ static void test_Accumulator(void)
Accumulator_Present_Value_Set(0, unsigned_value);
len = Accumulator_Read_Property(&rpdata);
zassert_not_equal(len, 0, NULL);
test_len = bacapp_decode_application_data(rpdata.application_data,
len, &value);
test_len = bacapp_decode_application_data(
rpdata.application_data, len, &value);
zassert_equal(len, test_len, NULL);
unsigned_value |= (unsigned_value<<1);
unsigned_value |= (unsigned_value << 1);
}
return;
@@ -80,15 +82,12 @@ static void test_Accumulator(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(acc_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(acc_tests,
ztest_unit_test(test_Accumulator)
);
ztest_test_suite(acc_tests, ztest_unit_test(test_Accumulator));
ztest_run_test_suite(acc_tests);
}
@@ -49,8 +49,9 @@ static void testAccessCredential(void)
zassert_true(len >= 0, NULL);
if (len >= 0) {
if (IS_CONTEXT_SPECIFIC(rpdata.application_data[0])) {
test_len = bacapp_decode_context_data(rpdata.application_data,
len, &value, rpdata.object_property);
test_len = bacapp_decode_context_data(
rpdata.application_data, len, &value,
rpdata.object_property);
} else {
test_len = bacapp_decode_application_data(
rpdata.application_data, len, &value);
@@ -61,7 +62,8 @@ static void testAccessCredential(void)
}
}
if (len != test_len) {
fprintf(stderr, "property '%d': failed to decode!\n",
fprintf(
stderr, "property '%d': failed to decode!\n",
rpdata.object_property);
}
zassert_true(len == test_len, NULL);
@@ -75,7 +77,6 @@ static void testAccessCredential(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(access_credential_tests, NULL, NULL, NULL, NULL, NULL);
#else
@@ -52,8 +52,9 @@ static void test_object_access_door(void)
len = Access_Door_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);
test_len = bacapp_decode_application_data(
rpdata.application_data, (uint8_t)rpdata.application_data_len,
&value);
zassert_true(test_len >= 0, NULL);
}
pRequired++;
@@ -64,8 +65,9 @@ static void test_object_access_door(void)
len = Access_Door_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);
test_len = bacapp_decode_application_data(
rpdata.application_data, (uint8_t)rpdata.application_data_len,
&value);
zassert_true(test_len >= 0, NULL);
}
pOptional++;
@@ -77,7 +79,6 @@ static void test_object_access_door(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(tests_object_access_door, NULL, NULL, NULL, NULL, NULL);
#else
@@ -30,7 +30,7 @@ static void testAccessPoint(void)
uint8_t apdu[MAX_APDU] = { 0 };
int len = 0, test_len = 0;
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
BACNET_APPLICATION_DATA_VALUE value = {0};
BACNET_APPLICATION_DATA_VALUE value = { 0 };
const int *required_property = NULL;
unsigned count = 0;
uint32_t object_instance = 0;
@@ -50,10 +50,12 @@ static void testAccessPoint(void)
len = Access_Point_Read_Property(&rpdata);
if (len >= 0) {
zassert_true(len >= 0, NULL);
test_len = bacapp_decode_known_property(rpdata.application_data,
len, &value, rpdata.object_type, rpdata.object_property);
test_len = bacapp_decode_known_property(
rpdata.application_data, len, &value, rpdata.object_type,
rpdata.object_property);
if (len != test_len) {
printf("property '%s': failed to decode!\n",
printf(
"property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
}
if (rpdata.object_property == PROP_ACCESS_DOORS) {
@@ -62,7 +64,8 @@ static void testAccessPoint(void)
}
zassert_equal(len, test_len, NULL);
} else {
printf("property '%s': failed to read!\n",
printf(
"property '%s': failed to read!\n",
bactext_property_name(rpdata.object_property));
}
required_property++;
@@ -72,7 +75,6 @@ static void testAccessPoint(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(access_point_tests, NULL, NULL, NULL, NULL, NULL);
#else
@@ -52,15 +52,12 @@ static void testAccessRights(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(access_rights_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(access_rights_tests,
ztest_unit_test(testAccessRights)
);
ztest_test_suite(access_rights_tests, ztest_unit_test(testAccessRights));
ztest_run_test_suite(access_rights_tests);
}
@@ -52,15 +52,12 @@ static void testAccessUser(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(access_user_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(access_user_tests,
ztest_unit_test(testAccessUser)
);
ztest_test_suite(access_user_tests, ztest_unit_test(testAccessUser));
ztest_run_test_suite(access_user_tests);
}
@@ -52,15 +52,12 @@ static void testAccessZone(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(access_zone_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(access_zone_tests,
ztest_unit_test(testAccessZone)
);
ztest_test_suite(access_zone_tests, ztest_unit_test(testAccessZone));
ztest_run_test_suite(access_zone_tests);
}
+3 -9
View File
@@ -37,11 +37,8 @@ static void testAnalogInput(void)
test_object_instance = Analog_Input_Index_To_Instance(0);
zassert_equal(object_instance, test_object_instance, NULL);
bacnet_object_properties_read_write_test(
OBJECT_ANALOG_INPUT,
object_instance,
Analog_Input_Property_Lists,
Analog_Input_Read_Property,
Analog_Input_Write_Property,
OBJECT_ANALOG_INPUT, object_instance, Analog_Input_Property_Lists,
Analog_Input_Read_Property, Analog_Input_Write_Property,
skip_fail_property_list);
status = Analog_Input_Delete(object_instance);
zassert_true(status, NULL);
@@ -50,15 +47,12 @@ static void testAnalogInput(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(ai_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(ai_tests,
ztest_unit_test(testAnalogInput)
);
ztest_test_suite(ai_tests, ztest_unit_test(testAnalogInput));
ztest_run_test_suite(ai_tests);
}
+2 -1
View File
@@ -18,7 +18,8 @@
#include "bacnet/get_alarm_sum.h"
#include "bacnet/npdu.h"
bool datetime_local(BACNET_DATE *bdate,
bool datetime_local(
BACNET_DATE *bdate,
BACNET_TIME *btime,
int16_t *utc_offset_minutes,
bool *dst_active)
+3 -9
View File
@@ -37,11 +37,8 @@ static void testAnalogOutput(void)
test_object_instance = Analog_Output_Index_To_Instance(0);
zassert_equal(object_instance, test_object_instance, NULL);
bacnet_object_properties_read_write_test(
OBJECT_ANALOG_OUTPUT,
object_instance,
Analog_Output_Property_Lists,
Analog_Output_Read_Property,
Analog_Output_Write_Property,
OBJECT_ANALOG_OUTPUT, object_instance, Analog_Output_Property_Lists,
Analog_Output_Read_Property, Analog_Output_Write_Property,
skip_fail_property_list);
status = Analog_Output_Delete(object_instance);
zassert_true(status, NULL);
@@ -50,15 +47,12 @@ static void testAnalogOutput(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(ao_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(ao_tests,
ztest_unit_test(testAnalogOutput)
);
ztest_test_suite(ao_tests, ztest_unit_test(testAnalogOutput));
ztest_run_test_suite(ao_tests);
}
+3 -9
View File
@@ -37,11 +37,8 @@ static void testAnalog_Value(void)
test_object_instance = Analog_Value_Index_To_Instance(0);
zassert_equal(object_instance, test_object_instance, NULL);
bacnet_object_properties_read_write_test(
OBJECT_ANALOG_VALUE,
object_instance,
Analog_Value_Property_Lists,
Analog_Value_Read_Property,
Analog_Value_Write_Property,
OBJECT_ANALOG_VALUE, object_instance, Analog_Value_Property_Lists,
Analog_Value_Read_Property, Analog_Value_Write_Property,
skip_fail_property_list);
status = Analog_Value_Delete(object_instance);
zassert_true(status, NULL);
@@ -50,15 +47,12 @@ static void testAnalog_Value(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(av_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(av_tests,
ztest_unit_test(testAnalog_Value)
);
ztest_test_suite(av_tests, ztest_unit_test(testAnalog_Value));
ztest_run_test_suite(av_tests);
}
+2 -1
View File
@@ -18,7 +18,8 @@
#include "bacnet/get_alarm_sum.h"
#include "bacnet/npdu.h"
bool datetime_local(BACNET_DATE *bdate,
bool datetime_local(
BACNET_DATE *bdate,
BACNET_TIME *btime,
int16_t *utc_offset_minutes,
bool *dst_active)
+9 -9
View File
@@ -29,7 +29,7 @@ static void test_BACnet_File_Object(void)
uint8_t apdu[MAX_APDU] = { 0 };
int len = 0, test_len = 0;
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
BACNET_APPLICATION_DATA_VALUE value = {0};
BACNET_APPLICATION_DATA_VALUE value = { 0 };
const int *required_property = NULL;
const uint32_t instance = 1;
@@ -46,15 +46,18 @@ static void test_BACnet_File_Object(void)
rpdata.object_property = *required_property;
len = bacfile_read_property(&rpdata);
if (len < 0) {
printf("property %u: failed to read!\n",
printf(
"property %u: failed to read!\n",
(unsigned)rpdata.object_property);
}
zassert_true(len >= 0, NULL);
if (len >= 0) {
test_len = bacapp_decode_known_property(rpdata.application_data,
len, &value, rpdata.object_type, rpdata.object_property);
test_len = bacapp_decode_known_property(
rpdata.application_data, len, &value, rpdata.object_type,
rpdata.object_property);
if (len != test_len) {
printf("property %u: failed to decode!\n",
printf(
"property %u: failed to decode!\n",
(unsigned)rpdata.object_property);
}
zassert_equal(len, test_len, NULL);
@@ -68,15 +71,12 @@ static void test_BACnet_File_Object(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(bacfile_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(bacfile_tests,
ztest_unit_test(test_BACnet_File_Object)
);
ztest_test_suite(bacfile_tests, ztest_unit_test(test_BACnet_File_Object));
ztest_run_test_suite(bacfile_tests);
}
+3 -9
View File
@@ -38,11 +38,8 @@ static void testBinaryInput(void)
test_object_instance = Binary_Input_Index_To_Instance(0);
zassert_equal(object_instance, test_object_instance, NULL);
bacnet_object_properties_read_write_test(
OBJECT_BINARY_INPUT,
object_instance,
Binary_Input_Property_Lists,
Binary_Input_Read_Property,
Binary_Input_Write_Property,
OBJECT_BINARY_INPUT, object_instance, Binary_Input_Property_Lists,
Binary_Input_Read_Property, Binary_Input_Write_Property,
skip_fail_property_list);
status = Binary_Input_Delete(object_instance);
zassert_true(status, NULL);
@@ -51,15 +48,12 @@ static void testBinaryInput(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(bi_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(bi_tests,
ztest_unit_test(testBinaryInput)
);
ztest_test_suite(bi_tests, ztest_unit_test(testBinaryInput));
ztest_run_test_suite(bi_tests);
}
+31 -21
View File
@@ -57,15 +57,17 @@ static void testBinaryLightingOutput(void)
rpdata.object_property = *pRequired;
rpdata.array_index = BACNET_ARRAY_ALL;
len = Binary_Lighting_Output_Read_Property(&rpdata);
zassert_not_equal(len, BACNET_STATUS_ERROR,
zassert_not_equal(
len, BACNET_STATUS_ERROR,
"property '%s': failed to ReadProperty!\n",
bactext_property_name(rpdata.object_property));
if (len >= 0) {
test_len = bacapp_decode_known_property(rpdata.application_data,
len, &value, rpdata.object_type, rpdata.object_property);
test_len = bacapp_decode_known_property(
rpdata.application_data, len, &value, rpdata.object_type,
rpdata.object_property);
if (rpdata.object_property != PROP_PRIORITY_ARRAY) {
zassert_equal(len, test_len,
"property '%s': failed to decode!\n",
zassert_equal(
len, test_len, "property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
}
/* check WriteProperty properties */
@@ -79,8 +81,8 @@ static void testBinaryLightingOutput(void)
status = Binary_Lighting_Output_Write_Property(&wpdata);
if (!status) {
/* verify WriteProperty property is known */
zassert_not_equal(wpdata.error_code,
ERROR_CODE_UNKNOWN_PROPERTY,
zassert_not_equal(
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
"property '%s': WriteProperty Unknown!\n",
bactext_property_name(rpdata.object_property));
}
@@ -91,13 +93,16 @@ static void testBinaryLightingOutput(void)
rpdata.object_property = *pOptional;
rpdata.array_index = BACNET_ARRAY_ALL;
len = Binary_Lighting_Output_Read_Property(&rpdata);
zassert_not_equal(len, BACNET_STATUS_ERROR,
zassert_not_equal(
len, BACNET_STATUS_ERROR,
"property '%s': failed to ReadProperty!\n",
bactext_property_name(rpdata.object_property));
if (len > 0) {
test_len = bacapp_decode_application_data(rpdata.application_data,
(uint8_t)rpdata.application_data_len, &value);
zassert_equal(len, test_len, "property '%s': failed to decode!\n",
test_len = bacapp_decode_application_data(
rpdata.application_data, (uint8_t)rpdata.application_data_len,
&value);
zassert_equal(
len, test_len, "property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
/* check WriteProperty properties */
wpdata.object_type = rpdata.object_type;
@@ -110,8 +115,8 @@ static void testBinaryLightingOutput(void)
status = Binary_Lighting_Output_Write_Property(&wpdata);
if (!status) {
/* verify WriteProperty property is known */
zassert_not_equal(wpdata.error_code,
ERROR_CODE_UNKNOWN_PROPERTY,
zassert_not_equal(
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
"property '%s': WriteProperty Unknown!\n",
bactext_property_name(rpdata.object_property));
}
@@ -137,7 +142,8 @@ static struct {
BACNET_BINARY_LIGHTING_PV pv;
uint32_t count;
} BLO_Value;
static void Binary_Lighting_Output_Write_Value_Handler(uint32_t object_instance,
static void Binary_Lighting_Output_Write_Value_Handler(
uint32_t object_instance,
BACNET_BINARY_LIGHTING_PV old_value,
BACNET_BINARY_LIGHTING_PV value)
{
@@ -210,8 +216,9 @@ static void testBinaryLightingOutputBlink(void)
zassert_equal(expect_pv, test_pv, NULL);
test_priority =
Binary_Lighting_Output_Present_Value_Priority(object_instance);
zassert_equal(wpdata.priority, test_priority,
"priority=%u test_priority=%u", wpdata.priority, test_priority);
zassert_equal(
wpdata.priority, test_priority, "priority=%u test_priority=%u",
wpdata.priority, test_priority);
zassert_equal(BLO_Blink.count, 0, NULL);
zassert_equal(BLO_Value.count, 1, "count=%u", BLO_Value.count);
zassert_equal(BLO_Value.pv, expect_pv, NULL);
@@ -232,8 +239,9 @@ static void testBinaryLightingOutputBlink(void)
zassert_equal(expect_pv, test_pv, NULL);
test_priority =
Binary_Lighting_Output_Present_Value_Priority(object_instance);
zassert_equal(wpdata.priority, test_priority,
"priority=%u test_priority=%u", wpdata.priority, test_priority);
zassert_equal(
wpdata.priority, test_priority, "priority=%u test_priority=%u",
wpdata.priority, test_priority);
zassert_equal(BLO_Blink.count, 0, NULL);
zassert_equal(BLO_Value.count, 2, "count=%u", BLO_Value.count);
zassert_equal(BLO_Value.pv, expect_pv, NULL);
@@ -254,8 +262,9 @@ static void testBinaryLightingOutputBlink(void)
zassert_equal(expect_pv, test_pv, "pv=%u", test_pv);
test_priority =
Binary_Lighting_Output_Present_Value_Priority(object_instance);
zassert_equal(wpdata.priority, test_priority,
"priority=%u test_priority=%u", wpdata.priority, test_priority);
zassert_equal(
wpdata.priority, test_priority, "priority=%u test_priority=%u",
wpdata.priority, test_priority);
zassert_equal(BLO_Blink.count, 0, NULL);
zassert_equal(BLO_Value.count, 2, "count=%u", BLO_Value.count);
zassert_equal(BLO_Value.pv, expect_pv, NULL);
@@ -271,7 +280,8 @@ ZTEST_SUITE(blo_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(blo_tests, ztest_unit_test(testBinaryLightingOutput),
ztest_test_suite(
blo_tests, ztest_unit_test(testBinaryLightingOutput),
ztest_unit_test(testBinaryLightingOutputBlink));
ztest_run_test_suite(blo_tests);
+3 -9
View File
@@ -37,11 +37,8 @@ static void testBinaryOutput(void)
test_object_instance = Binary_Output_Index_To_Instance(0);
zassert_equal(object_instance, test_object_instance, NULL);
bacnet_object_properties_read_write_test(
OBJECT_BINARY_OUTPUT,
object_instance,
Binary_Output_Property_Lists,
Binary_Output_Read_Property,
Binary_Output_Write_Property,
OBJECT_BINARY_OUTPUT, object_instance, Binary_Output_Property_Lists,
Binary_Output_Read_Property, Binary_Output_Write_Property,
skip_fail_property_list);
status = Binary_Output_Delete(object_instance);
zassert_true(status, NULL);
@@ -50,15 +47,12 @@ static void testBinaryOutput(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(bo_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(bo_tests,
ztest_unit_test(testBinaryOutput)
);
ztest_test_suite(bo_tests, ztest_unit_test(testBinaryOutput));
ztest_run_test_suite(bo_tests);
}
+3 -9
View File
@@ -39,11 +39,8 @@ static void testBinary_Value(void)
test_object_instance = Binary_Value_Index_To_Instance(0);
zassert_equal(object_instance, test_object_instance, NULL);
bacnet_object_properties_read_write_test(
OBJECT_BINARY_VALUE,
object_instance,
Binary_Value_Property_Lists,
Binary_Value_Read_Property,
Binary_Value_Write_Property,
OBJECT_BINARY_VALUE, object_instance, Binary_Value_Property_Lists,
Binary_Value_Read_Property, Binary_Value_Write_Property,
skip_fail_property_list);
status = Binary_Value_Delete(object_instance);
zassert_true(status, NULL);
@@ -52,15 +49,12 @@ static void testBinary_Value(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(bv_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(bv_tests,
ztest_unit_test(testBinary_Value)
);
ztest_test_suite(bv_tests, ztest_unit_test(testBinary_Value));
ztest_run_test_suite(bv_tests);
}
+24 -20
View File
@@ -29,7 +29,7 @@ static void testCalendar(void)
int len = 0, test_len = 0;
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
BACNET_WRITE_PROPERTY_DATA wpdata = { 0 };
BACNET_APPLICATION_DATA_VALUE value = {0};
BACNET_APPLICATION_DATA_VALUE value = { 0 };
const int *pRequired = NULL;
const int *pOptional = NULL;
const int *pProprietary = NULL;
@@ -57,14 +57,16 @@ static void testCalendar(void)
rpdata.object_property = *pRequired;
rpdata.array_index = BACNET_ARRAY_ALL;
len = Calendar_Read_Property(&rpdata);
zassert_not_equal(len, BACNET_STATUS_ERROR,
zassert_not_equal(
len, BACNET_STATUS_ERROR,
"property '%s': failed to ReadProperty!\n",
bactext_property_name(rpdata.object_property));
if (len >= 0) {
test_len = bacapp_decode_known_property(rpdata.application_data,
len, &value, rpdata.object_type, rpdata.object_property);
zassert_equal(len, test_len,
"property '%s': failed to decode!\n",
test_len = bacapp_decode_known_property(
rpdata.application_data, len, &value, rpdata.object_type,
rpdata.object_property);
zassert_equal(
len, test_len, "property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
/* check WriteProperty properties */
wpdata.object_type = rpdata.object_type;
@@ -77,8 +79,8 @@ static void testCalendar(void)
status = Calendar_Write_Property(&wpdata);
if (!status) {
/* verify WriteProperty property is known */
zassert_not_equal(wpdata.error_code,
ERROR_CODE_UNKNOWN_PROPERTY,
zassert_not_equal(
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
"property '%s': WriteProperty Unknown!\n",
bactext_property_name(rpdata.object_property));
}
@@ -89,13 +91,16 @@ static void testCalendar(void)
rpdata.object_property = *pOptional;
rpdata.array_index = BACNET_ARRAY_ALL;
len = Calendar_Read_Property(&rpdata);
zassert_not_equal(len, BACNET_STATUS_ERROR,
zassert_not_equal(
len, BACNET_STATUS_ERROR,
"property '%s': failed to ReadProperty!\n",
bactext_property_name(rpdata.object_property));
if (len > 0) {
test_len = bacapp_decode_application_data(rpdata.application_data,
(uint8_t)rpdata.application_data_len, &value);
zassert_equal(len, test_len, "property '%s': failed to decode!\n",
test_len = bacapp_decode_application_data(
rpdata.application_data, (uint8_t)rpdata.application_data_len,
&value);
zassert_equal(
len, test_len, "property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
/* check WriteProperty properties */
wpdata.object_type = rpdata.object_type;
@@ -108,8 +113,8 @@ static void testCalendar(void)
status = Calendar_Write_Property(&wpdata);
if (!status) {
/* verify WriteProperty property is known */
zassert_not_equal(wpdata.error_code,
ERROR_CODE_UNKNOWN_PROPERTY,
zassert_not_equal(
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
"property '%s': WriteProperty Unknown!\n",
bactext_property_name(rpdata.object_property));
}
@@ -182,7 +187,7 @@ static void testPresentValue(void)
zassert_true(Calendar_Present_Value(instance), NULL);
if (date.day > 1) {
value->type.DateRange.startdate.day --;
value->type.DateRange.startdate.day--;
value->type.DateRange.enddate.day = date.day;
zassert_true(Calendar_Present_Value(instance), NULL);
}
@@ -214,7 +219,7 @@ static void testPresentValue(void)
value->type.WeekNDay.weekofmonth = (date.day - 1) % 7 + 1;
zassert_true(Calendar_Present_Value(instance), NULL);
value->type.WeekNDay.weekofmonth++;
if (value->type.WeekNDay.weekofmonth >5)
if (value->type.WeekNDay.weekofmonth > 5)
value->type.WeekNDay.weekofmonth = 1;
zassert_false(Calendar_Present_Value(instance), NULL);
value->type.WeekNDay.weekofmonth = 0xff;
@@ -241,10 +246,9 @@ ZTEST_SUITE(bacnet_calendar, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(calendar_tests,
ztest_unit_test(testCalendar),
ztest_unit_test(testPresentValue)
);
ztest_test_suite(
calendar_tests, ztest_unit_test(testCalendar),
ztest_unit_test(testPresentValue));
ztest_run_test_suite(calendar_tests);
}
+4 -4
View File
@@ -11,10 +11,10 @@
#include "bacnet/datetime.h"
bool datetime_local(
BACNET_DATE * bdate,
BACNET_TIME * btime,
int16_t * utc_offset_minutes,
bool * dst_active)
BACNET_DATE *bdate,
BACNET_TIME *btime,
int16_t *utc_offset_minutes,
bool *dst_active)
{
bdate->year = 2023;
bdate->month = 6;
+19 -13
View File
@@ -55,20 +55,23 @@ static void test_Channel_ReadProperty(void)
rpdata.object_property = *pRequired;
rpdata.array_index = BACNET_ARRAY_ALL;
len = Channel_Read_Property(&rpdata);
zassert_not_equal(len, BACNET_STATUS_ERROR,
zassert_not_equal(
len, BACNET_STATUS_ERROR,
"property '%s': failed to ReadProperty!\n",
bactext_property_name(rpdata.object_property));
if (len > 0) {
test_len = bacapp_decode_application_data(rpdata.application_data,
(uint8_t)rpdata.application_data_len, &value);
test_len = bacapp_decode_application_data(
rpdata.application_data, (uint8_t)rpdata.application_data_len,
&value);
if ((rpdata.object_property == PROP_PRIORITY_ARRAY) ||
(rpdata.object_property == PROP_CONTROL_GROUPS) ||
(rpdata.object_property ==
PROP_LIST_OF_OBJECT_PROPERTY_REFERENCES)) {
PROP_LIST_OF_OBJECT_PROPERTY_REFERENCES)) {
/* FIXME: known fail to decode */
len = test_len;
}
zassert_equal(len, test_len, "property '%s': failed to decode!\n",
zassert_equal(
len, test_len, "property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
/* check WriteProperty properties */
wpdata.object_type = rpdata.object_type;
@@ -81,8 +84,8 @@ static void test_Channel_ReadProperty(void)
status = Channel_Write_Property(&wpdata);
if (!status) {
/* verify WriteProperty property is known */
zassert_not_equal(wpdata.error_code,
ERROR_CODE_UNKNOWN_PROPERTY,
zassert_not_equal(
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
"property '%s': WriteProperty Unknown!\n",
bactext_property_name(rpdata.object_property));
}
@@ -93,13 +96,16 @@ static void test_Channel_ReadProperty(void)
rpdata.object_property = *pOptional;
rpdata.array_index = BACNET_ARRAY_ALL;
len = Channel_Read_Property(&rpdata);
zassert_not_equal(len, BACNET_STATUS_ERROR,
zassert_not_equal(
len, BACNET_STATUS_ERROR,
"property '%s': failed to ReadProperty!\n",
bactext_property_name(rpdata.object_property));
if (len > 0) {
test_len = bacapp_decode_application_data(rpdata.application_data,
(uint8_t)rpdata.application_data_len, &value);
zassert_equal(len, test_len, "property '%s': failed to decode!\n",
test_len = bacapp_decode_application_data(
rpdata.application_data, (uint8_t)rpdata.application_data_len,
&value);
zassert_equal(
len, test_len, "property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
/* check WriteProperty properties */
wpdata.object_type = rpdata.object_type;
@@ -112,8 +118,8 @@ static void test_Channel_ReadProperty(void)
status = Channel_Write_Property(&wpdata);
if (!status) {
/* verify WriteProperty property is known */
zassert_not_equal(wpdata.error_code,
ERROR_CODE_UNKNOWN_PROPERTY,
zassert_not_equal(
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
"property '%s': WriteProperty Unknown!\n",
bactext_property_name(rpdata.object_property));
}
@@ -55,13 +55,16 @@ static void testColorObject(void)
rpdata.object_property = *pRequired;
rpdata.array_index = BACNET_ARRAY_ALL;
len = Color_Read_Property(&rpdata);
zassert_not_equal(len, BACNET_STATUS_ERROR,
zassert_not_equal(
len, BACNET_STATUS_ERROR,
"property '%s': failed to ReadProperty!\n",
bactext_property_name(rpdata.object_property));
if (len >= 0) {
test_len = bacapp_decode_known_property(rpdata.application_data,
len, &value, rpdata.object_type, rpdata.object_property);
zassert_equal(len, test_len, "property '%s': failed to decode!\n",
test_len = bacapp_decode_known_property(
rpdata.application_data, len, &value, rpdata.object_type,
rpdata.object_property);
zassert_equal(
len, test_len, "property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
/* check WriteProperty properties */
wpdata.object_type = rpdata.object_type;
@@ -74,8 +77,8 @@ static void testColorObject(void)
status = Color_Write_Property(&wpdata);
if (!status) {
/* verify WriteProperty property is known */
zassert_not_equal(wpdata.error_code,
ERROR_CODE_UNKNOWN_PROPERTY,
zassert_not_equal(
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
"property '%s': WriteProperty Unknown!\n",
bactext_property_name(rpdata.object_property));
}
@@ -86,13 +89,16 @@ static void testColorObject(void)
rpdata.object_property = *pOptional;
rpdata.array_index = BACNET_ARRAY_ALL;
len = Color_Read_Property(&rpdata);
zassert_not_equal(len, BACNET_STATUS_ERROR,
zassert_not_equal(
len, BACNET_STATUS_ERROR,
"property '%s': failed to ReadProperty!\n",
bactext_property_name(rpdata.object_property));
if (len > 0) {
test_len = bacapp_decode_application_data(rpdata.application_data,
(uint8_t)rpdata.application_data_len, &value);
zassert_equal(len, test_len, "property '%s': failed to decode!\n",
test_len = bacapp_decode_application_data(
rpdata.application_data, (uint8_t)rpdata.application_data_len,
&value);
zassert_equal(
len, test_len, "property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
/* check WriteProperty properties */
wpdata.object_type = rpdata.object_type;
@@ -105,8 +111,8 @@ static void testColorObject(void)
status = Color_Write_Property(&wpdata);
if (!status) {
/* verify WriteProperty property is known */
zassert_not_equal(wpdata.error_code,
ERROR_CODE_UNKNOWN_PROPERTY,
zassert_not_equal(
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
"property '%s': WriteProperty Unknown!\n",
bactext_property_name(rpdata.object_property));
}
@@ -10,7 +10,6 @@
#include <bacnet/bactext.h>
#include <bacnet/basic/object/color_temperature.h>
/**
* @addtogroup bacnet_tests
* @{
@@ -28,8 +27,8 @@ static void testColorTemperature(void)
uint8_t apdu[MAX_APDU] = { 0 };
int len = 0;
int test_len = 0;
BACNET_READ_PROPERTY_DATA rpdata = {0};
BACNET_APPLICATION_DATA_VALUE value = {0};
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
BACNET_APPLICATION_DATA_VALUE value = { 0 };
const int *pRequired = NULL;
const int *pOptional = NULL;
const int *pProprietary = NULL;
@@ -51,14 +50,17 @@ static void testColorTemperature(void)
rpdata.object_property = *pRequired;
rpdata.array_index = BACNET_ARRAY_ALL;
len = Color_Temperature_Read_Property(&rpdata);
zassert_not_equal(len, BACNET_STATUS_ERROR,
zassert_not_equal(
len, BACNET_STATUS_ERROR,
"property '%s': failed to ReadProperty!\n",
bactext_property_name(rpdata.object_property));
if (len >= 0) {
test_len = bacapp_decode_known_property(rpdata.application_data,
len, &value, rpdata.object_type, rpdata.object_property);
zassert_equal(len, test_len, "property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
test_len = bacapp_decode_known_property(
rpdata.application_data, len, &value, rpdata.object_type,
rpdata.object_property);
zassert_equal(
len, test_len, "property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
/* check WriteProperty properties */
wpdata.object_type = rpdata.object_type;
wpdata.object_instance = rpdata.object_instance;
@@ -70,8 +72,8 @@ static void testColorTemperature(void)
status = Color_Temperature_Write_Property(&wpdata);
if (!status) {
/* verify WriteProperty property is known */
zassert_not_equal(wpdata.error_code,
ERROR_CODE_UNKNOWN_PROPERTY,
zassert_not_equal(
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
"property '%s': WriteProperty Unknown!\n",
bactext_property_name(rpdata.object_property));
}
@@ -82,15 +84,17 @@ static void testColorTemperature(void)
rpdata.object_property = *pOptional;
rpdata.array_index = BACNET_ARRAY_ALL;
len = Color_Temperature_Read_Property(&rpdata);
zassert_not_equal(len, BACNET_STATUS_ERROR,
zassert_not_equal(
len, BACNET_STATUS_ERROR,
"property '%s': failed to ReadProperty!\n",
bactext_property_name(rpdata.object_property));
if (len > 0) {
test_len = bacapp_decode_application_data(
rpdata.application_data,
(uint8_t)rpdata.application_data_len, &value);
zassert_equal(len, test_len, "property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
rpdata.application_data, (uint8_t)rpdata.application_data_len,
&value);
zassert_equal(
len, test_len, "property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
/* check WriteProperty properties */
wpdata.object_type = rpdata.object_type;
wpdata.object_instance = rpdata.object_instance;
@@ -102,8 +106,8 @@ static void testColorTemperature(void)
status = Color_Temperature_Write_Property(&wpdata);
if (!status) {
/* verify WriteProperty property is known */
zassert_not_equal(wpdata.error_code,
ERROR_CODE_UNKNOWN_PROPERTY,
zassert_not_equal(
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
"property '%s': WriteProperty Unknown!\n",
bactext_property_name(rpdata.object_property));
}
@@ -125,15 +129,13 @@ static void testColorTemperature(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(color_temperature_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(color_temperature_tests,
ztest_unit_test(testColorTemperature)
);
ztest_test_suite(
color_temperature_tests, ztest_unit_test(testColorTemperature));
ztest_run_test_suite(color_temperature_tests);
}
+2 -6
View File
@@ -34,12 +34,8 @@ static void test_object_command(void)
zassert_true(count > 0, NULL);
object_instance = Command_Index_To_Instance(0);
bacnet_object_properties_read_write_test(
OBJECT_COMMAND,
object_instance,
Command_Property_Lists,
Command_Read_Property,
Command_Write_Property,
skip_fail_property_list);
OBJECT_COMMAND, object_instance, Command_Property_Lists,
Command_Read_Property, Command_Write_Property, skip_fail_property_list);
}
/**
* @}
@@ -27,37 +27,31 @@ static void testCredentialDataInput(void)
{
unsigned count = 0;
uint32_t object_instance = 0;
const int skip_fail_property_list[] = {
PROP_PRESENT_VALUE,
PROP_UPDATE_TIME,
PROP_SUPPORTED_FORMATS,
-1 };
const int skip_fail_property_list[] = { PROP_PRESENT_VALUE,
PROP_UPDATE_TIME,
PROP_SUPPORTED_FORMATS, -1 };
Credential_Data_Input_Init();
count = Credential_Data_Input_Count();
zassert_true(count > 0, NULL);
object_instance = Credential_Data_Input_Index_To_Instance(0);
bacnet_object_properties_read_write_test(
OBJECT_CREDENTIAL_DATA_INPUT,
object_instance,
OBJECT_CREDENTIAL_DATA_INPUT, object_instance,
Credential_Data_Input_Property_Lists,
Credential_Data_Input_Read_Property,
Credential_Data_Input_Write_Property,
skip_fail_property_list);
Credential_Data_Input_Write_Property, skip_fail_property_list);
}
/**
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(credential_data_input_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(credential_data_input_tests,
ztest_unit_test(testCredentialDataInput)
);
ztest_test_suite(
credential_data_input_tests, ztest_unit_test(testCredentialDataInput));
ztest_run_test_suite(credential_data_input_tests);
}
+15 -9
View File
@@ -24,7 +24,7 @@ static void testCharacterString_Value(void)
uint8_t apdu[MAX_APDU] = { 0 };
int len = 0, test_len = 0;
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
BACNET_APPLICATION_DATA_VALUE value = {0};
BACNET_APPLICATION_DATA_VALUE value = { 0 };
const int *pRequired = NULL;
const int *pOptional = NULL;
const int *pProprietary = NULL;
@@ -47,10 +47,12 @@ static void testCharacterString_Value(void)
len = CharacterString_Value_Read_Property(&rpdata);
zassert_true(len >= 0, NULL);
if (len >= 0) {
test_len = bacapp_decode_known_property(rpdata.application_data,
len, &value, rpdata.object_type, rpdata.object_property);
test_len = bacapp_decode_known_property(
rpdata.application_data, len, &value, rpdata.object_type,
rpdata.object_property);
if (len != test_len) {
printf("property '%s': failed to decode!\n",
printf(
"property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
}
if (rpdata.object_property == PROP_PRIORITY_ARRAY) {
@@ -59,7 +61,8 @@ static void testCharacterString_Value(void)
}
zassert_equal(len, test_len, NULL);
} else {
printf("property '%s': failed to read!\n",
printf(
"property '%s': failed to read!\n",
bactext_property_name(rpdata.object_property));
}
pRequired++;
@@ -70,15 +73,18 @@ static void testCharacterString_Value(void)
len = CharacterString_Value_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);
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",
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",
printf(
"property '%s': failed to read!\n",
bactext_property_name(rpdata.object_property));
}
pOptional++;
+46 -28
View File
@@ -48,18 +48,21 @@ static void test_Device_Data_Sharing(void)
rpdata.object_property = *pRequired;
rpdata.array_index = BACNET_ARRAY_ALL;
len = Device_Read_Property(&rpdata);
zassert_not_equal(len, BACNET_STATUS_ERROR,
zassert_not_equal(
len, BACNET_STATUS_ERROR,
"property '%s': failed to ReadProperty!\n",
bactext_property_name(rpdata.object_property));
if (len > 0) {
test_len = bacapp_decode_application_data(rpdata.application_data,
(uint8_t)rpdata.application_data_len, &value);
test_len = bacapp_decode_application_data(
rpdata.application_data, (uint8_t)rpdata.application_data_len,
&value);
if ((rpdata.object_property == PROP_PRIORITY_ARRAY) ||
(rpdata.object_property == PROP_OBJECT_LIST)) {
/* FIXME: known fail to decode */
len = test_len;
}
zassert_equal(test_len, len, "property '%s': failed to decode!\n",
zassert_equal(
test_len, len, "property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
/* check WriteProperty properties */
wpdata.object_type = rpdata.object_type;
@@ -72,8 +75,8 @@ static void test_Device_Data_Sharing(void)
status = Device_Write_Property(&wpdata);
if (!status) {
/* verify WriteProperty property is known */
zassert_not_equal(wpdata.error_code,
ERROR_CODE_UNKNOWN_PROPERTY,
zassert_not_equal(
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
"property '%s': WriteProperty Unknown!\n",
bactext_property_name(rpdata.object_property));
}
@@ -84,17 +87,21 @@ static void test_Device_Data_Sharing(void)
rpdata.object_property = *pOptional;
rpdata.array_index = BACNET_ARRAY_ALL;
len = Device_Read_Property(&rpdata);
zassert_not_equal(len, BACNET_STATUS_ERROR,
zassert_not_equal(
len, BACNET_STATUS_ERROR,
"property '%s': failed to ReadProperty!\n",
bactext_property_name(rpdata.object_property));
if (len > 0) {
test_len = bacapp_decode_application_data(rpdata.application_data,
(uint8_t)rpdata.application_data_len, &value);
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",
printf(
"property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
}
zassert_equal(test_len, len, "property '%s': failed to decode!\n",
zassert_equal(
test_len, len, "property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
/* check WriteProperty properties */
wpdata.object_type = rpdata.object_type;
@@ -107,8 +114,8 @@ static void test_Device_Data_Sharing(void)
status = Device_Write_Property(&wpdata);
if (!status) {
/* verify WriteProperty property is known */
zassert_not_equal(wpdata.error_code,
ERROR_CODE_UNKNOWN_PROPERTY,
zassert_not_equal(
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
"property '%s': WriteProperty Unknown!\n",
bactext_property_name(rpdata.object_property));
}
@@ -161,9 +168,11 @@ static void testDevice(void)
status = Device_Reinitialize_Password_Set(NULL);
status = Device_Reinitialize(&rd_data);
zassert_true(status, NULL);
zassert_equal(rd_data.error_class, ERROR_CLASS_DEVICE, "error-class=%s",
zassert_equal(
rd_data.error_class, ERROR_CLASS_DEVICE, "error-class=%s",
bactext_error_class_name(rd_data.error_class));
zassert_equal(rd_data.error_code, ERROR_CODE_SUCCESS, "error-code=%s",
zassert_equal(
rd_data.error_code, ERROR_CODE_SUCCESS, "error-code=%s",
bactext_error_code_name(rd_data.error_code));
/* Reinitialize with device valid password, service no password */
status = Device_Reinitialize_Password_Set("valid");
@@ -172,19 +181,23 @@ static void testDevice(void)
zassert_true(status, NULL);
status = Device_Reinitialize(&rd_data);
zassert_false(status, NULL);
zassert_equal(rd_data.error_class, ERROR_CLASS_SECURITY, "error-class=%s",
zassert_equal(
rd_data.error_class, ERROR_CLASS_SECURITY, "error-class=%s",
bactext_error_class_name(rd_data.error_class));
zassert_equal(rd_data.error_code, ERROR_CODE_PASSWORD_FAILURE,
"error-code=%s", bactext_error_code_name(rd_data.error_code));
zassert_equal(
rd_data.error_code, ERROR_CODE_PASSWORD_FAILURE, "error-code=%s",
bactext_error_code_name(rd_data.error_code));
/* Reinitialize with device valid password, service invalid password */
status = characterstring_init_ansi(&rd_data.password, "invalid");
zassert_true(status, NULL);
status = Device_Reinitialize(&rd_data);
zassert_false(status, NULL);
zassert_equal(rd_data.error_class, ERROR_CLASS_SECURITY, "error-class=%s",
zassert_equal(
rd_data.error_class, ERROR_CLASS_SECURITY, "error-class=%s",
bactext_error_class_name(rd_data.error_class));
zassert_equal(rd_data.error_code, ERROR_CODE_PASSWORD_FAILURE,
"error-code=%s", bactext_error_code_name(rd_data.error_code));
zassert_equal(
rd_data.error_code, ERROR_CODE_PASSWORD_FAILURE, "error-code=%s",
bactext_error_code_name(rd_data.error_code));
/* Reinitialize with device valid password, service valid password */
characterstring_init_ansi(&rd_data.password, "valid");
status = Device_Reinitialize(&rd_data);
@@ -193,20 +206,24 @@ static void testDevice(void)
characterstring_init_ansi(&rd_data.password, "abcdefghijklmnopqrstuvwxyz");
status = Device_Reinitialize(&rd_data);
zassert_false(status, NULL);
zassert_equal(rd_data.error_class, ERROR_CLASS_SERVICES, "error-class=%s",
zassert_equal(
rd_data.error_class, ERROR_CLASS_SERVICES, "error-class=%s",
bactext_error_class_name(rd_data.error_class));
zassert_equal(rd_data.error_code, ERROR_CODE_PARAMETER_OUT_OF_RANGE,
"error-code=%s", bactext_error_code_name(rd_data.error_code));
zassert_equal(
rd_data.error_code, ERROR_CODE_PARAMETER_OUT_OF_RANGE, "error-code=%s",
bactext_error_code_name(rd_data.error_code));
/* Reinitialize with device no password, unsupported state */
status = Device_Reinitialize_Password_Set(NULL);
zassert_true(status, NULL);
rd_data.state = BACNET_REINIT_MAX;
status = Device_Reinitialize(&rd_data);
zassert_false(status, NULL);
zassert_equal(rd_data.error_class, ERROR_CLASS_SERVICES, "error-class=%s",
zassert_equal(
rd_data.error_class, ERROR_CLASS_SERVICES, "error-class=%s",
bactext_error_class_name(rd_data.error_class));
zassert_equal(rd_data.error_code, ERROR_CODE_PARAMETER_OUT_OF_RANGE,
"error-code=%s", bactext_error_code_name(rd_data.error_code));
zassert_equal(
rd_data.error_code, ERROR_CODE_PARAMETER_OUT_OF_RANGE, "error-code=%s",
bactext_error_code_name(rd_data.error_code));
return;
}
@@ -219,7 +236,8 @@ ZTEST_SUITE(device_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(device_tests, ztest_unit_test(testDevice),
ztest_test_suite(
device_tests, ztest_unit_test(testDevice),
ztest_unit_test(test_Device_Data_Sharing));
ztest_run_test_suite(device_tests);
+8 -8
View File
@@ -36,22 +36,22 @@ void datetime_init(void)
}
bool datetime_local(
BACNET_DATE * bdate,
BACNET_TIME * btime,
int16_t * utc_offset_minutes,
bool * dst_active)
BACNET_DATE *bdate,
BACNET_TIME *btime,
int16_t *utc_offset_minutes,
bool *dst_active)
{
return true;
}
void bip_get_my_address(BACNET_ADDRESS * my_address)
void bip_get_my_address(BACNET_ADDRESS *my_address)
{
}
int bip_send_pdu(
BACNET_ADDRESS * dest,
BACNET_NPDU_DATA * npdu_data,
uint8_t * pdu,
BACNET_ADDRESS *dest,
BACNET_NPDU_DATA *npdu_data,
uint8_t *pdu,
unsigned pdu_len)
{
return 0;
+15 -9
View File
@@ -24,7 +24,7 @@ static void testInteger_Value(void)
uint8_t apdu[MAX_APDU] = { 0 };
int len = 0, test_len = 0;
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
BACNET_APPLICATION_DATA_VALUE value = {0};
BACNET_APPLICATION_DATA_VALUE value = { 0 };
const int *pRequired = NULL;
const int *pOptional = NULL;
const int *pProprietary = NULL;
@@ -47,10 +47,12 @@ static void testInteger_Value(void)
len = Integer_Value_Read_Property(&rpdata);
zassert_true(len >= 0, NULL);
if (len >= 0) {
test_len = bacapp_decode_known_property(rpdata.application_data,
len, &value, rpdata.object_type, rpdata.object_property);
test_len = bacapp_decode_known_property(
rpdata.application_data, len, &value, rpdata.object_type,
rpdata.object_property);
if (len != test_len) {
printf("property '%s': failed to decode!\n",
printf(
"property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
}
if (rpdata.object_property == PROP_PRIORITY_ARRAY) {
@@ -59,7 +61,8 @@ static void testInteger_Value(void)
}
zassert_equal(len, test_len, NULL);
} else {
printf("property '%s': failed to read!\n",
printf(
"property '%s': failed to read!\n",
bactext_property_name(rpdata.object_property));
}
pRequired++;
@@ -70,15 +73,18 @@ static void testInteger_Value(void)
len = Integer_Value_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);
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",
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",
printf(
"property '%s': failed to read!\n",
bactext_property_name(rpdata.object_property));
}
pOptional++;
+147 -133
View File
@@ -21,7 +21,6 @@
#define MAX_LOAD_CONTROLS 4
#endif
/**
* @addtogroup bacnet_tests
* @{
@@ -52,8 +51,8 @@ static void test_Load_Control_Count(void)
zassert_equal(Load_Control_Count(), MAX_LOAD_CONTROLS, NULL);
}
static void Load_Control_WriteProperty_Request_Shed_Level(
int instance, unsigned level)
static void
Load_Control_WriteProperty_Request_Shed_Level(int instance, unsigned level)
{
bool status = false;
BACNET_APPLICATION_DATA_VALUE value;
@@ -75,8 +74,7 @@ static void Load_Control_WriteProperty_Request_Shed_Level(
zassert_true(status, NULL);
}
static void Load_Control_WriteProperty_Enable(
int instance, bool enable)
static void Load_Control_WriteProperty_Enable(int instance, bool enable)
{
bool status = false;
BACNET_APPLICATION_DATA_VALUE value;
@@ -99,8 +97,8 @@ static void Load_Control_WriteProperty_Enable(
zassert_true(status, NULL);
}
static void Load_Control_WriteProperty_Shed_Duration(
int instance, unsigned duration)
static void
Load_Control_WriteProperty_Shed_Duration(int instance, unsigned duration)
{
bool status = false;
BACNET_APPLICATION_DATA_VALUE value;
@@ -122,8 +120,8 @@ static void Load_Control_WriteProperty_Shed_Duration(
zassert_true(status, NULL);
}
static void Load_Control_WriteProperty_Duty_Window(
int instance, unsigned duration)
static void
Load_Control_WriteProperty_Duty_Window(int instance, unsigned duration)
{
bool status = false;
BACNET_APPLICATION_DATA_VALUE value;
@@ -145,8 +143,7 @@ static void Load_Control_WriteProperty_Duty_Window(
zassert_true(status, NULL);
}
static void Load_Control_WriteProperty_Start_Time_Wildcards(
int instance)
static void Load_Control_WriteProperty_Start_Time_Wildcards(int instance)
{
int len = 0;
bool status = false;
@@ -220,18 +217,19 @@ ZTEST(lc_tests, testLoadControlStateMachine)
static void testLoadControlStateMachine(void)
#endif
{
//TODO: unsigned i = 0, j = 0;
// TODO: unsigned i = 0, j = 0;
uint8_t level = 0;
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: }
// 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: }
/* SHED_REQUEST_PENDING */
/* CancelShed - Start time has wildcards */
@@ -239,20 +237,22 @@ static void testLoadControlStateMachine(void)
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);
// 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);
// TODO: 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);
// 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);
// 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);
// TODO: zassert_equal(Load_Control_State[0], SHED_INACTIVE, NULL);
/* CancelShed - Non-default values, but Start time is passed */
Load_Control_Init();
@@ -260,11 +260,12 @@ 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);
// 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);
// 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);
// TODO: zassert_equal(Load_Control_State[0], SHED_INACTIVE, NULL);
/* ReconfigurePending - new write received while pending */
Load_Control_Init();
@@ -272,27 +273,35 @@ 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);
// 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);
// 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: 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);
// TODO: 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);
// TODO: 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);
// TODO: 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);
// 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: 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: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
// NULL);
/* CannotMeetShed -> FinishedUnsuccessfulShed */
Load_Control_Init();
@@ -300,22 +309,24 @@ 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);
// 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);
// 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: 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);
// 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);
// 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);
// TODO: zassert_equal(Load_Control_State[0], SHED_NON_COMPLIANT, NULL);
/* FinishedUnsuccessfulShed */
//TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 23, 0, 0, 0);
// 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);
// TODO: zassert_equal(Load_Control_State[0], SHED_INACTIVE, NULL);
/* CannotMeetShed -> UnsuccessfulShedReconfigured */
Load_Control_Init();
@@ -323,44 +334,47 @@ 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);
// 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);
// 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: 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);
// 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);
// 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);
// TODO: 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);
// 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);
// 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);
// TODO: 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);
// 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);
// TODO: zassert_equal(Load_Control_State[0], SHED_COMPLIANT, NULL);
level = Analog_Output_Present_Value(0);
//TODO: Fails: zassert_equal(level, 90, NULL);
// TODO: Fails: zassert_equal(level, 90, NULL);
/* FinishedSuccessfulShed */
//TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 23, 0, 0, 0);
// 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);
// TODO: zassert_equal(Load_Control_State[0], SHED_INACTIVE, NULL);
level = Analog_Output_Present_Value(0);
//TODO: Fails: zassert_equal(level, 100, NULL);
// TODO: Fails: zassert_equal(level, 100, NULL);
(void)level; // TODO: remove when level will be checked
}
#ifndef MAX_LOAD_CONTROLS
#define MAX_LOAD_CONTROLS (4)
#endif
@@ -376,12 +390,18 @@ static void test_api_stubs(void)
zassert_equal(Load_Control_Count(), MAX_LOAD_CONTROLS, NULL);
zassert_false(Load_Control_Valid_Instance(MAX_LOAD_CONTROLS), NULL);
zassert_equal(Load_Control_Index_To_Instance(MAX_LOAD_CONTROLS), Load_Control_Count(), NULL);
zassert_equal(Load_Control_Instance_To_Index(MAX_LOAD_CONTROLS), Load_Control_Count(), NULL);
zassert_equal(
Load_Control_Index_To_Instance(MAX_LOAD_CONTROLS), Load_Control_Count(),
NULL);
zassert_equal(
Load_Control_Instance_To_Index(MAX_LOAD_CONTROLS), Load_Control_Count(),
NULL);
zassert_false(Load_Control_Valid_Instance(UINT32_MAX), NULL);
zassert_equal(Load_Control_Index_To_Instance(UINT32_MAX), Load_Control_Count(), NULL);
zassert_equal(Load_Control_Instance_To_Index(UINT32_MAX), Load_Control_Count(), NULL);
zassert_equal(
Load_Control_Index_To_Instance(UINT32_MAX), Load_Control_Count(), NULL);
zassert_equal(
Load_Control_Instance_To_Index(UINT32_MAX), Load_Control_Count(), NULL);
zassert_true(Load_Control_Valid_Instance(0), NULL);
zassert_equal(Load_Control_Index_To_Instance(0), 0, NULL);
@@ -390,7 +410,6 @@ static void test_api_stubs(void)
zassert_false(Load_Control_Object_Name(0, NULL), NULL);
zassert_false(Load_Control_Object_Name(UINT32_MAX, &object_name_st), NULL);
zassert_true(Load_Control_Object_Name(0, &object_name_st), NULL);
zassert_true(characterstring_valid(&object_name_st), NULL);
zassert_true(characterstring_printable(&object_name_st), NULL);
@@ -414,7 +433,6 @@ static void test_Load_Control_Read_Write_Property(void)
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);
@@ -428,58 +446,57 @@ static void test_Load_Control_Read_Write_Property(void)
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++;
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++;
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++;
}
}
static bool init_wp_data_and_value(
BACNET_WRITE_PROPERTY_DATA *wp_data,
BACNET_APPLICATION_DATA_VALUE * value)
BACNET_WRITE_PROPERTY_DATA *wp_data, BACNET_APPLICATION_DATA_VALUE *value)
{
bool status = false;
if ((wp_data != NULL) && (value != NULL))
{
memset(value, 0, sizeof(*value));
memset(wp_data, 0, sizeof(*wp_data));
if ((wp_data != NULL) && (value != NULL)) {
memset(value, 0, sizeof(*value));
memset(wp_data, 0, sizeof(*wp_data));
wp_data->object_type = OBJECT_LOAD_CONTROL;
wp_data->object_instance = 0;
wp_data->array_index = BACNET_ARRAY_ALL;
wp_data->priority = BACNET_NO_PRIORITY;
wp_data->object_property = PROP_SHED_DURATION;
value->context_specific = false;
value->context_tag = 0;
value->tag = BACNET_APPLICATION_TAG_UNSIGNED_INT;
value->type.Unsigned_Int = 0; /* duration */
wp_data->application_data_len = bacapp_encode_application_data(&wp_data->application_data[0], value);
zassert_true(wp_data->application_data_len >= 0, NULL);
zassert_equal(wp_data->error_class, 0, NULL);
zassert_equal(wp_data->error_code, 0, NULL);
wp_data->object_type = OBJECT_LOAD_CONTROL;
wp_data->object_instance = 0;
wp_data->array_index = BACNET_ARRAY_ALL;
wp_data->priority = BACNET_NO_PRIORITY;
wp_data->object_property = PROP_SHED_DURATION;
value->context_specific = false;
value->context_tag = 0;
value->tag = BACNET_APPLICATION_TAG_UNSIGNED_INT;
value->type.Unsigned_Int = 0; /* duration */
wp_data->application_data_len = bacapp_encode_application_data(
&wp_data->application_data[0], value);
zassert_true(wp_data->application_data_len >= 0, NULL);
zassert_equal(wp_data->error_class, 0, NULL);
zassert_equal(wp_data->error_code, 0, NULL);
status = true;
status = true;
}
return status;
@@ -513,12 +530,11 @@ static void test_ShedInactive_gets_RcvShedRequests(void)
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_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
@@ -649,30 +665,28 @@ static void test_ShedCommpliant_gets_CanNoLongerComplyWithShed(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(lc_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(lc_tests,
ztest_unit_test(test_api_stubs),
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_test_suite(
lc_tests, ztest_unit_test(test_api_stubs),
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_run_test_suite(lc_tests);
}
+4 -4
View File
@@ -35,10 +35,10 @@ void datetime_init(void)
}
bool datetime_local(
BACNET_DATE * bdate,
BACNET_TIME * btime,
int16_t * utc_offset_minutes,
bool * dst_active)
BACNET_DATE *bdate,
BACNET_TIME *btime,
int16_t *utc_offset_minutes,
bool *dst_active)
{
return true;
}
+22 -19
View File
@@ -29,7 +29,7 @@ static void testLightingOutput(void)
uint8_t apdu[MAX_APDU] = { 0 };
int len = 0, test_len = 0;
BACNET_READ_PROPERTY_DATA rpdata;
BACNET_APPLICATION_DATA_VALUE value = {0};
BACNET_APPLICATION_DATA_VALUE value = { 0 };
const int *pRequired = NULL;
const int *pOptional = NULL;
const int *pProprietary = NULL;
@@ -57,15 +57,18 @@ static void testLightingOutput(void)
rpdata.object_property = *pRequired;
rpdata.array_index = BACNET_ARRAY_ALL;
len = Lighting_Output_Read_Property(&rpdata);
zassert_not_equal(len, BACNET_STATUS_ERROR,
zassert_not_equal(
len, BACNET_STATUS_ERROR,
"property '%s': failed to ReadProperty!\n",
bactext_property_name(rpdata.object_property));
if (len >= 0) {
test_len = bacapp_decode_known_property(rpdata.application_data,
len, &value, rpdata.object_type, rpdata.object_property);
test_len = bacapp_decode_known_property(
rpdata.application_data, len, &value, rpdata.object_type,
rpdata.object_property);
if (rpdata.object_property != PROP_PRIORITY_ARRAY) {
zassert_equal(len, test_len, "property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
zassert_equal(
len, test_len, "property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
}
/* check WriteProperty properties */
wpdata.object_type = rpdata.object_type;
@@ -78,8 +81,8 @@ static void testLightingOutput(void)
status = Lighting_Output_Write_Property(&wpdata);
if (!status) {
/* verify WriteProperty property is known */
zassert_not_equal(wpdata.error_code,
ERROR_CODE_UNKNOWN_PROPERTY,
zassert_not_equal(
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
"property '%s': WriteProperty Unknown!\n",
bactext_property_name(rpdata.object_property));
}
@@ -90,14 +93,17 @@ static void testLightingOutput(void)
rpdata.object_property = *pOptional;
rpdata.array_index = BACNET_ARRAY_ALL;
len = Lighting_Output_Read_Property(&rpdata);
zassert_not_equal(len, BACNET_STATUS_ERROR,
zassert_not_equal(
len, BACNET_STATUS_ERROR,
"property '%s': failed to ReadProperty!\n",
bactext_property_name(rpdata.object_property));
if (len > 0) {
test_len = bacapp_decode_application_data(rpdata.application_data,
(uint8_t)rpdata.application_data_len, &value);
zassert_equal(len, test_len, "property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
test_len = bacapp_decode_application_data(
rpdata.application_data, (uint8_t)rpdata.application_data_len,
&value);
zassert_equal(
len, test_len, "property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
/* check WriteProperty properties */
wpdata.object_type = rpdata.object_type;
wpdata.object_instance = rpdata.object_instance;
@@ -109,8 +115,8 @@ static void testLightingOutput(void)
status = Lighting_Output_Write_Property(&wpdata);
if (!status) {
/* verify WriteProperty property is known */
zassert_not_equal(wpdata.error_code,
ERROR_CODE_UNKNOWN_PROPERTY,
zassert_not_equal(
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
"property '%s': WriteProperty Unknown!\n",
bactext_property_name(rpdata.object_property));
}
@@ -135,15 +141,12 @@ static void testLightingOutput(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(lo_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(lo_tests,
ztest_unit_test(testLightingOutput)
);
ztest_test_suite(lo_tests, ztest_unit_test(testLightingOutput));
ztest_run_test_suite(lo_tests);
}
+19 -16
View File
@@ -58,14 +58,17 @@ static void testLifeSafetyPoint(void)
rpdata.object_property = *pRequired;
rpdata.array_index = BACNET_ARRAY_ALL;
len = Life_Safety_Point_Read_Property(&rpdata);
zassert_not_equal(len, BACNET_STATUS_ERROR,
zassert_not_equal(
len, BACNET_STATUS_ERROR,
"property '%s': failed to ReadProperty!\n",
bactext_property_name(rpdata.object_property));
if (len >= 0) {
test_len = bacapp_decode_known_property(rpdata.application_data,
len, &value, rpdata.object_type, rpdata.object_property);
test_len = bacapp_decode_known_property(
rpdata.application_data, len, &value, rpdata.object_type,
rpdata.object_property);
if (len != test_len) {
printf("property '%s': failed to decode!\n",
printf(
"property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
} else {
zassert_equal(len, test_len, NULL);
@@ -81,8 +84,8 @@ static void testLifeSafetyPoint(void)
status = Life_Safety_Point_Write_Property(&wpdata);
if (!status) {
/* verify WriteProperty property is known */
zassert_not_equal(wpdata.error_code,
ERROR_CODE_UNKNOWN_PROPERTY,
zassert_not_equal(
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
"property '%s': WriteProperty Unknown!\n",
bactext_property_name(rpdata.object_property));
}
@@ -93,13 +96,16 @@ static void testLifeSafetyPoint(void)
rpdata.object_property = *pOptional;
rpdata.array_index = BACNET_ARRAY_ALL;
len = Life_Safety_Point_Read_Property(&rpdata);
zassert_not_equal(len, BACNET_STATUS_ERROR,
zassert_not_equal(
len, BACNET_STATUS_ERROR,
"property '%s': failed to ReadProperty!\n",
bactext_property_name(rpdata.object_property));
if (len > 0) {
test_len = bacapp_decode_application_data(rpdata.application_data,
(uint8_t)rpdata.application_data_len, &value);
zassert_equal(len, test_len, "property '%s': failed to decode!\n",
test_len = bacapp_decode_application_data(
rpdata.application_data, (uint8_t)rpdata.application_data_len,
&value);
zassert_equal(
len, test_len, "property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
/* check WriteProperty properties */
wpdata.object_type = rpdata.object_type;
@@ -112,8 +118,8 @@ static void testLifeSafetyPoint(void)
status = Life_Safety_Point_Write_Property(&wpdata);
if (!status) {
/* verify WriteProperty property is known */
zassert_not_equal(wpdata.error_code,
ERROR_CODE_UNKNOWN_PROPERTY,
zassert_not_equal(
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
"property '%s': WriteProperty Unknown!\n",
bactext_property_name(rpdata.object_property));
}
@@ -135,15 +141,12 @@ static void testLifeSafetyPoint(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(lsp_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(lsp_tests,
ztest_unit_test(testLifeSafetyPoint)
);
ztest_test_suite(lsp_tests, ztest_unit_test(testLifeSafetyPoint));
ztest_run_test_suite(lsp_tests);
}
+4 -9
View File
@@ -39,12 +39,9 @@ static void testLifeSafetyZone(void)
test_object_instance = Life_Safety_Zone_Index_To_Instance(0);
zassert_equal(test_object_instance, object_instance, NULL);
bacnet_object_properties_read_write_test(
OBJECT_LIFE_SAFETY_ZONE,
object_instance,
Life_Safety_Zone_Property_Lists,
Life_Safety_Zone_Read_Property,
Life_Safety_Zone_Write_Property,
skip_fail_property_list);
OBJECT_LIFE_SAFETY_ZONE, object_instance,
Life_Safety_Zone_Property_Lists, Life_Safety_Zone_Read_Property,
Life_Safety_Zone_Write_Property, skip_fail_property_list);
}
/**
* @}
@@ -55,9 +52,7 @@ ZTEST_SUITE(testsLifeSafetyZone, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(testsLifeSafetyZone,
ztest_unit_test(testLifeSafetyZone)
);
ztest_test_suite(testsLifeSafetyZone, ztest_unit_test(testLifeSafetyZone));
ztest_run_test_suite(testsLifeSafetyZone);
}
+7 -15
View File
@@ -10,11 +10,10 @@
#include <bacnet/bactext.h>
#include <bacnet/basic/object/device.h>
bool Device_Valid_Object_Name(
BACNET_CHARACTER_STRING * object_name,
BACNET_CHARACTER_STRING *object_name,
BACNET_OBJECT_TYPE *object_type,
uint32_t * object_instance)
uint32_t *object_instance)
{
(void)object_name;
(void)object_type;
@@ -22,35 +21,28 @@ bool Device_Valid_Object_Name(
return true;
}
void Device_Inc_Database_Revision(
void)
void Device_Inc_Database_Revision(void)
{
}
uint32_t Device_Object_Instance_Number(
void)
uint32_t Device_Object_Instance_Number(void)
{
return 0;
}
bool Device_Write_Property(
BACNET_WRITE_PROPERTY_DATA * wp_data)
bool Device_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
{
(void)wp_data;
return false;
}
void Device_getCurrentDateTime(
BACNET_DATE_TIME * DateTime)
void Device_getCurrentDateTime(BACNET_DATE_TIME *DateTime)
{
(void)DateTime;
}
int Device_Read_Property(
BACNET_READ_PROPERTY_DATA * rpdata)
int Device_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
{
(void)rpdata;
return 0;
}
+4 -4
View File
@@ -11,10 +11,10 @@
bool tsm_get_transaction_pdu(
uint8_t invokeID,
BACNET_ADDRESS * dest,
BACNET_NPDU_DATA * ndpu_data,
uint8_t * apdu,
uint16_t * apdu_len)
BACNET_ADDRESS *dest,
BACNET_NPDU_DATA *ndpu_data,
uint8_t *apdu,
uint16_t *apdu_len)
{
(void)invokeID;
(void)dest;
+4 -10
View File
@@ -38,12 +38,9 @@ static void testMultistateInput(void)
test_object_instance = Multistate_Input_Index_To_Instance(0);
zassert_equal(object_instance, test_object_instance, NULL);
bacnet_object_properties_read_write_test(
OBJECT_MULTI_STATE_INPUT,
object_instance,
Multistate_Input_Property_Lists,
Multistate_Input_Read_Property,
Multistate_Input_Write_Property,
skip_fail_property_list);
OBJECT_MULTI_STATE_INPUT, object_instance,
Multistate_Input_Property_Lists, Multistate_Input_Read_Property,
Multistate_Input_Write_Property, skip_fail_property_list);
status = Multistate_Input_Delete(object_instance);
zassert_true(status, NULL);
}
@@ -51,15 +48,12 @@ static void testMultistateInput(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(ms_input_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(ms_input_tests,
ztest_unit_test(testMultistateInput)
);
ztest_test_suite(ms_input_tests, ztest_unit_test(testMultistateInput));
ztest_run_test_suite(ms_input_tests);
}
+4 -10
View File
@@ -37,12 +37,9 @@ static void testMultistateOutput(void)
test_object_instance = Multistate_Output_Index_To_Instance(0);
zassert_equal(object_instance, test_object_instance, NULL);
bacnet_object_properties_read_write_test(
OBJECT_MULTI_STATE_OUTPUT,
object_instance,
Multistate_Output_Property_Lists,
Multistate_Output_Read_Property,
Multistate_Output_Write_Property,
skip_fail_property_list);
OBJECT_MULTI_STATE_OUTPUT, object_instance,
Multistate_Output_Property_Lists, Multistate_Output_Read_Property,
Multistate_Output_Write_Property, skip_fail_property_list);
status = Multistate_Output_Delete(object_instance);
zassert_true(status, NULL);
}
@@ -50,15 +47,12 @@ static void testMultistateOutput(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(mso_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(mso_tests,
ztest_unit_test(testMultistateOutput)
);
ztest_test_suite(mso_tests, ztest_unit_test(testMultistateOutput));
ztest_run_test_suite(mso_tests);
}
+4 -10
View File
@@ -38,12 +38,9 @@ static void testMultistateValue(void)
test_object_instance = Multistate_Value_Index_To_Instance(0);
zassert_equal(object_instance, test_object_instance, NULL);
bacnet_object_properties_read_write_test(
OBJECT_MULTI_STATE_VALUE,
object_instance,
Multistate_Value_Property_Lists,
Multistate_Value_Read_Property,
Multistate_Value_Write_Property,
skip_fail_property_list);
OBJECT_MULTI_STATE_VALUE, object_instance,
Multistate_Value_Property_Lists, Multistate_Value_Read_Property,
Multistate_Value_Write_Property, skip_fail_property_list);
status = Multistate_Value_Delete(object_instance);
zassert_true(status, NULL);
}
@@ -51,15 +48,12 @@ static void testMultistateValue(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(msv_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(msv_tests,
ztest_unit_test(testMultistateValue)
);
ztest_test_suite(msv_tests, ztest_unit_test(testMultistateValue));
ztest_run_test_suite(msv_tests);
}
+21 -17
View File
@@ -56,16 +56,19 @@ static void test_Notification_Class(void)
rpdata.object_property = *pRequired;
rpdata.array_index = BACNET_ARRAY_ALL;
len = Notification_Class_Read_Property(&rpdata);
zassert_not_equal(len, BACNET_STATUS_ERROR,
zassert_not_equal(
len, BACNET_STATUS_ERROR,
"property '%s': failed to ReadProperty!\n",
bactext_property_name(rpdata.object_property));
if (len >= 0) {
test_len = bacapp_decode_known_property(rpdata.application_data,
len, &value, rpdata.object_type, rpdata.object_property);
test_len = bacapp_decode_known_property(
rpdata.application_data, len, &value, rpdata.object_type,
rpdata.object_property);
if ((rpdata.object_property != PROP_PRIORITY) &&
(rpdata.object_property != PROP_RECIPIENT_LIST)) {
zassert_equal(len, test_len, "property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
zassert_equal(
len, test_len, "property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
}
/* check WriteProperty properties */
wpdata.object_type = rpdata.object_type;
@@ -78,8 +81,8 @@ static void test_Notification_Class(void)
status = Notification_Class_Write_Property(&wpdata);
if (!status) {
/* verify WriteProperty property is known */
zassert_not_equal(wpdata.error_code,
ERROR_CODE_UNKNOWN_PROPERTY,
zassert_not_equal(
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
"property '%s': WriteProperty Unknown!\n",
bactext_property_name(rpdata.object_property));
}
@@ -90,13 +93,16 @@ static void test_Notification_Class(void)
rpdata.object_property = *pOptional;
rpdata.array_index = BACNET_ARRAY_ALL;
len = Notification_Class_Read_Property(&rpdata);
zassert_not_equal(len, BACNET_STATUS_ERROR,
zassert_not_equal(
len, BACNET_STATUS_ERROR,
"property '%s': failed to ReadProperty!\n",
bactext_property_name(rpdata.object_property));
if (len > 0) {
test_len = bacapp_decode_application_data(rpdata.application_data,
(uint8_t)rpdata.application_data_len, &value);
zassert_equal(len, test_len, "property '%s': failed to decode!\n",
test_len = bacapp_decode_application_data(
rpdata.application_data, (uint8_t)rpdata.application_data_len,
&value);
zassert_equal(
len, test_len, "property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
/* check WriteProperty properties */
wpdata.object_type = rpdata.object_type;
@@ -109,8 +115,8 @@ static void test_Notification_Class(void)
status = Notification_Class_Write_Property(&wpdata);
if (!status) {
/* verify WriteProperty property is known */
zassert_not_equal(wpdata.error_code,
ERROR_CODE_UNKNOWN_PROPERTY,
zassert_not_equal(
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
"property '%s': WriteProperty Unknown!\n",
bactext_property_name(rpdata.object_property));
}
@@ -130,15 +136,13 @@ static void test_Notification_Class(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(notification_class_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(notification_class_tests,
ztest_unit_test(test_Notification_Class)
);
ztest_test_suite(
notification_class_tests, ztest_unit_test(test_Notification_Class));
ztest_run_test_suite(notification_class_tests);
}
+6 -6
View File
@@ -27,8 +27,8 @@ int Send_UEvent_Notify(
return 0;
}
uint8_t Send_CEvent_Notify(
uint32_t device_id, BACNET_EVENT_NOTIFICATION_DATA *data)
uint8_t
Send_CEvent_Notify(uint32_t device_id, BACNET_EVENT_NOTIFICATION_DATA *data)
{
(void)device_id;
(void)data;
@@ -42,10 +42,10 @@ void Send_WhoIs(int32_t low_limit, int32_t high_limit)
}
bool datetime_local(
BACNET_DATE * bdate,
BACNET_TIME * btime,
int16_t * utc_offset_minutes,
bool * dst_active)
BACNET_DATE *bdate,
BACNET_TIME *btime,
int16_t *utc_offset_minutes,
bool *dst_active)
{
(void)bdate;
(void)btime;
+15 -12
View File
@@ -29,14 +29,20 @@ static void test_network_port(void)
bool status = false;
unsigned count = 0;
uint32_t object_instance = 0;
uint8_t port_type[] = { PORT_TYPE_ETHERNET, PORT_TYPE_ARCNET,
PORT_TYPE_MSTP, PORT_TYPE_PTP, PORT_TYPE_LONTALK, PORT_TYPE_BIP,
PORT_TYPE_ZIGBEE, PORT_TYPE_VIRTUAL, PORT_TYPE_NON_BACNET,
PORT_TYPE_BIP6, PORT_TYPE_MAX };
const int known_fail_property_list[] = { PROP_IP_DNS_SERVER,
uint8_t port_type[] = { PORT_TYPE_ETHERNET, PORT_TYPE_ARCNET,
PORT_TYPE_MSTP, PORT_TYPE_PTP,
PORT_TYPE_LONTALK, PORT_TYPE_BIP,
PORT_TYPE_ZIGBEE, PORT_TYPE_VIRTUAL,
PORT_TYPE_NON_BACNET, PORT_TYPE_BIP6,
PORT_TYPE_MAX };
const int known_fail_property_list[] = {
PROP_IP_DNS_SERVER,
PROP_BBMD_BROADCAST_DISTRIBUTION_TABLE,
PROP_BBMD_FOREIGN_DEVICE_TABLE, PROP_FD_BBMD_ADDRESS,
PROP_IPV6_DNS_SERVER, -1 };
PROP_BBMD_FOREIGN_DEVICE_TABLE,
PROP_FD_BBMD_ADDRESS,
PROP_IPV6_DNS_SERVER,
-1
};
while (port_type[port] != PORT_TYPE_MAX) {
object_instance = 1234;
@@ -48,11 +54,8 @@ static void test_network_port(void)
count = Network_Port_Count();
zassert_true(count > 0, NULL);
bacnet_object_properties_read_write_test(
OBJECT_NETWORK_PORT,
object_instance,
Network_Port_Property_Lists,
Network_Port_Read_Property,
Network_Port_Write_Property,
OBJECT_NETWORK_PORT, object_instance, Network_Port_Property_Lists,
Network_Port_Read_Property, Network_Port_Write_Property,
known_fail_property_list);
port++;
}
+1 -3
View File
@@ -71,8 +71,7 @@ void testBACnetObjects(Test *pTest)
for (test_point = 0; test_point < max_test_points; test_point++) {
device_id = test_point * (BACNET_MAX_INSTANCE / max_test_points);
pDevice = objects_device_data(test_point);
testBACnetObjectsCompare(
pTest, pDevice, objects_device_id(test_point));
testBACnetObjectsCompare(pTest, pDevice, objects_device_id(test_point));
}
for (test_point = 0; test_point < max_test_points; test_point++) {
status = objects_device_delete(0);
@@ -99,4 +98,3 @@ int main(void)
return 0;
}
+6 -9
View File
@@ -20,13 +20,14 @@
/**
* @brief Test
*/
static void testBACnetObjectsCompare(
OBJECT_DEVICE_T *pDevice, uint32_t expected_device_id)
static void
testBACnetObjectsCompare(OBJECT_DEVICE_T *pDevice, uint32_t expected_device_id)
{
zassert_not_null(pDevice, NULL);
if (pDevice) {
zassert_not_null(pDevice->Object_List, NULL);
zassert_equal(pDevice->Object_Identifier.instance, expected_device_id, NULL);
zassert_equal(
pDevice->Object_Identifier.instance, expected_device_id, NULL);
zassert_equal(pDevice->Object_Identifier.type, OBJECT_DEVICE, NULL);
zassert_equal(pDevice->Object_Type, OBJECT_DEVICE, NULL);
}
@@ -43,7 +44,6 @@ static void testBACnetObjects(void)
const unsigned max_test_points = 20;
OBJECT_DEVICE_T *pDevice;
/* Verify deleting a non-existant object returns the correct value */
zassert_false(objects_device_delete(0), NULL);
@@ -53,7 +53,7 @@ static void testBACnetObjects(void)
pDevice = objects_device_new(device_id);
testBACnetObjectsCompare(pDevice, device_id);
/* Verify the last created device can be fetched by ID */
/* Verify the last created device can be fetched by ID */
pDevice = objects_device_by_instance(device_id);
testBACnetObjectsCompare(pDevice, device_id);
}
@@ -83,15 +83,12 @@ static void testBACnetObjects(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(objects_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(objects_tests,
ztest_unit_test(testBACnetObjects)
);
ztest_test_suite(objects_tests, ztest_unit_test(testBACnetObjects));
ztest_run_test_suite(objects_tests);
}
+9 -9
View File
@@ -27,7 +27,7 @@ static void testOctetString_Value(void)
uint8_t apdu[MAX_APDU] = { 0 };
int len = 0, test_len = 0;
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
BACNET_APPLICATION_DATA_VALUE value = {0};
BACNET_APPLICATION_DATA_VALUE value = { 0 };
const int *required_property = NULL;
const uint32_t instance = 1;
@@ -44,10 +44,12 @@ static void testOctetString_Value(void)
len = OctetString_Value_Read_Property(&rpdata);
zassert_true(len >= 0, NULL);
if (len >= 0) {
test_len = bacapp_decode_known_property(rpdata.application_data,
len, &value, rpdata.object_type, rpdata.object_property);
test_len = bacapp_decode_known_property(
rpdata.application_data, len, &value, rpdata.object_type,
rpdata.object_property);
if (len != test_len) {
printf("property '%s': failed to decode!\n",
printf(
"property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
}
if (rpdata.object_property == PROP_PRIORITY_ARRAY) {
@@ -56,7 +58,8 @@ static void testOctetString_Value(void)
}
zassert_equal(len, test_len, NULL);
} else {
printf("property '%s': failed to read!\n",
printf(
"property '%s': failed to read!\n",
bactext_property_name(rpdata.object_property));
}
required_property++;
@@ -66,15 +69,12 @@ static void testOctetString_Value(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(osv_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(osv_tests,
ztest_unit_test(testOctetString_Value)
);
ztest_test_suite(osv_tests, ztest_unit_test(testOctetString_Value));
ztest_run_test_suite(osv_tests);
}
+7 -8
View File
@@ -28,7 +28,7 @@ static void testPositiveInteger_Value(void)
uint8_t apdu[MAX_APDU] = { 0 };
int len = 0, test_len = 0;
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
BACNET_APPLICATION_DATA_VALUE value = {0};
BACNET_APPLICATION_DATA_VALUE value = { 0 };
const int *required_property = NULL;
const uint32_t instance = 1;
@@ -45,10 +45,12 @@ static void testPositiveInteger_Value(void)
len = PositiveInteger_Value_Read_Property(&rpdata);
zassert_true(len >= 0, NULL);
if (len >= 0) {
test_len = bacapp_decode_known_property(rpdata.application_data,
len, &value, rpdata.object_type, rpdata.object_property);
test_len = bacapp_decode_known_property(
rpdata.application_data, len, &value, rpdata.object_type,
rpdata.object_property);
if (len != test_len) {
printf("property '%s': failed to decode!\n",
printf(
"property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
}
if (rpdata.object_property == PROP_PRIORITY_ARRAY) {
@@ -64,15 +66,12 @@ static void testPositiveInteger_Value(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(piv_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(piv_tests,
ztest_unit_test(testPositiveInteger_Value)
);
ztest_test_suite(piv_tests, ztest_unit_test(testPositiveInteger_Value));
ztest_run_test_suite(piv_tests);
}
+19 -13
View File
@@ -21,7 +21,8 @@
* are known to fail to decode after reading
* @return true if the property was written successfully, false if not
*/
bool bacnet_object_property_write_test(BACNET_WRITE_PROPERTY_DATA *wpdata,
bool bacnet_object_property_write_test(
BACNET_WRITE_PROPERTY_DATA *wpdata,
write_property_function write_property,
const int *skip_fail_property_list)
{
@@ -34,7 +35,8 @@ bool bacnet_object_property_write_test(BACNET_WRITE_PROPERTY_DATA *wpdata,
status = write_property(wpdata);
if (!status) {
/* verify WriteProperty property is known */
zassert_not_equal(wpdata->error_code, ERROR_CODE_UNKNOWN_PROPERTY,
zassert_not_equal(
wpdata->error_code, ERROR_CODE_UNKNOWN_PROPERTY,
"property '%s': WriteProperty Unknown!\n",
bactext_property_name(wpdata->object_property));
}
@@ -75,7 +77,8 @@ void bacnet_object_property_write_parameter_init(
* are known to fail to decode after reading
* @return length of the property value that was read
*/
int bacnet_object_property_read_test(BACNET_READ_PROPERTY_DATA *rpdata,
int bacnet_object_property_read_test(
BACNET_READ_PROPERTY_DATA *rpdata,
read_property_function read_property,
const int *skip_fail_property_list)
{
@@ -99,8 +102,9 @@ int bacnet_object_property_read_test(BACNET_READ_PROPERTY_DATA *rpdata,
apdu = rpdata->application_data;
apdu_len = read_len;
while (apdu_len) {
len = bacapp_decode_known_property(apdu, apdu_len, &value,
rpdata->object_type, rpdata->object_property);
len = bacapp_decode_known_property(
apdu, apdu_len, &value, rpdata->object_type,
rpdata->object_property);
if (len > 0) {
test_len += len;
if ((len < apdu_len) &&
@@ -116,15 +120,16 @@ int bacnet_object_property_read_test(BACNET_READ_PROPERTY_DATA *rpdata,
break;
}
} else {
printf("property '%s': failed to decode! len=%d\n",
bactext_property_name(rpdata->object_property),
len);
printf(
"property '%s': failed to decode! len=%d\n",
bactext_property_name(rpdata->object_property), len);
break;
}
}
if (read_len != test_len) {
printf("property '%s': failed to decode! %d!=%d\n",
bactext_property_name(rpdata->object_property), test_len,
printf(
"property '%s': failed to decode! %d!=%d\n",
bactext_property_name(rpdata->object_property), test_len,
read_len);
}
if (property_list_member(
@@ -136,8 +141,8 @@ int bacnet_object_property_read_test(BACNET_READ_PROPERTY_DATA *rpdata,
} else if (read_len == 0) {
/* empty response is valid for some properties */
} else {
zassert_not_equal(read_len, BACNET_STATUS_ERROR,
"property '%s': failed to read!\n",
zassert_not_equal(
read_len, BACNET_STATUS_ERROR, "property '%s': failed to read!\n",
bactext_property_name(rpdata->object_property));
}
@@ -155,7 +160,8 @@ int bacnet_object_property_read_test(BACNET_READ_PROPERTY_DATA *rpdata,
* @param skip_fail_property_list The list of properties that
* are known to fail to decode after reading
*/
void bacnet_object_properties_read_write_test(BACNET_OBJECT_TYPE object_type,
void bacnet_object_properties_read_write_test(
BACNET_OBJECT_TYPE object_type,
uint32_t object_instance,
rpm_property_lists_function property_list,
read_property_function read_property,
+6 -11
View File
@@ -27,34 +27,29 @@ static void testSchedule(void)
{
unsigned count = 0;
uint32_t object_instance = 0;
const int skip_fail_property_list[] = {
PROP_LIST_OF_OBJECT_PROPERTY_REFERENCES, -1 };
const int skip_fail_property_list[] = {
PROP_LIST_OF_OBJECT_PROPERTY_REFERENCES, -1
};
Schedule_Init();
count = Schedule_Count();
zassert_true(count > 0, NULL);
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,
OBJECT_SCHEDULE, object_instance, Schedule_Property_Lists,
Schedule_Read_Property, Schedule_Write_Property,
skip_fail_property_list);
}
/**
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(schedule_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(schedule_tests,
ztest_unit_test(testSchedule)
);
ztest_test_suite(schedule_tests, ztest_unit_test(testSchedule));
ztest_run_test_suite(schedule_tests);
}
@@ -37,11 +37,8 @@ static void testTimeValue(void)
zassert_true(count > 0, NULL);
object_instance = Time_Value_Index_To_Instance(0);
bacnet_object_properties_read_write_test(
OBJECT_TIME_VALUE,
object_instance,
Time_Value_Property_Lists,
Time_Value_Read_Property,
Time_Value_Write_Property,
OBJECT_TIME_VALUE, object_instance, Time_Value_Property_Lists,
Time_Value_Read_Property, Time_Value_Write_Property,
skip_fail_property_list);
/* check the delete function */
status = Time_Value_Delete(object_instance);
@@ -56,9 +53,7 @@ ZTEST_SUITE(bacnet_tv, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(tv_tests,
ztest_unit_test(testTimeValue)
);
ztest_test_suite(tv_tests, ztest_unit_test(testTimeValue));
ztest_run_test_suite(tv_tests);
}
+4 -4
View File
@@ -11,10 +11,10 @@
#include "bacnet/datetime.h"
bool datetime_local(
BACNET_DATE * bdate,
BACNET_TIME * btime,
int16_t * utc_offset_minutes,
bool * dst_active)
BACNET_DATE *bdate,
BACNET_TIME *btime,
int16_t *utc_offset_minutes,
bool *dst_active)
{
bdate->year = 2023;
bdate->month = 6;
+4 -7
View File
@@ -33,11 +33,8 @@ static void test_Trend_Log_ReadProperty(void)
status = Trend_Log_Valid_Instance(object_instance);
zassert_true(status, NULL);
bacnet_object_properties_read_write_test(
OBJECT_TRENDLOG,
object_instance,
Trend_Log_Property_Lists,
Trend_Log_Read_Property,
Trend_Log_Write_Property,
OBJECT_TRENDLOG, object_instance, Trend_Log_Property_Lists,
Trend_Log_Read_Property, Trend_Log_Write_Property,
known_fail_property_list);
}
/**
@@ -46,8 +43,8 @@ static void test_Trend_Log_ReadProperty(void)
void test_main(void)
{
ztest_test_suite(trendlog_tests,
ztest_unit_test(test_Trend_Log_ReadProperty));
ztest_test_suite(
trendlog_tests, ztest_unit_test(test_Trend_Log_ReadProperty));
ztest_run_test_suite(trendlog_tests);
}