Fixed the AtomicReadFile unit test for Record Access.
This commit is contained in:
+21
-10
@@ -405,6 +405,7 @@ void testAtomicReadFileAckAccess(
|
|||||||
int apdu_len = 0;
|
int apdu_len = 0;
|
||||||
uint8_t invoke_id = 128;
|
uint8_t invoke_id = 128;
|
||||||
uint8_t test_invoke_id = 0;
|
uint8_t test_invoke_id = 0;
|
||||||
|
unsigned int i = 0;
|
||||||
|
|
||||||
len = arf_ack_encode_apdu(&apdu[0], invoke_id, data);
|
len = arf_ack_encode_apdu(&apdu[0], invoke_id, data);
|
||||||
ct_test(pTest, len != 0);
|
ct_test(pTest, len != 0);
|
||||||
@@ -418,6 +419,12 @@ void testAtomicReadFileAckAccess(
|
|||||||
ct_test(pTest,
|
ct_test(pTest,
|
||||||
test_data.type.stream.fileStartPosition ==
|
test_data.type.stream.fileStartPosition ==
|
||||||
data->type.stream.fileStartPosition);
|
data->type.stream.fileStartPosition);
|
||||||
|
ct_test(pTest,
|
||||||
|
octetstring_length(&test_data.fileData[0]) ==
|
||||||
|
octetstring_length(&data->fileData[0]));
|
||||||
|
ct_test(pTest, memcmp(octetstring_value(&test_data.fileData[0]),
|
||||||
|
octetstring_value(&data->fileData[0]),
|
||||||
|
octetstring_length(&test_data.fileData[0])) == 0);
|
||||||
} else if (test_data.access == FILE_RECORD_ACCESS) {
|
} else if (test_data.access == FILE_RECORD_ACCESS) {
|
||||||
ct_test(pTest,
|
ct_test(pTest,
|
||||||
test_data.type.record.fileStartRecord ==
|
test_data.type.record.fileStartRecord ==
|
||||||
@@ -425,13 +432,15 @@ void testAtomicReadFileAckAccess(
|
|||||||
ct_test(pTest,
|
ct_test(pTest,
|
||||||
test_data.type.record.RecordCount ==
|
test_data.type.record.RecordCount ==
|
||||||
data->type.record.RecordCount);
|
data->type.record.RecordCount);
|
||||||
|
for (i = 0; i < data->type.record.RecordCount; i++) {
|
||||||
|
ct_test(pTest,
|
||||||
|
octetstring_length(&test_data.fileData[i]) ==
|
||||||
|
octetstring_length(&data->fileData[i]));
|
||||||
|
ct_test(pTest, memcmp(octetstring_value(&test_data.fileData[i]),
|
||||||
|
octetstring_value(&data->fileData[i]),
|
||||||
|
octetstring_length(&test_data.fileData[i])) == 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ct_test(pTest,
|
|
||||||
octetstring_length(&test_data.fileData[0]) ==
|
|
||||||
octetstring_length(&data->fileData[0]));
|
|
||||||
ct_test(pTest, memcmp(octetstring_value(&test_data.fileData[0]),
|
|
||||||
octetstring_value(&data->fileData[0]),
|
|
||||||
octetstring_length(&test_data.fileData[0])) == 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void testAtomicReadFileAck(
|
void testAtomicReadFileAck(
|
||||||
@@ -439,7 +448,7 @@ void testAtomicReadFileAck(
|
|||||||
{
|
{
|
||||||
BACNET_ATOMIC_READ_FILE_DATA data = { 0 };
|
BACNET_ATOMIC_READ_FILE_DATA data = { 0 };
|
||||||
uint8_t test_octet_string[32] = "Joshua-Mary-Anna-Christopher";
|
uint8_t test_octet_string[32] = "Joshua-Mary-Anna-Christopher";
|
||||||
|
unsigned int i = 0;
|
||||||
|
|
||||||
data.endOfFile = true;
|
data.endOfFile = true;
|
||||||
data.access = FILE_STREAM_ACCESS;
|
data.access = FILE_STREAM_ACCESS;
|
||||||
@@ -451,9 +460,11 @@ void testAtomicReadFileAck(
|
|||||||
data.endOfFile = false;
|
data.endOfFile = false;
|
||||||
data.access = FILE_RECORD_ACCESS;
|
data.access = FILE_RECORD_ACCESS;
|
||||||
data.type.record.fileStartRecord = 1;
|
data.type.record.fileStartRecord = 1;
|
||||||
data.type.record.RecordCount = 2;
|
data.type.record.RecordCount = BACNET_READ_FILE_RECORD_COUNT;
|
||||||
octetstring_init(&data.fileData[0], test_octet_string,
|
for (i = 0; i < data.type.record.RecordCount; i++) {
|
||||||
sizeof(test_octet_string));
|
octetstring_init(&data.fileData[i], test_octet_string,
|
||||||
|
sizeof(test_octet_string));
|
||||||
|
}
|
||||||
testAtomicReadFileAckAccess(pTest, &data);
|
testAtomicReadFileAckAccess(pTest, &data);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ CC = gcc
|
|||||||
SRC_DIR = ../src
|
SRC_DIR = ../src
|
||||||
INCLUDES = -I../include -I. -I../demo/object
|
INCLUDES = -I../include -I. -I../demo/object
|
||||||
DEFINES = -DBACFILE=1 -DBIG_ENDIAN=0 -DTEST -DTEST_ATOMIC_READ_FILE
|
DEFINES = -DBACFILE=1 -DBIG_ENDIAN=0 -DTEST -DTEST_ATOMIC_READ_FILE
|
||||||
|
DEFINES += -DBACNET_READ_FILE_RECORD_COUNT=2
|
||||||
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
|
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
|
||||||
|
|
||||||
SRCS = $(SRC_DIR)/bacdcode.c \
|
SRCS = $(SRC_DIR)/bacdcode.c \
|
||||||
@@ -17,18 +18,18 @@ OBJS = ${SRCS:.c=.o}
|
|||||||
TARGET = arf
|
TARGET = arf
|
||||||
|
|
||||||
all: ${TARGET}
|
all: ${TARGET}
|
||||||
|
|
||||||
${TARGET}: ${OBJS}
|
${TARGET}: ${OBJS}
|
||||||
${CC} -o $@ ${OBJS}
|
${CC} -o $@ ${OBJS}
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
${CC} -c ${CFLAGS} $*.c -o $@
|
${CC} -c ${CFLAGS} $*.c -o $@
|
||||||
|
|
||||||
depend:
|
depend:
|
||||||
rm -f .depend
|
rm -f .depend
|
||||||
${CC} -MM ${CFLAGS} *.c >> .depend
|
${CC} -MM ${CFLAGS} *.c >> .depend
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf ${TARGET} $(OBJS)
|
rm -rf ${TARGET} $(OBJS)
|
||||||
|
|
||||||
include: .depend
|
include: .depend
|
||||||
|
|||||||
Reference in New Issue
Block a user