Added AlignAfterOpenBracket: AlwaysBreak and BinPackArguments: true to clang-format. Updated test/bacnet c/h files with updated format.
This commit is contained in:
@@ -97,7 +97,7 @@ int bip_send_mpdu(BACNET_IP_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len)
|
||||
Test_Sent_Message_Length = message_length;
|
||||
bvlc_address_copy(&Test_Sent_Message_Dest, dest);
|
||||
if ((header_len == 4) && (mtu_len >= 4)) {
|
||||
memcpy(&Test_Sent_Message_Buffer[0], &mtu[4], mtu_len-4);
|
||||
memcpy(&Test_Sent_Message_Buffer[0], &mtu[4], mtu_len - 4);
|
||||
Test_Sent_Message_Buffer_Length = mtu_len - 4;
|
||||
} else {
|
||||
Test_Sent_Message_Buffer_Length = 0;
|
||||
@@ -151,7 +151,6 @@ static void test_setup(void)
|
||||
|
||||
static void test_cleanup(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,13 +158,13 @@ static void test_cleanup(void)
|
||||
*/
|
||||
static void test_Initiate_Original_Broadcast_NPDU(Test *pTest)
|
||||
{
|
||||
uint8_t pdu[MAX_MPDU] = {0};
|
||||
uint8_t pdu[MAX_MPDU] = { 0 };
|
||||
int npdu_len = 0;
|
||||
int apdu_len = 0;
|
||||
int pdu_len = 0;
|
||||
BACNET_ADDRESS dest = {0};
|
||||
BACNET_NPDU_DATA npdu_data = {0};
|
||||
uint8_t test_pdu[MAX_MPDU] = {0};
|
||||
BACNET_ADDRESS dest = { 0 };
|
||||
BACNET_NPDU_DATA npdu_data = { 0 };
|
||||
uint8_t test_pdu[MAX_MPDU] = { 0 };
|
||||
uint16_t test_pdu_len = 0;
|
||||
int function_len = 0;
|
||||
|
||||
@@ -174,23 +173,25 @@ static void test_Initiate_Original_Broadcast_NPDU(Test *pTest)
|
||||
dest.net = BACNET_BROADCAST_NETWORK;
|
||||
npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL);
|
||||
npdu_len = npdu_encode_pdu(&pdu[0], &dest, &IUT.BACnet_Address, &npdu_data);
|
||||
apdu_len = iam_encode_apdu(&pdu[npdu_len], IUT.Device_ID, MAX_APDU,
|
||||
SEGMENTATION_NONE, BACNET_VENDOR_ID);
|
||||
apdu_len = iam_encode_apdu(
|
||||
&pdu[npdu_len], IUT.Device_ID, MAX_APDU, SEGMENTATION_NONE,
|
||||
BACNET_VENDOR_ID);
|
||||
pdu_len = npdu_len + apdu_len;
|
||||
bvlc_send_pdu(&dest, &npdu_data, pdu, pdu_len);
|
||||
/* DA=Link Local Multicast Address */
|
||||
ct_test(pTest, !bvlc_address_different(&TD.BIP_Broadcast_Addr,
|
||||
&Test_Sent_Message_Dest));
|
||||
ct_test(
|
||||
pTest,
|
||||
!bvlc_address_different(
|
||||
&TD.BIP_Broadcast_Addr, &Test_Sent_Message_Dest));
|
||||
/* SA = IUT - done in port layer */
|
||||
/* Original-Broadcast-NPDU */
|
||||
ct_test(pTest, Test_Sent_Message_Type ==
|
||||
BVLC_ORIGINAL_BROADCAST_NPDU);
|
||||
ct_test(pTest, Test_Sent_Message_Type == BVLC_ORIGINAL_BROADCAST_NPDU);
|
||||
if (Test_Sent_Message_Type == BVLC_ORIGINAL_BROADCAST_NPDU) {
|
||||
function_len = bvlc_decode_original_broadcast(
|
||||
Test_Sent_Message_Buffer, Test_Sent_Message_Buffer_Length,
|
||||
test_pdu, sizeof(test_pdu), &test_pdu_len);
|
||||
printf("len=%u pdu[%u] test_pdu[%u]\n",
|
||||
(unsigned)function_len,
|
||||
Test_Sent_Message_Buffer, Test_Sent_Message_Buffer_Length, test_pdu,
|
||||
sizeof(test_pdu), &test_pdu_len);
|
||||
printf(
|
||||
"len=%u pdu[%u] test_pdu[%u]\n", (unsigned)function_len,
|
||||
(unsigned)Test_Sent_Message_Buffer_Length,
|
||||
(unsigned)sizeof(test_pdu));
|
||||
ct_test(pTest, function_len > 0);
|
||||
@@ -204,13 +205,15 @@ static void test_Initiate_Original_Broadcast_NPDU(Test *pTest)
|
||||
static void test_BBMD_Result(Test *pTest)
|
||||
{
|
||||
int result = 0;
|
||||
uint16_t result_code[] = { BVLC_RESULT_SUCCESSFUL_COMPLETION,
|
||||
uint16_t result_code[] = {
|
||||
BVLC_RESULT_SUCCESSFUL_COMPLETION,
|
||||
BVLC_RESULT_WRITE_BROADCAST_DISTRIBUTION_TABLE_NAK,
|
||||
BVLC_RESULT_READ_BROADCAST_DISTRIBUTION_TABLE_NAK,
|
||||
BVLC_RESULT_REGISTER_FOREIGN_DEVICE_NAK,
|
||||
BVLC_RESULT_READ_FOREIGN_DEVICE_TABLE_NAK,
|
||||
BVLC_RESULT_DELETE_FOREIGN_DEVICE_TABLE_ENTRY_NAK,
|
||||
BVLC_RESULT_DISTRIBUTE_BROADCAST_TO_NETWORK_NAK };
|
||||
BVLC_RESULT_DISTRIBUTE_BROADCAST_TO_NETWORK_NAK
|
||||
};
|
||||
size_t result_code_max = sizeof(result_code) / sizeof(result_code[0]);
|
||||
uint16_t test_result_code = 0;
|
||||
uint8_t test_function_code = 0;
|
||||
|
||||
@@ -82,7 +82,7 @@ int bip6_send_mpdu(BACNET_IP6_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len)
|
||||
Test_Sent_Message_Length = message_length;
|
||||
bvlc6_address_copy(&Test_Sent_Message_Dest, dest);
|
||||
if ((header_len == 4) && (mtu_len >= 4)) {
|
||||
memcpy(&Test_Sent_Message_Buffer[0], &mtu[4], mtu_len-4);
|
||||
memcpy(&Test_Sent_Message_Buffer[0], &mtu[4], mtu_len - 4);
|
||||
Test_Sent_Message_Buffer_Length = mtu_len - 4;
|
||||
} else {
|
||||
Test_Sent_Message_Buffer_Length = 0;
|
||||
@@ -126,22 +126,21 @@ static void test_setup(void)
|
||||
{
|
||||
bvlc6_init();
|
||||
/* BACnet_IPv6_Multicast_Address is FF02::BAC0 */
|
||||
bvlc6_address_set(&TD.BIP6_Broadcast_Addr,
|
||||
BIP6_MULTICAST_LINK_LOCAL, 0, 0, 0, 0, 0, 0,
|
||||
bvlc6_address_set(
|
||||
&TD.BIP6_Broadcast_Addr, BIP6_MULTICAST_LINK_LOCAL, 0, 0, 0, 0, 0, 0,
|
||||
BIP6_MULTICAST_GROUP_ID);
|
||||
bvlc6_address_set(&TD.BIP6_Addr,
|
||||
0x2001, 0x0DBB, 0xAC10, 0xFE01, 0, 0, 0,
|
||||
bvlc6_address_set(
|
||||
&TD.BIP6_Addr, 0x2001, 0x0DBB, 0xAC10, 0xFE01, 0, 0, 0,
|
||||
BIP6_MULTICAST_GROUP_ID);
|
||||
TD.Device_ID = 12345;
|
||||
bvlc6_vmac_address_set(&TD.BACnet_Address, TD.Device_ID);
|
||||
|
||||
|
||||
/* BACnet_IPv6_Multicast_Address is FF02::BAC0 */
|
||||
bvlc6_address_set(&IUT.BIP6_Broadcast_Addr,
|
||||
BIP6_MULTICAST_LINK_LOCAL, 0, 0, 0, 0, 0, 0,
|
||||
bvlc6_address_set(
|
||||
&IUT.BIP6_Broadcast_Addr, BIP6_MULTICAST_LINK_LOCAL, 0, 0, 0, 0, 0, 0,
|
||||
BIP6_MULTICAST_GROUP_ID);
|
||||
bvlc6_address_set(&IUT.BIP6_Addr,
|
||||
0x2001, 0x0DBB, 0xAC10, 0xFE01, 0, 0, 1,
|
||||
bvlc6_address_set(
|
||||
&IUT.BIP6_Addr, 0x2001, 0x0DBB, 0xAC10, 0xFE01, 0, 0, 1,
|
||||
BIP6_MULTICAST_GROUP_ID);
|
||||
IUT.Device_ID = 54321;
|
||||
bvlc6_vmac_address_set(&IUT.BACnet_Address, IUT.Device_ID);
|
||||
@@ -157,13 +156,13 @@ static void test_cleanup(void)
|
||||
*/
|
||||
static void test_Initiate_Original_Broadcast_NPDU(void)
|
||||
{
|
||||
uint8_t pdu[MAX_MPDU] = {0};
|
||||
uint8_t pdu[MAX_MPDU] = { 0 };
|
||||
int npdu_len = 0;
|
||||
int apdu_len = 0;
|
||||
int pdu_len = 0;
|
||||
BACNET_ADDRESS dest = {0};
|
||||
BACNET_NPDU_DATA npdu_data = {0};
|
||||
uint8_t test_pdu[MAX_MPDU] = {0};
|
||||
BACNET_ADDRESS dest = { 0 };
|
||||
BACNET_NPDU_DATA npdu_data = { 0 };
|
||||
uint8_t test_pdu[MAX_MPDU] = { 0 };
|
||||
uint16_t test_pdu_len = 0;
|
||||
uint32_t test_vmac_src = 0;
|
||||
int function_len = 0;
|
||||
@@ -173,17 +172,17 @@ static void test_Initiate_Original_Broadcast_NPDU(void)
|
||||
dest.net = BACNET_BROADCAST_NETWORK;
|
||||
npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL);
|
||||
npdu_len = npdu_encode_pdu(&pdu[0], &dest, &IUT.BACnet_Address, &npdu_data);
|
||||
apdu_len = iam_encode_apdu(&pdu[npdu_len], IUT.Device_ID, MAX_APDU,
|
||||
SEGMENTATION_NONE, BACNET_VENDOR_ID);
|
||||
apdu_len = iam_encode_apdu(
|
||||
&pdu[npdu_len], IUT.Device_ID, MAX_APDU, SEGMENTATION_NONE,
|
||||
BACNET_VENDOR_ID);
|
||||
pdu_len = npdu_len + apdu_len;
|
||||
bvlc6_send_pdu(&dest, &npdu_data, pdu, pdu_len);
|
||||
/* DA=Link Local Multicast Address */
|
||||
assert(!bvlc6_address_different(&TD.BIP6_Broadcast_Addr,
|
||||
&Test_Sent_Message_Dest));
|
||||
assert(!bvlc6_address_different(
|
||||
&TD.BIP6_Broadcast_Addr, &Test_Sent_Message_Dest));
|
||||
/* SA = IUT - done in port layer */
|
||||
/* Original-Broadcast-NPDU */
|
||||
assert(Test_Sent_Message_Type ==
|
||||
BVLC6_ORIGINAL_BROADCAST_NPDU);
|
||||
assert(Test_Sent_Message_Type == BVLC6_ORIGINAL_BROADCAST_NPDU);
|
||||
if (Test_Sent_Message_Type == BVLC6_ORIGINAL_BROADCAST_NPDU) {
|
||||
function_len = bvlc6_decode_original_broadcast(
|
||||
Test_Sent_Message_Buffer, Test_Sent_Message_Buffer_Length,
|
||||
@@ -203,7 +202,7 @@ static void test_Initiate_Original_Broadcast_NPDU(void)
|
||||
*/
|
||||
static void test_Execute_Virtual_Address_Resolution(void)
|
||||
{
|
||||
uint8_t mtu[MAX_MPDU] = {0};
|
||||
uint8_t mtu[MAX_MPDU] = { 0 };
|
||||
uint16_t mtu_len = 0;
|
||||
uint32_t test_vmac_src = 0;
|
||||
uint32_t test_vmac_dst = 0;
|
||||
@@ -214,13 +213,11 @@ static void test_Execute_Virtual_Address_Resolution(void)
|
||||
test_setup();
|
||||
mtu_len = bvlc6_encode_virtual_address_resolution(
|
||||
&mtu[0], sizeof(mtu), TD.Device_ID);
|
||||
result = bvlc6_bbmd_disabled_handler(&TD.BIP6_Addr, &TD.BACnet_Address,
|
||||
&mtu[0], mtu_len);
|
||||
result = bvlc6_bbmd_disabled_handler(
|
||||
&TD.BIP6_Addr, &TD.BACnet_Address, &mtu[0], mtu_len);
|
||||
assert(result == 0);
|
||||
assert(bvlc6_get_function_code() ==
|
||||
BVLC6_VIRTUAL_ADDRESS_RESOLUTION);
|
||||
assert(Test_Sent_Message_Type ==
|
||||
BVLC6_VIRTUAL_ADDRESS_RESOLUTION_ACK);
|
||||
assert(bvlc6_get_function_code() == BVLC6_VIRTUAL_ADDRESS_RESOLUTION);
|
||||
assert(Test_Sent_Message_Type == BVLC6_VIRTUAL_ADDRESS_RESOLUTION_ACK);
|
||||
assert(VMAC_Find_By_Key(TD.Device_ID) != NULL);
|
||||
if (Test_Sent_Message_Type == BVLC6_VIRTUAL_ADDRESS_RESOLUTION_ACK) {
|
||||
function_len = bvlc6_decode_virtual_address_resolution_ack(
|
||||
@@ -235,34 +232,31 @@ static void test_Execute_Virtual_Address_Resolution(void)
|
||||
TD.Device_ID += 42;
|
||||
mtu_len = bvlc6_encode_virtual_address_resolution(
|
||||
&mtu[0], sizeof(mtu), TD.Device_ID);
|
||||
result = bvlc6_bbmd_disabled_handler(&TD.BIP6_Addr, &TD.BACnet_Address,
|
||||
&mtu[0], mtu_len);
|
||||
result = bvlc6_bbmd_disabled_handler(
|
||||
&TD.BIP6_Addr, &TD.BACnet_Address, &mtu[0], mtu_len);
|
||||
assert(result == 0);
|
||||
assert(bvlc6_get_function_code() ==
|
||||
BVLC6_VIRTUAL_ADDRESS_RESOLUTION);
|
||||
assert(bvlc6_get_function_code() == BVLC6_VIRTUAL_ADDRESS_RESOLUTION);
|
||||
assert(VMAC_Find_By_Key(TD.Device_ID) != NULL);
|
||||
assert(VMAC_Find_By_Key(old_device_id) == NULL);
|
||||
/* change IPv6 address */
|
||||
mtu_len = bvlc6_encode_virtual_address_resolution(
|
||||
&mtu[0], sizeof(mtu), TD.Device_ID);
|
||||
bvlc6_address_set(&TD.BIP6_Addr,
|
||||
0x2001, 0x0DBB, 0xAC10, 0xFE01, 0, 0, 42,
|
||||
bvlc6_address_set(
|
||||
&TD.BIP6_Addr, 0x2001, 0x0DBB, 0xAC10, 0xFE01, 0, 0, 42,
|
||||
BIP6_MULTICAST_GROUP_ID);
|
||||
result = bvlc6_bbmd_disabled_handler(&TD.BIP6_Addr, &TD.BACnet_Address,
|
||||
&mtu[0], mtu_len);
|
||||
result = bvlc6_bbmd_disabled_handler(
|
||||
&TD.BIP6_Addr, &TD.BACnet_Address, &mtu[0], mtu_len);
|
||||
assert(result == 0);
|
||||
assert(bvlc6_get_function_code() ==
|
||||
BVLC6_VIRTUAL_ADDRESS_RESOLUTION);
|
||||
assert(bvlc6_get_function_code() == BVLC6_VIRTUAL_ADDRESS_RESOLUTION);
|
||||
assert(VMAC_Find_By_Key(TD.Device_ID) != NULL);
|
||||
/* repeat with same device ID and address */
|
||||
/* change IPv6 address */
|
||||
mtu_len = bvlc6_encode_virtual_address_resolution(
|
||||
&mtu[0], sizeof(mtu), TD.Device_ID);
|
||||
result = bvlc6_bbmd_disabled_handler(&TD.BIP6_Addr, &TD.BACnet_Address,
|
||||
&mtu[0], mtu_len);
|
||||
result = bvlc6_bbmd_disabled_handler(
|
||||
&TD.BIP6_Addr, &TD.BACnet_Address, &mtu[0], mtu_len);
|
||||
assert(result == 0);
|
||||
assert(bvlc6_get_function_code() ==
|
||||
BVLC6_VIRTUAL_ADDRESS_RESOLUTION);
|
||||
assert(bvlc6_get_function_code() == BVLC6_VIRTUAL_ADDRESS_RESOLUTION);
|
||||
assert(VMAC_Find_By_Key(TD.Device_ID) != NULL);
|
||||
|
||||
test_cleanup();
|
||||
@@ -272,12 +266,14 @@ static void test_BBMD_Result(void)
|
||||
{
|
||||
int result = 0;
|
||||
uint32_t vmac_src = 0x1234;
|
||||
uint16_t result_code[6] = { BVLC6_RESULT_SUCCESSFUL_COMPLETION,
|
||||
uint16_t result_code[6] = {
|
||||
BVLC6_RESULT_SUCCESSFUL_COMPLETION,
|
||||
BVLC6_RESULT_ADDRESS_RESOLUTION_NAK,
|
||||
BVLC6_RESULT_VIRTUAL_ADDRESS_RESOLUTION_NAK,
|
||||
BVLC6_RESULT_REGISTER_FOREIGN_DEVICE_NAK,
|
||||
BVLC6_RESULT_DELETE_FOREIGN_DEVICE_NAK,
|
||||
BVLC6_RESULT_DISTRIBUTE_BROADCAST_TO_NETWORK_NAK };
|
||||
BVLC6_RESULT_DISTRIBUTE_BROADCAST_TO_NETWORK_NAK
|
||||
};
|
||||
uint16_t test_result_code = 0;
|
||||
uint8_t test_function_code = 0;
|
||||
BACNET_IP6_ADDRESS addr;
|
||||
@@ -286,7 +282,8 @@ static void test_BBMD_Result(void)
|
||||
uint8_t mtu[MAX_MPDU] = { 0 };
|
||||
uint16_t mtu_len = 0;
|
||||
|
||||
bvlc6_address_set(&addr, BIP6_MULTICAST_LINK_LOCAL, 0, 0, 0, 0, 0, 0,
|
||||
bvlc6_address_set(
|
||||
&addr, BIP6_MULTICAST_LINK_LOCAL, 0, 0, 0, 0, 0, 0,
|
||||
BIP6_MULTICAST_GROUP_ID);
|
||||
addr.port = 0xBAC0U;
|
||||
bvlc6_vmac_address_set(&src, vmac_src);
|
||||
|
||||
@@ -44,7 +44,8 @@ static void set_address(unsigned index, BACNET_ADDRESS *dest)
|
||||
}
|
||||
}
|
||||
|
||||
static void set_file_address(const char *pFilename,
|
||||
static void set_file_address(
|
||||
const char *pFilename,
|
||||
uint32_t device_id,
|
||||
BACNET_ADDRESS *dest,
|
||||
uint16_t max_apdu)
|
||||
@@ -114,7 +115,6 @@ static void testAddressFile(void)
|
||||
address_remove_device(device_id);
|
||||
zassert_equal(address_count(), 0, NULL);
|
||||
|
||||
|
||||
/* create a fake address */
|
||||
device_id = 55555;
|
||||
src.mac_len = 6;
|
||||
@@ -170,12 +170,14 @@ static void testAddress(void)
|
||||
set_address(i, &src);
|
||||
/* test the lookup by device id */
|
||||
zassert_true(
|
||||
address_get_by_device(device_id, &test_max_apdu, &test_address), NULL);
|
||||
address_get_by_device(device_id, &test_max_apdu, &test_address),
|
||||
NULL);
|
||||
zassert_equal(test_max_apdu, max_apdu, NULL);
|
||||
zassert_true(bacnet_address_same(&test_address, &src), NULL);
|
||||
zassert_true(
|
||||
address_get_by_index(
|
||||
i, &test_device_id, &test_max_apdu, &test_address), NULL);
|
||||
i, &test_device_id, &test_max_apdu, &test_address),
|
||||
NULL);
|
||||
zassert_equal(test_device_id, device_id, NULL);
|
||||
zassert_equal(test_max_apdu, max_apdu, NULL);
|
||||
zassert_true(bacnet_address_same(&test_address, &src), NULL);
|
||||
@@ -189,7 +191,8 @@ static void testAddress(void)
|
||||
device_id = i * 255;
|
||||
address_remove_device(device_id);
|
||||
zassert_false(
|
||||
address_get_by_device(device_id, &test_max_apdu, &test_address), NULL);
|
||||
address_get_by_device(device_id, &test_max_apdu, &test_address),
|
||||
NULL);
|
||||
count = address_count();
|
||||
zassert_equal(count, (MAX_ADDRESS_CACHE - i - 1), NULL);
|
||||
}
|
||||
@@ -198,26 +201,21 @@ static void testAddress(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(address_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
#ifdef BACNET_ADDRESS_CACHE_FILE
|
||||
ztest_test_suite(address_tests,
|
||||
ztest_unit_test(testAddressFile),
|
||||
ztest_unit_test(testAddress)
|
||||
);
|
||||
ztest_test_suite(
|
||||
address_tests, ztest_unit_test(testAddressFile),
|
||||
ztest_unit_test(testAddress));
|
||||
|
||||
ztest_run_test_suite(address_tests);
|
||||
#else
|
||||
ztest_test_suite(address_tests,
|
||||
ztest_unit_test(testAddress)
|
||||
);
|
||||
ztest_test_suite(address_tests, ztest_unit_test(testAddress));
|
||||
|
||||
ztest_run_test_suite(address_tests);
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -29,8 +29,8 @@ static void test_Accumulator(void)
|
||||
uint8_t apdu[MAX_APDU] = { 0 };
|
||||
int len = 0;
|
||||
int test_len = 0;
|
||||
BACNET_READ_PROPERTY_DATA rpdata = {0};
|
||||
BACNET_APPLICATION_DATA_VALUE value = {0};
|
||||
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
|
||||
BACNET_APPLICATION_DATA_VALUE value = { 0 };
|
||||
const int *required_property = NULL;
|
||||
BACNET_UNSIGNED_INTEGER unsigned_value = 1;
|
||||
|
||||
@@ -48,14 +48,16 @@ static void test_Accumulator(void)
|
||||
zassert_true(len >= 0, NULL);
|
||||
if (len >= 0) {
|
||||
if (IS_CONTEXT_SPECIFIC(rpdata.application_data[0])) {
|
||||
test_len = bacapp_decode_context_data(rpdata.application_data,
|
||||
len, &value, rpdata.object_property);
|
||||
test_len = bacapp_decode_context_data(
|
||||
rpdata.application_data, len, &value,
|
||||
rpdata.object_property);
|
||||
} else {
|
||||
test_len = bacapp_decode_application_data(
|
||||
rpdata.application_data, len, &value);
|
||||
}
|
||||
if (len != test_len) {
|
||||
printf("property '%s': failed to decode!\n",
|
||||
printf(
|
||||
"property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
zassert_equal(len, test_len, NULL);
|
||||
@@ -68,10 +70,10 @@ static void test_Accumulator(void)
|
||||
Accumulator_Present_Value_Set(0, unsigned_value);
|
||||
len = Accumulator_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, 0, NULL);
|
||||
test_len = bacapp_decode_application_data(rpdata.application_data,
|
||||
len, &value);
|
||||
test_len = bacapp_decode_application_data(
|
||||
rpdata.application_data, len, &value);
|
||||
zassert_equal(len, test_len, NULL);
|
||||
unsigned_value |= (unsigned_value<<1);
|
||||
unsigned_value |= (unsigned_value << 1);
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -80,15 +82,12 @@ static void test_Accumulator(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(acc_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(acc_tests,
|
||||
ztest_unit_test(test_Accumulator)
|
||||
);
|
||||
ztest_test_suite(acc_tests, ztest_unit_test(test_Accumulator));
|
||||
|
||||
ztest_run_test_suite(acc_tests);
|
||||
}
|
||||
|
||||
@@ -49,8 +49,9 @@ static void testAccessCredential(void)
|
||||
zassert_true(len >= 0, NULL);
|
||||
if (len >= 0) {
|
||||
if (IS_CONTEXT_SPECIFIC(rpdata.application_data[0])) {
|
||||
test_len = bacapp_decode_context_data(rpdata.application_data,
|
||||
len, &value, rpdata.object_property);
|
||||
test_len = bacapp_decode_context_data(
|
||||
rpdata.application_data, len, &value,
|
||||
rpdata.object_property);
|
||||
} else {
|
||||
test_len = bacapp_decode_application_data(
|
||||
rpdata.application_data, len, &value);
|
||||
@@ -61,7 +62,8 @@ static void testAccessCredential(void)
|
||||
}
|
||||
}
|
||||
if (len != test_len) {
|
||||
fprintf(stderr, "property '%d': failed to decode!\n",
|
||||
fprintf(
|
||||
stderr, "property '%d': failed to decode!\n",
|
||||
rpdata.object_property);
|
||||
}
|
||||
zassert_true(len == test_len, NULL);
|
||||
@@ -75,7 +77,6 @@ static void testAccessCredential(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(access_credential_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
|
||||
@@ -52,8 +52,9 @@ static void test_object_access_door(void)
|
||||
len = Access_Door_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR, NULL);
|
||||
if (len > 0) {
|
||||
test_len = bacapp_decode_application_data(rpdata.application_data,
|
||||
(uint8_t)rpdata.application_data_len, &value);
|
||||
test_len = bacapp_decode_application_data(
|
||||
rpdata.application_data, (uint8_t)rpdata.application_data_len,
|
||||
&value);
|
||||
zassert_true(test_len >= 0, NULL);
|
||||
}
|
||||
pRequired++;
|
||||
@@ -64,8 +65,9 @@ static void test_object_access_door(void)
|
||||
len = Access_Door_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR, NULL);
|
||||
if (len > 0) {
|
||||
test_len = bacapp_decode_application_data(rpdata.application_data,
|
||||
(uint8_t)rpdata.application_data_len, &value);
|
||||
test_len = bacapp_decode_application_data(
|
||||
rpdata.application_data, (uint8_t)rpdata.application_data_len,
|
||||
&value);
|
||||
zassert_true(test_len >= 0, NULL);
|
||||
}
|
||||
pOptional++;
|
||||
@@ -77,7 +79,6 @@ static void test_object_access_door(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(tests_object_access_door, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
|
||||
@@ -30,7 +30,7 @@ static void testAccessPoint(void)
|
||||
uint8_t apdu[MAX_APDU] = { 0 };
|
||||
int len = 0, test_len = 0;
|
||||
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
|
||||
BACNET_APPLICATION_DATA_VALUE value = {0};
|
||||
BACNET_APPLICATION_DATA_VALUE value = { 0 };
|
||||
const int *required_property = NULL;
|
||||
unsigned count = 0;
|
||||
uint32_t object_instance = 0;
|
||||
@@ -50,10 +50,12 @@ static void testAccessPoint(void)
|
||||
len = Access_Point_Read_Property(&rpdata);
|
||||
if (len >= 0) {
|
||||
zassert_true(len >= 0, NULL);
|
||||
test_len = bacapp_decode_known_property(rpdata.application_data,
|
||||
len, &value, rpdata.object_type, rpdata.object_property);
|
||||
test_len = bacapp_decode_known_property(
|
||||
rpdata.application_data, len, &value, rpdata.object_type,
|
||||
rpdata.object_property);
|
||||
if (len != test_len) {
|
||||
printf("property '%s': failed to decode!\n",
|
||||
printf(
|
||||
"property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
if (rpdata.object_property == PROP_ACCESS_DOORS) {
|
||||
@@ -62,7 +64,8 @@ static void testAccessPoint(void)
|
||||
}
|
||||
zassert_equal(len, test_len, NULL);
|
||||
} else {
|
||||
printf("property '%s': failed to read!\n",
|
||||
printf(
|
||||
"property '%s': failed to read!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
required_property++;
|
||||
@@ -72,7 +75,6 @@ static void testAccessPoint(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(access_point_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
|
||||
@@ -52,15 +52,12 @@ static void testAccessRights(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(access_rights_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(access_rights_tests,
|
||||
ztest_unit_test(testAccessRights)
|
||||
);
|
||||
ztest_test_suite(access_rights_tests, ztest_unit_test(testAccessRights));
|
||||
|
||||
ztest_run_test_suite(access_rights_tests);
|
||||
}
|
||||
|
||||
@@ -52,15 +52,12 @@ static void testAccessUser(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(access_user_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(access_user_tests,
|
||||
ztest_unit_test(testAccessUser)
|
||||
);
|
||||
ztest_test_suite(access_user_tests, ztest_unit_test(testAccessUser));
|
||||
|
||||
ztest_run_test_suite(access_user_tests);
|
||||
}
|
||||
|
||||
@@ -52,15 +52,12 @@ static void testAccessZone(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(access_zone_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(access_zone_tests,
|
||||
ztest_unit_test(testAccessZone)
|
||||
);
|
||||
ztest_test_suite(access_zone_tests, ztest_unit_test(testAccessZone));
|
||||
|
||||
ztest_run_test_suite(access_zone_tests);
|
||||
}
|
||||
|
||||
@@ -37,11 +37,8 @@ static void testAnalogInput(void)
|
||||
test_object_instance = Analog_Input_Index_To_Instance(0);
|
||||
zassert_equal(object_instance, test_object_instance, NULL);
|
||||
bacnet_object_properties_read_write_test(
|
||||
OBJECT_ANALOG_INPUT,
|
||||
object_instance,
|
||||
Analog_Input_Property_Lists,
|
||||
Analog_Input_Read_Property,
|
||||
Analog_Input_Write_Property,
|
||||
OBJECT_ANALOG_INPUT, object_instance, Analog_Input_Property_Lists,
|
||||
Analog_Input_Read_Property, Analog_Input_Write_Property,
|
||||
skip_fail_property_list);
|
||||
status = Analog_Input_Delete(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
@@ -50,15 +47,12 @@ static void testAnalogInput(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(ai_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(ai_tests,
|
||||
ztest_unit_test(testAnalogInput)
|
||||
);
|
||||
ztest_test_suite(ai_tests, ztest_unit_test(testAnalogInput));
|
||||
|
||||
ztest_run_test_suite(ai_tests);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
#include "bacnet/get_alarm_sum.h"
|
||||
#include "bacnet/npdu.h"
|
||||
|
||||
bool datetime_local(BACNET_DATE *bdate,
|
||||
bool datetime_local(
|
||||
BACNET_DATE *bdate,
|
||||
BACNET_TIME *btime,
|
||||
int16_t *utc_offset_minutes,
|
||||
bool *dst_active)
|
||||
|
||||
@@ -37,11 +37,8 @@ static void testAnalogOutput(void)
|
||||
test_object_instance = Analog_Output_Index_To_Instance(0);
|
||||
zassert_equal(object_instance, test_object_instance, NULL);
|
||||
bacnet_object_properties_read_write_test(
|
||||
OBJECT_ANALOG_OUTPUT,
|
||||
object_instance,
|
||||
Analog_Output_Property_Lists,
|
||||
Analog_Output_Read_Property,
|
||||
Analog_Output_Write_Property,
|
||||
OBJECT_ANALOG_OUTPUT, object_instance, Analog_Output_Property_Lists,
|
||||
Analog_Output_Read_Property, Analog_Output_Write_Property,
|
||||
skip_fail_property_list);
|
||||
status = Analog_Output_Delete(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
@@ -50,15 +47,12 @@ static void testAnalogOutput(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(ao_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(ao_tests,
|
||||
ztest_unit_test(testAnalogOutput)
|
||||
);
|
||||
ztest_test_suite(ao_tests, ztest_unit_test(testAnalogOutput));
|
||||
|
||||
ztest_run_test_suite(ao_tests);
|
||||
}
|
||||
|
||||
@@ -37,11 +37,8 @@ static void testAnalog_Value(void)
|
||||
test_object_instance = Analog_Value_Index_To_Instance(0);
|
||||
zassert_equal(object_instance, test_object_instance, NULL);
|
||||
bacnet_object_properties_read_write_test(
|
||||
OBJECT_ANALOG_VALUE,
|
||||
object_instance,
|
||||
Analog_Value_Property_Lists,
|
||||
Analog_Value_Read_Property,
|
||||
Analog_Value_Write_Property,
|
||||
OBJECT_ANALOG_VALUE, object_instance, Analog_Value_Property_Lists,
|
||||
Analog_Value_Read_Property, Analog_Value_Write_Property,
|
||||
skip_fail_property_list);
|
||||
status = Analog_Value_Delete(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
@@ -50,15 +47,12 @@ static void testAnalog_Value(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(av_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(av_tests,
|
||||
ztest_unit_test(testAnalog_Value)
|
||||
);
|
||||
ztest_test_suite(av_tests, ztest_unit_test(testAnalog_Value));
|
||||
|
||||
ztest_run_test_suite(av_tests);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
#include "bacnet/get_alarm_sum.h"
|
||||
#include "bacnet/npdu.h"
|
||||
|
||||
bool datetime_local(BACNET_DATE *bdate,
|
||||
bool datetime_local(
|
||||
BACNET_DATE *bdate,
|
||||
BACNET_TIME *btime,
|
||||
int16_t *utc_offset_minutes,
|
||||
bool *dst_active)
|
||||
|
||||
@@ -29,7 +29,7 @@ static void test_BACnet_File_Object(void)
|
||||
uint8_t apdu[MAX_APDU] = { 0 };
|
||||
int len = 0, test_len = 0;
|
||||
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
|
||||
BACNET_APPLICATION_DATA_VALUE value = {0};
|
||||
BACNET_APPLICATION_DATA_VALUE value = { 0 };
|
||||
const int *required_property = NULL;
|
||||
const uint32_t instance = 1;
|
||||
|
||||
@@ -46,15 +46,18 @@ static void test_BACnet_File_Object(void)
|
||||
rpdata.object_property = *required_property;
|
||||
len = bacfile_read_property(&rpdata);
|
||||
if (len < 0) {
|
||||
printf("property %u: failed to read!\n",
|
||||
printf(
|
||||
"property %u: failed to read!\n",
|
||||
(unsigned)rpdata.object_property);
|
||||
}
|
||||
zassert_true(len >= 0, NULL);
|
||||
if (len >= 0) {
|
||||
test_len = bacapp_decode_known_property(rpdata.application_data,
|
||||
len, &value, rpdata.object_type, rpdata.object_property);
|
||||
test_len = bacapp_decode_known_property(
|
||||
rpdata.application_data, len, &value, rpdata.object_type,
|
||||
rpdata.object_property);
|
||||
if (len != test_len) {
|
||||
printf("property %u: failed to decode!\n",
|
||||
printf(
|
||||
"property %u: failed to decode!\n",
|
||||
(unsigned)rpdata.object_property);
|
||||
}
|
||||
zassert_equal(len, test_len, NULL);
|
||||
@@ -68,15 +71,12 @@ static void test_BACnet_File_Object(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(bacfile_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(bacfile_tests,
|
||||
ztest_unit_test(test_BACnet_File_Object)
|
||||
);
|
||||
ztest_test_suite(bacfile_tests, ztest_unit_test(test_BACnet_File_Object));
|
||||
|
||||
ztest_run_test_suite(bacfile_tests);
|
||||
}
|
||||
|
||||
@@ -38,11 +38,8 @@ static void testBinaryInput(void)
|
||||
test_object_instance = Binary_Input_Index_To_Instance(0);
|
||||
zassert_equal(object_instance, test_object_instance, NULL);
|
||||
bacnet_object_properties_read_write_test(
|
||||
OBJECT_BINARY_INPUT,
|
||||
object_instance,
|
||||
Binary_Input_Property_Lists,
|
||||
Binary_Input_Read_Property,
|
||||
Binary_Input_Write_Property,
|
||||
OBJECT_BINARY_INPUT, object_instance, Binary_Input_Property_Lists,
|
||||
Binary_Input_Read_Property, Binary_Input_Write_Property,
|
||||
skip_fail_property_list);
|
||||
status = Binary_Input_Delete(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
@@ -51,15 +48,12 @@ static void testBinaryInput(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(bi_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(bi_tests,
|
||||
ztest_unit_test(testBinaryInput)
|
||||
);
|
||||
ztest_test_suite(bi_tests, ztest_unit_test(testBinaryInput));
|
||||
|
||||
ztest_run_test_suite(bi_tests);
|
||||
}
|
||||
|
||||
@@ -57,15 +57,17 @@ static void testBinaryLightingOutput(void)
|
||||
rpdata.object_property = *pRequired;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Binary_Lighting_Output_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR,
|
||||
zassert_not_equal(
|
||||
len, BACNET_STATUS_ERROR,
|
||||
"property '%s': failed to ReadProperty!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
if (len >= 0) {
|
||||
test_len = bacapp_decode_known_property(rpdata.application_data,
|
||||
len, &value, rpdata.object_type, rpdata.object_property);
|
||||
test_len = bacapp_decode_known_property(
|
||||
rpdata.application_data, len, &value, rpdata.object_type,
|
||||
rpdata.object_property);
|
||||
if (rpdata.object_property != PROP_PRIORITY_ARRAY) {
|
||||
zassert_equal(len, test_len,
|
||||
"property '%s': failed to decode!\n",
|
||||
zassert_equal(
|
||||
len, test_len, "property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
/* check WriteProperty properties */
|
||||
@@ -79,8 +81,8 @@ static void testBinaryLightingOutput(void)
|
||||
status = Binary_Lighting_Output_Write_Property(&wpdata);
|
||||
if (!status) {
|
||||
/* verify WriteProperty property is known */
|
||||
zassert_not_equal(wpdata.error_code,
|
||||
ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
zassert_not_equal(
|
||||
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
"property '%s': WriteProperty Unknown!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
@@ -91,13 +93,16 @@ static void testBinaryLightingOutput(void)
|
||||
rpdata.object_property = *pOptional;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Binary_Lighting_Output_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR,
|
||||
zassert_not_equal(
|
||||
len, BACNET_STATUS_ERROR,
|
||||
"property '%s': failed to ReadProperty!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
if (len > 0) {
|
||||
test_len = bacapp_decode_application_data(rpdata.application_data,
|
||||
(uint8_t)rpdata.application_data_len, &value);
|
||||
zassert_equal(len, test_len, "property '%s': failed to decode!\n",
|
||||
test_len = bacapp_decode_application_data(
|
||||
rpdata.application_data, (uint8_t)rpdata.application_data_len,
|
||||
&value);
|
||||
zassert_equal(
|
||||
len, test_len, "property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
/* check WriteProperty properties */
|
||||
wpdata.object_type = rpdata.object_type;
|
||||
@@ -110,8 +115,8 @@ static void testBinaryLightingOutput(void)
|
||||
status = Binary_Lighting_Output_Write_Property(&wpdata);
|
||||
if (!status) {
|
||||
/* verify WriteProperty property is known */
|
||||
zassert_not_equal(wpdata.error_code,
|
||||
ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
zassert_not_equal(
|
||||
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
"property '%s': WriteProperty Unknown!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
@@ -137,7 +142,8 @@ static struct {
|
||||
BACNET_BINARY_LIGHTING_PV pv;
|
||||
uint32_t count;
|
||||
} BLO_Value;
|
||||
static void Binary_Lighting_Output_Write_Value_Handler(uint32_t object_instance,
|
||||
static void Binary_Lighting_Output_Write_Value_Handler(
|
||||
uint32_t object_instance,
|
||||
BACNET_BINARY_LIGHTING_PV old_value,
|
||||
BACNET_BINARY_LIGHTING_PV value)
|
||||
{
|
||||
@@ -210,8 +216,9 @@ static void testBinaryLightingOutputBlink(void)
|
||||
zassert_equal(expect_pv, test_pv, NULL);
|
||||
test_priority =
|
||||
Binary_Lighting_Output_Present_Value_Priority(object_instance);
|
||||
zassert_equal(wpdata.priority, test_priority,
|
||||
"priority=%u test_priority=%u", wpdata.priority, test_priority);
|
||||
zassert_equal(
|
||||
wpdata.priority, test_priority, "priority=%u test_priority=%u",
|
||||
wpdata.priority, test_priority);
|
||||
zassert_equal(BLO_Blink.count, 0, NULL);
|
||||
zassert_equal(BLO_Value.count, 1, "count=%u", BLO_Value.count);
|
||||
zassert_equal(BLO_Value.pv, expect_pv, NULL);
|
||||
@@ -232,8 +239,9 @@ static void testBinaryLightingOutputBlink(void)
|
||||
zassert_equal(expect_pv, test_pv, NULL);
|
||||
test_priority =
|
||||
Binary_Lighting_Output_Present_Value_Priority(object_instance);
|
||||
zassert_equal(wpdata.priority, test_priority,
|
||||
"priority=%u test_priority=%u", wpdata.priority, test_priority);
|
||||
zassert_equal(
|
||||
wpdata.priority, test_priority, "priority=%u test_priority=%u",
|
||||
wpdata.priority, test_priority);
|
||||
zassert_equal(BLO_Blink.count, 0, NULL);
|
||||
zassert_equal(BLO_Value.count, 2, "count=%u", BLO_Value.count);
|
||||
zassert_equal(BLO_Value.pv, expect_pv, NULL);
|
||||
@@ -254,8 +262,9 @@ static void testBinaryLightingOutputBlink(void)
|
||||
zassert_equal(expect_pv, test_pv, "pv=%u", test_pv);
|
||||
test_priority =
|
||||
Binary_Lighting_Output_Present_Value_Priority(object_instance);
|
||||
zassert_equal(wpdata.priority, test_priority,
|
||||
"priority=%u test_priority=%u", wpdata.priority, test_priority);
|
||||
zassert_equal(
|
||||
wpdata.priority, test_priority, "priority=%u test_priority=%u",
|
||||
wpdata.priority, test_priority);
|
||||
zassert_equal(BLO_Blink.count, 0, NULL);
|
||||
zassert_equal(BLO_Value.count, 2, "count=%u", BLO_Value.count);
|
||||
zassert_equal(BLO_Value.pv, expect_pv, NULL);
|
||||
@@ -271,7 +280,8 @@ ZTEST_SUITE(blo_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(blo_tests, ztest_unit_test(testBinaryLightingOutput),
|
||||
ztest_test_suite(
|
||||
blo_tests, ztest_unit_test(testBinaryLightingOutput),
|
||||
ztest_unit_test(testBinaryLightingOutputBlink));
|
||||
|
||||
ztest_run_test_suite(blo_tests);
|
||||
|
||||
@@ -37,11 +37,8 @@ static void testBinaryOutput(void)
|
||||
test_object_instance = Binary_Output_Index_To_Instance(0);
|
||||
zassert_equal(object_instance, test_object_instance, NULL);
|
||||
bacnet_object_properties_read_write_test(
|
||||
OBJECT_BINARY_OUTPUT,
|
||||
object_instance,
|
||||
Binary_Output_Property_Lists,
|
||||
Binary_Output_Read_Property,
|
||||
Binary_Output_Write_Property,
|
||||
OBJECT_BINARY_OUTPUT, object_instance, Binary_Output_Property_Lists,
|
||||
Binary_Output_Read_Property, Binary_Output_Write_Property,
|
||||
skip_fail_property_list);
|
||||
status = Binary_Output_Delete(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
@@ -50,15 +47,12 @@ static void testBinaryOutput(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(bo_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(bo_tests,
|
||||
ztest_unit_test(testBinaryOutput)
|
||||
);
|
||||
ztest_test_suite(bo_tests, ztest_unit_test(testBinaryOutput));
|
||||
|
||||
ztest_run_test_suite(bo_tests);
|
||||
}
|
||||
|
||||
@@ -39,11 +39,8 @@ static void testBinary_Value(void)
|
||||
test_object_instance = Binary_Value_Index_To_Instance(0);
|
||||
zassert_equal(object_instance, test_object_instance, NULL);
|
||||
bacnet_object_properties_read_write_test(
|
||||
OBJECT_BINARY_VALUE,
|
||||
object_instance,
|
||||
Binary_Value_Property_Lists,
|
||||
Binary_Value_Read_Property,
|
||||
Binary_Value_Write_Property,
|
||||
OBJECT_BINARY_VALUE, object_instance, Binary_Value_Property_Lists,
|
||||
Binary_Value_Read_Property, Binary_Value_Write_Property,
|
||||
skip_fail_property_list);
|
||||
status = Binary_Value_Delete(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
@@ -52,15 +49,12 @@ static void testBinary_Value(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(bv_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(bv_tests,
|
||||
ztest_unit_test(testBinary_Value)
|
||||
);
|
||||
ztest_test_suite(bv_tests, ztest_unit_test(testBinary_Value));
|
||||
|
||||
ztest_run_test_suite(bv_tests);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ static void testCalendar(void)
|
||||
int len = 0, test_len = 0;
|
||||
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
|
||||
BACNET_WRITE_PROPERTY_DATA wpdata = { 0 };
|
||||
BACNET_APPLICATION_DATA_VALUE value = {0};
|
||||
BACNET_APPLICATION_DATA_VALUE value = { 0 };
|
||||
const int *pRequired = NULL;
|
||||
const int *pOptional = NULL;
|
||||
const int *pProprietary = NULL;
|
||||
@@ -57,14 +57,16 @@ static void testCalendar(void)
|
||||
rpdata.object_property = *pRequired;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Calendar_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR,
|
||||
zassert_not_equal(
|
||||
len, BACNET_STATUS_ERROR,
|
||||
"property '%s': failed to ReadProperty!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
if (len >= 0) {
|
||||
test_len = bacapp_decode_known_property(rpdata.application_data,
|
||||
len, &value, rpdata.object_type, rpdata.object_property);
|
||||
zassert_equal(len, test_len,
|
||||
"property '%s': failed to decode!\n",
|
||||
test_len = bacapp_decode_known_property(
|
||||
rpdata.application_data, len, &value, rpdata.object_type,
|
||||
rpdata.object_property);
|
||||
zassert_equal(
|
||||
len, test_len, "property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
/* check WriteProperty properties */
|
||||
wpdata.object_type = rpdata.object_type;
|
||||
@@ -77,8 +79,8 @@ static void testCalendar(void)
|
||||
status = Calendar_Write_Property(&wpdata);
|
||||
if (!status) {
|
||||
/* verify WriteProperty property is known */
|
||||
zassert_not_equal(wpdata.error_code,
|
||||
ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
zassert_not_equal(
|
||||
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
"property '%s': WriteProperty Unknown!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
@@ -89,13 +91,16 @@ static void testCalendar(void)
|
||||
rpdata.object_property = *pOptional;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Calendar_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR,
|
||||
zassert_not_equal(
|
||||
len, BACNET_STATUS_ERROR,
|
||||
"property '%s': failed to ReadProperty!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
if (len > 0) {
|
||||
test_len = bacapp_decode_application_data(rpdata.application_data,
|
||||
(uint8_t)rpdata.application_data_len, &value);
|
||||
zassert_equal(len, test_len, "property '%s': failed to decode!\n",
|
||||
test_len = bacapp_decode_application_data(
|
||||
rpdata.application_data, (uint8_t)rpdata.application_data_len,
|
||||
&value);
|
||||
zassert_equal(
|
||||
len, test_len, "property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
/* check WriteProperty properties */
|
||||
wpdata.object_type = rpdata.object_type;
|
||||
@@ -108,8 +113,8 @@ static void testCalendar(void)
|
||||
status = Calendar_Write_Property(&wpdata);
|
||||
if (!status) {
|
||||
/* verify WriteProperty property is known */
|
||||
zassert_not_equal(wpdata.error_code,
|
||||
ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
zassert_not_equal(
|
||||
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
"property '%s': WriteProperty Unknown!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
@@ -182,7 +187,7 @@ static void testPresentValue(void)
|
||||
zassert_true(Calendar_Present_Value(instance), NULL);
|
||||
|
||||
if (date.day > 1) {
|
||||
value->type.DateRange.startdate.day --;
|
||||
value->type.DateRange.startdate.day--;
|
||||
value->type.DateRange.enddate.day = date.day;
|
||||
zassert_true(Calendar_Present_Value(instance), NULL);
|
||||
}
|
||||
@@ -214,7 +219,7 @@ static void testPresentValue(void)
|
||||
value->type.WeekNDay.weekofmonth = (date.day - 1) % 7 + 1;
|
||||
zassert_true(Calendar_Present_Value(instance), NULL);
|
||||
value->type.WeekNDay.weekofmonth++;
|
||||
if (value->type.WeekNDay.weekofmonth >5)
|
||||
if (value->type.WeekNDay.weekofmonth > 5)
|
||||
value->type.WeekNDay.weekofmonth = 1;
|
||||
zassert_false(Calendar_Present_Value(instance), NULL);
|
||||
value->type.WeekNDay.weekofmonth = 0xff;
|
||||
@@ -241,10 +246,9 @@ ZTEST_SUITE(bacnet_calendar, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(calendar_tests,
|
||||
ztest_unit_test(testCalendar),
|
||||
ztest_unit_test(testPresentValue)
|
||||
);
|
||||
ztest_test_suite(
|
||||
calendar_tests, ztest_unit_test(testCalendar),
|
||||
ztest_unit_test(testPresentValue));
|
||||
|
||||
ztest_run_test_suite(calendar_tests);
|
||||
}
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
#include "bacnet/datetime.h"
|
||||
|
||||
bool datetime_local(
|
||||
BACNET_DATE * bdate,
|
||||
BACNET_TIME * btime,
|
||||
int16_t * utc_offset_minutes,
|
||||
bool * dst_active)
|
||||
BACNET_DATE *bdate,
|
||||
BACNET_TIME *btime,
|
||||
int16_t *utc_offset_minutes,
|
||||
bool *dst_active)
|
||||
{
|
||||
bdate->year = 2023;
|
||||
bdate->month = 6;
|
||||
|
||||
@@ -55,20 +55,23 @@ static void test_Channel_ReadProperty(void)
|
||||
rpdata.object_property = *pRequired;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Channel_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR,
|
||||
zassert_not_equal(
|
||||
len, BACNET_STATUS_ERROR,
|
||||
"property '%s': failed to ReadProperty!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
if (len > 0) {
|
||||
test_len = bacapp_decode_application_data(rpdata.application_data,
|
||||
(uint8_t)rpdata.application_data_len, &value);
|
||||
test_len = bacapp_decode_application_data(
|
||||
rpdata.application_data, (uint8_t)rpdata.application_data_len,
|
||||
&value);
|
||||
if ((rpdata.object_property == PROP_PRIORITY_ARRAY) ||
|
||||
(rpdata.object_property == PROP_CONTROL_GROUPS) ||
|
||||
(rpdata.object_property ==
|
||||
PROP_LIST_OF_OBJECT_PROPERTY_REFERENCES)) {
|
||||
PROP_LIST_OF_OBJECT_PROPERTY_REFERENCES)) {
|
||||
/* FIXME: known fail to decode */
|
||||
len = test_len;
|
||||
}
|
||||
zassert_equal(len, test_len, "property '%s': failed to decode!\n",
|
||||
zassert_equal(
|
||||
len, test_len, "property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
/* check WriteProperty properties */
|
||||
wpdata.object_type = rpdata.object_type;
|
||||
@@ -81,8 +84,8 @@ static void test_Channel_ReadProperty(void)
|
||||
status = Channel_Write_Property(&wpdata);
|
||||
if (!status) {
|
||||
/* verify WriteProperty property is known */
|
||||
zassert_not_equal(wpdata.error_code,
|
||||
ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
zassert_not_equal(
|
||||
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
"property '%s': WriteProperty Unknown!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
@@ -93,13 +96,16 @@ static void test_Channel_ReadProperty(void)
|
||||
rpdata.object_property = *pOptional;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Channel_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR,
|
||||
zassert_not_equal(
|
||||
len, BACNET_STATUS_ERROR,
|
||||
"property '%s': failed to ReadProperty!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
if (len > 0) {
|
||||
test_len = bacapp_decode_application_data(rpdata.application_data,
|
||||
(uint8_t)rpdata.application_data_len, &value);
|
||||
zassert_equal(len, test_len, "property '%s': failed to decode!\n",
|
||||
test_len = bacapp_decode_application_data(
|
||||
rpdata.application_data, (uint8_t)rpdata.application_data_len,
|
||||
&value);
|
||||
zassert_equal(
|
||||
len, test_len, "property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
/* check WriteProperty properties */
|
||||
wpdata.object_type = rpdata.object_type;
|
||||
@@ -112,8 +118,8 @@ static void test_Channel_ReadProperty(void)
|
||||
status = Channel_Write_Property(&wpdata);
|
||||
if (!status) {
|
||||
/* verify WriteProperty property is known */
|
||||
zassert_not_equal(wpdata.error_code,
|
||||
ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
zassert_not_equal(
|
||||
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
"property '%s': WriteProperty Unknown!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
|
||||
@@ -55,13 +55,16 @@ static void testColorObject(void)
|
||||
rpdata.object_property = *pRequired;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Color_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR,
|
||||
zassert_not_equal(
|
||||
len, BACNET_STATUS_ERROR,
|
||||
"property '%s': failed to ReadProperty!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
if (len >= 0) {
|
||||
test_len = bacapp_decode_known_property(rpdata.application_data,
|
||||
len, &value, rpdata.object_type, rpdata.object_property);
|
||||
zassert_equal(len, test_len, "property '%s': failed to decode!\n",
|
||||
test_len = bacapp_decode_known_property(
|
||||
rpdata.application_data, len, &value, rpdata.object_type,
|
||||
rpdata.object_property);
|
||||
zassert_equal(
|
||||
len, test_len, "property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
/* check WriteProperty properties */
|
||||
wpdata.object_type = rpdata.object_type;
|
||||
@@ -74,8 +77,8 @@ static void testColorObject(void)
|
||||
status = Color_Write_Property(&wpdata);
|
||||
if (!status) {
|
||||
/* verify WriteProperty property is known */
|
||||
zassert_not_equal(wpdata.error_code,
|
||||
ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
zassert_not_equal(
|
||||
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
"property '%s': WriteProperty Unknown!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
@@ -86,13 +89,16 @@ static void testColorObject(void)
|
||||
rpdata.object_property = *pOptional;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Color_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR,
|
||||
zassert_not_equal(
|
||||
len, BACNET_STATUS_ERROR,
|
||||
"property '%s': failed to ReadProperty!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
if (len > 0) {
|
||||
test_len = bacapp_decode_application_data(rpdata.application_data,
|
||||
(uint8_t)rpdata.application_data_len, &value);
|
||||
zassert_equal(len, test_len, "property '%s': failed to decode!\n",
|
||||
test_len = bacapp_decode_application_data(
|
||||
rpdata.application_data, (uint8_t)rpdata.application_data_len,
|
||||
&value);
|
||||
zassert_equal(
|
||||
len, test_len, "property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
/* check WriteProperty properties */
|
||||
wpdata.object_type = rpdata.object_type;
|
||||
@@ -105,8 +111,8 @@ static void testColorObject(void)
|
||||
status = Color_Write_Property(&wpdata);
|
||||
if (!status) {
|
||||
/* verify WriteProperty property is known */
|
||||
zassert_not_equal(wpdata.error_code,
|
||||
ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
zassert_not_equal(
|
||||
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
"property '%s': WriteProperty Unknown!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <bacnet/bactext.h>
|
||||
#include <bacnet/basic/object/color_temperature.h>
|
||||
|
||||
|
||||
/**
|
||||
* @addtogroup bacnet_tests
|
||||
* @{
|
||||
@@ -28,8 +27,8 @@ static void testColorTemperature(void)
|
||||
uint8_t apdu[MAX_APDU] = { 0 };
|
||||
int len = 0;
|
||||
int test_len = 0;
|
||||
BACNET_READ_PROPERTY_DATA rpdata = {0};
|
||||
BACNET_APPLICATION_DATA_VALUE value = {0};
|
||||
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
|
||||
BACNET_APPLICATION_DATA_VALUE value = { 0 };
|
||||
const int *pRequired = NULL;
|
||||
const int *pOptional = NULL;
|
||||
const int *pProprietary = NULL;
|
||||
@@ -51,14 +50,17 @@ static void testColorTemperature(void)
|
||||
rpdata.object_property = *pRequired;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Color_Temperature_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR,
|
||||
zassert_not_equal(
|
||||
len, BACNET_STATUS_ERROR,
|
||||
"property '%s': failed to ReadProperty!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
if (len >= 0) {
|
||||
test_len = bacapp_decode_known_property(rpdata.application_data,
|
||||
len, &value, rpdata.object_type, rpdata.object_property);
|
||||
zassert_equal(len, test_len, "property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
test_len = bacapp_decode_known_property(
|
||||
rpdata.application_data, len, &value, rpdata.object_type,
|
||||
rpdata.object_property);
|
||||
zassert_equal(
|
||||
len, test_len, "property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
/* check WriteProperty properties */
|
||||
wpdata.object_type = rpdata.object_type;
|
||||
wpdata.object_instance = rpdata.object_instance;
|
||||
@@ -70,8 +72,8 @@ static void testColorTemperature(void)
|
||||
status = Color_Temperature_Write_Property(&wpdata);
|
||||
if (!status) {
|
||||
/* verify WriteProperty property is known */
|
||||
zassert_not_equal(wpdata.error_code,
|
||||
ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
zassert_not_equal(
|
||||
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
"property '%s': WriteProperty Unknown!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
@@ -82,15 +84,17 @@ static void testColorTemperature(void)
|
||||
rpdata.object_property = *pOptional;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Color_Temperature_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR,
|
||||
zassert_not_equal(
|
||||
len, BACNET_STATUS_ERROR,
|
||||
"property '%s': failed to ReadProperty!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
if (len > 0) {
|
||||
test_len = bacapp_decode_application_data(
|
||||
rpdata.application_data,
|
||||
(uint8_t)rpdata.application_data_len, &value);
|
||||
zassert_equal(len, test_len, "property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
rpdata.application_data, (uint8_t)rpdata.application_data_len,
|
||||
&value);
|
||||
zassert_equal(
|
||||
len, test_len, "property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
/* check WriteProperty properties */
|
||||
wpdata.object_type = rpdata.object_type;
|
||||
wpdata.object_instance = rpdata.object_instance;
|
||||
@@ -102,8 +106,8 @@ static void testColorTemperature(void)
|
||||
status = Color_Temperature_Write_Property(&wpdata);
|
||||
if (!status) {
|
||||
/* verify WriteProperty property is known */
|
||||
zassert_not_equal(wpdata.error_code,
|
||||
ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
zassert_not_equal(
|
||||
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
"property '%s': WriteProperty Unknown!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
@@ -125,15 +129,13 @@ static void testColorTemperature(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(color_temperature_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(color_temperature_tests,
|
||||
ztest_unit_test(testColorTemperature)
|
||||
);
|
||||
ztest_test_suite(
|
||||
color_temperature_tests, ztest_unit_test(testColorTemperature));
|
||||
|
||||
ztest_run_test_suite(color_temperature_tests);
|
||||
}
|
||||
|
||||
@@ -34,12 +34,8 @@ static void test_object_command(void)
|
||||
zassert_true(count > 0, NULL);
|
||||
object_instance = Command_Index_To_Instance(0);
|
||||
bacnet_object_properties_read_write_test(
|
||||
OBJECT_COMMAND,
|
||||
object_instance,
|
||||
Command_Property_Lists,
|
||||
Command_Read_Property,
|
||||
Command_Write_Property,
|
||||
skip_fail_property_list);
|
||||
OBJECT_COMMAND, object_instance, Command_Property_Lists,
|
||||
Command_Read_Property, Command_Write_Property, skip_fail_property_list);
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -27,37 +27,31 @@ static void testCredentialDataInput(void)
|
||||
{
|
||||
unsigned count = 0;
|
||||
uint32_t object_instance = 0;
|
||||
const int skip_fail_property_list[] = {
|
||||
PROP_PRESENT_VALUE,
|
||||
PROP_UPDATE_TIME,
|
||||
PROP_SUPPORTED_FORMATS,
|
||||
-1 };
|
||||
const int skip_fail_property_list[] = { PROP_PRESENT_VALUE,
|
||||
PROP_UPDATE_TIME,
|
||||
PROP_SUPPORTED_FORMATS, -1 };
|
||||
|
||||
Credential_Data_Input_Init();
|
||||
count = Credential_Data_Input_Count();
|
||||
zassert_true(count > 0, NULL);
|
||||
object_instance = Credential_Data_Input_Index_To_Instance(0);
|
||||
bacnet_object_properties_read_write_test(
|
||||
OBJECT_CREDENTIAL_DATA_INPUT,
|
||||
object_instance,
|
||||
OBJECT_CREDENTIAL_DATA_INPUT, object_instance,
|
||||
Credential_Data_Input_Property_Lists,
|
||||
Credential_Data_Input_Read_Property,
|
||||
Credential_Data_Input_Write_Property,
|
||||
skip_fail_property_list);
|
||||
Credential_Data_Input_Write_Property, skip_fail_property_list);
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(credential_data_input_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(credential_data_input_tests,
|
||||
ztest_unit_test(testCredentialDataInput)
|
||||
);
|
||||
ztest_test_suite(
|
||||
credential_data_input_tests, ztest_unit_test(testCredentialDataInput));
|
||||
|
||||
ztest_run_test_suite(credential_data_input_tests);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ static void testCharacterString_Value(void)
|
||||
uint8_t apdu[MAX_APDU] = { 0 };
|
||||
int len = 0, test_len = 0;
|
||||
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
|
||||
BACNET_APPLICATION_DATA_VALUE value = {0};
|
||||
BACNET_APPLICATION_DATA_VALUE value = { 0 };
|
||||
const int *pRequired = NULL;
|
||||
const int *pOptional = NULL;
|
||||
const int *pProprietary = NULL;
|
||||
@@ -47,10 +47,12 @@ static void testCharacterString_Value(void)
|
||||
len = CharacterString_Value_Read_Property(&rpdata);
|
||||
zassert_true(len >= 0, NULL);
|
||||
if (len >= 0) {
|
||||
test_len = bacapp_decode_known_property(rpdata.application_data,
|
||||
len, &value, rpdata.object_type, rpdata.object_property);
|
||||
test_len = bacapp_decode_known_property(
|
||||
rpdata.application_data, len, &value, rpdata.object_type,
|
||||
rpdata.object_property);
|
||||
if (len != test_len) {
|
||||
printf("property '%s': failed to decode!\n",
|
||||
printf(
|
||||
"property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
if (rpdata.object_property == PROP_PRIORITY_ARRAY) {
|
||||
@@ -59,7 +61,8 @@ static void testCharacterString_Value(void)
|
||||
}
|
||||
zassert_equal(len, test_len, NULL);
|
||||
} else {
|
||||
printf("property '%s': failed to read!\n",
|
||||
printf(
|
||||
"property '%s': failed to read!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
pRequired++;
|
||||
@@ -70,15 +73,18 @@ static void testCharacterString_Value(void)
|
||||
len = CharacterString_Value_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR, NULL);
|
||||
if (len > 0) {
|
||||
test_len = bacapp_decode_application_data(rpdata.application_data,
|
||||
(uint8_t)rpdata.application_data_len, &value);
|
||||
test_len = bacapp_decode_application_data(
|
||||
rpdata.application_data, (uint8_t)rpdata.application_data_len,
|
||||
&value);
|
||||
if (len != test_len) {
|
||||
printf("property '%s': failed to decode!\n",
|
||||
printf(
|
||||
"property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
zassert_true(test_len >= 0, NULL);
|
||||
} else {
|
||||
printf("property '%s': failed to read!\n",
|
||||
printf(
|
||||
"property '%s': failed to read!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
pOptional++;
|
||||
|
||||
@@ -48,18 +48,21 @@ static void test_Device_Data_Sharing(void)
|
||||
rpdata.object_property = *pRequired;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Device_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR,
|
||||
zassert_not_equal(
|
||||
len, BACNET_STATUS_ERROR,
|
||||
"property '%s': failed to ReadProperty!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
if (len > 0) {
|
||||
test_len = bacapp_decode_application_data(rpdata.application_data,
|
||||
(uint8_t)rpdata.application_data_len, &value);
|
||||
test_len = bacapp_decode_application_data(
|
||||
rpdata.application_data, (uint8_t)rpdata.application_data_len,
|
||||
&value);
|
||||
if ((rpdata.object_property == PROP_PRIORITY_ARRAY) ||
|
||||
(rpdata.object_property == PROP_OBJECT_LIST)) {
|
||||
/* FIXME: known fail to decode */
|
||||
len = test_len;
|
||||
}
|
||||
zassert_equal(test_len, len, "property '%s': failed to decode!\n",
|
||||
zassert_equal(
|
||||
test_len, len, "property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
/* check WriteProperty properties */
|
||||
wpdata.object_type = rpdata.object_type;
|
||||
@@ -72,8 +75,8 @@ static void test_Device_Data_Sharing(void)
|
||||
status = Device_Write_Property(&wpdata);
|
||||
if (!status) {
|
||||
/* verify WriteProperty property is known */
|
||||
zassert_not_equal(wpdata.error_code,
|
||||
ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
zassert_not_equal(
|
||||
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
"property '%s': WriteProperty Unknown!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
@@ -84,17 +87,21 @@ static void test_Device_Data_Sharing(void)
|
||||
rpdata.object_property = *pOptional;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Device_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR,
|
||||
zassert_not_equal(
|
||||
len, BACNET_STATUS_ERROR,
|
||||
"property '%s': failed to ReadProperty!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
if (len > 0) {
|
||||
test_len = bacapp_decode_application_data(rpdata.application_data,
|
||||
(uint8_t)rpdata.application_data_len, &value);
|
||||
test_len = bacapp_decode_application_data(
|
||||
rpdata.application_data, (uint8_t)rpdata.application_data_len,
|
||||
&value);
|
||||
if (len != test_len) {
|
||||
printf("property '%s': failed to decode!\n",
|
||||
printf(
|
||||
"property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
zassert_equal(test_len, len, "property '%s': failed to decode!\n",
|
||||
zassert_equal(
|
||||
test_len, len, "property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
/* check WriteProperty properties */
|
||||
wpdata.object_type = rpdata.object_type;
|
||||
@@ -107,8 +114,8 @@ static void test_Device_Data_Sharing(void)
|
||||
status = Device_Write_Property(&wpdata);
|
||||
if (!status) {
|
||||
/* verify WriteProperty property is known */
|
||||
zassert_not_equal(wpdata.error_code,
|
||||
ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
zassert_not_equal(
|
||||
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
"property '%s': WriteProperty Unknown!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
@@ -161,9 +168,11 @@ static void testDevice(void)
|
||||
status = Device_Reinitialize_Password_Set(NULL);
|
||||
status = Device_Reinitialize(&rd_data);
|
||||
zassert_true(status, NULL);
|
||||
zassert_equal(rd_data.error_class, ERROR_CLASS_DEVICE, "error-class=%s",
|
||||
zassert_equal(
|
||||
rd_data.error_class, ERROR_CLASS_DEVICE, "error-class=%s",
|
||||
bactext_error_class_name(rd_data.error_class));
|
||||
zassert_equal(rd_data.error_code, ERROR_CODE_SUCCESS, "error-code=%s",
|
||||
zassert_equal(
|
||||
rd_data.error_code, ERROR_CODE_SUCCESS, "error-code=%s",
|
||||
bactext_error_code_name(rd_data.error_code));
|
||||
/* Reinitialize with device valid password, service no password */
|
||||
status = Device_Reinitialize_Password_Set("valid");
|
||||
@@ -172,19 +181,23 @@ static void testDevice(void)
|
||||
zassert_true(status, NULL);
|
||||
status = Device_Reinitialize(&rd_data);
|
||||
zassert_false(status, NULL);
|
||||
zassert_equal(rd_data.error_class, ERROR_CLASS_SECURITY, "error-class=%s",
|
||||
zassert_equal(
|
||||
rd_data.error_class, ERROR_CLASS_SECURITY, "error-class=%s",
|
||||
bactext_error_class_name(rd_data.error_class));
|
||||
zassert_equal(rd_data.error_code, ERROR_CODE_PASSWORD_FAILURE,
|
||||
"error-code=%s", bactext_error_code_name(rd_data.error_code));
|
||||
zassert_equal(
|
||||
rd_data.error_code, ERROR_CODE_PASSWORD_FAILURE, "error-code=%s",
|
||||
bactext_error_code_name(rd_data.error_code));
|
||||
/* Reinitialize with device valid password, service invalid password */
|
||||
status = characterstring_init_ansi(&rd_data.password, "invalid");
|
||||
zassert_true(status, NULL);
|
||||
status = Device_Reinitialize(&rd_data);
|
||||
zassert_false(status, NULL);
|
||||
zassert_equal(rd_data.error_class, ERROR_CLASS_SECURITY, "error-class=%s",
|
||||
zassert_equal(
|
||||
rd_data.error_class, ERROR_CLASS_SECURITY, "error-class=%s",
|
||||
bactext_error_class_name(rd_data.error_class));
|
||||
zassert_equal(rd_data.error_code, ERROR_CODE_PASSWORD_FAILURE,
|
||||
"error-code=%s", bactext_error_code_name(rd_data.error_code));
|
||||
zassert_equal(
|
||||
rd_data.error_code, ERROR_CODE_PASSWORD_FAILURE, "error-code=%s",
|
||||
bactext_error_code_name(rd_data.error_code));
|
||||
/* Reinitialize with device valid password, service valid password */
|
||||
characterstring_init_ansi(&rd_data.password, "valid");
|
||||
status = Device_Reinitialize(&rd_data);
|
||||
@@ -193,20 +206,24 @@ static void testDevice(void)
|
||||
characterstring_init_ansi(&rd_data.password, "abcdefghijklmnopqrstuvwxyz");
|
||||
status = Device_Reinitialize(&rd_data);
|
||||
zassert_false(status, NULL);
|
||||
zassert_equal(rd_data.error_class, ERROR_CLASS_SERVICES, "error-class=%s",
|
||||
zassert_equal(
|
||||
rd_data.error_class, ERROR_CLASS_SERVICES, "error-class=%s",
|
||||
bactext_error_class_name(rd_data.error_class));
|
||||
zassert_equal(rd_data.error_code, ERROR_CODE_PARAMETER_OUT_OF_RANGE,
|
||||
"error-code=%s", bactext_error_code_name(rd_data.error_code));
|
||||
zassert_equal(
|
||||
rd_data.error_code, ERROR_CODE_PARAMETER_OUT_OF_RANGE, "error-code=%s",
|
||||
bactext_error_code_name(rd_data.error_code));
|
||||
/* Reinitialize with device no password, unsupported state */
|
||||
status = Device_Reinitialize_Password_Set(NULL);
|
||||
zassert_true(status, NULL);
|
||||
rd_data.state = BACNET_REINIT_MAX;
|
||||
status = Device_Reinitialize(&rd_data);
|
||||
zassert_false(status, NULL);
|
||||
zassert_equal(rd_data.error_class, ERROR_CLASS_SERVICES, "error-class=%s",
|
||||
zassert_equal(
|
||||
rd_data.error_class, ERROR_CLASS_SERVICES, "error-class=%s",
|
||||
bactext_error_class_name(rd_data.error_class));
|
||||
zassert_equal(rd_data.error_code, ERROR_CODE_PARAMETER_OUT_OF_RANGE,
|
||||
"error-code=%s", bactext_error_code_name(rd_data.error_code));
|
||||
zassert_equal(
|
||||
rd_data.error_code, ERROR_CODE_PARAMETER_OUT_OF_RANGE, "error-code=%s",
|
||||
bactext_error_code_name(rd_data.error_code));
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -219,7 +236,8 @@ ZTEST_SUITE(device_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(device_tests, ztest_unit_test(testDevice),
|
||||
ztest_test_suite(
|
||||
device_tests, ztest_unit_test(testDevice),
|
||||
ztest_unit_test(test_Device_Data_Sharing));
|
||||
|
||||
ztest_run_test_suite(device_tests);
|
||||
|
||||
@@ -36,22 +36,22 @@ void datetime_init(void)
|
||||
}
|
||||
|
||||
bool datetime_local(
|
||||
BACNET_DATE * bdate,
|
||||
BACNET_TIME * btime,
|
||||
int16_t * utc_offset_minutes,
|
||||
bool * dst_active)
|
||||
BACNET_DATE *bdate,
|
||||
BACNET_TIME *btime,
|
||||
int16_t *utc_offset_minutes,
|
||||
bool *dst_active)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void bip_get_my_address(BACNET_ADDRESS * my_address)
|
||||
void bip_get_my_address(BACNET_ADDRESS *my_address)
|
||||
{
|
||||
}
|
||||
|
||||
int bip_send_pdu(
|
||||
BACNET_ADDRESS * dest,
|
||||
BACNET_NPDU_DATA * npdu_data,
|
||||
uint8_t * pdu,
|
||||
BACNET_ADDRESS *dest,
|
||||
BACNET_NPDU_DATA *npdu_data,
|
||||
uint8_t *pdu,
|
||||
unsigned pdu_len)
|
||||
{
|
||||
return 0;
|
||||
|
||||
@@ -24,7 +24,7 @@ static void testInteger_Value(void)
|
||||
uint8_t apdu[MAX_APDU] = { 0 };
|
||||
int len = 0, test_len = 0;
|
||||
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
|
||||
BACNET_APPLICATION_DATA_VALUE value = {0};
|
||||
BACNET_APPLICATION_DATA_VALUE value = { 0 };
|
||||
const int *pRequired = NULL;
|
||||
const int *pOptional = NULL;
|
||||
const int *pProprietary = NULL;
|
||||
@@ -47,10 +47,12 @@ static void testInteger_Value(void)
|
||||
len = Integer_Value_Read_Property(&rpdata);
|
||||
zassert_true(len >= 0, NULL);
|
||||
if (len >= 0) {
|
||||
test_len = bacapp_decode_known_property(rpdata.application_data,
|
||||
len, &value, rpdata.object_type, rpdata.object_property);
|
||||
test_len = bacapp_decode_known_property(
|
||||
rpdata.application_data, len, &value, rpdata.object_type,
|
||||
rpdata.object_property);
|
||||
if (len != test_len) {
|
||||
printf("property '%s': failed to decode!\n",
|
||||
printf(
|
||||
"property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
if (rpdata.object_property == PROP_PRIORITY_ARRAY) {
|
||||
@@ -59,7 +61,8 @@ static void testInteger_Value(void)
|
||||
}
|
||||
zassert_equal(len, test_len, NULL);
|
||||
} else {
|
||||
printf("property '%s': failed to read!\n",
|
||||
printf(
|
||||
"property '%s': failed to read!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
pRequired++;
|
||||
@@ -70,15 +73,18 @@ static void testInteger_Value(void)
|
||||
len = Integer_Value_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR, NULL);
|
||||
if (len > 0) {
|
||||
test_len = bacapp_decode_application_data(rpdata.application_data,
|
||||
(uint8_t)rpdata.application_data_len, &value);
|
||||
test_len = bacapp_decode_application_data(
|
||||
rpdata.application_data, (uint8_t)rpdata.application_data_len,
|
||||
&value);
|
||||
if (len != test_len) {
|
||||
printf("property '%s': failed to decode!\n",
|
||||
printf(
|
||||
"property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
zassert_true(test_len >= 0, NULL);
|
||||
} else {
|
||||
printf("property '%s': failed to read!\n",
|
||||
printf(
|
||||
"property '%s': failed to read!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
pOptional++;
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#define MAX_LOAD_CONTROLS 4
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @addtogroup bacnet_tests
|
||||
* @{
|
||||
@@ -52,8 +51,8 @@ static void test_Load_Control_Count(void)
|
||||
zassert_equal(Load_Control_Count(), MAX_LOAD_CONTROLS, NULL);
|
||||
}
|
||||
|
||||
static void Load_Control_WriteProperty_Request_Shed_Level(
|
||||
int instance, unsigned level)
|
||||
static void
|
||||
Load_Control_WriteProperty_Request_Shed_Level(int instance, unsigned level)
|
||||
{
|
||||
bool status = false;
|
||||
BACNET_APPLICATION_DATA_VALUE value;
|
||||
@@ -75,8 +74,7 @@ static void Load_Control_WriteProperty_Request_Shed_Level(
|
||||
zassert_true(status, NULL);
|
||||
}
|
||||
|
||||
static void Load_Control_WriteProperty_Enable(
|
||||
int instance, bool enable)
|
||||
static void Load_Control_WriteProperty_Enable(int instance, bool enable)
|
||||
{
|
||||
bool status = false;
|
||||
BACNET_APPLICATION_DATA_VALUE value;
|
||||
@@ -99,8 +97,8 @@ static void Load_Control_WriteProperty_Enable(
|
||||
zassert_true(status, NULL);
|
||||
}
|
||||
|
||||
static void Load_Control_WriteProperty_Shed_Duration(
|
||||
int instance, unsigned duration)
|
||||
static void
|
||||
Load_Control_WriteProperty_Shed_Duration(int instance, unsigned duration)
|
||||
{
|
||||
bool status = false;
|
||||
BACNET_APPLICATION_DATA_VALUE value;
|
||||
@@ -122,8 +120,8 @@ static void Load_Control_WriteProperty_Shed_Duration(
|
||||
zassert_true(status, NULL);
|
||||
}
|
||||
|
||||
static void Load_Control_WriteProperty_Duty_Window(
|
||||
int instance, unsigned duration)
|
||||
static void
|
||||
Load_Control_WriteProperty_Duty_Window(int instance, unsigned duration)
|
||||
{
|
||||
bool status = false;
|
||||
BACNET_APPLICATION_DATA_VALUE value;
|
||||
@@ -145,8 +143,7 @@ static void Load_Control_WriteProperty_Duty_Window(
|
||||
zassert_true(status, NULL);
|
||||
}
|
||||
|
||||
static void Load_Control_WriteProperty_Start_Time_Wildcards(
|
||||
int instance)
|
||||
static void Load_Control_WriteProperty_Start_Time_Wildcards(int instance)
|
||||
{
|
||||
int len = 0;
|
||||
bool status = false;
|
||||
@@ -220,18 +217,19 @@ ZTEST(lc_tests, testLoadControlStateMachine)
|
||||
static void testLoadControlStateMachine(void)
|
||||
#endif
|
||||
{
|
||||
//TODO: unsigned i = 0, j = 0;
|
||||
// TODO: unsigned i = 0, j = 0;
|
||||
uint8_t level = 0;
|
||||
|
||||
Load_Control_Init();
|
||||
|
||||
//TODO: /* validate the triggers for each state change */
|
||||
//TODO: for (j = 0; j < 20; j++) {
|
||||
//TODO: Load_Control_State_Machine(0);
|
||||
//TODO: for (i = 0; i < MAX_LOAD_CONTROLS; i++) {
|
||||
//TODO: zassert_equal(Load_Control_State[i], SHED_INACTIVE, NULL);
|
||||
//TODO: }
|
||||
//TODO: }
|
||||
// TODO: /* validate the triggers for each state change */
|
||||
// TODO: for (j = 0; j < 20; j++) {
|
||||
// TODO: Load_Control_State_Machine(0);
|
||||
// TODO: for (i = 0; i < MAX_LOAD_CONTROLS; i++) {
|
||||
// TODO: zassert_equal(Load_Control_State[i], SHED_INACTIVE,
|
||||
// NULL);
|
||||
// TODO: }
|
||||
// TODO: }
|
||||
|
||||
/* SHED_REQUEST_PENDING */
|
||||
/* CancelShed - Start time has wildcards */
|
||||
@@ -239,20 +237,22 @@ static void testLoadControlStateMachine(void)
|
||||
Load_Control_WriteProperty_Shed_Duration(0, 60);
|
||||
Load_Control_WriteProperty_Start_Time_Wildcards(0);
|
||||
Load_Control_State_Machine(0);
|
||||
//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL);
|
||||
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
|
||||
// NULL);
|
||||
Load_Control_State_Machine(0);
|
||||
//TODO: zassert_equal(Load_Control_State[0], SHED_INACTIVE, NULL);
|
||||
// TODO: zassert_equal(Load_Control_State[0], SHED_INACTIVE, NULL);
|
||||
|
||||
/* CancelShed - Requested_Shed_Level equal to default value */
|
||||
Load_Control_Init();
|
||||
Load_Control_WriteProperty_Request_Shed_Level(0, 0);
|
||||
Load_Control_WriteProperty_Start_Time(0, 2007, 2, 27, 15, 0, 0, 0);
|
||||
Load_Control_WriteProperty_Shed_Duration(0, 5);
|
||||
//TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 15, 0, 0, 0);
|
||||
// TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 15, 0, 0, 0);
|
||||
Load_Control_State_Machine(0);
|
||||
//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL);
|
||||
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
|
||||
// NULL);
|
||||
Load_Control_State_Machine(0);
|
||||
//TODO: zassert_equal(Load_Control_State[0], SHED_INACTIVE, NULL);
|
||||
// TODO: zassert_equal(Load_Control_State[0], SHED_INACTIVE, NULL);
|
||||
|
||||
/* CancelShed - Non-default values, but Start time is passed */
|
||||
Load_Control_Init();
|
||||
@@ -260,11 +260,12 @@ static void testLoadControlStateMachine(void)
|
||||
Load_Control_WriteProperty_Request_Shed_Level(0, 1);
|
||||
Load_Control_WriteProperty_Shed_Duration(0, 5);
|
||||
Load_Control_WriteProperty_Start_Time(0, 2007, 2, 27, 15, 0, 0, 0);
|
||||
//TODO: datetime_set_values(&Current_Time, 2007, 2, 28, 15, 0, 0, 0);
|
||||
// TODO: datetime_set_values(&Current_Time, 2007, 2, 28, 15, 0, 0, 0);
|
||||
Load_Control_State_Machine(0);
|
||||
//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL);
|
||||
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
|
||||
// NULL);
|
||||
Load_Control_State_Machine(0);
|
||||
//TODO: zassert_equal(Load_Control_State[0], SHED_INACTIVE, NULL);
|
||||
// TODO: zassert_equal(Load_Control_State[0], SHED_INACTIVE, NULL);
|
||||
|
||||
/* ReconfigurePending - new write received while pending */
|
||||
Load_Control_Init();
|
||||
@@ -272,27 +273,35 @@ static void testLoadControlStateMachine(void)
|
||||
Load_Control_WriteProperty_Request_Shed_Level(0, 1);
|
||||
Load_Control_WriteProperty_Shed_Duration(0, 5);
|
||||
Load_Control_WriteProperty_Start_Time(0, 2007, 2, 27, 15, 0, 0, 0);
|
||||
//TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 5, 0, 0, 0);
|
||||
// TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 5, 0, 0, 0);
|
||||
Load_Control_State_Machine(0);
|
||||
//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL);
|
||||
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
|
||||
// NULL);
|
||||
Load_Control_State_Machine(0);
|
||||
//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL);
|
||||
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
|
||||
// NULL);
|
||||
Load_Control_WriteProperty_Request_Shed_Level(0, 2);
|
||||
Load_Control_State_Machine(0);
|
||||
//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL);
|
||||
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
|
||||
// NULL);
|
||||
Load_Control_WriteProperty_Shed_Duration(0, 6);
|
||||
Load_Control_State_Machine(0);
|
||||
//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL);
|
||||
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
|
||||
// NULL);
|
||||
Load_Control_WriteProperty_Duty_Window(0, 60);
|
||||
Load_Control_State_Machine(0);
|
||||
//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL);
|
||||
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
|
||||
// NULL);
|
||||
Load_Control_WriteProperty_Start_Time(0, 2007, 2, 27, 15, 0, 0, 1);
|
||||
Load_Control_State_Machine(0);
|
||||
//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL);
|
||||
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
|
||||
// NULL);
|
||||
Load_Control_State_Machine(0);
|
||||
//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL);
|
||||
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
|
||||
// NULL);
|
||||
Load_Control_State_Machine(0);
|
||||
//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL);
|
||||
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
|
||||
// NULL);
|
||||
|
||||
/* CannotMeetShed -> FinishedUnsuccessfulShed */
|
||||
Load_Control_Init();
|
||||
@@ -300,22 +309,24 @@ static void testLoadControlStateMachine(void)
|
||||
Load_Control_WriteProperty_Request_Shed_Level(0, 1);
|
||||
Load_Control_WriteProperty_Shed_Duration(0, 120);
|
||||
Load_Control_WriteProperty_Start_Time(0, 2007, 2, 27, 15, 0, 0, 0);
|
||||
//TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 5, 0, 0, 0);
|
||||
// TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 5, 0, 0, 0);
|
||||
Load_Control_State_Machine(0);
|
||||
//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL);
|
||||
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
|
||||
// NULL);
|
||||
Load_Control_State_Machine(0);
|
||||
//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL);
|
||||
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
|
||||
// NULL);
|
||||
/* set to lowest value so we cannot meet the shed level */
|
||||
//TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 16, 0, 0, 0);
|
||||
// TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 16, 0, 0, 0);
|
||||
Analog_Output_Present_Value_Set(0, 0, 16);
|
||||
Load_Control_State_Machine(0);
|
||||
//TODO: zassert_equal(Load_Control_State[0], SHED_NON_COMPLIANT, NULL);
|
||||
// TODO: zassert_equal(Load_Control_State[0], SHED_NON_COMPLIANT, NULL);
|
||||
Load_Control_State_Machine(0);
|
||||
//TODO: zassert_equal(Load_Control_State[0], SHED_NON_COMPLIANT, NULL);
|
||||
// TODO: zassert_equal(Load_Control_State[0], SHED_NON_COMPLIANT, NULL);
|
||||
/* FinishedUnsuccessfulShed */
|
||||
//TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 23, 0, 0, 0);
|
||||
// TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 23, 0, 0, 0);
|
||||
Load_Control_State_Machine(0);
|
||||
//TODO: zassert_equal(Load_Control_State[0], SHED_INACTIVE, NULL);
|
||||
// TODO: zassert_equal(Load_Control_State[0], SHED_INACTIVE, NULL);
|
||||
|
||||
/* CannotMeetShed -> UnsuccessfulShedReconfigured */
|
||||
Load_Control_Init();
|
||||
@@ -323,44 +334,47 @@ static void testLoadControlStateMachine(void)
|
||||
Load_Control_WriteProperty_Request_Shed_Level(0, 1);
|
||||
Load_Control_WriteProperty_Shed_Duration(0, 120);
|
||||
Load_Control_WriteProperty_Start_Time(0, 2007, 2, 27, 15, 0, 0, 0);
|
||||
//TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 5, 0, 0, 0);
|
||||
// TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 5, 0, 0, 0);
|
||||
Load_Control_State_Machine(0);
|
||||
//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL);
|
||||
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
|
||||
// NULL);
|
||||
Load_Control_State_Machine(0);
|
||||
//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL);
|
||||
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
|
||||
// NULL);
|
||||
/* set to lowest value so we cannot meet the shed level */
|
||||
//TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 16, 0, 0, 0);
|
||||
// TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 16, 0, 0, 0);
|
||||
Analog_Output_Present_Value_Set(0, 0, 16);
|
||||
Load_Control_State_Machine(0);
|
||||
//TODO: zassert_equal(Load_Control_State[0], SHED_NON_COMPLIANT, NULL);
|
||||
// TODO: zassert_equal(Load_Control_State[0], SHED_NON_COMPLIANT, NULL);
|
||||
Load_Control_State_Machine(0);
|
||||
//TODO: zassert_equal(Load_Control_State[0], SHED_NON_COMPLIANT, NULL);
|
||||
// TODO: zassert_equal(Load_Control_State[0], SHED_NON_COMPLIANT, NULL);
|
||||
/* FinishedUnsuccessfulShed */
|
||||
Load_Control_WriteProperty_Start_Time(0, 2007, 2, 27, 16, 0, 0, 0);
|
||||
Load_Control_State_Machine(0);
|
||||
//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL);
|
||||
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
|
||||
// NULL);
|
||||
Load_Control_State_Machine(0);
|
||||
//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL);
|
||||
//TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 16, 0, 1, 0);
|
||||
// TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING,
|
||||
// NULL);
|
||||
// TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 16, 0, 1, 0);
|
||||
Load_Control_State_Machine(0);
|
||||
//TODO: zassert_equal(Load_Control_State[0], SHED_NON_COMPLIANT, NULL);
|
||||
// TODO: zassert_equal(Load_Control_State[0], SHED_NON_COMPLIANT, NULL);
|
||||
/* CanNowComplyWithShed */
|
||||
Analog_Output_Present_Value_Set(0, 100, 16);
|
||||
//TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 16, 0, 2, 0);
|
||||
// TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 16, 0, 2, 0);
|
||||
Load_Control_State_Machine(0);
|
||||
//TODO: zassert_equal(Load_Control_State[0], SHED_COMPLIANT, NULL);
|
||||
// TODO: zassert_equal(Load_Control_State[0], SHED_COMPLIANT, NULL);
|
||||
level = Analog_Output_Present_Value(0);
|
||||
//TODO: Fails: zassert_equal(level, 90, NULL);
|
||||
// TODO: Fails: zassert_equal(level, 90, NULL);
|
||||
/* FinishedSuccessfulShed */
|
||||
//TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 23, 0, 0, 0);
|
||||
// TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 23, 0, 0, 0);
|
||||
Load_Control_State_Machine(0);
|
||||
//TODO: zassert_equal(Load_Control_State[0], SHED_INACTIVE, NULL);
|
||||
// TODO: zassert_equal(Load_Control_State[0], SHED_INACTIVE, NULL);
|
||||
level = Analog_Output_Present_Value(0);
|
||||
//TODO: Fails: zassert_equal(level, 100, NULL);
|
||||
// TODO: Fails: zassert_equal(level, 100, NULL);
|
||||
(void)level; // TODO: remove when level will be checked
|
||||
}
|
||||
|
||||
|
||||
#ifndef MAX_LOAD_CONTROLS
|
||||
#define MAX_LOAD_CONTROLS (4)
|
||||
#endif
|
||||
@@ -376,12 +390,18 @@ static void test_api_stubs(void)
|
||||
zassert_equal(Load_Control_Count(), MAX_LOAD_CONTROLS, NULL);
|
||||
|
||||
zassert_false(Load_Control_Valid_Instance(MAX_LOAD_CONTROLS), NULL);
|
||||
zassert_equal(Load_Control_Index_To_Instance(MAX_LOAD_CONTROLS), Load_Control_Count(), NULL);
|
||||
zassert_equal(Load_Control_Instance_To_Index(MAX_LOAD_CONTROLS), Load_Control_Count(), NULL);
|
||||
zassert_equal(
|
||||
Load_Control_Index_To_Instance(MAX_LOAD_CONTROLS), Load_Control_Count(),
|
||||
NULL);
|
||||
zassert_equal(
|
||||
Load_Control_Instance_To_Index(MAX_LOAD_CONTROLS), Load_Control_Count(),
|
||||
NULL);
|
||||
|
||||
zassert_false(Load_Control_Valid_Instance(UINT32_MAX), NULL);
|
||||
zassert_equal(Load_Control_Index_To_Instance(UINT32_MAX), Load_Control_Count(), NULL);
|
||||
zassert_equal(Load_Control_Instance_To_Index(UINT32_MAX), Load_Control_Count(), NULL);
|
||||
zassert_equal(
|
||||
Load_Control_Index_To_Instance(UINT32_MAX), Load_Control_Count(), NULL);
|
||||
zassert_equal(
|
||||
Load_Control_Instance_To_Index(UINT32_MAX), Load_Control_Count(), NULL);
|
||||
|
||||
zassert_true(Load_Control_Valid_Instance(0), NULL);
|
||||
zassert_equal(Load_Control_Index_To_Instance(0), 0, NULL);
|
||||
@@ -390,7 +410,6 @@ static void test_api_stubs(void)
|
||||
zassert_false(Load_Control_Object_Name(0, NULL), NULL);
|
||||
zassert_false(Load_Control_Object_Name(UINT32_MAX, &object_name_st), NULL);
|
||||
|
||||
|
||||
zassert_true(Load_Control_Object_Name(0, &object_name_st), NULL);
|
||||
zassert_true(characterstring_valid(&object_name_st), NULL);
|
||||
zassert_true(characterstring_printable(&object_name_st), NULL);
|
||||
@@ -414,7 +433,6 @@ static void test_Load_Control_Read_Write_Property(void)
|
||||
unsigned count = 0;
|
||||
uint32_t object_instance = 0;
|
||||
|
||||
|
||||
zassert_equal(Load_Control_Read_Property(NULL), 0, NULL);
|
||||
zassert_false(Load_Control_Write_Property(NULL), NULL);
|
||||
|
||||
@@ -428,58 +446,57 @@ static void test_Load_Control_Read_Write_Property(void)
|
||||
rpdata.object_instance = object_instance;
|
||||
Load_Control_Property_Lists(&pRequired, &pOptional, &pProprietary);
|
||||
while ((*pRequired) != -1) {
|
||||
rpdata.object_property = *pRequired;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Load_Control_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR, NULL);
|
||||
if (len > 0) {
|
||||
test_len = bacapp_decode_application_data(
|
||||
rpdata.application_data,
|
||||
(uint8_t)rpdata.application_data_len, &value);
|
||||
zassert_true(test_len >= 0, NULL);
|
||||
}
|
||||
pRequired++;
|
||||
rpdata.object_property = *pRequired;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Load_Control_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR, NULL);
|
||||
if (len > 0) {
|
||||
test_len = bacapp_decode_application_data(
|
||||
rpdata.application_data, (uint8_t)rpdata.application_data_len,
|
||||
&value);
|
||||
zassert_true(test_len >= 0, NULL);
|
||||
}
|
||||
pRequired++;
|
||||
}
|
||||
while ((*pOptional) != -1) {
|
||||
rpdata.object_property = *pOptional;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Load_Control_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR, NULL);
|
||||
if (len > 0) {
|
||||
test_len = bacapp_decode_application_data(
|
||||
rpdata.application_data,
|
||||
(uint8_t)rpdata.application_data_len, &value);
|
||||
zassert_true(test_len >= 0, NULL);
|
||||
}
|
||||
pOptional++;
|
||||
rpdata.object_property = *pOptional;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Load_Control_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR, NULL);
|
||||
if (len > 0) {
|
||||
test_len = bacapp_decode_application_data(
|
||||
rpdata.application_data, (uint8_t)rpdata.application_data_len,
|
||||
&value);
|
||||
zassert_true(test_len >= 0, NULL);
|
||||
}
|
||||
pOptional++;
|
||||
}
|
||||
}
|
||||
|
||||
static bool init_wp_data_and_value(
|
||||
BACNET_WRITE_PROPERTY_DATA *wp_data,
|
||||
BACNET_APPLICATION_DATA_VALUE * value)
|
||||
BACNET_WRITE_PROPERTY_DATA *wp_data, BACNET_APPLICATION_DATA_VALUE *value)
|
||||
{
|
||||
bool status = false;
|
||||
if ((wp_data != NULL) && (value != NULL))
|
||||
{
|
||||
memset(value, 0, sizeof(*value));
|
||||
memset(wp_data, 0, sizeof(*wp_data));
|
||||
if ((wp_data != NULL) && (value != NULL)) {
|
||||
memset(value, 0, sizeof(*value));
|
||||
memset(wp_data, 0, sizeof(*wp_data));
|
||||
|
||||
wp_data->object_type = OBJECT_LOAD_CONTROL;
|
||||
wp_data->object_instance = 0;
|
||||
wp_data->array_index = BACNET_ARRAY_ALL;
|
||||
wp_data->priority = BACNET_NO_PRIORITY;
|
||||
wp_data->object_property = PROP_SHED_DURATION;
|
||||
value->context_specific = false;
|
||||
value->context_tag = 0;
|
||||
value->tag = BACNET_APPLICATION_TAG_UNSIGNED_INT;
|
||||
value->type.Unsigned_Int = 0; /* duration */
|
||||
wp_data->application_data_len = bacapp_encode_application_data(&wp_data->application_data[0], value);
|
||||
zassert_true(wp_data->application_data_len >= 0, NULL);
|
||||
zassert_equal(wp_data->error_class, 0, NULL);
|
||||
zassert_equal(wp_data->error_code, 0, NULL);
|
||||
wp_data->object_type = OBJECT_LOAD_CONTROL;
|
||||
wp_data->object_instance = 0;
|
||||
wp_data->array_index = BACNET_ARRAY_ALL;
|
||||
wp_data->priority = BACNET_NO_PRIORITY;
|
||||
wp_data->object_property = PROP_SHED_DURATION;
|
||||
value->context_specific = false;
|
||||
value->context_tag = 0;
|
||||
value->tag = BACNET_APPLICATION_TAG_UNSIGNED_INT;
|
||||
value->type.Unsigned_Int = 0; /* duration */
|
||||
wp_data->application_data_len = bacapp_encode_application_data(
|
||||
&wp_data->application_data[0], value);
|
||||
zassert_true(wp_data->application_data_len >= 0, NULL);
|
||||
zassert_equal(wp_data->error_class, 0, NULL);
|
||||
zassert_equal(wp_data->error_code, 0, NULL);
|
||||
|
||||
status = true;
|
||||
status = true;
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -513,12 +530,11 @@ static void test_ShedInactive_gets_RcvShedRequests(void)
|
||||
zassert_equal(wp_data.error_class, ERROR_CLASS_PROPERTY, NULL);
|
||||
zassert_equal(wp_data.error_code, ERROR_CODE_VALUE_OUT_OF_RANGE, NULL);
|
||||
|
||||
|
||||
/* Verify calls to dependencies are properly made */
|
||||
// object_property == PROP_REQUESTED_SHED_LEVEL calls bacapp_decode_context_data()
|
||||
// object_property == PROP_START_TIME calls bacapp_decode_application_data()
|
||||
// object_property == PROP_SHED_DURATION calls nothing
|
||||
// object_property == PROP_DUTY_WINDOW calls nothing
|
||||
// object_property == PROP_REQUESTED_SHED_LEVEL calls
|
||||
// bacapp_decode_context_data() object_property == PROP_START_TIME calls
|
||||
// bacapp_decode_application_data() object_property == PROP_SHED_DURATION
|
||||
// calls nothing object_property == PROP_DUTY_WINDOW calls nothing
|
||||
// object_property == PROP_SHED_LEVELS calls nothing
|
||||
// object_property == PROP_ENABLE calls nothing
|
||||
// default returns error
|
||||
@@ -649,30 +665,28 @@ static void test_ShedCommpliant_gets_CanNoLongerComplyWithShed(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(lc_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(lc_tests,
|
||||
ztest_unit_test(test_api_stubs),
|
||||
ztest_unit_test(test_Load_Control_Count),
|
||||
ztest_unit_test(test_Load_Control_Read_Write_Property),
|
||||
ztest_unit_test(testLoadControlStateMachine),
|
||||
ztest_unit_test(test_ShedInactive_gets_RcvShedRequests),
|
||||
ztest_unit_test(test_ShedReqPending_gets_ReconfigPending),
|
||||
ztest_unit_test(test_ShedReqPending_gets_CancelShed),
|
||||
ztest_unit_test(test_ShedReqPending_gets_CannotMeetShed),
|
||||
ztest_unit_test(test_ShedReqPending_gets_PrepareToShed),
|
||||
ztest_unit_test(test_ShedReqPending_gets_AbleToMeetShed),
|
||||
ztest_unit_test(test_ShedNonCommpliant_gets_UnsuccessfulShedReconfig),
|
||||
ztest_unit_test(test_ShedNonCommpliant_gets_FinishedUnsuccessfulShed),
|
||||
ztest_unit_test(test_ShedNonCommpliant_gets_CanNowComplyWithShed),
|
||||
ztest_unit_test(test_ShedCommpliant_gets_FinishedSuccessfulShed),
|
||||
ztest_unit_test(test_ShedCommpliant_gets_SuccessfulShedReconfig),
|
||||
ztest_unit_test(test_ShedCommpliant_gets_CanNoLongerComplyWithShed)
|
||||
);
|
||||
ztest_test_suite(
|
||||
lc_tests, ztest_unit_test(test_api_stubs),
|
||||
ztest_unit_test(test_Load_Control_Count),
|
||||
ztest_unit_test(test_Load_Control_Read_Write_Property),
|
||||
ztest_unit_test(testLoadControlStateMachine),
|
||||
ztest_unit_test(test_ShedInactive_gets_RcvShedRequests),
|
||||
ztest_unit_test(test_ShedReqPending_gets_ReconfigPending),
|
||||
ztest_unit_test(test_ShedReqPending_gets_CancelShed),
|
||||
ztest_unit_test(test_ShedReqPending_gets_CannotMeetShed),
|
||||
ztest_unit_test(test_ShedReqPending_gets_PrepareToShed),
|
||||
ztest_unit_test(test_ShedReqPending_gets_AbleToMeetShed),
|
||||
ztest_unit_test(test_ShedNonCommpliant_gets_UnsuccessfulShedReconfig),
|
||||
ztest_unit_test(test_ShedNonCommpliant_gets_FinishedUnsuccessfulShed),
|
||||
ztest_unit_test(test_ShedNonCommpliant_gets_CanNowComplyWithShed),
|
||||
ztest_unit_test(test_ShedCommpliant_gets_FinishedSuccessfulShed),
|
||||
ztest_unit_test(test_ShedCommpliant_gets_SuccessfulShedReconfig),
|
||||
ztest_unit_test(test_ShedCommpliant_gets_CanNoLongerComplyWithShed));
|
||||
|
||||
ztest_run_test_suite(lc_tests);
|
||||
}
|
||||
|
||||
@@ -35,10 +35,10 @@ void datetime_init(void)
|
||||
}
|
||||
|
||||
bool datetime_local(
|
||||
BACNET_DATE * bdate,
|
||||
BACNET_TIME * btime,
|
||||
int16_t * utc_offset_minutes,
|
||||
bool * dst_active)
|
||||
BACNET_DATE *bdate,
|
||||
BACNET_TIME *btime,
|
||||
int16_t *utc_offset_minutes,
|
||||
bool *dst_active)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ static void testLightingOutput(void)
|
||||
uint8_t apdu[MAX_APDU] = { 0 };
|
||||
int len = 0, test_len = 0;
|
||||
BACNET_READ_PROPERTY_DATA rpdata;
|
||||
BACNET_APPLICATION_DATA_VALUE value = {0};
|
||||
BACNET_APPLICATION_DATA_VALUE value = { 0 };
|
||||
const int *pRequired = NULL;
|
||||
const int *pOptional = NULL;
|
||||
const int *pProprietary = NULL;
|
||||
@@ -57,15 +57,18 @@ static void testLightingOutput(void)
|
||||
rpdata.object_property = *pRequired;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Lighting_Output_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR,
|
||||
zassert_not_equal(
|
||||
len, BACNET_STATUS_ERROR,
|
||||
"property '%s': failed to ReadProperty!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
if (len >= 0) {
|
||||
test_len = bacapp_decode_known_property(rpdata.application_data,
|
||||
len, &value, rpdata.object_type, rpdata.object_property);
|
||||
test_len = bacapp_decode_known_property(
|
||||
rpdata.application_data, len, &value, rpdata.object_type,
|
||||
rpdata.object_property);
|
||||
if (rpdata.object_property != PROP_PRIORITY_ARRAY) {
|
||||
zassert_equal(len, test_len, "property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
zassert_equal(
|
||||
len, test_len, "property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
/* check WriteProperty properties */
|
||||
wpdata.object_type = rpdata.object_type;
|
||||
@@ -78,8 +81,8 @@ static void testLightingOutput(void)
|
||||
status = Lighting_Output_Write_Property(&wpdata);
|
||||
if (!status) {
|
||||
/* verify WriteProperty property is known */
|
||||
zassert_not_equal(wpdata.error_code,
|
||||
ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
zassert_not_equal(
|
||||
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
"property '%s': WriteProperty Unknown!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
@@ -90,14 +93,17 @@ static void testLightingOutput(void)
|
||||
rpdata.object_property = *pOptional;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Lighting_Output_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR,
|
||||
zassert_not_equal(
|
||||
len, BACNET_STATUS_ERROR,
|
||||
"property '%s': failed to ReadProperty!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
if (len > 0) {
|
||||
test_len = bacapp_decode_application_data(rpdata.application_data,
|
||||
(uint8_t)rpdata.application_data_len, &value);
|
||||
zassert_equal(len, test_len, "property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
test_len = bacapp_decode_application_data(
|
||||
rpdata.application_data, (uint8_t)rpdata.application_data_len,
|
||||
&value);
|
||||
zassert_equal(
|
||||
len, test_len, "property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
/* check WriteProperty properties */
|
||||
wpdata.object_type = rpdata.object_type;
|
||||
wpdata.object_instance = rpdata.object_instance;
|
||||
@@ -109,8 +115,8 @@ static void testLightingOutput(void)
|
||||
status = Lighting_Output_Write_Property(&wpdata);
|
||||
if (!status) {
|
||||
/* verify WriteProperty property is known */
|
||||
zassert_not_equal(wpdata.error_code,
|
||||
ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
zassert_not_equal(
|
||||
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
"property '%s': WriteProperty Unknown!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
@@ -135,15 +141,12 @@ static void testLightingOutput(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(lo_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(lo_tests,
|
||||
ztest_unit_test(testLightingOutput)
|
||||
);
|
||||
ztest_test_suite(lo_tests, ztest_unit_test(testLightingOutput));
|
||||
|
||||
ztest_run_test_suite(lo_tests);
|
||||
}
|
||||
|
||||
@@ -58,14 +58,17 @@ static void testLifeSafetyPoint(void)
|
||||
rpdata.object_property = *pRequired;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Life_Safety_Point_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR,
|
||||
zassert_not_equal(
|
||||
len, BACNET_STATUS_ERROR,
|
||||
"property '%s': failed to ReadProperty!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
if (len >= 0) {
|
||||
test_len = bacapp_decode_known_property(rpdata.application_data,
|
||||
len, &value, rpdata.object_type, rpdata.object_property);
|
||||
test_len = bacapp_decode_known_property(
|
||||
rpdata.application_data, len, &value, rpdata.object_type,
|
||||
rpdata.object_property);
|
||||
if (len != test_len) {
|
||||
printf("property '%s': failed to decode!\n",
|
||||
printf(
|
||||
"property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
} else {
|
||||
zassert_equal(len, test_len, NULL);
|
||||
@@ -81,8 +84,8 @@ static void testLifeSafetyPoint(void)
|
||||
status = Life_Safety_Point_Write_Property(&wpdata);
|
||||
if (!status) {
|
||||
/* verify WriteProperty property is known */
|
||||
zassert_not_equal(wpdata.error_code,
|
||||
ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
zassert_not_equal(
|
||||
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
"property '%s': WriteProperty Unknown!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
@@ -93,13 +96,16 @@ static void testLifeSafetyPoint(void)
|
||||
rpdata.object_property = *pOptional;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Life_Safety_Point_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR,
|
||||
zassert_not_equal(
|
||||
len, BACNET_STATUS_ERROR,
|
||||
"property '%s': failed to ReadProperty!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
if (len > 0) {
|
||||
test_len = bacapp_decode_application_data(rpdata.application_data,
|
||||
(uint8_t)rpdata.application_data_len, &value);
|
||||
zassert_equal(len, test_len, "property '%s': failed to decode!\n",
|
||||
test_len = bacapp_decode_application_data(
|
||||
rpdata.application_data, (uint8_t)rpdata.application_data_len,
|
||||
&value);
|
||||
zassert_equal(
|
||||
len, test_len, "property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
/* check WriteProperty properties */
|
||||
wpdata.object_type = rpdata.object_type;
|
||||
@@ -112,8 +118,8 @@ static void testLifeSafetyPoint(void)
|
||||
status = Life_Safety_Point_Write_Property(&wpdata);
|
||||
if (!status) {
|
||||
/* verify WriteProperty property is known */
|
||||
zassert_not_equal(wpdata.error_code,
|
||||
ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
zassert_not_equal(
|
||||
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
"property '%s': WriteProperty Unknown!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
@@ -135,15 +141,12 @@ static void testLifeSafetyPoint(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(lsp_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(lsp_tests,
|
||||
ztest_unit_test(testLifeSafetyPoint)
|
||||
);
|
||||
ztest_test_suite(lsp_tests, ztest_unit_test(testLifeSafetyPoint));
|
||||
|
||||
ztest_run_test_suite(lsp_tests);
|
||||
}
|
||||
|
||||
@@ -39,12 +39,9 @@ static void testLifeSafetyZone(void)
|
||||
test_object_instance = Life_Safety_Zone_Index_To_Instance(0);
|
||||
zassert_equal(test_object_instance, object_instance, NULL);
|
||||
bacnet_object_properties_read_write_test(
|
||||
OBJECT_LIFE_SAFETY_ZONE,
|
||||
object_instance,
|
||||
Life_Safety_Zone_Property_Lists,
|
||||
Life_Safety_Zone_Read_Property,
|
||||
Life_Safety_Zone_Write_Property,
|
||||
skip_fail_property_list);
|
||||
OBJECT_LIFE_SAFETY_ZONE, object_instance,
|
||||
Life_Safety_Zone_Property_Lists, Life_Safety_Zone_Read_Property,
|
||||
Life_Safety_Zone_Write_Property, skip_fail_property_list);
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
@@ -55,9 +52,7 @@ ZTEST_SUITE(testsLifeSafetyZone, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(testsLifeSafetyZone,
|
||||
ztest_unit_test(testLifeSafetyZone)
|
||||
);
|
||||
ztest_test_suite(testsLifeSafetyZone, ztest_unit_test(testLifeSafetyZone));
|
||||
|
||||
ztest_run_test_suite(testsLifeSafetyZone);
|
||||
}
|
||||
|
||||
@@ -10,11 +10,10 @@
|
||||
#include <bacnet/bactext.h>
|
||||
#include <bacnet/basic/object/device.h>
|
||||
|
||||
|
||||
bool Device_Valid_Object_Name(
|
||||
BACNET_CHARACTER_STRING * object_name,
|
||||
BACNET_CHARACTER_STRING *object_name,
|
||||
BACNET_OBJECT_TYPE *object_type,
|
||||
uint32_t * object_instance)
|
||||
uint32_t *object_instance)
|
||||
{
|
||||
(void)object_name;
|
||||
(void)object_type;
|
||||
@@ -22,35 +21,28 @@ bool Device_Valid_Object_Name(
|
||||
return true;
|
||||
}
|
||||
|
||||
void Device_Inc_Database_Revision(
|
||||
void)
|
||||
void Device_Inc_Database_Revision(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
uint32_t Device_Object_Instance_Number(
|
||||
void)
|
||||
uint32_t Device_Object_Instance_Number(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Device_Write_Property(
|
||||
BACNET_WRITE_PROPERTY_DATA * wp_data)
|
||||
bool Device_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
{
|
||||
(void)wp_data;
|
||||
return false;
|
||||
}
|
||||
|
||||
void Device_getCurrentDateTime(
|
||||
BACNET_DATE_TIME * DateTime)
|
||||
void Device_getCurrentDateTime(BACNET_DATE_TIME *DateTime)
|
||||
{
|
||||
(void)DateTime;
|
||||
}
|
||||
|
||||
int Device_Read_Property(
|
||||
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||
int Device_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
{
|
||||
(void)rpdata;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
|
||||
bool tsm_get_transaction_pdu(
|
||||
uint8_t invokeID,
|
||||
BACNET_ADDRESS * dest,
|
||||
BACNET_NPDU_DATA * ndpu_data,
|
||||
uint8_t * apdu,
|
||||
uint16_t * apdu_len)
|
||||
BACNET_ADDRESS *dest,
|
||||
BACNET_NPDU_DATA *ndpu_data,
|
||||
uint8_t *apdu,
|
||||
uint16_t *apdu_len)
|
||||
{
|
||||
(void)invokeID;
|
||||
(void)dest;
|
||||
|
||||
@@ -38,12 +38,9 @@ static void testMultistateInput(void)
|
||||
test_object_instance = Multistate_Input_Index_To_Instance(0);
|
||||
zassert_equal(object_instance, test_object_instance, NULL);
|
||||
bacnet_object_properties_read_write_test(
|
||||
OBJECT_MULTI_STATE_INPUT,
|
||||
object_instance,
|
||||
Multistate_Input_Property_Lists,
|
||||
Multistate_Input_Read_Property,
|
||||
Multistate_Input_Write_Property,
|
||||
skip_fail_property_list);
|
||||
OBJECT_MULTI_STATE_INPUT, object_instance,
|
||||
Multistate_Input_Property_Lists, Multistate_Input_Read_Property,
|
||||
Multistate_Input_Write_Property, skip_fail_property_list);
|
||||
status = Multistate_Input_Delete(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
}
|
||||
@@ -51,15 +48,12 @@ static void testMultistateInput(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(ms_input_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(ms_input_tests,
|
||||
ztest_unit_test(testMultistateInput)
|
||||
);
|
||||
ztest_test_suite(ms_input_tests, ztest_unit_test(testMultistateInput));
|
||||
|
||||
ztest_run_test_suite(ms_input_tests);
|
||||
}
|
||||
|
||||
@@ -37,12 +37,9 @@ static void testMultistateOutput(void)
|
||||
test_object_instance = Multistate_Output_Index_To_Instance(0);
|
||||
zassert_equal(object_instance, test_object_instance, NULL);
|
||||
bacnet_object_properties_read_write_test(
|
||||
OBJECT_MULTI_STATE_OUTPUT,
|
||||
object_instance,
|
||||
Multistate_Output_Property_Lists,
|
||||
Multistate_Output_Read_Property,
|
||||
Multistate_Output_Write_Property,
|
||||
skip_fail_property_list);
|
||||
OBJECT_MULTI_STATE_OUTPUT, object_instance,
|
||||
Multistate_Output_Property_Lists, Multistate_Output_Read_Property,
|
||||
Multistate_Output_Write_Property, skip_fail_property_list);
|
||||
status = Multistate_Output_Delete(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
}
|
||||
@@ -50,15 +47,12 @@ static void testMultistateOutput(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(mso_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(mso_tests,
|
||||
ztest_unit_test(testMultistateOutput)
|
||||
);
|
||||
ztest_test_suite(mso_tests, ztest_unit_test(testMultistateOutput));
|
||||
|
||||
ztest_run_test_suite(mso_tests);
|
||||
}
|
||||
|
||||
@@ -38,12 +38,9 @@ static void testMultistateValue(void)
|
||||
test_object_instance = Multistate_Value_Index_To_Instance(0);
|
||||
zassert_equal(object_instance, test_object_instance, NULL);
|
||||
bacnet_object_properties_read_write_test(
|
||||
OBJECT_MULTI_STATE_VALUE,
|
||||
object_instance,
|
||||
Multistate_Value_Property_Lists,
|
||||
Multistate_Value_Read_Property,
|
||||
Multistate_Value_Write_Property,
|
||||
skip_fail_property_list);
|
||||
OBJECT_MULTI_STATE_VALUE, object_instance,
|
||||
Multistate_Value_Property_Lists, Multistate_Value_Read_Property,
|
||||
Multistate_Value_Write_Property, skip_fail_property_list);
|
||||
status = Multistate_Value_Delete(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
}
|
||||
@@ -51,15 +48,12 @@ static void testMultistateValue(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(msv_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(msv_tests,
|
||||
ztest_unit_test(testMultistateValue)
|
||||
);
|
||||
ztest_test_suite(msv_tests, ztest_unit_test(testMultistateValue));
|
||||
|
||||
ztest_run_test_suite(msv_tests);
|
||||
}
|
||||
|
||||
@@ -56,16 +56,19 @@ static void test_Notification_Class(void)
|
||||
rpdata.object_property = *pRequired;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Notification_Class_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR,
|
||||
zassert_not_equal(
|
||||
len, BACNET_STATUS_ERROR,
|
||||
"property '%s': failed to ReadProperty!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
if (len >= 0) {
|
||||
test_len = bacapp_decode_known_property(rpdata.application_data,
|
||||
len, &value, rpdata.object_type, rpdata.object_property);
|
||||
test_len = bacapp_decode_known_property(
|
||||
rpdata.application_data, len, &value, rpdata.object_type,
|
||||
rpdata.object_property);
|
||||
if ((rpdata.object_property != PROP_PRIORITY) &&
|
||||
(rpdata.object_property != PROP_RECIPIENT_LIST)) {
|
||||
zassert_equal(len, test_len, "property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
zassert_equal(
|
||||
len, test_len, "property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
/* check WriteProperty properties */
|
||||
wpdata.object_type = rpdata.object_type;
|
||||
@@ -78,8 +81,8 @@ static void test_Notification_Class(void)
|
||||
status = Notification_Class_Write_Property(&wpdata);
|
||||
if (!status) {
|
||||
/* verify WriteProperty property is known */
|
||||
zassert_not_equal(wpdata.error_code,
|
||||
ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
zassert_not_equal(
|
||||
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
"property '%s': WriteProperty Unknown!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
@@ -90,13 +93,16 @@ static void test_Notification_Class(void)
|
||||
rpdata.object_property = *pOptional;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Notification_Class_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR,
|
||||
zassert_not_equal(
|
||||
len, BACNET_STATUS_ERROR,
|
||||
"property '%s': failed to ReadProperty!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
if (len > 0) {
|
||||
test_len = bacapp_decode_application_data(rpdata.application_data,
|
||||
(uint8_t)rpdata.application_data_len, &value);
|
||||
zassert_equal(len, test_len, "property '%s': failed to decode!\n",
|
||||
test_len = bacapp_decode_application_data(
|
||||
rpdata.application_data, (uint8_t)rpdata.application_data_len,
|
||||
&value);
|
||||
zassert_equal(
|
||||
len, test_len, "property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
/* check WriteProperty properties */
|
||||
wpdata.object_type = rpdata.object_type;
|
||||
@@ -109,8 +115,8 @@ static void test_Notification_Class(void)
|
||||
status = Notification_Class_Write_Property(&wpdata);
|
||||
if (!status) {
|
||||
/* verify WriteProperty property is known */
|
||||
zassert_not_equal(wpdata.error_code,
|
||||
ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
zassert_not_equal(
|
||||
wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
"property '%s': WriteProperty Unknown!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
@@ -130,15 +136,13 @@ static void test_Notification_Class(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(notification_class_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(notification_class_tests,
|
||||
ztest_unit_test(test_Notification_Class)
|
||||
);
|
||||
ztest_test_suite(
|
||||
notification_class_tests, ztest_unit_test(test_Notification_Class));
|
||||
|
||||
ztest_run_test_suite(notification_class_tests);
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ int Send_UEvent_Notify(
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t Send_CEvent_Notify(
|
||||
uint32_t device_id, BACNET_EVENT_NOTIFICATION_DATA *data)
|
||||
uint8_t
|
||||
Send_CEvent_Notify(uint32_t device_id, BACNET_EVENT_NOTIFICATION_DATA *data)
|
||||
{
|
||||
(void)device_id;
|
||||
(void)data;
|
||||
@@ -42,10 +42,10 @@ void Send_WhoIs(int32_t low_limit, int32_t high_limit)
|
||||
}
|
||||
|
||||
bool datetime_local(
|
||||
BACNET_DATE * bdate,
|
||||
BACNET_TIME * btime,
|
||||
int16_t * utc_offset_minutes,
|
||||
bool * dst_active)
|
||||
BACNET_DATE *bdate,
|
||||
BACNET_TIME *btime,
|
||||
int16_t *utc_offset_minutes,
|
||||
bool *dst_active)
|
||||
{
|
||||
(void)bdate;
|
||||
(void)btime;
|
||||
|
||||
@@ -29,14 +29,20 @@ static void test_network_port(void)
|
||||
bool status = false;
|
||||
unsigned count = 0;
|
||||
uint32_t object_instance = 0;
|
||||
uint8_t port_type[] = { PORT_TYPE_ETHERNET, PORT_TYPE_ARCNET,
|
||||
PORT_TYPE_MSTP, PORT_TYPE_PTP, PORT_TYPE_LONTALK, PORT_TYPE_BIP,
|
||||
PORT_TYPE_ZIGBEE, PORT_TYPE_VIRTUAL, PORT_TYPE_NON_BACNET,
|
||||
PORT_TYPE_BIP6, PORT_TYPE_MAX };
|
||||
const int known_fail_property_list[] = { PROP_IP_DNS_SERVER,
|
||||
uint8_t port_type[] = { PORT_TYPE_ETHERNET, PORT_TYPE_ARCNET,
|
||||
PORT_TYPE_MSTP, PORT_TYPE_PTP,
|
||||
PORT_TYPE_LONTALK, PORT_TYPE_BIP,
|
||||
PORT_TYPE_ZIGBEE, PORT_TYPE_VIRTUAL,
|
||||
PORT_TYPE_NON_BACNET, PORT_TYPE_BIP6,
|
||||
PORT_TYPE_MAX };
|
||||
const int known_fail_property_list[] = {
|
||||
PROP_IP_DNS_SERVER,
|
||||
PROP_BBMD_BROADCAST_DISTRIBUTION_TABLE,
|
||||
PROP_BBMD_FOREIGN_DEVICE_TABLE, PROP_FD_BBMD_ADDRESS,
|
||||
PROP_IPV6_DNS_SERVER, -1 };
|
||||
PROP_BBMD_FOREIGN_DEVICE_TABLE,
|
||||
PROP_FD_BBMD_ADDRESS,
|
||||
PROP_IPV6_DNS_SERVER,
|
||||
-1
|
||||
};
|
||||
|
||||
while (port_type[port] != PORT_TYPE_MAX) {
|
||||
object_instance = 1234;
|
||||
@@ -48,11 +54,8 @@ static void test_network_port(void)
|
||||
count = Network_Port_Count();
|
||||
zassert_true(count > 0, NULL);
|
||||
bacnet_object_properties_read_write_test(
|
||||
OBJECT_NETWORK_PORT,
|
||||
object_instance,
|
||||
Network_Port_Property_Lists,
|
||||
Network_Port_Read_Property,
|
||||
Network_Port_Write_Property,
|
||||
OBJECT_NETWORK_PORT, object_instance, Network_Port_Property_Lists,
|
||||
Network_Port_Read_Property, Network_Port_Write_Property,
|
||||
known_fail_property_list);
|
||||
port++;
|
||||
}
|
||||
|
||||
@@ -71,8 +71,7 @@ void testBACnetObjects(Test *pTest)
|
||||
for (test_point = 0; test_point < max_test_points; test_point++) {
|
||||
device_id = test_point * (BACNET_MAX_INSTANCE / max_test_points);
|
||||
pDevice = objects_device_data(test_point);
|
||||
testBACnetObjectsCompare(
|
||||
pTest, pDevice, objects_device_id(test_point));
|
||||
testBACnetObjectsCompare(pTest, pDevice, objects_device_id(test_point));
|
||||
}
|
||||
for (test_point = 0; test_point < max_test_points; test_point++) {
|
||||
status = objects_device_delete(0);
|
||||
@@ -99,4 +98,3 @@ int main(void)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,13 +20,14 @@
|
||||
/**
|
||||
* @brief Test
|
||||
*/
|
||||
static void testBACnetObjectsCompare(
|
||||
OBJECT_DEVICE_T *pDevice, uint32_t expected_device_id)
|
||||
static void
|
||||
testBACnetObjectsCompare(OBJECT_DEVICE_T *pDevice, uint32_t expected_device_id)
|
||||
{
|
||||
zassert_not_null(pDevice, NULL);
|
||||
if (pDevice) {
|
||||
zassert_not_null(pDevice->Object_List, NULL);
|
||||
zassert_equal(pDevice->Object_Identifier.instance, expected_device_id, NULL);
|
||||
zassert_equal(
|
||||
pDevice->Object_Identifier.instance, expected_device_id, NULL);
|
||||
zassert_equal(pDevice->Object_Identifier.type, OBJECT_DEVICE, NULL);
|
||||
zassert_equal(pDevice->Object_Type, OBJECT_DEVICE, NULL);
|
||||
}
|
||||
@@ -43,7 +44,6 @@ static void testBACnetObjects(void)
|
||||
const unsigned max_test_points = 20;
|
||||
OBJECT_DEVICE_T *pDevice;
|
||||
|
||||
|
||||
/* Verify deleting a non-existant object returns the correct value */
|
||||
zassert_false(objects_device_delete(0), NULL);
|
||||
|
||||
@@ -53,7 +53,7 @@ static void testBACnetObjects(void)
|
||||
pDevice = objects_device_new(device_id);
|
||||
testBACnetObjectsCompare(pDevice, device_id);
|
||||
|
||||
/* Verify the last created device can be fetched by ID */
|
||||
/* Verify the last created device can be fetched by ID */
|
||||
pDevice = objects_device_by_instance(device_id);
|
||||
testBACnetObjectsCompare(pDevice, device_id);
|
||||
}
|
||||
@@ -83,15 +83,12 @@ static void testBACnetObjects(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(objects_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(objects_tests,
|
||||
ztest_unit_test(testBACnetObjects)
|
||||
);
|
||||
ztest_test_suite(objects_tests, ztest_unit_test(testBACnetObjects));
|
||||
|
||||
ztest_run_test_suite(objects_tests);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ static void testOctetString_Value(void)
|
||||
uint8_t apdu[MAX_APDU] = { 0 };
|
||||
int len = 0, test_len = 0;
|
||||
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
|
||||
BACNET_APPLICATION_DATA_VALUE value = {0};
|
||||
BACNET_APPLICATION_DATA_VALUE value = { 0 };
|
||||
const int *required_property = NULL;
|
||||
const uint32_t instance = 1;
|
||||
|
||||
@@ -44,10 +44,12 @@ static void testOctetString_Value(void)
|
||||
len = OctetString_Value_Read_Property(&rpdata);
|
||||
zassert_true(len >= 0, NULL);
|
||||
if (len >= 0) {
|
||||
test_len = bacapp_decode_known_property(rpdata.application_data,
|
||||
len, &value, rpdata.object_type, rpdata.object_property);
|
||||
test_len = bacapp_decode_known_property(
|
||||
rpdata.application_data, len, &value, rpdata.object_type,
|
||||
rpdata.object_property);
|
||||
if (len != test_len) {
|
||||
printf("property '%s': failed to decode!\n",
|
||||
printf(
|
||||
"property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
if (rpdata.object_property == PROP_PRIORITY_ARRAY) {
|
||||
@@ -56,7 +58,8 @@ static void testOctetString_Value(void)
|
||||
}
|
||||
zassert_equal(len, test_len, NULL);
|
||||
} else {
|
||||
printf("property '%s': failed to read!\n",
|
||||
printf(
|
||||
"property '%s': failed to read!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
required_property++;
|
||||
@@ -66,15 +69,12 @@ static void testOctetString_Value(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(osv_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(osv_tests,
|
||||
ztest_unit_test(testOctetString_Value)
|
||||
);
|
||||
ztest_test_suite(osv_tests, ztest_unit_test(testOctetString_Value));
|
||||
|
||||
ztest_run_test_suite(osv_tests);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ static void testPositiveInteger_Value(void)
|
||||
uint8_t apdu[MAX_APDU] = { 0 };
|
||||
int len = 0, test_len = 0;
|
||||
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
|
||||
BACNET_APPLICATION_DATA_VALUE value = {0};
|
||||
BACNET_APPLICATION_DATA_VALUE value = { 0 };
|
||||
const int *required_property = NULL;
|
||||
const uint32_t instance = 1;
|
||||
|
||||
@@ -45,10 +45,12 @@ static void testPositiveInteger_Value(void)
|
||||
len = PositiveInteger_Value_Read_Property(&rpdata);
|
||||
zassert_true(len >= 0, NULL);
|
||||
if (len >= 0) {
|
||||
test_len = bacapp_decode_known_property(rpdata.application_data,
|
||||
len, &value, rpdata.object_type, rpdata.object_property);
|
||||
test_len = bacapp_decode_known_property(
|
||||
rpdata.application_data, len, &value, rpdata.object_type,
|
||||
rpdata.object_property);
|
||||
if (len != test_len) {
|
||||
printf("property '%s': failed to decode!\n",
|
||||
printf(
|
||||
"property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
if (rpdata.object_property == PROP_PRIORITY_ARRAY) {
|
||||
@@ -64,15 +66,12 @@ static void testPositiveInteger_Value(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(piv_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(piv_tests,
|
||||
ztest_unit_test(testPositiveInteger_Value)
|
||||
);
|
||||
ztest_test_suite(piv_tests, ztest_unit_test(testPositiveInteger_Value));
|
||||
|
||||
ztest_run_test_suite(piv_tests);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
* are known to fail to decode after reading
|
||||
* @return true if the property was written successfully, false if not
|
||||
*/
|
||||
bool bacnet_object_property_write_test(BACNET_WRITE_PROPERTY_DATA *wpdata,
|
||||
bool bacnet_object_property_write_test(
|
||||
BACNET_WRITE_PROPERTY_DATA *wpdata,
|
||||
write_property_function write_property,
|
||||
const int *skip_fail_property_list)
|
||||
{
|
||||
@@ -34,7 +35,8 @@ bool bacnet_object_property_write_test(BACNET_WRITE_PROPERTY_DATA *wpdata,
|
||||
status = write_property(wpdata);
|
||||
if (!status) {
|
||||
/* verify WriteProperty property is known */
|
||||
zassert_not_equal(wpdata->error_code, ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
zassert_not_equal(
|
||||
wpdata->error_code, ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
"property '%s': WriteProperty Unknown!\n",
|
||||
bactext_property_name(wpdata->object_property));
|
||||
}
|
||||
@@ -75,7 +77,8 @@ void bacnet_object_property_write_parameter_init(
|
||||
* are known to fail to decode after reading
|
||||
* @return length of the property value that was read
|
||||
*/
|
||||
int bacnet_object_property_read_test(BACNET_READ_PROPERTY_DATA *rpdata,
|
||||
int bacnet_object_property_read_test(
|
||||
BACNET_READ_PROPERTY_DATA *rpdata,
|
||||
read_property_function read_property,
|
||||
const int *skip_fail_property_list)
|
||||
{
|
||||
@@ -99,8 +102,9 @@ int bacnet_object_property_read_test(BACNET_READ_PROPERTY_DATA *rpdata,
|
||||
apdu = rpdata->application_data;
|
||||
apdu_len = read_len;
|
||||
while (apdu_len) {
|
||||
len = bacapp_decode_known_property(apdu, apdu_len, &value,
|
||||
rpdata->object_type, rpdata->object_property);
|
||||
len = bacapp_decode_known_property(
|
||||
apdu, apdu_len, &value, rpdata->object_type,
|
||||
rpdata->object_property);
|
||||
if (len > 0) {
|
||||
test_len += len;
|
||||
if ((len < apdu_len) &&
|
||||
@@ -116,15 +120,16 @@ int bacnet_object_property_read_test(BACNET_READ_PROPERTY_DATA *rpdata,
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
printf("property '%s': failed to decode! len=%d\n",
|
||||
bactext_property_name(rpdata->object_property),
|
||||
len);
|
||||
printf(
|
||||
"property '%s': failed to decode! len=%d\n",
|
||||
bactext_property_name(rpdata->object_property), len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (read_len != test_len) {
|
||||
printf("property '%s': failed to decode! %d!=%d\n",
|
||||
bactext_property_name(rpdata->object_property), test_len,
|
||||
printf(
|
||||
"property '%s': failed to decode! %d!=%d\n",
|
||||
bactext_property_name(rpdata->object_property), test_len,
|
||||
read_len);
|
||||
}
|
||||
if (property_list_member(
|
||||
@@ -136,8 +141,8 @@ int bacnet_object_property_read_test(BACNET_READ_PROPERTY_DATA *rpdata,
|
||||
} else if (read_len == 0) {
|
||||
/* empty response is valid for some properties */
|
||||
} else {
|
||||
zassert_not_equal(read_len, BACNET_STATUS_ERROR,
|
||||
"property '%s': failed to read!\n",
|
||||
zassert_not_equal(
|
||||
read_len, BACNET_STATUS_ERROR, "property '%s': failed to read!\n",
|
||||
bactext_property_name(rpdata->object_property));
|
||||
}
|
||||
|
||||
@@ -155,7 +160,8 @@ int bacnet_object_property_read_test(BACNET_READ_PROPERTY_DATA *rpdata,
|
||||
* @param skip_fail_property_list The list of properties that
|
||||
* are known to fail to decode after reading
|
||||
*/
|
||||
void bacnet_object_properties_read_write_test(BACNET_OBJECT_TYPE object_type,
|
||||
void bacnet_object_properties_read_write_test(
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
rpm_property_lists_function property_list,
|
||||
read_property_function read_property,
|
||||
|
||||
@@ -27,34 +27,29 @@ static void testSchedule(void)
|
||||
{
|
||||
unsigned count = 0;
|
||||
uint32_t object_instance = 0;
|
||||
const int skip_fail_property_list[] = {
|
||||
PROP_LIST_OF_OBJECT_PROPERTY_REFERENCES, -1 };
|
||||
const int skip_fail_property_list[] = {
|
||||
PROP_LIST_OF_OBJECT_PROPERTY_REFERENCES, -1
|
||||
};
|
||||
|
||||
Schedule_Init();
|
||||
count = Schedule_Count();
|
||||
zassert_true(count > 0, NULL);
|
||||
object_instance = Schedule_Index_To_Instance(0);
|
||||
bacnet_object_properties_read_write_test(
|
||||
OBJECT_SCHEDULE,
|
||||
object_instance,
|
||||
Schedule_Property_Lists,
|
||||
Schedule_Read_Property,
|
||||
Schedule_Write_Property,
|
||||
OBJECT_SCHEDULE, object_instance, Schedule_Property_Lists,
|
||||
Schedule_Read_Property, Schedule_Write_Property,
|
||||
skip_fail_property_list);
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(schedule_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(schedule_tests,
|
||||
ztest_unit_test(testSchedule)
|
||||
);
|
||||
ztest_test_suite(schedule_tests, ztest_unit_test(testSchedule));
|
||||
|
||||
ztest_run_test_suite(schedule_tests);
|
||||
}
|
||||
|
||||
@@ -37,11 +37,8 @@ static void testTimeValue(void)
|
||||
zassert_true(count > 0, NULL);
|
||||
object_instance = Time_Value_Index_To_Instance(0);
|
||||
bacnet_object_properties_read_write_test(
|
||||
OBJECT_TIME_VALUE,
|
||||
object_instance,
|
||||
Time_Value_Property_Lists,
|
||||
Time_Value_Read_Property,
|
||||
Time_Value_Write_Property,
|
||||
OBJECT_TIME_VALUE, object_instance, Time_Value_Property_Lists,
|
||||
Time_Value_Read_Property, Time_Value_Write_Property,
|
||||
skip_fail_property_list);
|
||||
/* check the delete function */
|
||||
status = Time_Value_Delete(object_instance);
|
||||
@@ -56,9 +53,7 @@ ZTEST_SUITE(bacnet_tv, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(tv_tests,
|
||||
ztest_unit_test(testTimeValue)
|
||||
);
|
||||
ztest_test_suite(tv_tests, ztest_unit_test(testTimeValue));
|
||||
|
||||
ztest_run_test_suite(tv_tests);
|
||||
}
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
#include "bacnet/datetime.h"
|
||||
|
||||
bool datetime_local(
|
||||
BACNET_DATE * bdate,
|
||||
BACNET_TIME * btime,
|
||||
int16_t * utc_offset_minutes,
|
||||
bool * dst_active)
|
||||
BACNET_DATE *bdate,
|
||||
BACNET_TIME *btime,
|
||||
int16_t *utc_offset_minutes,
|
||||
bool *dst_active)
|
||||
{
|
||||
bdate->year = 2023;
|
||||
bdate->month = 6;
|
||||
|
||||
@@ -33,11 +33,8 @@ static void test_Trend_Log_ReadProperty(void)
|
||||
status = Trend_Log_Valid_Instance(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
bacnet_object_properties_read_write_test(
|
||||
OBJECT_TRENDLOG,
|
||||
object_instance,
|
||||
Trend_Log_Property_Lists,
|
||||
Trend_Log_Read_Property,
|
||||
Trend_Log_Write_Property,
|
||||
OBJECT_TRENDLOG, object_instance, Trend_Log_Property_Lists,
|
||||
Trend_Log_Read_Property, Trend_Log_Write_Property,
|
||||
known_fail_property_list);
|
||||
}
|
||||
/**
|
||||
@@ -46,8 +43,8 @@ static void test_Trend_Log_ReadProperty(void)
|
||||
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(trendlog_tests,
|
||||
ztest_unit_test(test_Trend_Log_ReadProperty));
|
||||
ztest_test_suite(
|
||||
trendlog_tests, ztest_unit_test(test_Trend_Log_ReadProperty));
|
||||
|
||||
ztest_run_test_suite(trendlog_tests);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
/**
|
||||
* @brief compare two floating point values to 3 decimal places
|
||||
*
|
||||
*
|
||||
* @param x1 - first comparison value
|
||||
* @param x2 - second comparison value
|
||||
* @return true if the value is the same to 3 decimal points
|
||||
@@ -34,7 +34,8 @@ static bool is_float_equal(float x1, float x2)
|
||||
/**
|
||||
* Unit Test for sRGB to CIE xy
|
||||
*/
|
||||
static void test_color_rgb_xy_gamma_unit(uint8_t red,
|
||||
static void test_color_rgb_xy_gamma_unit(
|
||||
uint8_t red,
|
||||
uint8_t green,
|
||||
uint8_t blue,
|
||||
float x_coordinate,
|
||||
@@ -46,22 +47,28 @@ static void test_color_rgb_xy_gamma_unit(uint8_t red,
|
||||
uint8_t test_red = 0, test_green = 0, test_blue = 0;
|
||||
|
||||
/* functions with gamma correction */
|
||||
color_rgb_to_xy_gamma(red, green, blue, &test_x_coordinate,
|
||||
&test_y_coordinate, &test_brightness);
|
||||
color_rgb_from_xy_gamma(&test_red, &test_green, &test_blue, x_coordinate,
|
||||
y_coordinate, brightness);
|
||||
zassert_true(is_float_equal(x_coordinate, test_x_coordinate),
|
||||
"(x=%.3f,test_x=%.3f)", x_coordinate, test_x_coordinate);
|
||||
zassert_true(is_float_equal(y_coordinate, test_y_coordinate),
|
||||
"(y=%.3f,test_y=%.3f)", y_coordinate, test_y_coordinate);
|
||||
zassert_equal(brightness, test_brightness, "b=%u, test_b=%u", brightness,
|
||||
color_rgb_to_xy_gamma(
|
||||
red, green, blue, &test_x_coordinate, &test_y_coordinate,
|
||||
&test_brightness);
|
||||
color_rgb_from_xy_gamma(
|
||||
&test_red, &test_green, &test_blue, x_coordinate, y_coordinate,
|
||||
brightness);
|
||||
zassert_true(
|
||||
is_float_equal(x_coordinate, test_x_coordinate), "(x=%.3f,test_x=%.3f)",
|
||||
x_coordinate, test_x_coordinate);
|
||||
zassert_true(
|
||||
is_float_equal(y_coordinate, test_y_coordinate), "(y=%.3f,test_y=%.3f)",
|
||||
y_coordinate, test_y_coordinate);
|
||||
zassert_equal(
|
||||
brightness, test_brightness, "b=%u, test_b=%u", brightness,
|
||||
test_brightness);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unit Test for sRGB to CIE xy
|
||||
*/
|
||||
static void test_color_rgb_xy_unit(uint8_t red,
|
||||
static void test_color_rgb_xy_unit(
|
||||
uint8_t red,
|
||||
uint8_t green,
|
||||
uint8_t blue,
|
||||
float x_coordinate,
|
||||
@@ -72,15 +79,20 @@ static void test_color_rgb_xy_unit(uint8_t red,
|
||||
uint8_t test_brightness = 0;
|
||||
uint8_t test_red = 0, test_green = 0, test_blue = 0;
|
||||
|
||||
color_rgb_to_xy(red, green, blue, &test_x_coordinate, &test_y_coordinate,
|
||||
color_rgb_to_xy(
|
||||
red, green, blue, &test_x_coordinate, &test_y_coordinate,
|
||||
&test_brightness);
|
||||
color_rgb_from_xy(&test_red, &test_green, &test_blue, x_coordinate,
|
||||
y_coordinate, brightness);
|
||||
zassert_true(is_float_equal(x_coordinate, test_x_coordinate),
|
||||
"(x=%.3f,test_x=%.3f)", x_coordinate, test_x_coordinate);
|
||||
zassert_true(is_float_equal(y_coordinate, test_y_coordinate),
|
||||
"(y=%.3f,test_y=%.3f)", y_coordinate, test_y_coordinate);
|
||||
zassert_equal(brightness, test_brightness, "b=%u, test_b=%u", brightness,
|
||||
color_rgb_from_xy(
|
||||
&test_red, &test_green, &test_blue, x_coordinate, y_coordinate,
|
||||
brightness);
|
||||
zassert_true(
|
||||
is_float_equal(x_coordinate, test_x_coordinate), "(x=%.3f,test_x=%.3f)",
|
||||
x_coordinate, test_x_coordinate);
|
||||
zassert_true(
|
||||
is_float_equal(y_coordinate, test_y_coordinate), "(y=%.3f,test_y=%.3f)",
|
||||
y_coordinate, test_y_coordinate);
|
||||
zassert_equal(
|
||||
brightness, test_brightness, "b=%u, test_b=%u", brightness,
|
||||
test_brightness);
|
||||
}
|
||||
|
||||
@@ -166,7 +178,8 @@ ZTEST_SUITE(color_rgb_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(color_rgb_tests, ztest_unit_test(test_color_rgb_ascii),
|
||||
ztest_test_suite(
|
||||
color_rgb_tests, ztest_unit_test(test_color_rgb_ascii),
|
||||
ztest_unit_test(test_color_rgb_xy));
|
||||
|
||||
ztest_run_test_suite(color_rgb_tests);
|
||||
|
||||
@@ -17,13 +17,10 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unit Test for the days, checking the epoch conversion
|
||||
*/
|
||||
* Unit Test for the days, checking the epoch conversion
|
||||
*/
|
||||
static void test_epoch_conversion_date(
|
||||
uint16_t epoch_year,
|
||||
uint16_t year,
|
||||
uint8_t month,
|
||||
uint8_t day)
|
||||
uint16_t epoch_year, uint16_t year, uint8_t month, uint8_t day)
|
||||
{
|
||||
uint32_t days;
|
||||
uint16_t test_year;
|
||||
@@ -32,8 +29,8 @@ static void test_epoch_conversion_date(
|
||||
|
||||
/* conversions of day and date */
|
||||
days = days_since_epoch(epoch_year, year, month, day);
|
||||
days_since_epoch_to_date(epoch_year, days, &test_year, &test_month,
|
||||
&test_day);
|
||||
days_since_epoch_to_date(
|
||||
epoch_year, days, &test_year, &test_month, &test_day);
|
||||
zassert_equal(year, test_year, NULL);
|
||||
zassert_equal(month, test_month, NULL);
|
||||
zassert_equal(day, test_day, NULL);
|
||||
@@ -61,15 +58,12 @@ static void test_days_epoch_conversion(void)
|
||||
* Unit Test for the days and year to month date year
|
||||
*/
|
||||
static void test_days_of_year_to_month_day_date(
|
||||
uint16_t year,
|
||||
uint16_t days,
|
||||
uint8_t month,
|
||||
uint8_t day)
|
||||
uint16_t year, uint16_t days, uint8_t month, uint8_t day)
|
||||
{
|
||||
uint8_t test_month = 0;
|
||||
uint8_t test_day = 0;
|
||||
/* conversions of days and year */
|
||||
days_of_year_to_month_day(days , year, &test_month, &test_day);
|
||||
days_of_year_to_month_day(days, year, &test_month, &test_day);
|
||||
zassert_equal(month, test_month, NULL);
|
||||
zassert_equal(day, test_day, NULL);
|
||||
}
|
||||
@@ -91,11 +85,9 @@ static void test_days_of_year_to_md(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* Unit Test for the days, checking the date to see if it is a valid day
|
||||
*/
|
||||
static void test_date_is_valid_day(
|
||||
uint16_t year,
|
||||
uint8_t month)
|
||||
* Unit Test for the days, checking the date to see if it is a valid day
|
||||
*/
|
||||
static void test_date_is_valid_day(uint16_t year, uint8_t month)
|
||||
{
|
||||
uint8_t last_day = days_per_month(year, month);
|
||||
|
||||
@@ -107,8 +99,8 @@ static void test_date_is_valid_day(
|
||||
}
|
||||
|
||||
/**
|
||||
* Unit Test for the days, checking the date to see if it is a valid date
|
||||
*/
|
||||
* Unit Test for the days, checking the date to see if it is a valid date
|
||||
*/
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST(days_tests, test_days_date_is_valid)
|
||||
#else
|
||||
@@ -143,8 +135,8 @@ static void test_days_date_is_valid(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* Unit Test for days apart, checking the dates to see how many days apart
|
||||
*/
|
||||
* Unit Test for days apart, checking the dates to see how many days apart
|
||||
*/
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST(days_tests, test_days_apart)
|
||||
#else
|
||||
@@ -163,18 +155,16 @@ static void test_days_apart(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(days_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(days_tests,
|
||||
ztest_unit_test(test_days_epoch_conversion),
|
||||
ztest_unit_test(test_days_of_year_to_md),
|
||||
ztest_unit_test(test_days_date_is_valid),
|
||||
ztest_unit_test(test_days_apart)
|
||||
);
|
||||
ztest_test_suite(
|
||||
days_tests, ztest_unit_test(test_days_epoch_conversion),
|
||||
ztest_unit_test(test_days_of_year_to_md),
|
||||
ztest_unit_test(test_days_date_is_valid),
|
||||
ztest_unit_test(test_days_apart));
|
||||
|
||||
ztest_run_test_suite(days_tests);
|
||||
}
|
||||
|
||||
@@ -138,8 +138,8 @@ static void testFIFOBuffer(void)
|
||||
status = FIFO_Add(&test_buffer, add_data, sizeof(add_data));
|
||||
zassert_true(status, NULL);
|
||||
count = FIFO_Count(&test_buffer);
|
||||
test_count = FIFO_Peek_Ahead(&test_buffer, &test_add_data[0], count-1);
|
||||
zassert_equal(count-1, test_count, NULL);
|
||||
test_count = FIFO_Peek_Ahead(&test_buffer, &test_add_data[0], count - 1);
|
||||
zassert_equal(count - 1, test_count, NULL);
|
||||
for (index = 0; index < test_count; index++) {
|
||||
zassert_equal(test_add_data[index], add_data[index], NULL);
|
||||
}
|
||||
@@ -150,15 +150,12 @@ static void testFIFOBuffer(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(fifo_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(fifo_tests,
|
||||
ztest_unit_test(testFIFOBuffer)
|
||||
);
|
||||
ztest_test_suite(fifo_tests, ztest_unit_test(testFIFOBuffer));
|
||||
|
||||
ztest_run_test_suite(fifo_tests);
|
||||
}
|
||||
|
||||
@@ -49,15 +49,12 @@ static void testFilename(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(filename_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(filename_tests,
|
||||
ztest_unit_test(testFilename)
|
||||
);
|
||||
ztest_test_suite(filename_tests, ztest_unit_test(testFilename));
|
||||
|
||||
ztest_run_test_suite(filename_tests);
|
||||
}
|
||||
|
||||
@@ -349,20 +349,16 @@ static void testKeySample(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(keylist_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(keylist_tests,
|
||||
ztest_unit_test(testKeyListFIFO),
|
||||
ztest_unit_test(testKeyListFILO),
|
||||
ztest_unit_test(testKeyListDataKey),
|
||||
ztest_unit_test(testKeyListDataIndex),
|
||||
ztest_unit_test(testKeyListLarge),
|
||||
ztest_unit_test(testKeySample)
|
||||
);
|
||||
ztest_test_suite(
|
||||
keylist_tests, ztest_unit_test(testKeyListFIFO),
|
||||
ztest_unit_test(testKeyListFILO), ztest_unit_test(testKeyListDataKey),
|
||||
ztest_unit_test(testKeyListDataIndex),
|
||||
ztest_unit_test(testKeyListLarge), ztest_unit_test(testKeySample));
|
||||
|
||||
ztest_run_test_suite(keylist_tests);
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unit Test for linear interpolation of floating point values, rounded
|
||||
*/
|
||||
* Unit Test for linear interpolation of floating point values, rounded
|
||||
*/
|
||||
void testLinearInterpolateRound(void)
|
||||
{
|
||||
uint16_t x2 = 0;
|
||||
@@ -82,8 +82,8 @@ void testLinearInterpolateRound(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* Unit Test for linear interpolation of integers
|
||||
*/
|
||||
* Unit Test for linear interpolation of integers
|
||||
*/
|
||||
void testLinearInterpolateInt(void)
|
||||
{
|
||||
uint16_t y2 = 0;
|
||||
@@ -103,7 +103,7 @@ void testLinearInterpolateInt(void)
|
||||
|
||||
y2 = linear_interpolate_int(1, (65535 / 2), 65535, 1, 100);
|
||||
zassert_equal(y2, 50, NULL);
|
||||
|
||||
|
||||
y2 = linear_interpolate_int(1, ((65535 * 3) / 4), 65535, 1, 100);
|
||||
zassert_equal(y2, 75, NULL);
|
||||
|
||||
@@ -126,10 +126,9 @@ ZTEST_SUITE(Linear_Interpolate, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(Linear_Interpolate,
|
||||
ztest_unit_test(testLinearInterpolateRound),
|
||||
ztest_unit_test(testLinearInterpolateInt)
|
||||
);
|
||||
ztest_test_suite(
|
||||
Linear_Interpolate, ztest_unit_test(testLinearInterpolateRound),
|
||||
ztest_unit_test(testLinearInterpolateInt));
|
||||
|
||||
ztest_run_test_suite(Linear_Interpolate);
|
||||
}
|
||||
|
||||
@@ -175,7 +175,8 @@ static void testRingBufSizeSmall(void)
|
||||
uint8_t data_element[5];
|
||||
uint8_t data_store[sizeof(data_element) * NEXT_POWER_OF_2(16)];
|
||||
|
||||
testRingBuf(data_store, data_element, sizeof(data_element),
|
||||
testRingBuf(
|
||||
data_store, data_element, sizeof(data_element),
|
||||
sizeof(data_store) / sizeof(data_element));
|
||||
}
|
||||
|
||||
@@ -191,7 +192,8 @@ static void testRingBufSizeLarge(void)
|
||||
uint8_t data_element[16];
|
||||
uint8_t data_store[sizeof(data_element) * NEXT_POWER_OF_2(99)];
|
||||
|
||||
testRingBuf(data_store, data_element, sizeof(data_element),
|
||||
testRingBuf(
|
||||
data_store, data_element, sizeof(data_element),
|
||||
sizeof(data_store) / sizeof(data_element));
|
||||
}
|
||||
|
||||
@@ -208,10 +210,11 @@ static void testRingBufSizeInvalid(void)
|
||||
uint8_t data_element[16];
|
||||
uint8_t data_store[sizeof(data_element) * 99];
|
||||
|
||||
zassert_false(Ringbuf_Init(&test_buffer,
|
||||
data_store, sizeof(data_element),
|
||||
sizeof(data_store) / sizeof(data_element)),
|
||||
NULL);
|
||||
zassert_false(
|
||||
Ringbuf_Init(
|
||||
&test_buffer, data_store, sizeof(data_element),
|
||||
sizeof(data_store) / sizeof(data_element)),
|
||||
NULL);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
@@ -344,27 +347,26 @@ static void testRingBufNextElementSizeSmall(void)
|
||||
uint8_t data_element[5];
|
||||
uint8_t data_store[sizeof(data_element) * NEXT_POWER_OF_2(16)];
|
||||
|
||||
status = testRingBufNextElement(data_store, data_element,
|
||||
sizeof(data_element), sizeof(data_store) / sizeof(data_element));
|
||||
status = testRingBufNextElement(
|
||||
data_store, data_element, sizeof(data_element),
|
||||
sizeof(data_store) / sizeof(data_element));
|
||||
zassert_true(status, NULL);
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(ringbuf_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(ringbuf_tests,
|
||||
ztest_unit_test(testRingBufPowerOfTwo),
|
||||
ztest_unit_test(testRingBufSizeSmall),
|
||||
ztest_unit_test(testRingBufSizeLarge),
|
||||
ztest_unit_test(testRingBufSizeInvalid),
|
||||
ztest_unit_test(testRingBufNextElementSizeSmall)
|
||||
);
|
||||
ztest_test_suite(
|
||||
ringbuf_tests, ztest_unit_test(testRingBufPowerOfTwo),
|
||||
ztest_unit_test(testRingBufSizeSmall),
|
||||
ztest_unit_test(testRingBufSizeLarge),
|
||||
ztest_unit_test(testRingBufSizeInvalid),
|
||||
ztest_unit_test(testRingBufNextElementSizeSmall));
|
||||
|
||||
ztest_run_test_suite(ringbuf_tests);
|
||||
}
|
||||
|
||||
@@ -78,15 +78,12 @@ static void testStaticBuffer(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(sbuf_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(sbuf_tests,
|
||||
ztest_unit_test(testStaticBuffer)
|
||||
);
|
||||
ztest_test_suite(sbuf_tests, ztest_unit_test(testStaticBuffer));
|
||||
|
||||
ztest_run_test_suite(sbuf_tests);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user