Fixed unit test compiler warnings
This commit is contained in:
@@ -105,6 +105,7 @@ if (CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID MATCHES "AppleCla
|
|||||||
add_compile_options(-Wall -Wextra -pedantic)
|
add_compile_options(-Wall -Wextra -pedantic)
|
||||||
add_compile_options(-Wfloat-equal -Wconversion)
|
add_compile_options(-Wfloat-equal -Wconversion)
|
||||||
add_compile_options(-Wredundant-decls -Wswitch-default)
|
add_compile_options(-Wredundant-decls -Wswitch-default)
|
||||||
|
add_compile_options(-Wunused-variable)
|
||||||
# don't warn about conversion, sign, compares, long long and attributes
|
# don't warn about conversion, sign, compares, long long and attributes
|
||||||
# since they are common in embedded
|
# since they are common in embedded
|
||||||
add_compile_options(-Wno-sign-conversion -Wno-conversion)
|
add_compile_options(-Wno-sign-conversion -Wno-conversion)
|
||||||
|
|||||||
+5
-2
@@ -146,12 +146,15 @@ CSTANDARD ?= -std=gnu89
|
|||||||
OPTIMIZATION ?= -Os
|
OPTIMIZATION ?= -Os
|
||||||
DEBUGGING ?=
|
DEBUGGING ?=
|
||||||
# enable all relevant warnings that find bugs
|
# enable all relevant warnings that find bugs
|
||||||
WARNING_ALL := -Wall -Wextra -Wfloat-equal -Wconversion
|
WARNING_ALL := -Wall -Wextra -pedantic
|
||||||
WARNING_ALL += -Wredundant-decls -Wswitch-default -pedantic
|
WARNING_ALL += -Wfloat-equal -Wconversion
|
||||||
|
WARNING_ALL += -Wredundant-decls -Wswitch-default
|
||||||
|
WARNING_ALL += -Wunused-variable
|
||||||
# don't warn about conversion, sign, compares, long long and attributes
|
# don't warn about conversion, sign, compares, long long and attributes
|
||||||
# since they are common in embedded
|
# since they are common in embedded
|
||||||
WARNING_ALL += -Wno-sign-conversion -Wno-conversion -Wno-sign-compare
|
WARNING_ALL += -Wno-sign-conversion -Wno-conversion -Wno-sign-compare
|
||||||
WARNING_ALL += -Wno-long-long -Wno-attributes
|
WARNING_ALL += -Wno-long-long -Wno-attributes
|
||||||
|
# don't warn about implicit fallthrough since it's common in network protocols
|
||||||
WARNING_ALL += -Wno-implicit-fallthrough
|
WARNING_ALL += -Wno-implicit-fallthrough
|
||||||
#WARNING_ALL += -Werror
|
#WARNING_ALL += -Werror
|
||||||
WARNINGS ?= $(WARNING_ALL)
|
WARNINGS ?= $(WARNING_ALL)
|
||||||
|
|||||||
+1
-1
@@ -1069,8 +1069,8 @@ static int decode_priority_array_value(
|
|||||||
BACNET_OBJECT_TYPE object_type)
|
BACNET_OBJECT_TYPE object_type)
|
||||||
{
|
{
|
||||||
int apdu_len = 0;
|
int apdu_len = 0;
|
||||||
int len = 0;
|
|
||||||
#if defined(BACAPP_COMPLEX_TYPES)
|
#if defined(BACAPP_COMPLEX_TYPES)
|
||||||
|
int len = 0;
|
||||||
BACNET_APPLICATION_TAG tag = MAX_BACNET_APPLICATION_TAG;
|
BACNET_APPLICATION_TAG tag = MAX_BACNET_APPLICATION_TAG;
|
||||||
|
|
||||||
if (bacnet_is_opening_tag_number(apdu, apdu_size, 0, &len)) {
|
if (bacnet_is_opening_tag_number(apdu, apdu_size, 0, &len)) {
|
||||||
|
|||||||
@@ -1602,7 +1602,6 @@ int bvlc6_broadcast_distribution_table_entry_encode(uint8_t *apdu,
|
|||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
int apdu_len = 0;
|
int apdu_len = 0;
|
||||||
int entry_size = 0;
|
|
||||||
BACNET_OCTET_STRING octet_string;
|
BACNET_OCTET_STRING octet_string;
|
||||||
|
|
||||||
if (bdt_entry) {
|
if (bdt_entry) {
|
||||||
|
|||||||
+2
-5
@@ -15,20 +15,17 @@ if (CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID MATCHES "GNU")
|
|||||||
add_definitions(-fprofile-arcs -ftest-coverage)
|
add_definitions(-fprofile-arcs -ftest-coverage)
|
||||||
add_compile_options(-g -O0 -W -fprofile-arcs -ftest-coverage)
|
add_compile_options(-g -O0 -W -fprofile-arcs -ftest-coverage)
|
||||||
# enable all relevant warnings that find bugs
|
# enable all relevant warnings that find bugs
|
||||||
|
add_compile_options(-Werror)
|
||||||
add_compile_options(-Wall -Wextra -pedantic)
|
add_compile_options(-Wall -Wextra -pedantic)
|
||||||
add_compile_options(-Wfloat-equal -Wconversion)
|
add_compile_options(-Wfloat-equal -Wconversion)
|
||||||
add_compile_options(-Wredundant-decls -Wswitch-default)
|
add_compile_options(-Wredundant-decls -Wswitch-default)
|
||||||
|
add_compile_options(-Wunused-variable)
|
||||||
# don't warn about conversion, sign, compares, long long and attributes
|
# don't warn about conversion, sign, compares, long long and attributes
|
||||||
# since they are common in embedded
|
# since they are common in embedded
|
||||||
add_compile_options(-Wno-sign-conversion -Wno-conversion)
|
add_compile_options(-Wno-sign-conversion -Wno-conversion)
|
||||||
add_compile_options(-Wno-sign-compare -Wno-long-long -Wno-attributes)
|
add_compile_options(-Wno-sign-compare -Wno-long-long -Wno-attributes)
|
||||||
# don't warn about implicit fallthrough since it's common in network protocols
|
# don't warn about implicit fallthrough since it's common in network protocols
|
||||||
add_compile_options(-Wno-implicit-fallthrough)
|
add_compile_options(-Wno-implicit-fallthrough)
|
||||||
# FIXME: ignore some warnings that occur in the unit tests
|
|
||||||
add_compile_options(-Wno-missing-braces)
|
|
||||||
add_compile_options(-Wno-unused-variable)
|
|
||||||
add_compile_options(-Wno-unused-function)
|
|
||||||
add_compile_options(-Wno-unused-parameter)
|
|
||||||
add_link_options(-fprofile-arcs -ftest-coverage)
|
add_link_options(-fprofile-arcs -ftest-coverage)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -7,7 +7,7 @@
|
|||||||
# all: demos router-ipv6 ${DEMO_LINUX}
|
# all: demos router-ipv6 ${DEMO_LINUX}
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: test
|
all: test coverage
|
||||||
|
|
||||||
BUILD_DIR=build
|
BUILD_DIR=build
|
||||||
|
|
||||||
@@ -56,12 +56,14 @@ test:
|
|||||||
[ -d $(BUILD_DIR) ] && cd $(BUILD_DIR) && cmake .. && cd ..
|
[ -d $(BUILD_DIR) ] && cd $(BUILD_DIR) && cmake .. && cd ..
|
||||||
[ -d $(BUILD_DIR) ] && cd $(BUILD_DIR) && cmake --build . $(JOBS) --clean-first && cd ..
|
[ -d $(BUILD_DIR) ] && cd $(BUILD_DIR) && cmake --build . $(JOBS) --clean-first && cd ..
|
||||||
[ -d $(BUILD_DIR) ] && cd $(BUILD_DIR) && ctest $(CTEST_OPTIONS)
|
[ -d $(BUILD_DIR) ] && cd $(BUILD_DIR) && ctest $(CTEST_OPTIONS)
|
||||||
[ -d $(BUILD_DIR) ] && $(MAKE) -C $(BUILD_DIR) lcov
|
|
||||||
|
|
||||||
.PHONY: retest
|
.PHONY: retest
|
||||||
retest:
|
retest:
|
||||||
[ -d $(BUILD_DIR) ] && cd $(BUILD_DIR) && cmake --build . $(JOBS) && cd ..
|
[ -d $(BUILD_DIR) ] && cd $(BUILD_DIR) && cmake --build . $(JOBS) && cd ..
|
||||||
[ -d $(BUILD_DIR) ] && cd $(BUILD_DIR) && ctest $(CTEST_OPTIONS)
|
[ -d $(BUILD_DIR) ] && cd $(BUILD_DIR) && ctest $(CTEST_OPTIONS)
|
||||||
|
|
||||||
|
.PHONY: coverage
|
||||||
|
coverage:
|
||||||
[ -d $(BUILD_DIR) ] && $(MAKE) -C $(BUILD_DIR) lcov
|
[ -d $(BUILD_DIR) ] && $(MAKE) -C $(BUILD_DIR) lcov
|
||||||
|
|
||||||
.PHONY: report
|
.PHONY: report
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ static void test_BACNET_ADDRESS(void)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
BACNET_ADDRESS src = { 0 }, dest = { 0 };
|
BACNET_ADDRESS src = { 0 }, dest = { 0 };
|
||||||
BACNET_ADDRESS test_src = { 0 }, test_dest = { 0 };
|
|
||||||
BACNET_MAC_ADDRESS mac = { 0 }, adr = { 0 };
|
BACNET_MAC_ADDRESS mac = { 0 }, adr = { 0 };
|
||||||
uint16_t dnet = 0;
|
uint16_t dnet = 0;
|
||||||
bool status = false;
|
bool status = false;
|
||||||
|
|||||||
@@ -71,7 +71,9 @@ static const BACNET_APPLICATION_TAG tag_list[] = {
|
|||||||
/* BACnetActionCommand */
|
/* BACnetActionCommand */
|
||||||
BACNET_APPLICATION_TAG_ACTION_COMMAND,
|
BACNET_APPLICATION_TAG_ACTION_COMMAND,
|
||||||
/* BACnetScale */
|
/* BACnetScale */
|
||||||
BACNET_APPLICATION_TAG_SCALE
|
BACNET_APPLICATION_TAG_SCALE,
|
||||||
|
/* BACnetShedLevel */
|
||||||
|
BACNET_APPLICATION_TAG_SHED_LEVEL
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -578,7 +578,6 @@ static void testBACnetDateRangeDecodes(void)
|
|||||||
int len;
|
int len;
|
||||||
int null_len;
|
int null_len;
|
||||||
int test_len;
|
int test_len;
|
||||||
int outLen2;
|
|
||||||
|
|
||||||
BACNET_DATE_RANGE data;
|
BACNET_DATE_RANGE data;
|
||||||
BACNET_DATE_RANGE test_data;
|
BACNET_DATE_RANGE test_data;
|
||||||
@@ -1212,8 +1211,6 @@ static void testBACDCodeBitString(void)
|
|||||||
BACNET_BIT_STRING value;
|
BACNET_BIT_STRING value;
|
||||||
BACNET_BIT_STRING test_value;
|
BACNET_BIT_STRING test_value;
|
||||||
uint8_t apdu[MAX_APDU] = { 0 };
|
uint8_t apdu[MAX_APDU] = { 0 };
|
||||||
uint32_t len_value = 0;
|
|
||||||
uint8_t tag_number = 0;
|
|
||||||
int len, null_len, apdu_len, test_len;
|
int len, null_len, apdu_len, test_len;
|
||||||
BACNET_TAG tag = { 0 };
|
BACNET_TAG tag = { 0 };
|
||||||
|
|
||||||
@@ -1386,12 +1383,12 @@ static void testSignedContextDecodes(void)
|
|||||||
value = BIT(i);
|
value = BIT(i);
|
||||||
for (j = 0; j < 8; j++) {
|
for (j = 0; j < 8; j++) {
|
||||||
context_tag = BIT(j);
|
context_tag = BIT(j);
|
||||||
test_unsigned_context_codec(value, context_tag);
|
test_signed_context_codec(value, context_tag);
|
||||||
}
|
}
|
||||||
value = BIT(i) | BIT(31);
|
value = BIT(i) | BIT(31);
|
||||||
for (j = 0; j < 8; j++) {
|
for (j = 0; j < 8; j++) {
|
||||||
context_tag = BIT(j);
|
context_tag = BIT(j);
|
||||||
test_unsigned_context_codec(value, context_tag);
|
test_signed_context_codec(value, context_tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1438,7 +1435,6 @@ ZTEST(bacdcode_tests, testEnumeratedContextDecodes)
|
|||||||
static void testEnumeratedContextDecodes(void)
|
static void testEnumeratedContextDecodes(void)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
uint8_t apdu[MAX_APDU] = { 0 };
|
|
||||||
uint8_t context_tag = 10;
|
uint8_t context_tag = 10;
|
||||||
|
|
||||||
/* 32-bit value */
|
/* 32-bit value */
|
||||||
|
|||||||
@@ -73,16 +73,28 @@ static void testBACnetDestination(void)
|
|||||||
{
|
{
|
||||||
uint8_t apdu[MAX_APDU] = { 0 };
|
uint8_t apdu[MAX_APDU] = { 0 };
|
||||||
BACNET_DESTINATION destination = { 0 }, test_destination = { 0 };
|
BACNET_DESTINATION destination = { 0 }, test_destination = { 0 };
|
||||||
int len = 0, apdu_len = 0, null_len = 0, test_len = 0;
|
int apdu_len = 0, null_len = 0, test_len = 0;
|
||||||
|
|
||||||
destination.Recipient.tag = BACNET_RECIPIENT_TAG_DEVICE;
|
destination.Recipient.tag = BACNET_RECIPIENT_TAG_DEVICE;
|
||||||
|
destination.Recipient.type.device.type = OBJECT_DEVICE;
|
||||||
|
destination.Recipient.type.device.instance = 1234;
|
||||||
null_len = bacnet_destination_encode(NULL, &destination);
|
null_len = bacnet_destination_encode(NULL, &destination);
|
||||||
apdu_len = bacnet_destination_encode(apdu, &destination);
|
apdu_len = bacnet_destination_encode(apdu, &destination);
|
||||||
zassert_equal(apdu_len, null_len, NULL);
|
zassert_equal(apdu_len, null_len, NULL);
|
||||||
test_len = bacnet_destination_decode(apdu, apdu_len, &test_destination);
|
test_len = bacnet_destination_decode(apdu, apdu_len, &test_destination);
|
||||||
zassert_equal(apdu_len, test_len, NULL);
|
zassert_equal(apdu_len, test_len, NULL);
|
||||||
|
testBACnetRecipientData(&destination.Recipient,
|
||||||
|
&test_destination.Recipient);
|
||||||
|
|
||||||
destination.Recipient.tag = BACNET_RECIPIENT_TAG_ADDRESS;
|
destination.Recipient.tag = BACNET_RECIPIENT_TAG_ADDRESS;
|
||||||
|
destination.Recipient.type.address.net = 1234;
|
||||||
|
destination.Recipient.type.address.len = 6;
|
||||||
|
destination.Recipient.type.address.adr[0] = 1;
|
||||||
|
destination.Recipient.type.address.adr[1] = 2;
|
||||||
|
destination.Recipient.type.address.adr[2] = 3;
|
||||||
|
destination.Recipient.type.address.adr[3] = 4;
|
||||||
|
destination.Recipient.type.address.adr[4] = 5;
|
||||||
|
destination.Recipient.type.address.adr[5] = 6;
|
||||||
null_len = bacnet_destination_encode(NULL, &destination);
|
null_len = bacnet_destination_encode(NULL, &destination);
|
||||||
apdu_len = bacnet_destination_encode(apdu, &destination);
|
apdu_len = bacnet_destination_encode(apdu, &destination);
|
||||||
zassert_equal(apdu_len, null_len, NULL);
|
zassert_equal(apdu_len, null_len, NULL);
|
||||||
|
|||||||
@@ -51,6 +51,11 @@ static BACNET_IP_ADDRESS Test_Sent_Message_Dest;
|
|||||||
uint16_t bip_receive(
|
uint16_t bip_receive(
|
||||||
BACNET_ADDRESS *src, uint8_t *npdu, uint16_t max_npdu, unsigned timeout)
|
BACNET_ADDRESS *src, uint8_t *npdu, uint16_t max_npdu, unsigned timeout)
|
||||||
{
|
{
|
||||||
|
(void)src;
|
||||||
|
(void)npdu;
|
||||||
|
(void)max_npdu;
|
||||||
|
(void)timeout;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,11 @@ static BACNET_IP6_ADDRESS Test_Sent_Message_Dest;
|
|||||||
uint16_t bip6_receive(
|
uint16_t bip6_receive(
|
||||||
BACNET_ADDRESS *src, uint8_t *npdu, uint16_t max_npdu, unsigned timeout)
|
BACNET_ADDRESS *src, uint8_t *npdu, uint16_t max_npdu, unsigned timeout)
|
||||||
{
|
{
|
||||||
|
(void)src;
|
||||||
|
(void)npdu;
|
||||||
|
(void)max_npdu;
|
||||||
|
(void)timeout;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,9 @@
|
|||||||
* @addtogroup bacnet_tests
|
* @addtogroup bacnet_tests
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
#ifdef BACNET_ADDRESS_CACHE_FILE
|
||||||
static const char *Address_Cache_Filename = "address_cache";
|
static const char *Address_Cache_Filename = "address_cache";
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Test
|
* @brief Test
|
||||||
@@ -44,6 +45,7 @@ static void set_address(unsigned index, BACNET_ADDRESS *dest)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BACNET_ADDRESS_CACHE_FILE
|
||||||
static void set_file_address(
|
static void set_file_address(
|
||||||
const char *pFilename,
|
const char *pFilename,
|
||||||
uint32_t device_id,
|
uint32_t device_id,
|
||||||
@@ -78,6 +80,7 @@ static void set_file_address(
|
|||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef BACNET_ADDRESS_CACHE_FILE
|
#ifdef BACNET_ADDRESS_CACHE_FILE
|
||||||
/* Validate that the address data in the file */
|
/* Validate that the address data in the file */
|
||||||
|
|||||||
@@ -25,9 +25,6 @@ ZTEST(bitstring_value_object_tests, test_BitString_Value_Object)
|
|||||||
static void test_BitString_Value_Object(void)
|
static void test_BitString_Value_Object(void)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
uint8_t apdu[MAX_APDU] = { 0 };
|
|
||||||
int len = 0;
|
|
||||||
int test_len = 0;
|
|
||||||
const int skip_fail_property_list[] = { -1 };
|
const int skip_fail_property_list[] = { -1 };
|
||||||
const uint32_t instance = 123;
|
const uint32_t instance = 123;
|
||||||
uint32_t test_instance = 0;
|
uint32_t test_instance = 0;
|
||||||
@@ -37,9 +34,6 @@ static void test_BitString_Value_Object(void)
|
|||||||
BACNET_WRITE_PROPERTY_DATA wpdata = { 0 };
|
BACNET_WRITE_PROPERTY_DATA wpdata = { 0 };
|
||||||
BACNET_APPLICATION_DATA_VALUE value = { 0 };
|
BACNET_APPLICATION_DATA_VALUE value = { 0 };
|
||||||
BACNET_PROPERTY_VALUE value_list[2] = { 0 };
|
BACNET_PROPERTY_VALUE value_list[2] = { 0 };
|
||||||
const int *required_property = NULL;
|
|
||||||
const int *optional_property = NULL;
|
|
||||||
const int *proprietary_property = NULL;
|
|
||||||
|
|
||||||
BitString_Value_Init();
|
BitString_Value_Init();
|
||||||
status = BitString_Value_Create(instance);
|
status = BitString_Value_Create(instance);
|
||||||
|
|||||||
@@ -175,7 +175,6 @@ static void testBinaryLightingOutputBlink(void)
|
|||||||
BACNET_BINARY_LIGHTING_PV pv, test_pv, expect_pv;
|
BACNET_BINARY_LIGHTING_PV pv, test_pv, expect_pv;
|
||||||
unsigned test_priority;
|
unsigned test_priority;
|
||||||
BACNET_WRITE_PROPERTY_DATA wpdata = { 0 };
|
BACNET_WRITE_PROPERTY_DATA wpdata = { 0 };
|
||||||
BACNET_APPLICATION_DATA_VALUE value = { 0 };
|
|
||||||
|
|
||||||
Binary_Lighting_Output_Init();
|
Binary_Lighting_Output_Init();
|
||||||
Binary_Lighting_Output_Create(object_instance);
|
Binary_Lighting_Output_Create(object_instance);
|
||||||
|
|||||||
@@ -41,11 +41,17 @@ bool datetime_local(
|
|||||||
int16_t *utc_offset_minutes,
|
int16_t *utc_offset_minutes,
|
||||||
bool *dst_active)
|
bool *dst_active)
|
||||||
{
|
{
|
||||||
|
(void)bdate;
|
||||||
|
(void)btime;
|
||||||
|
(void)utc_offset_minutes;
|
||||||
|
(void)dst_active;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bip_get_my_address(BACNET_ADDRESS *my_address)
|
void bip_get_my_address(BACNET_ADDRESS *my_address)
|
||||||
{
|
{
|
||||||
|
(void)my_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bip_send_pdu(
|
int bip_send_pdu(
|
||||||
@@ -54,5 +60,10 @@ int bip_send_pdu(
|
|||||||
uint8_t *pdu,
|
uint8_t *pdu,
|
||||||
unsigned pdu_len)
|
unsigned pdu_len)
|
||||||
{
|
{
|
||||||
|
(void)dest;
|
||||||
|
(void)npdu_data;
|
||||||
|
(void)pdu;
|
||||||
|
(void)pdu_len;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -448,7 +448,6 @@ ZTEST(lc_tests, test_Load_Control_Read_Write_Property)
|
|||||||
static void test_Load_Control_Read_Write_Property(void)
|
static void test_Load_Control_Read_Write_Property(void)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
bool status = false;
|
|
||||||
unsigned count = 0;
|
unsigned count = 0;
|
||||||
uint32_t object_instance = BACNET_MAX_INSTANCE, test_object_instance = 0;
|
uint32_t object_instance = BACNET_MAX_INSTANCE, test_object_instance = 0;
|
||||||
const int skip_fail_property_list[] = { -1 };
|
const int skip_fail_property_list[] = { -1 };
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ ZTEST(testsLifeSafetyZone, testLifeSafetyZone)
|
|||||||
static void testLifeSafetyZone(void)
|
static void testLifeSafetyZone(void)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
bool status = false;
|
|
||||||
unsigned count = 0;
|
unsigned count = 0;
|
||||||
uint32_t object_instance = 0, test_object_instance = 0;
|
uint32_t object_instance = 0, test_object_instance = 0;
|
||||||
const int skip_fail_property_list[] = { -1 };
|
const int skip_fail_property_list[] = { -1 };
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ static void testOctetString_Value(void)
|
|||||||
rpdata.application_data = &apdu[0];
|
rpdata.application_data = &apdu[0];
|
||||||
rpdata.application_data_len = sizeof(apdu);
|
rpdata.application_data_len = sizeof(apdu);
|
||||||
rpdata.object_type = OBJECT_OCTETSTRING_VALUE;
|
rpdata.object_type = OBJECT_OCTETSTRING_VALUE;
|
||||||
rpdata.object_instance = 1;
|
rpdata.object_instance = instance;
|
||||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||||
|
|
||||||
OctetString_Value_Property_Lists(&required_property, NULL, NULL);
|
OctetString_Value_Property_Lists(&required_property, NULL, NULL);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ static void testPositiveInteger_Value(void)
|
|||||||
rpdata.application_data = &apdu[0];
|
rpdata.application_data = &apdu[0];
|
||||||
rpdata.application_data_len = sizeof(apdu);
|
rpdata.application_data_len = sizeof(apdu);
|
||||||
rpdata.object_type = OBJECT_POSITIVE_INTEGER_VALUE;
|
rpdata.object_type = OBJECT_POSITIVE_INTEGER_VALUE;
|
||||||
rpdata.object_instance = 1;
|
rpdata.object_instance = instance;
|
||||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||||
|
|
||||||
PositiveInteger_Value_Property_Lists(&required_property, NULL, NULL);
|
PositiveInteger_Value_Property_Lists(&required_property, NULL, NULL);
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ bool bacnet_object_property_write_test(
|
|||||||
const int *skip_fail_property_list)
|
const int *skip_fail_property_list)
|
||||||
{
|
{
|
||||||
bool status = false;
|
bool status = false;
|
||||||
int len = 0;
|
|
||||||
int test_len = 0;
|
|
||||||
|
|
||||||
(void)skip_fail_property_list;
|
(void)skip_fail_property_list;
|
||||||
if (wpdata && write_property) {
|
if (wpdata && write_property) {
|
||||||
@@ -82,14 +80,12 @@ int bacnet_object_property_read_test(
|
|||||||
read_property_function read_property,
|
read_property_function read_property,
|
||||||
const int *skip_fail_property_list)
|
const int *skip_fail_property_list)
|
||||||
{
|
{
|
||||||
bool status = false;
|
|
||||||
int len = 0;
|
int len = 0;
|
||||||
int test_len = 0;
|
int test_len = 0;
|
||||||
int apdu_len = 0;
|
int apdu_len = 0;
|
||||||
int read_len = 0;
|
int read_len = 0;
|
||||||
uint8_t *apdu;
|
uint8_t *apdu;
|
||||||
BACNET_ARRAY_INDEX array_index = 0;
|
BACNET_ARRAY_INDEX array_index = 0;
|
||||||
BACNET_WRITE_PROPERTY_DATA wpdata = { 0 };
|
|
||||||
BACNET_APPLICATION_DATA_VALUE value = { 0 };
|
BACNET_APPLICATION_DATA_VALUE value = { 0 };
|
||||||
|
|
||||||
read_len = read_property(rpdata);
|
read_len = read_property(rpdata);
|
||||||
@@ -174,7 +170,6 @@ void bacnet_object_properties_read_write_test(
|
|||||||
const int *pRequired = NULL;
|
const int *pRequired = NULL;
|
||||||
const int *pOptional = NULL;
|
const int *pOptional = NULL;
|
||||||
const int *pProprietary = NULL;
|
const int *pProprietary = NULL;
|
||||||
unsigned count = 0;
|
|
||||||
int len = 0;
|
int len = 0;
|
||||||
bool status = false;
|
bool status = false;
|
||||||
|
|
||||||
|
|||||||
@@ -151,9 +151,6 @@ static void test_color_rgb_ascii(void)
|
|||||||
uint8_t red, green, blue;
|
uint8_t red, green, blue;
|
||||||
uint8_t test_red, test_green, test_blue;
|
uint8_t test_red, test_green, test_blue;
|
||||||
unsigned test_index;
|
unsigned test_index;
|
||||||
float x_coordinate;
|
|
||||||
float y_coordinate;
|
|
||||||
float brightness;
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < count; i++) {
|
for (unsigned i = 0; i < count; i++) {
|
||||||
name = color_rgb_from_index(i, &red, &green, &blue);
|
name = color_rgb_from_index(i, &red, &green, &blue);
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ static void test_CreateObject(void)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
BACNET_CREATE_OBJECT_DATA data = { 0 };
|
BACNET_CREATE_OBJECT_DATA data = { 0 };
|
||||||
int len = 0, apdu_len = 0, null_len = 0, test_len = 0;
|
|
||||||
|
|
||||||
test_CreateObjectCodec(&data);
|
test_CreateObjectCodec(&data);
|
||||||
data.object_instance = BACNET_MAX_INSTANCE;
|
data.object_instance = BACNET_MAX_INSTANCE;
|
||||||
@@ -83,7 +82,6 @@ static void test_CreateObjectACK(void)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
BACNET_CREATE_OBJECT_DATA data = { 0 };
|
BACNET_CREATE_OBJECT_DATA data = { 0 };
|
||||||
int len = 0, apdu_len = 0, null_len = 0, test_len = 0;
|
|
||||||
|
|
||||||
test_CreateObjectAckCodec(&data);
|
test_CreateObjectAckCodec(&data);
|
||||||
data.object_instance = BACNET_MAX_INSTANCE;
|
data.object_instance = BACNET_MAX_INSTANCE;
|
||||||
|
|||||||
@@ -538,8 +538,6 @@ static void test_BVLC_Broadcast_Distribution_Table_Encode(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void test_BVLC_Write_Broadcast_Distribution_Table_Message(
|
static void test_BVLC_Write_Broadcast_Distribution_Table_Message(
|
||||||
uint8_t *npdu,
|
|
||||||
uint16_t npdu_len,
|
|
||||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_list)
|
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_list)
|
||||||
{
|
{
|
||||||
uint8_t pdu[480] = { 0 };
|
uint8_t pdu[480] = { 0 };
|
||||||
@@ -578,8 +576,6 @@ ZTEST(bvlc_tests, test_BVLC_Write_Broadcast_Distribution_Table)
|
|||||||
static void test_BVLC_Write_Broadcast_Distribution_Table(void)
|
static void test_BVLC_Write_Broadcast_Distribution_Table(void)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
uint8_t npdu[480] = { 0 };
|
|
||||||
uint16_t npdu_len = 0;
|
|
||||||
uint16_t i = 0;
|
uint16_t i = 0;
|
||||||
uint16_t count = 0;
|
uint16_t count = 0;
|
||||||
uint16_t test_count = 0;
|
uint16_t test_count = 0;
|
||||||
@@ -620,20 +616,10 @@ static void test_BVLC_Write_Broadcast_Distribution_Table(void)
|
|||||||
&bdt_list[0], &bdt_list[i]);
|
&bdt_list[0], &bdt_list[i]);
|
||||||
zassert_true(status, NULL);
|
zassert_true(status, NULL);
|
||||||
}
|
}
|
||||||
test_BVLC_Write_Broadcast_Distribution_Table_Message(
|
test_BVLC_Write_Broadcast_Distribution_Table_Message(&bdt_list[0]);
|
||||||
npdu, npdu_len, &bdt_list[0]);
|
|
||||||
/* now with some NPDU data */
|
|
||||||
for (i = 0; i < sizeof(npdu); i++) {
|
|
||||||
npdu[i] = i;
|
|
||||||
}
|
|
||||||
npdu_len = sizeof(npdu);
|
|
||||||
test_BVLC_Write_Broadcast_Distribution_Table_Message(
|
|
||||||
npdu, npdu_len, &bdt_list[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_BVLC_Read_Foreign_Device_Table_Ack_Message(
|
static void test_BVLC_Read_Foreign_Device_Table_Ack_Message(
|
||||||
uint8_t *npdu,
|
|
||||||
uint16_t npdu_len,
|
|
||||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_list)
|
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_list)
|
||||||
{
|
{
|
||||||
uint8_t pdu[480] = { 0 };
|
uint8_t pdu[480] = { 0 };
|
||||||
@@ -669,8 +655,6 @@ ZTEST(bvlc_tests, test_BVLC_Read_Foreign_Device_Table_Ack)
|
|||||||
static void test_BVLC_Read_Foreign_Device_Table_Ack(void)
|
static void test_BVLC_Read_Foreign_Device_Table_Ack(void)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
uint8_t npdu[480] = { 0 };
|
|
||||||
uint16_t npdu_len = 0;
|
|
||||||
uint16_t i = 0;
|
uint16_t i = 0;
|
||||||
uint16_t count = 0;
|
uint16_t count = 0;
|
||||||
uint16_t test_count = 0;
|
uint16_t test_count = 0;
|
||||||
@@ -701,13 +685,7 @@ static void test_BVLC_Read_Foreign_Device_Table_Ack(void)
|
|||||||
}
|
}
|
||||||
test_count = bvlc_foreign_device_table_valid_count(fdt_list);
|
test_count = bvlc_foreign_device_table_valid_count(fdt_list);
|
||||||
zassert_equal(test_count, count, NULL);
|
zassert_equal(test_count, count, NULL);
|
||||||
test_BVLC_Read_Foreign_Device_Table_Ack_Message(npdu, npdu_len, fdt_list);
|
test_BVLC_Read_Foreign_Device_Table_Ack_Message(fdt_list);
|
||||||
/* now with some NPDU data */
|
|
||||||
for (i = 0; i < sizeof(npdu); i++) {
|
|
||||||
npdu[i] = i;
|
|
||||||
}
|
|
||||||
npdu_len = sizeof(npdu);
|
|
||||||
test_BVLC_Read_Foreign_Device_Table_Ack_Message(npdu, npdu_len, fdt_list);
|
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
dest_address.port = test_port_start + i;
|
dest_address.port = test_port_start + i;
|
||||||
|
|||||||
@@ -103,7 +103,10 @@ uint16_t MSTP_Put_Receive(struct mstp_port_struct_t *mstp_port)
|
|||||||
* @return amount of PDU data
|
* @return amount of PDU data
|
||||||
*/
|
*/
|
||||||
uint16_t MSTP_Get_Send(struct mstp_port_struct_t *mstp_port, unsigned timeout)
|
uint16_t MSTP_Get_Send(struct mstp_port_struct_t *mstp_port, unsigned timeout)
|
||||||
{ /* milliseconds to wait for a packet */
|
{
|
||||||
|
(void)mstp_port;
|
||||||
|
(void)timeout;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +117,10 @@ uint16_t MSTP_Get_Send(struct mstp_port_struct_t *mstp_port, unsigned timeout)
|
|||||||
* @return amount of PDU data
|
* @return amount of PDU data
|
||||||
*/
|
*/
|
||||||
uint16_t MSTP_Get_Reply(struct mstp_port_struct_t *mstp_port, unsigned timeout)
|
uint16_t MSTP_Get_Reply(struct mstp_port_struct_t *mstp_port, unsigned timeout)
|
||||||
{ /* milliseconds to wait for a packet */
|
{
|
||||||
|
(void)mstp_port;
|
||||||
|
(void)timeout;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -593,8 +599,6 @@ static void testMasterNodeFSM(void)
|
|||||||
static void testSlaveNodeFSM(void)
|
static void testSlaveNodeFSM(void)
|
||||||
{
|
{
|
||||||
struct mstp_port_struct_t MSTP_Port = { 0 }; /* port data */
|
struct mstp_port_struct_t MSTP_Port = { 0 }; /* port data */
|
||||||
bool transition_now, non_zero;
|
|
||||||
unsigned slots, silence, i;
|
|
||||||
|
|
||||||
MSTP_Port.InputBuffer = &RxBuffer[0];
|
MSTP_Port.InputBuffer = &RxBuffer[0];
|
||||||
MSTP_Port.InputBufferSize = sizeof(RxBuffer);
|
MSTP_Port.InputBufferSize = sizeof(RxBuffer);
|
||||||
@@ -677,8 +681,7 @@ static void testZeroConfigNode_Init(struct mstp_port_struct_t *mstp_port)
|
|||||||
static void
|
static void
|
||||||
testZeroConfigNode_No_Events_Timeout(struct mstp_port_struct_t *mstp_port)
|
testZeroConfigNode_No_Events_Timeout(struct mstp_port_struct_t *mstp_port)
|
||||||
{
|
{
|
||||||
bool transition_now, non_zero;
|
bool transition_now;
|
||||||
unsigned slots, silence, i;
|
|
||||||
|
|
||||||
SilenceTime = mstp_port->Zero_Config_Silence + 1;
|
SilenceTime = mstp_port->Zero_Config_Silence + 1;
|
||||||
transition_now = MSTP_Master_Node_FSM(mstp_port);
|
transition_now = MSTP_Master_Node_FSM(mstp_port);
|
||||||
@@ -690,8 +693,7 @@ testZeroConfigNode_No_Events_Timeout(struct mstp_port_struct_t *mstp_port)
|
|||||||
static void testZeroConfigNode_Test_Request_Unsupported(
|
static void testZeroConfigNode_Test_Request_Unsupported(
|
||||||
struct mstp_port_struct_t *mstp_port)
|
struct mstp_port_struct_t *mstp_port)
|
||||||
{
|
{
|
||||||
bool transition_now, non_zero;
|
bool transition_now;
|
||||||
unsigned slots, silence, i;
|
|
||||||
|
|
||||||
/* test case: remote node does not support Test-Request; timeout */
|
/* test case: remote node does not support Test-Request; timeout */
|
||||||
SilenceTime = mstp_port->Treply_timeout + 1;
|
SilenceTime = mstp_port->Treply_timeout + 1;
|
||||||
@@ -703,31 +705,10 @@ static void testZeroConfigNode_Test_Request_Unsupported(
|
|||||||
mstp_port->This_Station == mstp_port->Zero_Config_Station, NULL);
|
mstp_port->This_Station == mstp_port->Zero_Config_Station, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
testZeroConfigNode_Test_Request_Supported(struct mstp_port_struct_t *mstp_port)
|
|
||||||
{
|
|
||||||
bool transition_now, non_zero;
|
|
||||||
unsigned slots, silence, i;
|
|
||||||
|
|
||||||
/* test case: remote node supports Test-Request */
|
|
||||||
SilenceTime = 0;
|
|
||||||
|
|
||||||
mstp_port->DestinationAddress = mstp_port->Zero_Config_Station;
|
|
||||||
mstp_port->SourceAddress = 0;
|
|
||||||
mstp_port->FrameType = FRAME_TYPE_TEST_RESPONSE;
|
|
||||||
transition_now = MSTP_Master_Node_FSM(mstp_port);
|
|
||||||
zassert_true(transition_now, NULL);
|
|
||||||
zassert_true(
|
|
||||||
mstp_port->Zero_Config_State == MSTP_ZERO_CONFIG_STATE_USE, NULL);
|
|
||||||
zassert_true(
|
|
||||||
mstp_port->This_Station == mstp_port->Zero_Config_Station, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
testZeroConfigNode_Test_IDLE_InvalidFrame(struct mstp_port_struct_t *mstp_port)
|
testZeroConfigNode_Test_IDLE_InvalidFrame(struct mstp_port_struct_t *mstp_port)
|
||||||
{
|
{
|
||||||
bool transition_now, non_zero;
|
bool transition_now;
|
||||||
unsigned slots, silence, i;
|
|
||||||
|
|
||||||
/* test case: waiting for a invalid frame */
|
/* test case: waiting for a invalid frame */
|
||||||
SilenceTime = 0;
|
SilenceTime = 0;
|
||||||
@@ -747,8 +728,7 @@ testZeroConfigNode_Test_IDLE_InvalidFrame(struct mstp_port_struct_t *mstp_port)
|
|||||||
static void testZeroConfigNode_Test_IDLE_ValidFrameTimeout(
|
static void testZeroConfigNode_Test_IDLE_ValidFrameTimeout(
|
||||||
struct mstp_port_struct_t *mstp_port)
|
struct mstp_port_struct_t *mstp_port)
|
||||||
{
|
{
|
||||||
bool transition_now, non_zero;
|
bool transition_now;
|
||||||
unsigned slots, silence, i;
|
|
||||||
|
|
||||||
/* test case: get a valid frame, followed by timeout */
|
/* test case: get a valid frame, followed by timeout */
|
||||||
SilenceTime = 0;
|
SilenceTime = 0;
|
||||||
@@ -775,8 +755,7 @@ static void testZeroConfigNode_Test_IDLE_ValidFrameTimeout(
|
|||||||
static void
|
static void
|
||||||
testZeroConfigNode_Test_IDLE_ValidFrame(struct mstp_port_struct_t *mstp_port)
|
testZeroConfigNode_Test_IDLE_ValidFrame(struct mstp_port_struct_t *mstp_port)
|
||||||
{
|
{
|
||||||
bool transition_now, non_zero;
|
bool transition_now;
|
||||||
unsigned slots, silence, i;
|
|
||||||
|
|
||||||
/* test case: get a valid frame, followed by timeout */
|
/* test case: get a valid frame, followed by timeout */
|
||||||
SilenceTime = 0;
|
SilenceTime = 0;
|
||||||
@@ -793,8 +772,7 @@ testZeroConfigNode_Test_IDLE_ValidFrame(struct mstp_port_struct_t *mstp_port)
|
|||||||
static void
|
static void
|
||||||
testZeroConfigNode_Test_LURK_AddressInUse(struct mstp_port_struct_t *mstp_port)
|
testZeroConfigNode_Test_LURK_AddressInUse(struct mstp_port_struct_t *mstp_port)
|
||||||
{
|
{
|
||||||
bool transition_now, non_zero;
|
bool transition_now;
|
||||||
unsigned slots, silence, i;
|
|
||||||
uint8_t src, dst;
|
uint8_t src, dst;
|
||||||
|
|
||||||
/* test case: src emits a token from each MAC in the zero-config range */
|
/* test case: src emits a token from each MAC in the zero-config range */
|
||||||
@@ -820,9 +798,8 @@ testZeroConfigNode_Test_LURK_AddressInUse(struct mstp_port_struct_t *mstp_port)
|
|||||||
static void testZeroConfigNode_Test_LURK_LearnMaxMaster(
|
static void testZeroConfigNode_Test_LURK_LearnMaxMaster(
|
||||||
struct mstp_port_struct_t *mstp_port)
|
struct mstp_port_struct_t *mstp_port)
|
||||||
{
|
{
|
||||||
bool transition_now, non_zero;
|
bool transition_now;
|
||||||
unsigned slots, silence, i;
|
uint8_t dst;
|
||||||
uint8_t src, dst;
|
|
||||||
|
|
||||||
/* test case: src emits a token from each MAC in the zero-config range */
|
/* test case: src emits a token from each MAC in the zero-config range */
|
||||||
SilenceTime = 0;
|
SilenceTime = 0;
|
||||||
@@ -843,8 +820,7 @@ static void testZeroConfigNode_Test_LURK_LearnMaxMaster(
|
|||||||
static void
|
static void
|
||||||
testZeroConfigNode_Test_LURK_Claim(struct mstp_port_struct_t *mstp_port)
|
testZeroConfigNode_Test_LURK_Claim(struct mstp_port_struct_t *mstp_port)
|
||||||
{
|
{
|
||||||
bool transition_now, non_zero;
|
bool transition_now;
|
||||||
unsigned slots, silence, i;
|
|
||||||
uint8_t src = 0, dst, count, count_max, count_claim;
|
uint8_t src = 0, dst, count, count_max, count_claim;
|
||||||
|
|
||||||
/* test case: src emits a PFM from each MAC in the zero-config range */
|
/* test case: src emits a PFM from each MAC in the zero-config range */
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ static void test_DeleteObject(void)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
BACNET_DELETE_OBJECT_DATA data = { 0 };
|
BACNET_DELETE_OBJECT_DATA data = { 0 };
|
||||||
int len = 0, apdu_len = 0, null_len = 0, test_len = 0;
|
|
||||||
|
|
||||||
test_DeleteObjectCodec(&data);
|
test_DeleteObjectCodec(&data);
|
||||||
data.object_instance = BACNET_MAX_INSTANCE;
|
data.object_instance = BACNET_MAX_INSTANCE;
|
||||||
|
|||||||
@@ -26,8 +26,6 @@
|
|||||||
static int get_alarm_summary_decode_apdu(
|
static int get_alarm_summary_decode_apdu(
|
||||||
uint8_t *apdu, unsigned apdu_size, uint8_t *invoke_id)
|
uint8_t *apdu, unsigned apdu_size, uint8_t *invoke_id)
|
||||||
{
|
{
|
||||||
int len = 0;
|
|
||||||
|
|
||||||
if (!apdu) {
|
if (!apdu) {
|
||||||
return BACNET_STATUS_ERROR;
|
return BACNET_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
@@ -99,7 +97,6 @@ static void testGetAlarmSummaryAck(void)
|
|||||||
uint8_t test_invoke_id = 0;
|
uint8_t test_invoke_id = 0;
|
||||||
BACNET_GET_ALARM_SUMMARY_DATA alarm_data;
|
BACNET_GET_ALARM_SUMMARY_DATA alarm_data;
|
||||||
BACNET_GET_ALARM_SUMMARY_DATA test_alarm_data;
|
BACNET_GET_ALARM_SUMMARY_DATA test_alarm_data;
|
||||||
unsigned i = 0;
|
|
||||||
|
|
||||||
alarm_data.objectIdentifier.type = OBJECT_BINARY_INPUT;
|
alarm_data.objectIdentifier.type = OBJECT_BINARY_INPUT;
|
||||||
alarm_data.objectIdentifier.instance = 1;
|
alarm_data.objectIdentifier.instance = 1;
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ static void test_HostNPort(void)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
BACNET_HOST_N_PORT data = { 0 };
|
BACNET_HOST_N_PORT data = { 0 };
|
||||||
int len = 0, apdu_len = 0, null_len = 0, test_len = 0;
|
|
||||||
|
|
||||||
/* none */
|
/* none */
|
||||||
test_HostNPortCodec(&data);
|
test_HostNPortCodec(&data);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ static void test_ListElement(void)
|
|||||||
{
|
{
|
||||||
uint8_t apdu[MAX_APDU] = { 0 };
|
uint8_t apdu[MAX_APDU] = { 0 };
|
||||||
BACNET_LIST_ELEMENT_DATA list_element = { 0 }, test_list_element = { 0 };
|
BACNET_LIST_ELEMENT_DATA list_element = { 0 }, test_list_element = { 0 };
|
||||||
int len = 0, apdu_len = 0, null_len = 0, test_len = 0;
|
int apdu_len = 0, null_len = 0, test_len = 0;
|
||||||
uint8_t application_data[MAX_APDU] = { 0 }, *test_application_data = NULL;
|
uint8_t application_data[MAX_APDU] = { 0 }, *test_application_data = NULL;
|
||||||
int application_data_len = 0, test_application_data_len = 0;
|
int application_data_len = 0, test_application_data_len = 0;
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
@@ -79,7 +79,7 @@ static void test_ListElementError(void)
|
|||||||
{
|
{
|
||||||
uint8_t apdu[MAX_APDU] = { 0 };
|
uint8_t apdu[MAX_APDU] = { 0 };
|
||||||
BACNET_LIST_ELEMENT_DATA list_element = { 0 }, test_list_element = { 0 };
|
BACNET_LIST_ELEMENT_DATA list_element = { 0 }, test_list_element = { 0 };
|
||||||
int len = 0, apdu_len = 0, null_len = 0, test_len = 0;
|
int apdu_len = 0, null_len = 0, test_len = 0;
|
||||||
|
|
||||||
list_element.error_class = ERROR_CLASS_SERVICES;
|
list_element.error_class = ERROR_CLASS_SERVICES;
|
||||||
list_element.error_code = ERROR_CODE_REJECT_PARAMETER_OUT_OF_RANGE;
|
list_element.error_code = ERROR_CODE_REJECT_PARAMETER_OUT_OF_RANGE;
|
||||||
|
|||||||
@@ -36,5 +36,10 @@ int bip_send_pdu(
|
|||||||
uint8_t *pdu,
|
uint8_t *pdu,
|
||||||
unsigned pdu_len)
|
unsigned pdu_len)
|
||||||
{
|
{
|
||||||
|
(void)dest;
|
||||||
|
(void)npdu_data;
|
||||||
|
(void)pdu;
|
||||||
|
(void)pdu_len;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,51 +36,29 @@ static void test_BACnetSpecialEvent_CalendarRef(void)
|
|||||||
int len, apdu_len, null_len;
|
int len, apdu_len, null_len;
|
||||||
uint8_t apdu[MAX_APDU] = { 0 };
|
uint8_t apdu[MAX_APDU] = { 0 };
|
||||||
|
|
||||||
BACNET_SPECIAL_EVENT in = {
|
BACNET_SPECIAL_EVENT in = { 0 };
|
||||||
.periodTag = BACNET_SPECIAL_EVENT_PERIOD_CALENDAR_REFERENCE,
|
|
||||||
.period = {
|
|
||||||
.calendarReference = {
|
|
||||||
.instance = 5,
|
|
||||||
.type = OBJECT_CALENDAR,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
.timeValues = {
|
|
||||||
.TV_Count = 2,
|
|
||||||
.Time_Values = {
|
|
||||||
{
|
|
||||||
.Time = {
|
|
||||||
.hour = 12,
|
|
||||||
.min = 30,
|
|
||||||
.sec = 15,
|
|
||||||
.hundredths = 5
|
|
||||||
},
|
|
||||||
.Value = {
|
|
||||||
.tag = BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
|
||||||
.type = {
|
|
||||||
.Unsigned_Int = 15,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.Time = {
|
|
||||||
.hour = 16,
|
|
||||||
.min = 1,
|
|
||||||
.sec = 2,
|
|
||||||
.hundredths = 3
|
|
||||||
},
|
|
||||||
.Value = {
|
|
||||||
.tag = BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
|
||||||
.type = {
|
|
||||||
.Unsigned_Int = 0,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
.priority = 5,
|
|
||||||
};
|
|
||||||
BACNET_SPECIAL_EVENT out = { 0 };
|
BACNET_SPECIAL_EVENT out = { 0 };
|
||||||
|
|
||||||
|
in.periodTag = BACNET_SPECIAL_EVENT_PERIOD_CALENDAR_REFERENCE;
|
||||||
|
in.period.calendarReference.instance = 5;
|
||||||
|
in.period.calendarReference.type = OBJECT_CALENDAR;
|
||||||
|
in.timeValues.TV_Count = 2;
|
||||||
|
in.timeValues.Time_Values[0].Time.hour = 12;
|
||||||
|
in.timeValues.Time_Values[0].Time.min = 30;
|
||||||
|
in.timeValues.Time_Values[0].Time.sec = 15;
|
||||||
|
in.timeValues.Time_Values[0].Time.hundredths = 5;
|
||||||
|
in.timeValues.Time_Values[0].Value.tag =
|
||||||
|
BACNET_APPLICATION_TAG_UNSIGNED_INT;
|
||||||
|
in.timeValues.Time_Values[0].Value.type.Unsigned_Int = 15;
|
||||||
|
in.timeValues.Time_Values[1].Time.hour = 16;
|
||||||
|
in.timeValues.Time_Values[1].Time.min = 1;
|
||||||
|
in.timeValues.Time_Values[1].Time.sec = 2;
|
||||||
|
in.timeValues.Time_Values[1].Time.hundredths = 3;
|
||||||
|
in.timeValues.Time_Values[1].Value.tag =
|
||||||
|
BACNET_APPLICATION_TAG_UNSIGNED_INT;
|
||||||
|
in.timeValues.Time_Values[1].Value.type.Unsigned_Int = 0;
|
||||||
|
in.priority = 5;
|
||||||
|
|
||||||
len = bacnet_special_event_encode(apdu, &in);
|
len = bacnet_special_event_encode(apdu, &in);
|
||||||
null_len = bacnet_special_event_encode(NULL, &in);
|
null_len = bacnet_special_event_encode(NULL, &in);
|
||||||
zassert_equal(len, null_len, NULL);
|
zassert_equal(len, null_len, NULL);
|
||||||
@@ -152,29 +130,18 @@ static void test_BACnetSpecialEvent_Date(void)
|
|||||||
int len, apdu_len, null_len;
|
int len, apdu_len, null_len;
|
||||||
uint8_t apdu[MAX_APDU] = { 0 };
|
uint8_t apdu[MAX_APDU] = { 0 };
|
||||||
|
|
||||||
BACNET_SPECIAL_EVENT in = {
|
BACNET_SPECIAL_EVENT in = { 0 };
|
||||||
.periodTag = BACNET_SPECIAL_EVENT_PERIOD_CALENDAR_ENTRY,
|
|
||||||
.period = {
|
|
||||||
.calendarEntry = {
|
|
||||||
.tag = BACNET_CALENDAR_DATE,
|
|
||||||
.type = {
|
|
||||||
.Date = {
|
|
||||||
.year = 2155,
|
|
||||||
.month = 10,
|
|
||||||
.day = 0xff,
|
|
||||||
.wday = 0xff,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
.timeValues = {
|
|
||||||
.TV_Count = 0,
|
|
||||||
.Time_Values = { 0 }
|
|
||||||
},
|
|
||||||
.priority = 16,
|
|
||||||
};
|
|
||||||
BACNET_SPECIAL_EVENT out = { 0 };
|
BACNET_SPECIAL_EVENT out = { 0 };
|
||||||
|
|
||||||
|
in.periodTag = BACNET_SPECIAL_EVENT_PERIOD_CALENDAR_ENTRY;
|
||||||
|
in.period.calendarEntry.tag = BACNET_CALENDAR_DATE;
|
||||||
|
in.period.calendarEntry.type.Date.year = 2155;
|
||||||
|
in.period.calendarEntry.type.Date.month = 10;
|
||||||
|
in.period.calendarEntry.type.Date.day = 0xff;
|
||||||
|
in.period.calendarEntry.type.Date.wday = 0xff;
|
||||||
|
in.timeValues.TV_Count = 0;
|
||||||
|
in.priority = 16;
|
||||||
|
|
||||||
len = bacnet_special_event_encode(apdu, &in);
|
len = bacnet_special_event_encode(apdu, &in);
|
||||||
null_len = bacnet_special_event_encode(NULL, &in);
|
null_len = bacnet_special_event_encode(NULL, &in);
|
||||||
zassert_equal(len, null_len, NULL);
|
zassert_equal(len, null_len, NULL);
|
||||||
@@ -212,38 +179,22 @@ static void test_BACnetSpecialEvent_DateRange(void)
|
|||||||
{
|
{
|
||||||
int len, apdu_len, null_len;
|
int len, apdu_len, null_len;
|
||||||
uint8_t apdu[MAX_APDU] = { 0 };
|
uint8_t apdu[MAX_APDU] = { 0 };
|
||||||
|
BACNET_SPECIAL_EVENT in = { 0 };
|
||||||
BACNET_SPECIAL_EVENT in = {
|
|
||||||
.periodTag = BACNET_SPECIAL_EVENT_PERIOD_CALENDAR_ENTRY,
|
|
||||||
.period = {
|
|
||||||
.calendarEntry = {
|
|
||||||
.tag = BACNET_CALENDAR_DATE_RANGE,
|
|
||||||
.type = {
|
|
||||||
.DateRange = {
|
|
||||||
.startdate = {
|
|
||||||
.day = 1,
|
|
||||||
.month = 12,
|
|
||||||
.year = 2155,
|
|
||||||
.wday = 0xff,
|
|
||||||
},
|
|
||||||
.enddate = {
|
|
||||||
.day = 31,
|
|
||||||
.month = 12,
|
|
||||||
.year = 2155,
|
|
||||||
.wday = 0xff,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
.timeValues = {
|
|
||||||
.TV_Count = 0,
|
|
||||||
.Time_Values = { 0 }
|
|
||||||
},
|
|
||||||
.priority = 0,
|
|
||||||
};
|
|
||||||
BACNET_SPECIAL_EVENT out = { 0 };
|
BACNET_SPECIAL_EVENT out = { 0 };
|
||||||
|
|
||||||
|
in.periodTag = BACNET_SPECIAL_EVENT_PERIOD_CALENDAR_ENTRY;
|
||||||
|
in.period.calendarEntry.tag = BACNET_CALENDAR_DATE_RANGE;
|
||||||
|
in.period.calendarEntry.type.DateRange.startdate.year = 2155;
|
||||||
|
in.period.calendarEntry.type.DateRange.startdate.month = 12;
|
||||||
|
in.period.calendarEntry.type.DateRange.startdate.day = 1;
|
||||||
|
in.period.calendarEntry.type.DateRange.startdate.wday = 0xff;
|
||||||
|
in.period.calendarEntry.type.DateRange.enddate.year = 2155;
|
||||||
|
in.period.calendarEntry.type.DateRange.enddate.month = 12;
|
||||||
|
in.period.calendarEntry.type.DateRange.enddate.day = 31;
|
||||||
|
in.period.calendarEntry.type.DateRange.enddate.wday = 0xff;
|
||||||
|
in.timeValues.TV_Count = 0;
|
||||||
|
in.priority = 0;
|
||||||
|
|
||||||
len = bacnet_special_event_encode(apdu, &in);
|
len = bacnet_special_event_encode(apdu, &in);
|
||||||
null_len = bacnet_special_event_encode(NULL, &in);
|
null_len = bacnet_special_event_encode(NULL, &in);
|
||||||
zassert_equal(len, null_len, NULL);
|
zassert_equal(len, null_len, NULL);
|
||||||
@@ -296,29 +247,17 @@ static void test_BACnetSpecialEvent_WeekNDate(void)
|
|||||||
{
|
{
|
||||||
int len, apdu_len, null_len;
|
int len, apdu_len, null_len;
|
||||||
uint8_t apdu[MAX_APDU] = { 0 };
|
uint8_t apdu[MAX_APDU] = { 0 };
|
||||||
|
BACNET_SPECIAL_EVENT in = { 0 };
|
||||||
BACNET_SPECIAL_EVENT in = {
|
|
||||||
.periodTag = BACNET_SPECIAL_EVENT_PERIOD_CALENDAR_ENTRY,
|
|
||||||
.period = {
|
|
||||||
.calendarEntry = {
|
|
||||||
.tag = BACNET_CALENDAR_WEEK_N_DAY,
|
|
||||||
.type = {
|
|
||||||
.WeekNDay = {
|
|
||||||
.month = 0xff,
|
|
||||||
.dayofweek = 1, /* mondays */
|
|
||||||
.weekofmonth = 0xff,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
.timeValues = {
|
|
||||||
.TV_Count = 0,
|
|
||||||
.Time_Values = { 0 }
|
|
||||||
},
|
|
||||||
.priority = 16,
|
|
||||||
};
|
|
||||||
BACNET_SPECIAL_EVENT out = { 0 };
|
BACNET_SPECIAL_EVENT out = { 0 };
|
||||||
|
|
||||||
|
in.periodTag = BACNET_SPECIAL_EVENT_PERIOD_CALENDAR_ENTRY;
|
||||||
|
in.period.calendarEntry.tag = BACNET_CALENDAR_WEEK_N_DAY;
|
||||||
|
in.period.calendarEntry.type.WeekNDay.month = 0xff;
|
||||||
|
in.period.calendarEntry.type.WeekNDay.dayofweek = 1; /* mondays */
|
||||||
|
in.period.calendarEntry.type.WeekNDay.weekofmonth = 0xff;
|
||||||
|
in.timeValues.TV_Count = 0;
|
||||||
|
in.priority = 16;
|
||||||
|
|
||||||
len = bacnet_special_event_encode(apdu, &in);
|
len = bacnet_special_event_encode(apdu, &in);
|
||||||
null_len = bacnet_special_event_encode(NULL, &in);
|
null_len = bacnet_special_event_encode(NULL, &in);
|
||||||
zassert_equal(len, null_len, NULL);
|
zassert_equal(len, null_len, NULL);
|
||||||
@@ -350,7 +289,7 @@ ZTEST(BACnetSpecialEvent_tests, test_BACnetSpecialEvent_DecodeRealAPDU)
|
|||||||
static void test_BACnetSpecialEvent_DecodeRealAPDU(void)
|
static void test_BACnetSpecialEvent_DecodeRealAPDU(void)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
int len, apdu_len;
|
int apdu_len;
|
||||||
BACNET_SPECIAL_EVENT out = { 0 };
|
BACNET_SPECIAL_EVENT out = { 0 };
|
||||||
uint8_t sample[18] = {
|
uint8_t sample[18] = {
|
||||||
0x0e, 0x0c, 0xff, 0x0a, 0x1c, 0xff, 0x0f, 0x2e, 0xb4,
|
0x0e, 0x0c, 0xff, 0x0a, 0x1c, 0xff, 0x0f, 0x2e, 0xb4,
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ static void test_BACnetWeeklySchedule(void)
|
|||||||
BACNET_WEEKLY_SCHEDULE empty_value = { 0 };
|
BACNET_WEEKLY_SCHEDULE empty_value = { 0 };
|
||||||
BACNET_WEEKLY_SCHEDULE value = { 0 };
|
BACNET_WEEKLY_SCHEDULE value = { 0 };
|
||||||
BACNET_WEEKLY_SCHEDULE decoded = { 0 };
|
BACNET_WEEKLY_SCHEDULE decoded = { 0 };
|
||||||
int diff = 0;
|
|
||||||
bool status = false;
|
bool status = false;
|
||||||
uint8_t tag_number = 0;
|
uint8_t tag_number = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ static int wpm_decode_apdu(uint8_t *apdu, unsigned apdu_len, uint8_t *invoke_id)
|
|||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
|
|
||||||
|
(void)apdu_len;
|
||||||
if (!apdu) {
|
if (!apdu) {
|
||||||
return BACNET_STATUS_ERROR;
|
return BACNET_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,6 +116,8 @@ static inline void test_time_ms(void)
|
|||||||
uint32_t spend_cycle = k_cycle_get_32() - tc_start_time;
|
uint32_t spend_cycle = k_cycle_get_32() - tc_start_time;
|
||||||
|
|
||||||
tc_spend_time = k_cyc_to_ms_ceil32(spend_cycle);
|
tc_spend_time = k_cyc_to_ms_ceil32(spend_cycle);
|
||||||
|
#else
|
||||||
|
tc_spend_time = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ static inline bool z_zassert(bool cond,
|
|||||||
bool _ret = z_zassert(cond, msg ? ("(" default_msg ")") : (default_msg), \
|
bool _ret = z_zassert(cond, msg ? ("(" default_msg ")") : (default_msg), \
|
||||||
__FILE__, __LINE__, __func__, \
|
__FILE__, __LINE__, __func__, \
|
||||||
msg ? msg : "", ##__VA_ARGS__); \
|
msg ? msg : "", ##__VA_ARGS__); \
|
||||||
|
(void)_ret; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user