Feature - added create/delete/COV services for analog, binary, and multistate objects (#612)
* Added Create/Delete object services to Analog Input, Analog Value, Binary Input, Binary Value, Multistate Input, Multistate Value object examples, and updated their units tests.
This commit is contained in:
@@ -23,10 +23,12 @@ set(ZTST_DIR "${TST_DIR}/ztest/src")
|
||||
add_compile_definitions(
|
||||
BIG_ENDIAN=0
|
||||
CONFIG_ZTEST=1
|
||||
INTRINSIC_REPORTING=1
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${SRC_DIR}
|
||||
${TST_DIR}/bacnet/basic/object
|
||||
${TST_DIR}/ztest/include
|
||||
)
|
||||
|
||||
@@ -43,10 +45,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/bactext.c
|
||||
${SRC_DIR}/bacnet/bacapp.c
|
||||
${SRC_DIR}/bacnet/bacdevobjpropref.c
|
||||
${SRC_DIR}/bacnet/basic/sys/bigend.c
|
||||
${SRC_DIR}/bacnet/cov.c
|
||||
${SRC_DIR}/bacnet/datetime.c
|
||||
${SRC_DIR}/bacnet/basic/sys/days.c
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
@@ -59,8 +59,14 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
${SRC_DIR}/bacnet/basic/sys/bigend.c
|
||||
${SRC_DIR}/bacnet/basic/sys/days.c
|
||||
${SRC_DIR}/bacnet/basic/sys/debug.c
|
||||
${SRC_DIR}/bacnet/basic/sys/keylist.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
./stubs.c
|
||||
${TST_DIR}/bacnet/basic/object/property_test.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
${ZTST_DIR}/ztest.c
|
||||
)
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Legrand North America, LLC.
|
||||
/**
|
||||
* @file
|
||||
* @brief Unit test for object
|
||||
* @author Steve Karg <skarg@users.sourceforge.net>
|
||||
* @date April 2024
|
||||
* @section LICENSE
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/* @file
|
||||
* @brief test BACnet integer encode/decode APIs
|
||||
*/
|
||||
|
||||
#include <zephyr/ztest.h>
|
||||
#include <bacnet/basic/object/ai.h>
|
||||
#include <bacnet/bactext.h>
|
||||
#include <property_test.h>
|
||||
|
||||
/**
|
||||
* @addtogroup bacnet_tests
|
||||
@@ -26,36 +25,26 @@ ZTEST(ai_tests, testAnalogInput)
|
||||
static void testAnalogInput(void)
|
||||
#endif
|
||||
{
|
||||
uint8_t apdu[MAX_APDU] = { 0 };
|
||||
int len = 0, test_len = 0;
|
||||
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
|
||||
BACNET_APPLICATION_DATA_VALUE value = {0};
|
||||
const int *required_property = NULL;
|
||||
const uint32_t instance = 1;
|
||||
bool status = false;
|
||||
unsigned count = 0;
|
||||
uint32_t object_instance = BACNET_MAX_INSTANCE, test_object_instance = 0;
|
||||
const int skip_fail_property_list[] = { -1 };
|
||||
|
||||
Analog_Input_Init();
|
||||
rpdata.application_data = &apdu[0];
|
||||
rpdata.application_data_len = sizeof(apdu);
|
||||
rpdata.object_type = OBJECT_ANALOG_INPUT;
|
||||
rpdata.object_instance = instance;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
|
||||
Analog_Input_Property_Lists(&required_property, NULL, NULL);
|
||||
while ((*required_property) >= 0) {
|
||||
rpdata.object_property = *required_property;
|
||||
len = Analog_Input_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);
|
||||
if (len != test_len) {
|
||||
printf("property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
zassert_equal(len, test_len, NULL);
|
||||
}
|
||||
required_property++;
|
||||
}
|
||||
object_instance = Analog_Input_Create(object_instance);
|
||||
count = Analog_Input_Count();
|
||||
zassert_true(count == 1, NULL);
|
||||
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,
|
||||
skip_fail_property_list);
|
||||
status = Analog_Input_Delete(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief Stub functions for unit test of a BACnet object
|
||||
* @author Steve Karg <skarg@users.sourceforge.net>
|
||||
* @date December 2022
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "bacnet/bacdef.h"
|
||||
#include "bacnet/alarm_ack.h"
|
||||
#include "bacnet/datetime.h"
|
||||
#include "bacnet/event.h"
|
||||
#include "bacnet/getevent.h"
|
||||
#include "bacnet/get_alarm_sum.h"
|
||||
#include "bacnet/npdu.h"
|
||||
|
||||
bool datetime_local(BACNET_DATE *bdate,
|
||||
BACNET_TIME *btime,
|
||||
int16_t *utc_offset_minutes,
|
||||
bool *dst_active)
|
||||
{
|
||||
(void)bdate;
|
||||
(void)btime;
|
||||
(void)utc_offset_minutes;
|
||||
(void)dst_active;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Notification_Class_common_reporting_function(
|
||||
BACNET_EVENT_NOTIFICATION_DATA *event_data)
|
||||
{
|
||||
(void)event_data;
|
||||
}
|
||||
|
||||
void Notification_Class_Get_Priorities(
|
||||
uint32_t Object_Instance, uint32_t *pPriorityArray)
|
||||
{
|
||||
(void)Object_Instance;
|
||||
(void)pPriorityArray;
|
||||
}
|
||||
|
||||
void handler_get_event_information_set(
|
||||
BACNET_OBJECT_TYPE object_type, get_event_info_function pFunction)
|
||||
{
|
||||
(void)object_type;
|
||||
(void)pFunction;
|
||||
}
|
||||
|
||||
void handler_alarm_ack_set(
|
||||
BACNET_OBJECT_TYPE object_type, alarm_ack_function pFunction)
|
||||
{
|
||||
(void)object_type;
|
||||
(void)pFunction;
|
||||
}
|
||||
|
||||
void handler_get_alarm_summary_set(
|
||||
BACNET_OBJECT_TYPE object_type, get_alarm_summary_function pFunction)
|
||||
{
|
||||
(void)object_type;
|
||||
(void)pFunction;
|
||||
}
|
||||
@@ -7,7 +7,6 @@ project(test_${basename}
|
||||
VERSION 1.0.0
|
||||
LANGUAGES C)
|
||||
|
||||
|
||||
string(REGEX REPLACE
|
||||
"/test/bacnet/[a-zA-Z_/-]*$"
|
||||
"/src"
|
||||
@@ -27,6 +26,7 @@ add_compile_definitions(
|
||||
|
||||
include_directories(
|
||||
${SRC_DIR}
|
||||
${TST_DIR}/bacnet/basic/object
|
||||
${TST_DIR}/ztest/include
|
||||
)
|
||||
|
||||
@@ -43,14 +43,12 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/bacreal.c
|
||||
${SRC_DIR}/bacnet/bacstr.c
|
||||
${SRC_DIR}/bacnet/bactext.c
|
||||
${SRC_DIR}/bacnet/basic/sys/bigend.c
|
||||
${SRC_DIR}/bacnet/cov.c
|
||||
${SRC_DIR}/bacnet/datetime.c
|
||||
${SRC_DIR}/bacnet/basic/sys/days.c
|
||||
${SRC_DIR}/bacnet/basic/sys/keylist.c
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
${SRC_DIR}/bacnet/proplist.c
|
||||
${SRC_DIR}/bacnet/memcopy.c
|
||||
${SRC_DIR}/bacnet/timestamp.c
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
@@ -59,9 +57,12 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
${SRC_DIR}/bacnet/basic/sys/bigend.c
|
||||
${SRC_DIR}/bacnet/basic/sys/days.c
|
||||
${SRC_DIR}/bacnet/basic/sys/keylist.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
../mock/device_mock.c
|
||||
${TST_DIR}/bacnet/basic/object/property_test.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
${ZTST_DIR}/ztest.c
|
||||
)
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Legrand North America, LLC.
|
||||
/**
|
||||
* @file
|
||||
* @brief Unit test for object
|
||||
* @author Steve Karg <skarg@users.sourceforge.net>
|
||||
* @date April 2024
|
||||
* @section LICENSE
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/* @file
|
||||
* @brief test BACnet integer encode/decode APIs
|
||||
*/
|
||||
|
||||
#include <zephyr/ztest.h>
|
||||
#include <bacnet/basic/object/ao.h>
|
||||
#include <property_test.h>
|
||||
|
||||
/**
|
||||
* @addtogroup bacnet_tests
|
||||
@@ -25,47 +25,26 @@ ZTEST(ao_tests, testAnalogOutput)
|
||||
static void testAnalogOutput(void)
|
||||
#endif
|
||||
{
|
||||
uint8_t apdu[MAX_APDU] = { 0 };
|
||||
int len = 0, test_len = 0;
|
||||
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
|
||||
BACNET_APPLICATION_DATA_VALUE value = {0};
|
||||
const int *required_property = NULL;
|
||||
const uint32_t instance = 1;
|
||||
bool status = false;
|
||||
unsigned count = 0;
|
||||
uint32_t object_instance = BACNET_MAX_INSTANCE, test_object_instance = 0;
|
||||
const int skip_fail_property_list[] = { PROP_PRIORITY_ARRAY, -1 };
|
||||
|
||||
Analog_Output_Init();
|
||||
Analog_Output_Create(1);
|
||||
rpdata.application_data = &apdu[0];
|
||||
rpdata.application_data_len = sizeof(apdu);
|
||||
rpdata.object_type = OBJECT_ANALOG_OUTPUT;
|
||||
rpdata.object_instance = instance;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
|
||||
Analog_Output_Property_Lists(&required_property, NULL, NULL);
|
||||
while ((*required_property) >= 0) {
|
||||
rpdata.object_property = *required_property;
|
||||
len = Analog_Output_Read_Property(&rpdata);
|
||||
if (len < 0) {
|
||||
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);
|
||||
if (len != test_len) {
|
||||
printf("property %u: failed to decode!\n",
|
||||
(unsigned)rpdata.object_property);
|
||||
}
|
||||
if (rpdata.object_property == PROP_PRIORITY_ARRAY) {
|
||||
/* FIXME: known fail to decode */
|
||||
len = test_len;
|
||||
}
|
||||
zassert_equal(len, test_len, NULL);
|
||||
}
|
||||
required_property++;
|
||||
}
|
||||
|
||||
return;
|
||||
object_instance = Analog_Output_Create(object_instance);
|
||||
count = Analog_Output_Count();
|
||||
zassert_true(count == 1, NULL);
|
||||
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,
|
||||
skip_fail_property_list);
|
||||
status = Analog_Output_Delete(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -23,10 +23,12 @@ set(ZTST_DIR "${TST_DIR}/ztest/src")
|
||||
add_compile_definitions(
|
||||
BIG_ENDIAN=0
|
||||
CONFIG_ZTEST=1
|
||||
INTRINSIC_REPORTING=1
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${SRC_DIR}
|
||||
${TST_DIR}/bacnet/basic/object
|
||||
${TST_DIR}/ztest/include
|
||||
)
|
||||
|
||||
@@ -43,10 +45,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/bacreal.c
|
||||
${SRC_DIR}/bacnet/bacstr.c
|
||||
${SRC_DIR}/bacnet/bactext.c
|
||||
${SRC_DIR}/bacnet/basic/sys/bigend.c
|
||||
${SRC_DIR}/bacnet/cov.c
|
||||
${SRC_DIR}/bacnet/datetime.c
|
||||
${SRC_DIR}/bacnet/basic/sys/days.c
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
@@ -59,8 +59,14 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
${SRC_DIR}/bacnet/basic/sys/bigend.c
|
||||
${SRC_DIR}/bacnet/basic/sys/days.c
|
||||
${SRC_DIR}/bacnet/basic/sys/debug.c
|
||||
${SRC_DIR}/bacnet/basic/sys/keylist.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
./stubs.c
|
||||
${TST_DIR}/bacnet/basic/object/property_test.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
${ZTST_DIR}/ztest.c
|
||||
)
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Legrand North America, LLC.
|
||||
/**
|
||||
* @file
|
||||
* @brief Unit test for object
|
||||
* @author Steve Karg <skarg@users.sourceforge.net>
|
||||
* @date April 2024
|
||||
* @section LICENSE
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/* @file
|
||||
* @brief test BACnet integer encode/decode APIs
|
||||
*/
|
||||
|
||||
#include <zephyr/ztest.h>
|
||||
#include <bacnet/basic/object/av.h>
|
||||
#include <property_test.h>
|
||||
|
||||
/**
|
||||
* @addtogroup bacnet_tests
|
||||
@@ -25,40 +25,26 @@ ZTEST(av_tests, testAnalog_Value)
|
||||
static void testAnalog_Value(void)
|
||||
#endif
|
||||
{
|
||||
uint8_t apdu[MAX_APDU] = { 0 };
|
||||
int len = 0, test_len = 0;
|
||||
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
|
||||
BACNET_APPLICATION_DATA_VALUE value = {0};
|
||||
const int *required_property = NULL;
|
||||
const uint32_t instance = 1;
|
||||
bool status = false;
|
||||
unsigned count = 0;
|
||||
uint32_t object_instance = BACNET_MAX_INSTANCE, test_object_instance = 0;
|
||||
const int skip_fail_property_list[] = { -1 };
|
||||
|
||||
Analog_Value_Init();
|
||||
rpdata.application_data = &apdu[0];
|
||||
rpdata.application_data_len = sizeof(apdu);
|
||||
rpdata.object_type = OBJECT_ANALOG_VALUE;
|
||||
rpdata.object_instance = instance;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
|
||||
Analog_Value_Property_Lists(&required_property, NULL, NULL);
|
||||
while ((*required_property) >= 0) {
|
||||
rpdata.object_property = *required_property;
|
||||
len = Analog_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);
|
||||
if (len != test_len) {
|
||||
//printf("property '%s': failed to decode!\n",
|
||||
// bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
if (rpdata.object_property == PROP_PRIORITY_ARRAY) {
|
||||
/* FIXME: known fail to decode */
|
||||
len = test_len;
|
||||
}
|
||||
zassert_equal(len, test_len, NULL);
|
||||
}
|
||||
required_property++;
|
||||
}
|
||||
object_instance = Analog_Value_Create(object_instance);
|
||||
count = Analog_Value_Count();
|
||||
zassert_true(count == 1, NULL);
|
||||
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,
|
||||
skip_fail_property_list);
|
||||
status = Analog_Value_Delete(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief Stub functions for unit test of a BACnet object
|
||||
* @author Steve Karg <skarg@users.sourceforge.net>
|
||||
* @date December 2022
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "bacnet/bacdef.h"
|
||||
#include "bacnet/alarm_ack.h"
|
||||
#include "bacnet/datetime.h"
|
||||
#include "bacnet/event.h"
|
||||
#include "bacnet/getevent.h"
|
||||
#include "bacnet/get_alarm_sum.h"
|
||||
#include "bacnet/npdu.h"
|
||||
|
||||
bool datetime_local(BACNET_DATE *bdate,
|
||||
BACNET_TIME *btime,
|
||||
int16_t *utc_offset_minutes,
|
||||
bool *dst_active)
|
||||
{
|
||||
(void)bdate;
|
||||
(void)btime;
|
||||
(void)utc_offset_minutes;
|
||||
(void)dst_active;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Notification_Class_common_reporting_function(
|
||||
BACNET_EVENT_NOTIFICATION_DATA *event_data)
|
||||
{
|
||||
(void)event_data;
|
||||
}
|
||||
|
||||
void Notification_Class_Get_Priorities(
|
||||
uint32_t Object_Instance, uint32_t *pPriorityArray)
|
||||
{
|
||||
(void)Object_Instance;
|
||||
(void)pPriorityArray;
|
||||
}
|
||||
|
||||
void handler_get_event_information_set(
|
||||
BACNET_OBJECT_TYPE object_type, get_event_info_function pFunction)
|
||||
{
|
||||
(void)object_type;
|
||||
(void)pFunction;
|
||||
}
|
||||
|
||||
void handler_alarm_ack_set(
|
||||
BACNET_OBJECT_TYPE object_type, alarm_ack_function pFunction)
|
||||
{
|
||||
(void)object_type;
|
||||
(void)pFunction;
|
||||
}
|
||||
|
||||
void handler_get_alarm_summary_set(
|
||||
BACNET_OBJECT_TYPE object_type, get_alarm_summary_function pFunction)
|
||||
{
|
||||
(void)object_type;
|
||||
(void)pFunction;
|
||||
}
|
||||
@@ -27,6 +27,7 @@ add_compile_definitions(
|
||||
|
||||
include_directories(
|
||||
${SRC_DIR}
|
||||
${TST_DIR}/bacnet/basic/object
|
||||
${TST_DIR}/ztest/include
|
||||
)
|
||||
|
||||
@@ -43,13 +44,12 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/bacreal.c
|
||||
${SRC_DIR}/bacnet/bacstr.c
|
||||
${SRC_DIR}/bacnet/bactext.c
|
||||
${SRC_DIR}/bacnet/basic/sys/bigend.c
|
||||
${SRC_DIR}/bacnet/cov.c
|
||||
${SRC_DIR}/bacnet/datetime.c
|
||||
${SRC_DIR}/bacnet/basic/sys/days.c
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
${SRC_DIR}/bacnet/proplist.c
|
||||
${SRC_DIR}/bacnet/timestamp.c
|
||||
${SRC_DIR}/bacnet/memcopy.c
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
@@ -58,8 +58,13 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
${SRC_DIR}/bacnet/basic/sys/bigend.c
|
||||
${SRC_DIR}/bacnet/basic/sys/days.c
|
||||
${SRC_DIR}/bacnet/basic/sys/debug.c
|
||||
${SRC_DIR}/bacnet/basic/sys/keylist.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${TST_DIR}/bacnet/basic/object/property_test.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
${ZTST_DIR}/ztest.c
|
||||
)
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Legrand North America, LLC.
|
||||
/**
|
||||
* @file
|
||||
* @brief Unit test for object
|
||||
* @author Steve Karg <skarg@users.sourceforge.net>
|
||||
* @date April 2024
|
||||
* @section LICENSE
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/* @file
|
||||
* @brief test BACnet integer encode/decode APIs
|
||||
*/
|
||||
|
||||
#include <zephyr/ztest.h>
|
||||
#include <bacnet/basic/object/bi.h>
|
||||
#include <bacnet/bactext.h>
|
||||
#include <bacnet/basic/object/bi.h>
|
||||
#include <property_test.h>
|
||||
|
||||
/**
|
||||
* @addtogroup bacnet_tests
|
||||
@@ -26,36 +26,26 @@ ZTEST(bi_tests, testBinaryInput)
|
||||
static void testBinaryInput(void)
|
||||
#endif
|
||||
{
|
||||
uint8_t apdu[MAX_APDU] = { 0 };
|
||||
int len = 0, test_len = 0;
|
||||
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
|
||||
BACNET_APPLICATION_DATA_VALUE value = {0};
|
||||
const int *required_property = NULL;
|
||||
const uint32_t instance = 1;
|
||||
bool status = false;
|
||||
unsigned count = 0;
|
||||
uint32_t object_instance = BACNET_MAX_INSTANCE, test_object_instance = 0;
|
||||
const int skip_fail_property_list[] = { -1 };
|
||||
|
||||
Binary_Input_Init();
|
||||
rpdata.application_data = &apdu[0];
|
||||
rpdata.application_data_len = sizeof(apdu);
|
||||
rpdata.object_type = OBJECT_BINARY_INPUT;
|
||||
rpdata.object_instance = instance;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
|
||||
Binary_Input_Property_Lists(&required_property, NULL, NULL);
|
||||
while ((*required_property) >= 0) {
|
||||
rpdata.object_property = *required_property;
|
||||
len = Binary_Input_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);
|
||||
if (len != test_len) {
|
||||
printf("property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
zassert_equal(len, test_len, NULL);
|
||||
}
|
||||
required_property++;
|
||||
}
|
||||
object_instance = Binary_Input_Create(object_instance);
|
||||
count = Binary_Input_Count();
|
||||
zassert_true(count == 1, NULL);
|
||||
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,
|
||||
skip_fail_property_list);
|
||||
status = Binary_Input_Delete(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -27,6 +27,7 @@ add_compile_definitions(
|
||||
|
||||
include_directories(
|
||||
${SRC_DIR}
|
||||
${TST_DIR}/bacnet/basic/object
|
||||
${TST_DIR}/ztest/include
|
||||
)
|
||||
|
||||
@@ -43,14 +44,12 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/bacreal.c
|
||||
${SRC_DIR}/bacnet/bacstr.c
|
||||
${SRC_DIR}/bacnet/bactext.c
|
||||
${SRC_DIR}/bacnet/basic/sys/bigend.c
|
||||
${SRC_DIR}/bacnet/cov.c
|
||||
${SRC_DIR}/bacnet/datetime.c
|
||||
${SRC_DIR}/bacnet/basic/sys/days.c
|
||||
${SRC_DIR}/bacnet/basic/sys/keylist.c
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
${SRC_DIR}/bacnet/proplist.c
|
||||
${SRC_DIR}/bacnet/memcopy.c
|
||||
${SRC_DIR}/bacnet/timestamp.c
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
@@ -59,9 +58,13 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
${SRC_DIR}/bacnet/basic/sys/bigend.c
|
||||
${SRC_DIR}/bacnet/basic/sys/days.c
|
||||
${SRC_DIR}/bacnet/basic/sys/debug.c
|
||||
${SRC_DIR}/bacnet/basic/sys/keylist.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
../mock/device_mock.c
|
||||
${TST_DIR}/bacnet/basic/object/property_test.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
${ZTST_DIR}/ztest.c
|
||||
)
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Legrand North America, LLC.
|
||||
/**
|
||||
* @file
|
||||
* @brief Unit test for object
|
||||
* @author Steve Karg <skarg@users.sourceforge.net>
|
||||
* @date April 2024
|
||||
* @section LICENSE
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/* @file
|
||||
* @brief test BACnet integer encode/decode APIs
|
||||
*/
|
||||
|
||||
#include <zephyr/ztest.h>
|
||||
#include <bacnet/basic/object/bo.h>
|
||||
#include <property_test.h>
|
||||
|
||||
/**
|
||||
* @addtogroup bacnet_tests
|
||||
@@ -25,45 +25,26 @@ ZTEST(bo_tests, testBinaryOutput)
|
||||
static void testBinaryOutput(void)
|
||||
#endif
|
||||
{
|
||||
uint8_t apdu[MAX_APDU] = { 0 };
|
||||
int len = 0, test_len = 0;
|
||||
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
|
||||
BACNET_APPLICATION_DATA_VALUE value = {0};
|
||||
const int *required_property = NULL;
|
||||
const uint32_t instance = 1;
|
||||
bool status = false;
|
||||
unsigned count = 0;
|
||||
uint32_t object_instance = BACNET_MAX_INSTANCE, test_object_instance = 0;
|
||||
const int skip_fail_property_list[] = { PROP_PRIORITY_ARRAY, -1 };
|
||||
|
||||
Binary_Output_Init();
|
||||
Binary_Output_Create(1);
|
||||
rpdata.application_data = &apdu[0];
|
||||
rpdata.application_data_len = sizeof(apdu);
|
||||
rpdata.object_type = OBJECT_BINARY_OUTPUT;
|
||||
rpdata.object_instance = instance;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
|
||||
Binary_Output_Property_Lists(&required_property, NULL, NULL);
|
||||
while ((*required_property) >= 0) {
|
||||
rpdata.object_property = *required_property;
|
||||
len = Binary_Output_Read_Property(&rpdata);
|
||||
if (len < 0) {
|
||||
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);
|
||||
if (len != test_len) {
|
||||
printf("property %u: failed to decode!\n",
|
||||
(unsigned)rpdata.object_property);
|
||||
}
|
||||
if (rpdata.object_property == PROP_PRIORITY_ARRAY) {
|
||||
/* FIXME: known fail to decode */
|
||||
len = test_len;
|
||||
}
|
||||
zassert_equal(len, test_len, NULL);
|
||||
}
|
||||
required_property++;
|
||||
}
|
||||
object_instance = Binary_Output_Create(object_instance);
|
||||
count = Binary_Output_Count();
|
||||
zassert_true(count == 1, NULL);
|
||||
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,
|
||||
skip_fail_property_list);
|
||||
status = Binary_Output_Delete(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -27,6 +27,7 @@ add_compile_definitions(
|
||||
|
||||
include_directories(
|
||||
${SRC_DIR}
|
||||
${TST_DIR}/bacnet/basic/object
|
||||
${TST_DIR}/ztest/include
|
||||
)
|
||||
|
||||
@@ -43,12 +44,12 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/bacreal.c
|
||||
${SRC_DIR}/bacnet/bacstr.c
|
||||
${SRC_DIR}/bacnet/bactext.c
|
||||
${SRC_DIR}/bacnet/basic/sys/bigend.c
|
||||
${SRC_DIR}/bacnet/cov.c
|
||||
${SRC_DIR}/bacnet/datetime.c
|
||||
${SRC_DIR}/bacnet/basic/sys/days.c
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
${SRC_DIR}/bacnet/proplist.c
|
||||
${SRC_DIR}/bacnet/timestamp.c
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
@@ -56,8 +57,13 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
${SRC_DIR}/bacnet/basic/sys/bigend.c
|
||||
${SRC_DIR}/bacnet/basic/sys/days.c
|
||||
${SRC_DIR}/bacnet/basic/sys/debug.c
|
||||
${SRC_DIR}/bacnet/basic/sys/keylist.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${TST_DIR}/bacnet/basic/object/property_test.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
${ZTST_DIR}/ztest.c
|
||||
)
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
*/
|
||||
|
||||
#include <zephyr/ztest.h>
|
||||
#include <bacnet/bactext.h>
|
||||
#include <bacnet/basic/object/bv.h>
|
||||
#include <property_test.h>
|
||||
|
||||
/**
|
||||
* @addtogroup bacnet_tests
|
||||
@@ -25,40 +27,26 @@ ZTEST(bv_tests, testBinary_Value)
|
||||
static void testBinary_Value(void)
|
||||
#endif
|
||||
{
|
||||
uint8_t apdu[MAX_APDU] = { 0 };
|
||||
int len = 0, test_len = 0;
|
||||
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
|
||||
BACNET_APPLICATION_DATA_VALUE value = {0};
|
||||
const int *required_property = NULL;
|
||||
const uint32_t instance = 1;
|
||||
bool status = false;
|
||||
unsigned count = 0;
|
||||
uint32_t object_instance = BACNET_MAX_INSTANCE, test_object_instance = 0;
|
||||
const int skip_fail_property_list[] = { -1 };
|
||||
|
||||
Binary_Value_Init();
|
||||
rpdata.application_data = &apdu[0];
|
||||
rpdata.application_data_len = sizeof(apdu);
|
||||
rpdata.object_type = OBJECT_BINARY_VALUE;
|
||||
rpdata.object_instance = instance;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
|
||||
Binary_Value_Property_Lists(&required_property, NULL, NULL);
|
||||
while ((*required_property) >= 0) {
|
||||
rpdata.object_property = *required_property;
|
||||
len = Binary_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);
|
||||
if (len != test_len) {
|
||||
//printf("property '%s': failed to decode!\n",
|
||||
// bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
if (rpdata.object_property == PROP_PRIORITY_ARRAY) {
|
||||
/* FIXME: known fail to decode */
|
||||
len = test_len;
|
||||
}
|
||||
zassert_equal(len, test_len, NULL);
|
||||
}
|
||||
required_property++;
|
||||
}
|
||||
object_instance = Binary_Value_Create(object_instance);
|
||||
count = Binary_Value_Count();
|
||||
zassert_true(count == 1, NULL);
|
||||
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,
|
||||
skip_fail_property_list);
|
||||
status = Binary_Value_Delete(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
* @brief Unit test for object
|
||||
* @author Steve Karg <skarg@users.sourceforge.net>
|
||||
* @date July 2023
|
||||
* @section LICENSE
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <zephyr/ztest.h>
|
||||
#include <bacnet/basic/object/channel.h>
|
||||
#include <bacnet/bactext.h>
|
||||
|
||||
@@ -27,6 +27,7 @@ add_compile_definitions(
|
||||
|
||||
include_directories(
|
||||
${SRC_DIR}
|
||||
${TST_DIR}/bacnet/basic/object
|
||||
${TST_DIR}/ztest/include
|
||||
)
|
||||
|
||||
@@ -43,12 +44,12 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/bacreal.c
|
||||
${SRC_DIR}/bacnet/bacstr.c
|
||||
${SRC_DIR}/bacnet/bactext.c
|
||||
${SRC_DIR}/bacnet/basic/sys/bigend.c
|
||||
${SRC_DIR}/bacnet/cov.c
|
||||
${SRC_DIR}/bacnet/datetime.c
|
||||
${SRC_DIR}/bacnet/basic/sys/days.c
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
${SRC_DIR}/bacnet/proplist.c
|
||||
${SRC_DIR}/bacnet/timestamp.c
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
@@ -56,9 +57,13 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
${SRC_DIR}/bacnet/basic/sys/bigend.c
|
||||
${SRC_DIR}/bacnet/basic/sys/days.c
|
||||
${SRC_DIR}/bacnet/basic/sys/debug.c
|
||||
${SRC_DIR}/bacnet/basic/sys/keylist.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
../mock/device_mock.c
|
||||
${TST_DIR}/bacnet/basic/object/property_test.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
${ZTST_DIR}/ztest.c
|
||||
)
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Legrand North America, LLC.
|
||||
/**
|
||||
* @file
|
||||
* @brief Unit test for object
|
||||
* @author Steve Karg <skarg@users.sourceforge.net>
|
||||
* @date April 2024
|
||||
* @section LICENSE
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/* @file
|
||||
* @brief test BACnet integer encode/decode APIs
|
||||
*/
|
||||
|
||||
#include <zephyr/ztest.h>
|
||||
#include <bacnet/basic/object/ms-input.h>
|
||||
#include <bacnet/bactext.h>
|
||||
#include <property_test.h>
|
||||
|
||||
/**
|
||||
* @addtogroup bacnet_tests
|
||||
@@ -26,68 +26,26 @@ ZTEST(ms_input_tests, testMultistateInput)
|
||||
static void testMultistateInput(void)
|
||||
#endif
|
||||
{
|
||||
uint8_t apdu[MAX_APDU] = { 0 };
|
||||
int len = 0, test_len = 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;
|
||||
unsigned count = 0;
|
||||
bool status = false;
|
||||
unsigned count = 0;
|
||||
uint32_t object_instance = BACNET_MAX_INSTANCE, test_object_instance = 0;
|
||||
const int skip_fail_property_list[] = { -1 };
|
||||
|
||||
Multistate_Input_Init();
|
||||
object_instance = Multistate_Input_Create(object_instance);
|
||||
count = Multistate_Input_Count();
|
||||
zassert_true(count > 0, NULL);
|
||||
rpdata.application_data = &apdu[0];
|
||||
rpdata.application_data_len = sizeof(apdu);
|
||||
rpdata.object_type = OBJECT_MULTI_STATE_INPUT;
|
||||
rpdata.object_instance = Multistate_Input_Index_To_Instance(0);
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
status = Multistate_Input_Valid_Instance(rpdata.object_instance);
|
||||
zassert_true(count == 1, NULL);
|
||||
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);
|
||||
status = Multistate_Input_Delete(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
Multistate_Input_Property_Lists(&pRequired, &pOptional, &pProprietary);
|
||||
while ((*pRequired) >= 0) {
|
||||
rpdata.object_property = *pRequired;
|
||||
len = Multistate_Input_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);
|
||||
if (len != test_len) {
|
||||
printf("property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
if (rpdata.object_property == PROP_PRIORITY_ARRAY) {
|
||||
/* FIXME: known fail to decode */
|
||||
len = test_len;
|
||||
}
|
||||
zassert_equal(len, test_len, NULL);
|
||||
} else {
|
||||
printf("property '%s': failed to read!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
pRequired++;
|
||||
}
|
||||
while ((*pOptional) != -1) {
|
||||
rpdata.object_property = *pOptional;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Multistate_Input_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR, NULL);
|
||||
if (len > 0) {
|
||||
test_len = bacapp_decode_application_data(rpdata.application_data,
|
||||
(uint8_t)rpdata.application_data_len, &value);
|
||||
if (len != test_len) {
|
||||
printf("property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
zassert_true(test_len >= 0, NULL);
|
||||
} else {
|
||||
printf("property '%s': failed to read!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
pOptional++;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -27,6 +27,7 @@ add_compile_definitions(
|
||||
|
||||
include_directories(
|
||||
${SRC_DIR}
|
||||
${TST_DIR}/bacnet/basic/object
|
||||
${TST_DIR}/ztest/include
|
||||
)
|
||||
|
||||
@@ -43,14 +44,12 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/bacreal.c
|
||||
${SRC_DIR}/bacnet/bacstr.c
|
||||
${SRC_DIR}/bacnet/bactext.c
|
||||
${SRC_DIR}/bacnet/basic/sys/bigend.c
|
||||
${SRC_DIR}/bacnet/cov.c
|
||||
${SRC_DIR}/bacnet/datetime.c
|
||||
${SRC_DIR}/bacnet/basic/sys/days.c
|
||||
${SRC_DIR}/bacnet/basic/sys/keylist.c
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
${SRC_DIR}/bacnet/proplist.c
|
||||
${SRC_DIR}/bacnet/memcopy.c
|
||||
${SRC_DIR}/bacnet/timestamp.c
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
@@ -59,9 +58,13 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
${SRC_DIR}/bacnet/basic/sys/bigend.c
|
||||
${SRC_DIR}/bacnet/basic/sys/days.c
|
||||
${SRC_DIR}/bacnet/basic/sys/debug.c
|
||||
${SRC_DIR}/bacnet/basic/sys/keylist.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
../mock/device_mock.c
|
||||
${TST_DIR}/bacnet/basic/object/property_test.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
${ZTST_DIR}/ztest.c
|
||||
)
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Legrand North America, LLC.
|
||||
/**
|
||||
* @file
|
||||
* @brief Unit test for object
|
||||
* @author Steve Karg <skarg@users.sourceforge.net>
|
||||
* @date April 2024
|
||||
* @section LICENSE
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/* @file
|
||||
* @brief test BACnet integer encode/decode APIs
|
||||
*/
|
||||
|
||||
#include <zephyr/ztest.h>
|
||||
#include <bacnet/basic/object/mso.h>
|
||||
#include <property_test.h>
|
||||
|
||||
/**
|
||||
* @addtogroup bacnet_tests
|
||||
@@ -25,47 +25,26 @@ ZTEST(mso_tests, testMultistateOutput)
|
||||
static void testMultistateOutput(void)
|
||||
#endif
|
||||
{
|
||||
uint8_t apdu[MAX_APDU] = { 0 };
|
||||
int len = 0, test_len = 0;
|
||||
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
|
||||
BACNET_APPLICATION_DATA_VALUE value = {0};
|
||||
const int *required_property = NULL;
|
||||
const uint32_t instance = 1;
|
||||
bool status = false;
|
||||
unsigned count = 0;
|
||||
uint32_t object_instance = BACNET_MAX_INSTANCE, test_object_instance = 0;
|
||||
const int skip_fail_property_list[] = { PROP_PRIORITY_ARRAY, -1 };
|
||||
|
||||
Multistate_Output_Init();
|
||||
Multistate_Output_Create(1);
|
||||
rpdata.application_data = &apdu[0];
|
||||
rpdata.application_data_len = sizeof(apdu);
|
||||
rpdata.object_type = OBJECT_MULTI_STATE_OUTPUT;
|
||||
rpdata.object_instance = instance;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
|
||||
Multistate_Output_Property_Lists(&required_property, NULL, NULL);
|
||||
while ((*required_property) >= 0) {
|
||||
rpdata.object_property = *required_property;
|
||||
len = Multistate_Output_Read_Property(&rpdata);
|
||||
if (len < 0) {
|
||||
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);
|
||||
if (len != test_len) {
|
||||
printf("property %u: failed to decode!\n",
|
||||
(unsigned)rpdata.object_property);
|
||||
}
|
||||
if (rpdata.object_property == PROP_PRIORITY_ARRAY) {
|
||||
/* FIXME: known fail to decode */
|
||||
len = test_len;
|
||||
}
|
||||
zassert_equal(len, test_len, NULL);
|
||||
}
|
||||
required_property++;
|
||||
}
|
||||
|
||||
return;
|
||||
object_instance = Multistate_Output_Create(object_instance);
|
||||
count = Multistate_Output_Count();
|
||||
zassert_true(count == 1, NULL);
|
||||
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);
|
||||
status = Multistate_Output_Delete(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -27,6 +27,7 @@ add_compile_definitions(
|
||||
|
||||
include_directories(
|
||||
${SRC_DIR}
|
||||
${TST_DIR}/bacnet/basic/object
|
||||
${TST_DIR}/ztest/include
|
||||
)
|
||||
|
||||
@@ -43,23 +44,26 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/bacreal.c
|
||||
${SRC_DIR}/bacnet/bacstr.c
|
||||
${SRC_DIR}/bacnet/bactext.c
|
||||
${SRC_DIR}/bacnet/basic/sys/bigend.c
|
||||
${SRC_DIR}/bacnet/cov.c
|
||||
${SRC_DIR}/bacnet/datetime.c
|
||||
${SRC_DIR}/bacnet/basic/sys/days.c
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
${SRC_DIR}/bacnet/proplist.c
|
||||
${SRC_DIR}/bacnet/timestamp.c
|
||||
${SRC_DIR}/bacnet/memcopy.c
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
${SRC_DIR}/bacnet/basic/sys/bigend.c
|
||||
${SRC_DIR}/bacnet/basic/sys/days.c
|
||||
${SRC_DIR}/bacnet/basic/sys/debug.c
|
||||
${SRC_DIR}/bacnet/basic/sys/keylist.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${TST_DIR}/bacnet/basic/object/property_test.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
${ZTST_DIR}/ztest.c
|
||||
)
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Legrand North America, LLC.
|
||||
/**
|
||||
* @file
|
||||
* @brief Unit test for object
|
||||
* @author Steve Karg <skarg@users.sourceforge.net>
|
||||
* @date April 2024
|
||||
* @section LICENSE
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/* @file
|
||||
* @brief test BACnet integer encode/decode APIs
|
||||
*/
|
||||
|
||||
#include <zephyr/ztest.h>
|
||||
#include <bacnet/basic/object/msv.h>
|
||||
#include <bacnet/bactext.h>
|
||||
#include <property_test.h>
|
||||
|
||||
/**
|
||||
* @addtogroup bacnet_tests
|
||||
@@ -26,70 +26,26 @@ ZTEST(msv_tests, testMultistateValue)
|
||||
static void testMultistateValue(void)
|
||||
#endif
|
||||
{
|
||||
uint8_t apdu[MAX_APDU] = { 0 };
|
||||
int len = 0;
|
||||
int test_len = 0;
|
||||
BACNET_READ_PROPERTY_DATA rpdata;
|
||||
/* for decode value data */
|
||||
BACNET_APPLICATION_DATA_VALUE value;
|
||||
const int *pRequired = NULL;
|
||||
const int *pOptional = NULL;
|
||||
const int *pProprietary = NULL;
|
||||
unsigned count = 0;
|
||||
bool status = false;
|
||||
unsigned count = 0;
|
||||
uint32_t object_instance = BACNET_MAX_INSTANCE, test_object_instance = 0;
|
||||
const int skip_fail_property_list[] = { -1 };
|
||||
|
||||
Multistate_Value_Init();
|
||||
object_instance = Multistate_Value_Create(object_instance);
|
||||
count = Multistate_Value_Count();
|
||||
zassert_true(count > 0, NULL);
|
||||
rpdata.application_data = &apdu[0];
|
||||
rpdata.application_data_len = sizeof(apdu);
|
||||
rpdata.object_type = OBJECT_MULTI_STATE_VALUE;
|
||||
rpdata.object_instance = Multistate_Value_Index_To_Instance(0);;
|
||||
status = Multistate_Value_Valid_Instance(rpdata.object_instance);
|
||||
zassert_true(count == 1, NULL);
|
||||
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);
|
||||
status = Multistate_Value_Delete(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
Multistate_Value_Property_Lists(&pRequired, &pOptional, &pProprietary);
|
||||
while ((*pRequired) != -1) {
|
||||
rpdata.object_property = *pRequired;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Multistate_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);
|
||||
if (len != test_len) {
|
||||
printf("property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
if (rpdata.object_property == PROP_PRIORITY_ARRAY) {
|
||||
/* FIXME: known fail to decode */
|
||||
len = test_len;
|
||||
}
|
||||
zassert_true(test_len >= 0, NULL);
|
||||
} else {
|
||||
printf("property '%s': failed to read!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
pRequired++;
|
||||
}
|
||||
while ((*pOptional) != -1) {
|
||||
rpdata.object_property = *pOptional;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Multistate_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);
|
||||
if (len != test_len) {
|
||||
printf("property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
zassert_true(test_len >= 0, NULL);
|
||||
} else {
|
||||
printf("property '%s': failed to read!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
pOptional++;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
|
||||
Reference in New Issue
Block a user