Added AlignAfterOpenBracket: AlwaysBreak and BinPackArguments: true to clang-format. Updated test/bacnet c/h files with updated format.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
* @brief test BACnet integer encode/decode APIs
|
||||
*/
|
||||
|
||||
#include <stdlib.h> /* For calloc() */
|
||||
#include <stdlib.h> /* For calloc() */
|
||||
#include <zephyr/ztest.h>
|
||||
#include <bacnet/bactext.h>
|
||||
#include <bacnet/datalink/bvlc.h>
|
||||
@@ -22,8 +22,7 @@
|
||||
* @brief Test
|
||||
*/
|
||||
static void test_BVLC_Address(
|
||||
BACNET_IP_ADDRESS *bip_address_1,
|
||||
BACNET_IP_ADDRESS *bip_address_2)
|
||||
BACNET_IP_ADDRESS *bip_address_1, BACNET_IP_ADDRESS *bip_address_2)
|
||||
{
|
||||
zassert_false(bvlc_address_different(bip_address_1, bip_address_2), NULL);
|
||||
}
|
||||
@@ -62,7 +61,7 @@ static void test_BVLC_Foreign_Device_Table_Entry(
|
||||
zassert_equal(fdt_entry_1->ttl_seconds, fdt_entry_2->ttl_seconds, NULL);
|
||||
zassert_equal(
|
||||
fdt_entry_1->ttl_seconds_remaining,
|
||||
fdt_entry_2->ttl_seconds_remaining, NULL);
|
||||
fdt_entry_2->ttl_seconds_remaining, NULL);
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -112,13 +111,15 @@ ZTEST(bvlc_tests, test_BVLC_Result)
|
||||
static void test_BVLC_Result(void)
|
||||
#endif
|
||||
{
|
||||
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
|
||||
};
|
||||
unsigned int i = 0;
|
||||
size_t result_code_max = sizeof(result_code) / sizeof(result_code[0]);
|
||||
|
||||
@@ -127,8 +128,8 @@ static void test_BVLC_Result(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void test_BVLC_Original_Unicast_NPDU_Message(
|
||||
uint8_t *npdu, uint16_t npdu_len)
|
||||
static void
|
||||
test_BVLC_Original_Unicast_NPDU_Message(uint8_t *npdu, uint16_t npdu_len)
|
||||
{
|
||||
uint8_t test_npdu[50] = { 0 };
|
||||
uint8_t pdu[60] = { 0 };
|
||||
@@ -174,8 +175,8 @@ static void test_BVLC_Original_Unicast_NPDU(void)
|
||||
test_BVLC_Original_Unicast_NPDU_Message(npdu, npdu_len);
|
||||
}
|
||||
|
||||
static void test_BVLC_Original_Broadcast_NPDU_Message(
|
||||
uint8_t *npdu, uint16_t npdu_len)
|
||||
static void
|
||||
test_BVLC_Original_Broadcast_NPDU_Message(uint8_t *npdu, uint16_t npdu_len)
|
||||
{
|
||||
uint8_t test_npdu[50] = { 0 };
|
||||
uint8_t pdu[60] = { 0 };
|
||||
@@ -222,9 +223,7 @@ static void test_BVLC_Original_Broadcast_NPDU(void)
|
||||
}
|
||||
|
||||
static void test_BVLC_Forwarded_NPDU_Message(
|
||||
uint8_t *npdu,
|
||||
uint16_t npdu_len,
|
||||
BACNET_IP_ADDRESS *bip_address)
|
||||
uint8_t *npdu, uint16_t npdu_len, BACNET_IP_ADDRESS *bip_address)
|
||||
{
|
||||
uint8_t test_npdu[50] = { 0 };
|
||||
uint8_t pdu[75] = { 0 };
|
||||
@@ -243,8 +242,9 @@ static void test_BVLC_Forwarded_NPDU_Message(
|
||||
zassert_equal(test_len, 4, NULL);
|
||||
zassert_equal(message_type, BVLC_FORWARDED_NPDU, NULL);
|
||||
zassert_equal(length, msg_len, NULL);
|
||||
test_len += bvlc_decode_forwarded_npdu(&pdu[4], length - 4,
|
||||
&test_bip_address, test_npdu, sizeof(test_npdu), &test_npdu_len);
|
||||
test_len += bvlc_decode_forwarded_npdu(
|
||||
&pdu[4], length - 4, &test_bip_address, test_npdu, sizeof(test_npdu),
|
||||
&test_npdu_len);
|
||||
zassert_equal(len, test_len, NULL);
|
||||
zassert_equal(msg_len, test_len, NULL);
|
||||
test_BVLC_Address(bip_address, &test_bip_address);
|
||||
@@ -278,8 +278,7 @@ static void test_BVLC_Forwarded_NPDU(void)
|
||||
test_BVLC_Forwarded_NPDU_Message(npdu, npdu_len, &bip_address);
|
||||
}
|
||||
|
||||
static void test_BVLC_Register_Foreign_Device_Message(
|
||||
uint16_t ttl_seconds)
|
||||
static void test_BVLC_Register_Foreign_Device_Message(uint16_t ttl_seconds)
|
||||
{
|
||||
uint8_t pdu[60] = { 0 };
|
||||
uint16_t test_ttl_seconds = 0;
|
||||
@@ -338,8 +337,7 @@ static void test_BVLC_Delete_Foreign_Device_Message(
|
||||
if (msg_len != test_len) {
|
||||
printf("msg:%u test:%u\n", msg_len, test_len);
|
||||
}
|
||||
test_BVLC_Address(
|
||||
&fdt_entry->dest_address, &test_fdt_entry.dest_address);
|
||||
test_BVLC_Address(&fdt_entry->dest_address, &test_fdt_entry.dest_address);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
@@ -364,8 +362,7 @@ static void test_BVLC_Delete_Foreign_Device(void)
|
||||
test_BVLC_Delete_Foreign_Device_Message(&fdt_entry);
|
||||
}
|
||||
|
||||
static void test_BVLC_Secure_BVLL_Message(
|
||||
uint8_t *sbuf, uint16_t sbuf_len)
|
||||
static void test_BVLC_Secure_BVLL_Message(uint8_t *sbuf, uint16_t sbuf_len)
|
||||
{
|
||||
uint8_t test_sbuf[50] = { 0 };
|
||||
uint8_t pdu[60] = { 0 };
|
||||
@@ -524,12 +521,12 @@ static void test_BVLC_Broadcast_Distribution_Table_Encode(void)
|
||||
}
|
||||
zassert_equal(test_count, count, NULL);
|
||||
/* test the encode/decode pair */
|
||||
apdu_len = bvlc_broadcast_distribution_table_encode(&apdu[0],
|
||||
sizeof(apdu), &bdt_list[0]);
|
||||
apdu_len = bvlc_broadcast_distribution_table_encode(
|
||||
&apdu[0], sizeof(apdu), &bdt_list[0]);
|
||||
test_count = sizeof(test_bdt_list) / sizeof(test_bdt_list[0]);
|
||||
bvlc_broadcast_distribution_table_link_array(&test_bdt_list[0], test_count);
|
||||
test_apdu_len = bvlc_broadcast_distribution_table_decode(&apdu[0],
|
||||
apdu_len, &error_code, &test_bdt_list[0]);
|
||||
test_apdu_len = bvlc_broadcast_distribution_table_decode(
|
||||
&apdu[0], apdu_len, &error_code, &test_bdt_list[0]);
|
||||
zassert_equal(test_apdu_len, apdu_len, NULL);
|
||||
count = bvlc_broadcast_distribution_table_count(&test_bdt_list[0]);
|
||||
zassert_equal(test_count, count, NULL);
|
||||
@@ -662,8 +659,7 @@ static void test_BVLC_Read_Foreign_Device_Table_Ack_Message(
|
||||
&pdu[4], length - 4, test_fdt_list);
|
||||
zassert_equal(msg_len, test_len, NULL);
|
||||
for (i = 0; i < count; i++) {
|
||||
test_BVLC_Foreign_Device_Table_Entry(
|
||||
&fdt_list[i], &test_fdt_list[i]);
|
||||
test_BVLC_Foreign_Device_Table_Entry(&fdt_list[i], &test_fdt_list[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -705,15 +701,13 @@ static void test_BVLC_Read_Foreign_Device_Table_Ack(void)
|
||||
}
|
||||
test_count = bvlc_foreign_device_table_valid_count(fdt_list);
|
||||
zassert_equal(test_count, count, NULL);
|
||||
test_BVLC_Read_Foreign_Device_Table_Ack_Message(
|
||||
npdu, npdu_len, fdt_list);
|
||||
test_BVLC_Read_Foreign_Device_Table_Ack_Message(npdu, npdu_len, fdt_list);
|
||||
/* now with some NPDU data */
|
||||
for (i = 0; i < sizeof(npdu); i++) {
|
||||
npdu[i] = i;
|
||||
}
|
||||
npdu_len = sizeof(npdu);
|
||||
test_BVLC_Read_Foreign_Device_Table_Ack_Message(
|
||||
npdu, npdu_len, fdt_list);
|
||||
test_BVLC_Read_Foreign_Device_Table_Ack_Message(npdu, npdu_len, fdt_list);
|
||||
/* cleanup */
|
||||
for (i = 0; i < count; i++) {
|
||||
dest_address.port = test_port_start + i;
|
||||
@@ -824,14 +818,14 @@ static void test_BVLC_Address_Get_Set(void)
|
||||
if (status) {
|
||||
status = bvlc_address_get(
|
||||
&src, &test_octet0, &test_octet1, &test_octet2, &test_octet3);
|
||||
printf("src:%u.%u.%u.%u\n", (unsigned)test_octet0,
|
||||
(unsigned)test_octet1, (unsigned)test_octet2,
|
||||
(unsigned)test_octet3);
|
||||
printf(
|
||||
"src:%u.%u.%u.%u\n", (unsigned)test_octet0, (unsigned)test_octet1,
|
||||
(unsigned)test_octet2, (unsigned)test_octet3);
|
||||
status = bvlc_address_get(
|
||||
&dst, &test_octet0, &test_octet1, &test_octet2, &test_octet3);
|
||||
printf("dst:%u.%u.%u.%u\n", (unsigned)test_octet0,
|
||||
(unsigned)test_octet1, (unsigned)test_octet2,
|
||||
(unsigned)test_octet3);
|
||||
printf(
|
||||
"dst:%u.%u.%u.%u\n", (unsigned)test_octet0, (unsigned)test_octet1,
|
||||
(unsigned)test_octet2, (unsigned)test_octet3);
|
||||
}
|
||||
zassert_false(status, NULL);
|
||||
/* BACnet to IPv4 address conversions */
|
||||
@@ -887,14 +881,14 @@ static void test_BVLC_BBMD_Address(void)
|
||||
BACNET_ERROR_CODE error_code = ERROR_CODE_SUCCESS;
|
||||
bool status = false;
|
||||
|
||||
status = bvlc_address_port_from_ascii(
|
||||
&bbmd_address, "192.168.0.255", "0xBAC0");
|
||||
status =
|
||||
bvlc_address_port_from_ascii(&bbmd_address, "192.168.0.255", "0xBAC0");
|
||||
zassert_true(status, NULL);
|
||||
apdu_len = bvlc_foreign_device_bbmd_host_address_encode(apdu, sizeof(apdu),
|
||||
&bbmd_address);
|
||||
apdu_len = bvlc_foreign_device_bbmd_host_address_encode(
|
||||
apdu, sizeof(apdu), &bbmd_address);
|
||||
zassert_not_equal(apdu_len, 0, NULL);
|
||||
test_apdu_len = bvlc_foreign_device_bbmd_host_address_decode(apdu,
|
||||
apdu_len, &error_code, &test_bbmd_address);
|
||||
test_apdu_len = bvlc_foreign_device_bbmd_host_address_decode(
|
||||
apdu, apdu_len, &error_code, &test_bbmd_address);
|
||||
if (test_apdu_len < 0) {
|
||||
printf("BVLC: error-code=%s\n", bactext_error_code_name(error_code));
|
||||
}
|
||||
@@ -910,29 +904,27 @@ static void test_BVLC_BBMD_Address(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(bvlc_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(bvlc_tests,
|
||||
ztest_unit_test(test_BVLC_Result),
|
||||
ztest_unit_test(test_BVLC_Write_Broadcast_Distribution_Table),
|
||||
ztest_unit_test(test_BVLC_Read_Broadcast_Distribution_Table_Message),
|
||||
ztest_unit_test(test_BVLC_Forwarded_NPDU),
|
||||
ztest_unit_test(test_BVLC_Register_Foreign_Device),
|
||||
ztest_unit_test(test_BVLC_Read_Foreign_Device_Table_Ack),
|
||||
ztest_unit_test(test_BVLC_Delete_Foreign_Device),
|
||||
ztest_unit_test(test_BVLC_Distribute_Broadcast_To_Network),
|
||||
ztest_unit_test(test_BVLC_Broadcast_Distribution_Table_Encode),
|
||||
ztest_unit_test(test_BVLC_Original_Unicast_NPDU),
|
||||
ztest_unit_test(test_BVLC_Original_Broadcast_NPDU),
|
||||
ztest_unit_test(test_BVLC_Secure_BVLL),
|
||||
ztest_unit_test(test_BVLC_Address_Copy),
|
||||
ztest_unit_test(test_BVLC_Address_Get_Set),
|
||||
ztest_unit_test(test_BVLC_BBMD_Address)
|
||||
);
|
||||
ztest_test_suite(
|
||||
bvlc_tests, ztest_unit_test(test_BVLC_Result),
|
||||
ztest_unit_test(test_BVLC_Write_Broadcast_Distribution_Table),
|
||||
ztest_unit_test(test_BVLC_Read_Broadcast_Distribution_Table_Message),
|
||||
ztest_unit_test(test_BVLC_Forwarded_NPDU),
|
||||
ztest_unit_test(test_BVLC_Register_Foreign_Device),
|
||||
ztest_unit_test(test_BVLC_Read_Foreign_Device_Table_Ack),
|
||||
ztest_unit_test(test_BVLC_Delete_Foreign_Device),
|
||||
ztest_unit_test(test_BVLC_Distribute_Broadcast_To_Network),
|
||||
ztest_unit_test(test_BVLC_Broadcast_Distribution_Table_Encode),
|
||||
ztest_unit_test(test_BVLC_Original_Unicast_NPDU),
|
||||
ztest_unit_test(test_BVLC_Original_Broadcast_NPDU),
|
||||
ztest_unit_test(test_BVLC_Secure_BVLL),
|
||||
ztest_unit_test(test_BVLC_Address_Copy),
|
||||
ztest_unit_test(test_BVLC_Address_Get_Set),
|
||||
ztest_unit_test(test_BVLC_BBMD_Address));
|
||||
|
||||
ztest_run_test_suite(bvlc_tests);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user