corrected unit tests
This commit is contained in:
+7
-2
@@ -131,13 +131,18 @@ void testAnalogInput(Test * pTest)
|
||||
BACNET_OBJECT_TYPE decoded_type = OBJECT_ANALOG_OUTPUT;
|
||||
uint32_t decoded_instance = 0;
|
||||
uint32_t instance = 123;
|
||||
BACNET_ERROR_CLASS error_class;
|
||||
BACNET_ERROR_CODE error_code;
|
||||
|
||||
|
||||
|
||||
// FIXME: we should do a lot more testing here...
|
||||
len = Analog_Input_Encode_Property_APDU(
|
||||
&apdu[0],
|
||||
instance,
|
||||
PROP_OBJECT_IDENTIFIER,
|
||||
BACNET_ARRAY_ALL);
|
||||
BACNET_ARRAY_ALL,
|
||||
&error_class,
|
||||
&error_code);
|
||||
ct_test(pTest, len != 0);
|
||||
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
||||
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||
|
||||
+1
-19
@@ -42,25 +42,6 @@
|
||||
#include "tsm.h"
|
||||
#include "iam.h"
|
||||
|
||||
#ifdef TEST
|
||||
void tsm_free_invoke_id(uint8_t invokeID)
|
||||
{
|
||||
// dummy stub for testing
|
||||
(void)invokeID;
|
||||
}
|
||||
|
||||
void iam_handler(
|
||||
uint8_t *service_request,
|
||||
uint16_t service_len,
|
||||
BACNET_ADDRESS *src)
|
||||
{
|
||||
// dummy stub for testing
|
||||
(void)service_request;
|
||||
(void)service_len;
|
||||
(void)src;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Confirmed Function Handlers
|
||||
// If they are not set, they are handled by a reject message
|
||||
static confirmed_function
|
||||
@@ -360,3 +341,4 @@ void apdu_handler(
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
// addition of passing a network number or datalink number
|
||||
// as part of the calls.
|
||||
|
||||
/* returns number of bytes sent on success, negative on failure */
|
||||
int datalink_send_pdu(
|
||||
BACNET_ADDRESS *dest, // destination address
|
||||
uint8_t *pdu, // any data to be sent - may be null
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
#include "bip.h"
|
||||
#endif
|
||||
|
||||
|
||||
/* returns number of bytes sent on success, negative on failure */
|
||||
int datalink_send_pdu(
|
||||
BACNET_ADDRESS *dest, // destination address
|
||||
uint8_t *pdu, // any data to be sent - may be null
|
||||
|
||||
@@ -538,6 +538,39 @@ void testDevice(Test * pTest)
|
||||
}
|
||||
|
||||
#ifdef TEST_DEVICE
|
||||
// stubs to dependencies to keep unit test simple
|
||||
unsigned Analog_Input_Count(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t Analog_Input_Index_To_Instance(unsigned index)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
||||
unsigned Analog_Output_Count(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t Analog_Output_Index_To_Instance(unsigned index)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
||||
uint32_t bacfile_count(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t bacfile_index_to_instance(unsigned find_index)
|
||||
{
|
||||
return find_index;
|
||||
}
|
||||
|
||||
bool I_Am_Request = false;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
Test *pTest;
|
||||
|
||||
@@ -48,7 +48,7 @@ void ethernet_cleanup(void);
|
||||
bool ethernet_init(char *interface_name);
|
||||
|
||||
/* function to send a packet out the 802.2 socket */
|
||||
/* returns 0 on success, non-zero on failure */
|
||||
/* returns number of bytes sent on success, negative on failure */
|
||||
int ethernet_send(
|
||||
BACNET_ADDRESS *dest, // destination address
|
||||
BACNET_ADDRESS *src, // source address
|
||||
@@ -56,7 +56,7 @@ int ethernet_send(
|
||||
unsigned pdu_len); // number of bytes of data
|
||||
|
||||
/* function to send a packet out the 802.2 socket */
|
||||
/* returns zero on success, non-zero on failure */
|
||||
/* returns number of bytes sent on success, negative on failure */
|
||||
int ethernet_send_pdu(
|
||||
BACNET_ADDRESS *dest, // destination address
|
||||
uint8_t *pdu, // any data to be sent - may be null
|
||||
|
||||
@@ -266,6 +266,52 @@ void testIAm(Test * pTest)
|
||||
}
|
||||
|
||||
#ifdef TEST_IAM
|
||||
// Dummy stubs to eliminate depencies
|
||||
void datalink_get_broadcast_address(
|
||||
BACNET_ADDRESS *dest) // destination address
|
||||
{
|
||||
(void)dest;
|
||||
}
|
||||
|
||||
int datalink_send_pdu(
|
||||
BACNET_ADDRESS *dest, // destination address
|
||||
uint8_t *pdu, // any data to be sent - may be null
|
||||
unsigned pdu_len) // number of bytes of data
|
||||
{
|
||||
(void)dest;
|
||||
(void)pdu;
|
||||
|
||||
return pdu_len;
|
||||
}
|
||||
|
||||
uint16_t Device_Vendor_Identifier(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t Device_Object_Instance_Number(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void address_add_binding(
|
||||
uint32_t device_id,
|
||||
unsigned max_apdu,
|
||||
BACNET_ADDRESS *src)
|
||||
{
|
||||
(void)device_id;
|
||||
(void)max_apdu;
|
||||
(void)src;
|
||||
}
|
||||
|
||||
// dummy for apdu dependency
|
||||
void tsm_free_invoke_id(uint8_t invokeID)
|
||||
{
|
||||
// dummy stub for testing
|
||||
(void)invokeID;
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
Test *pTest;
|
||||
|
||||
@@ -8,6 +8,8 @@ CFLAGS = -Wall -I. -Itest -DTEST -DTEST_IAM -g
|
||||
|
||||
SRCS = bacdcode.c \
|
||||
bigend.c \
|
||||
npdu.c \
|
||||
apdu.c \
|
||||
iam.c \
|
||||
test/ctest.c
|
||||
|
||||
|
||||
+4
-4
@@ -1114,7 +1114,7 @@ void MSTP_Master_Node_FSM(volatile struct mstp_port_struct_t *mstp_port)
|
||||
FRAME_TYPE_TEST_RESPONSE,
|
||||
mstp_port->SourceAddress,
|
||||
mstp_port->This_Station,
|
||||
mstp_port->InputBuffer,
|
||||
(uint8_t *)&mstp_port->InputBuffer[0],
|
||||
mstp_port->Index);
|
||||
}
|
||||
mstp_port->master_state = MSTP_MASTER_STATE_IDLE;
|
||||
@@ -1210,7 +1210,7 @@ void RS485_Send_Frame(
|
||||
}
|
||||
|
||||
#define RING_BUFFER_DATA_SIZE 1
|
||||
#define RING_BUFFER_SIZE INPUT_BUFFER_SIZE
|
||||
#define RING_BUFFER_SIZE MAX_MPDU
|
||||
static RING_BUFFER Test_Buffer;
|
||||
static uint8_t Test_Buffer_Data[RING_BUFFER_DATA_SIZE * RING_BUFFER_SIZE];
|
||||
static void Load_Input_Buffer(uint8_t *buffer,size_t len)
|
||||
@@ -1270,8 +1270,8 @@ void testReceiveNodeFSM(Test* pTest)
|
||||
uint8_t FrameType = 0; // type of packet that was sent
|
||||
unsigned len; // used for the size of the message packet
|
||||
size_t i; // used to loop through the message bytes
|
||||
uint8_t buffer[INPUT_BUFFER_SIZE] = {0};
|
||||
uint8_t data[INPUT_BUFFER_SIZE - 8 /*header*/ - 2 /*CRC*/] = {0};
|
||||
uint8_t buffer[MAX_MPDU] = {0};
|
||||
uint8_t data[MAX_MPDU - 8 /*header*/ - 2 /*CRC*/] = {0};
|
||||
|
||||
MSTP_Init(&mstp_port,my_mac);
|
||||
|
||||
|
||||
@@ -484,6 +484,22 @@ void testNPDU1(Test * pTest)
|
||||
}
|
||||
|
||||
#ifdef TEST_NPDU
|
||||
// dummy stub for testing
|
||||
void tsm_free_invoke_id(uint8_t invokeID)
|
||||
{
|
||||
(void)invokeID;
|
||||
}
|
||||
|
||||
void iam_handler(
|
||||
uint8_t *service_request,
|
||||
uint16_t service_len,
|
||||
BACNET_ADDRESS *src)
|
||||
{
|
||||
(void)service_request;
|
||||
(void)service_len;
|
||||
(void)src;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
Test *pTest;
|
||||
|
||||
Reference in New Issue
Block a user