1
0
mirror of https://github.com/stargieg/bacnet-stack synced 2025-10-26 23:35:52 +08:00
This commit is contained in:
Patrick Grimm
2013-03-21 22:53:31 +01:00
parent 5668c55fca
commit 01349ec9e8
843 changed files with 190207 additions and 0 deletions

35
test/abort.mak Normal file
View File

@@ -0,0 +1,35 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_ABORT
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/bacdcode.c \
$(SRC_DIR)/bacint.c \
$(SRC_DIR)/bacstr.c \
$(SRC_DIR)/bacreal.c \
$(SRC_DIR)/abort.c \
ctest.c
TARGET = abort
all: ${TARGET}
OBJS = ${SRCS:.c=.o}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf ${TARGET} $(OBJS)
include: .depend

55
test/address.cbp Normal file
View File

@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="address" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin\Debug\address" prefix_auto="1" extension_auto="1" />
<Option object_output="obj\Debug\" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin\Release\address" prefix_auto="1" extension_auto="1" />
<Option object_output="obj\Release\" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
<Add option="-fexceptions" />
<Add option="-DBIG_ENDIAN=0" />
<Add option="-DTEST" />
<Add option="-DTEST_ADDRESS" />
<Add directory="..\include" />
<Add directory="." />
</Compiler>
<Unit filename="..\src\address.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\src\bacaddr.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="ctest.c">
<Option compilerVar="CC" />
</Unit>
<Extensions>
<code_completion />
<envvars />
<debugger />
</Extensions>
</Project>
</CodeBlocks_project_file>

40
test/address.mak Normal file
View File

@@ -0,0 +1,40 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_ADDRESS
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/address.c \
$(SRC_DIR)/bacaddr.c \
$(SRC_DIR)/bacdcode.c \
$(SRC_DIR)/bacint.c \
$(SRC_DIR)/bacstr.c \
$(SRC_DIR)/bacreal.c \
$(SRC_DIR)/bacapp.c \
$(SRC_DIR)/datetime.c \
$(SRC_DIR)/bactext.c \
$(SRC_DIR)/indtext.c \
ctest.c
OBJS = ${SRCS:.c=.o}
TARGET = address
all: ${TARGET}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf ${TARGET} $(OBJS)
include: .depend

34
test/arf.mak Normal file
View File

@@ -0,0 +1,34 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I. -I../demo/object
DEFINES = -DBACFILE=1 -DBIG_ENDIAN=0 -DTEST -DTEST_ATOMIC_READ_FILE
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/bacdcode.c \
$(SRC_DIR)/bacint.c \
$(SRC_DIR)/bacstr.c \
$(SRC_DIR)/bacreal.c \
$(SRC_DIR)/arf.c \
ctest.c
OBJS = ${SRCS:.c=.o}
TARGET = arf
all: ${TARGET}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf ${TARGET} $(OBJS)
include: .depend

35
test/awf.mak Normal file
View File

@@ -0,0 +1,35 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I. -I../demo/object
DEFINES = -DBACFILE=1 -DBIG_ENDIAN=0 -DTEST -DTEST_ATOMIC_WRITE_FILE
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/bacdcode.c \
$(SRC_DIR)/bacint.c \
$(SRC_DIR)/bacstr.c \
$(SRC_DIR)/bacreal.c \
$(SRC_DIR)/awf.c \
ctest.c
OBJS = ${SRCS:.c=.o}
TARGET = awf
all: ${TARGET}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf ${TARGET} $(OBJS)
include: .depend

BIN
test/bacapp.ide Normal file

Binary file not shown.

40
test/bacapp.mak Normal file
View File

@@ -0,0 +1,40 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_BACNET_APPLICATION_DATA
DEFINES += -DBACAPP_ALL -DPRINT_ENABLED=1
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/bacdcode.c \
$(SRC_DIR)/bacint.c \
$(SRC_DIR)/bacstr.c \
$(SRC_DIR)/bacreal.c \
$(SRC_DIR)/bacapp.c \
$(SRC_DIR)/datetime.c \
$(SRC_DIR)/bactext.c \
$(SRC_DIR)/indtext.c \
ctest.c
OBJS = ${SRCS:.c=.o}
TARGET = bacapp
all: ${TARGET}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf ${TARGET} $(OBJS)
include: .depend

BIN
test/bacdcode.ide Normal file

Binary file not shown.

34
test/bacdcode.mak Normal file
View File

@@ -0,0 +1,34 @@
#Makefile to build unit tests
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_DECODE -DMAX_APDU=50
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
TARGET = bacdcode
SRCS = $(SRC_DIR)/bacdcode.c \
$(SRC_DIR)/bacint.c \
$(SRC_DIR)/bacstr.c \
$(SRC_DIR)/bacreal.c \
ctest.c
OBJS = ${SRCS:.c=.o}
all: ${TARGET}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf ${OBJS} ${TARGET}
include: .depend

35
test/bacerror.mak Normal file
View File

@@ -0,0 +1,35 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_BACERROR
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/bacdcode.c \
$(SRC_DIR)/bacint.c \
$(SRC_DIR)/bacstr.c \
$(SRC_DIR)/bacreal.c \
$(SRC_DIR)/bacerror.c \
ctest.c
OBJS = ${SRCS:.c=.o}
TARGET = bacerror
all: ${TARGET}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf ${TARGET} $(OBJS)
include: .depend

58
test/bacint.cbp Normal file
View File

@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="bacint" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin\Debug\bacint" prefix_auto="1" extension_auto="1" />
<Option object_output="obj\Debug\" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-Wall" />
<Add option="-g" />
<Add option="-DBIG_ENDIAN=0" />
<Add option="-DTEST" />
<Add option="-DTEST_BACINT" />
<Add directory="test" />
<Add directory="." />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin\Release\bacint" prefix_auto="1" extension_auto="1" />
<Option object_output="obj\Release\" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
<Add option="-fexceptions" />
<Add option="-DTEST" />
<Add option="-DTEST_BACINT" />
<Add directory="." />
<Add directory="..\include" />
</Compiler>
<Unit filename="..\src\bacint.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="ctest.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="ctest.h" />
<Extensions>
<code_completion />
<envvars />
<debugger />
</Extensions>
</Project>
</CodeBlocks_project_file>

32
test/bacint.mak Normal file
View File

@@ -0,0 +1,32 @@
#Makefile to build unit tests
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_BACINT
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
TARGET = bacint
SRCS = $(SRC_DIR)/bacint.c \
$(SRC_DIR)/bacstr.c \
ctest.c
OBJS = ${SRCS:.c=.o}
all: ${TARGET}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf ${OBJS} ${TARGET}
include: .depend

31
test/bacstr.mak Normal file
View File

@@ -0,0 +1,31 @@
#Makefile to build unit tests
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_BACSTR
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
TARGET = bacstr
SRCS = $(SRC_DIR)/bacstr.c \
ctest.c
OBJS = ${SRCS:.c=.o}
all: ${TARGET}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${OBJS} ${TARGET} *.bak
include: .depend

98
test/bvlc.cbp Normal file
View File

@@ -0,0 +1,98 @@
<?xml version="1.0"?>
<!DOCTYPE CodeBlocks_project_file>
<CodeBlocks_project_file>
<FileVersion major="1" minor="1"/>
<Project>
<Option title="BVLC Unit Test"/>
<Option makefile="Makefile"/>
<Option makefile_is_custom="0"/>
<Option compiler="2"/>
<Build>
<Target title="default">
<Option output="C:\code\bacnet-stack\bbmd.exe"/>
<Option working_dir="."/>
<Option object_output=".objs"/>
<Option deps_output=".deps"/>
<Option type="1"/>
<Option compiler="2"/>
<Option projectResourceIncludeDirsRelation="1"/>
</Target>
</Build>
<Compiler>
<Add option="-w-aus"/>
<Add option="-w-sig"/>
<Add option="-DTEST;TEST_BBMD;BACDL_BIP=1;TSM_ENABLED=1"/>
<Add directory="."/>
<Add directory="demo\handler"/>
<Add directory="demo\object"/>
<Add directory="ports\win32"/>
<Add directory="test"/>
</Compiler>
<Linker>
<Add library="..\..\BCC55\Lib\import32.lib"/>
<Add library="..\..\BCC55\Lib\cw32mt.lib"/>
</Linker>
<Unit filename="bacdcode.c">
<Option compilerVar="CC"/>
<Option target="default"/>
</Unit>
<Unit filename="bacdcode.h">
<Option compilerVar=""/>
<Option compile="0"/>
<Option link="0"/>
<Option target="default"/>
</Unit>
<Unit filename="bacdef.h">
<Option compilerVar=""/>
<Option compile="0"/>
<Option link="0"/>
<Option target="default"/>
</Unit>
<Unit filename="bacenum.h">
<Option compilerVar=""/>
<Option compile="0"/>
<Option link="0"/>
<Option target="default"/>
</Unit>
<Unit filename="bacstr.c">
<Option compilerVar="CC"/>
<Option target="default"/>
</Unit>
<Unit filename="bacstr.h">
<Option compilerVar=""/>
<Option compile="0"/>
<Option link="0"/>
<Option target="default"/>
</Unit>
<Unit filename="bigend.c">
<Option compilerVar="CC"/>
<Option target="default"/>
</Unit>
<Unit filename="bigend.h">
<Option compilerVar=""/>
<Option compile="0"/>
<Option link="0"/>
<Option target="default"/>
</Unit>
<Unit filename="bvlc.c">
<Option compilerVar="CC"/>
<Option target="default"/>
</Unit>
<Unit filename="bvlc.h">
<Option compilerVar=""/>
<Option compile="0"/>
<Option link="0"/>
<Option target="default"/>
</Unit>
<Unit filename="test\ctest.c">
<Option compilerVar="CC"/>
<Option target="default"/>
</Unit>
<Unit filename="test\ctest.h">
<Option compilerVar=""/>
<Option compile="0"/>
<Option link="0"/>
<Option target="default"/>
</Unit>
</Project>
</CodeBlocks_project_file>

35
test/bvlc.mak Normal file
View File

@@ -0,0 +1,35 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I. -I../ports/linux
DEFINES = -DBACDL_BIP -DBIG_ENDIAN=0 -DTEST -DTEST_BVLC
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/bacdcode.c \
$(SRC_DIR)/bacint.c \
$(SRC_DIR)/bacstr.c \
$(SRC_DIR)/bacreal.c \
$(SRC_DIR)/bvlc.c \
ctest.c
OBJS = ${SRCS:.c=.o}
TARGET = bvlc
all: ${TARGET}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS) *.bak *.1 *.ini
include: .depend

68
test/cov.cbp Normal file
View File

@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="COV Unit Test" />
<Option pch_mode="0" />
<Option compiler="gcc" />
<Build>
<Target title="default">
<Option output="C:\code\bacnet-stack\cov.exe" prefix_auto="0" extension_auto="0" />
<Option type="1" />
<Option compiler="gcc" />
<Option projectResourceIncludeDirsRelation="1" />
</Target>
</Build>
<VirtualTargets>
<Add alias="All" targets="default;" />
</VirtualTargets>
<Compiler>
<Add option="-Wall" />
<Add option="-g" />
<Add option="-DBACDL_TEST" />
<Add option="-DBIG_ENDIAN=0" />
<Add option="-DTEST" />
<Add option="-DTEST_COV" />
<Add directory="test" />
<Add directory="demo\object" />
<Add directory="." />
</Compiler>
<Unit filename="bacapp.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="bacapp.h" />
<Unit filename="bacdcode.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="bacdcode.h" />
<Unit filename="bacdef.h" />
<Unit filename="bacenum.h" />
<Unit filename="bacstr.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="bacstr.h" />
<Unit filename="bactext.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="bactext.h" />
<Unit filename="cov.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="cov.h" />
<Unit filename="datetime.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="datetime.h" />
<Unit filename="indtext.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="indtext.h" />
<Unit filename="test\ctest.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="test\ctest.h" />
<Extensions>
<code_completion />
</Extensions>
</Project>
</CodeBlocks_project_file>

39
test/cov.mak Normal file
View File

@@ -0,0 +1,39 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I. -I../demo/object
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_COV -DBACAPP_ALL
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/bacdcode.c \
$(SRC_DIR)/bacint.c \
$(SRC_DIR)/bacstr.c \
$(SRC_DIR)/bacreal.c \
$(SRC_DIR)/datetime.c \
$(SRC_DIR)/bacapp.c \
$(SRC_DIR)/indtext.c \
$(SRC_DIR)/bactext.c \
$(SRC_DIR)/cov.c \
ctest.c
OBJS = ${SRCS:.c=.o}
TARGET = cov
all: ${TARGET}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS) *.bak *.1 *.ini
include: .depend

BIN
test/crc.ide Normal file

Binary file not shown.

32
test/crc.mak Normal file
View File

@@ -0,0 +1,32 @@
#Makefile to build CRC tests
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I. -I../demo/object
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_CRC
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/crc.c \
ctest.c
OBJS = ${SRCS:.c=.o}
TARGET = crc
all: ${TARGET}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS) *.bak *.1 *.ini
include: .depend

191
test/ctest.c Normal file
View File

@@ -0,0 +1,191 @@
/* ctest.c: Implements the CTest Framework */
#include "ctest.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
/* Number of tests to hold incrementally */
enum { CHUNK = 10 };
Test *ct_create(
const char *name,
void (*init) (Test *))
{
int backOutLevel = 0;
Test *pTest = malloc(sizeof(Test));
if (pTest) {
pTest->nPass = pTest->nFail = pTest->nTests = 0;
pTest->pStream = stdout;
/* Allocate array of fptrs: */
assert(CHUNK);
pTest->pTestFuns = calloc(CHUNK, sizeof(TestFunc));
if (pTest->pTestFuns) {
pTest->maxTests = CHUNK;
/* Allocate test name: */
assert(name);
pTest->name = malloc(strlen(name) + 1);
if (pTest->name)
strcpy(pTest->name, name);
else
++backOutLevel;
} else
++backOutLevel;
}
/* Back-out allocations if memory failed: */
if (backOutLevel) {
switch (backOutLevel) {
case 2:
free(pTest->pTestFuns);
pTest->pTestFuns = NULL;
case 1:
free(pTest);
pTest = NULL;
}
} else if (init) {
assert(pTest);
init(pTest);
}
return pTest;
}
void ct_destroy(
Test * pTest)
{
assert(pTest);
assert(pTest->pTestFuns);
free(pTest->pTestFuns);
pTest->pTestFuns = NULL;
assert(pTest->name);
free(pTest->name);
pTest->name = NULL;
free(pTest);
}
bool ct_addTestFunction(
Test * pTest,
TestFunc tfun)
{
assert(pTest);
assert(pTest->pTestFuns);
if (pTest->nTests == pTest->maxTests) {
size_t newSize = pTest->nTests + CHUNK;
TestFunc *new_pTestFuns = realloc(pTest->pTestFuns,
newSize * sizeof(TestFunc));
if (!new_pTestFuns)
return false;
pTest->pTestFuns = new_pTestFuns;
pTest->maxTests += CHUNK;
}
assert(pTest->nTests < pTest->maxTests);
pTest->pTestFuns[pTest->nTests++] = tfun;
return true;
}
void ct_setStream(
Test * pTest,
FILE * pStream)
{
pTest->pStream = pStream;
}
FILE *ct_getStream(
Test * pTest)
{
return pTest->pStream;
}
long ct_report(
Test * pTest)
{
assert(pTest);
if (pTest->pStream) {
fprintf(pTest->pStream, "Test \"%s\":\n\tPassed: %ld\n\tFailed: %ld\n",
pTest->name, pTest->nPass, pTest->nFail);
}
return pTest->nFail;
}
void ct_succeed(
Test * pTest)
{
assert(pTest);
++pTest->nPass;
}
void ct_do_test(
Test * pTest,
const char *str,
bool cond,
const char *file,
long line)
{
assert(pTest);
if (!cond)
ct_do_fail(pTest, str, file, line);
else
ct_succeed(pTest);
}
void ct_do_fail(
Test * pTest,
const char *str,
const char *file,
long line)
{
assert(pTest);
++pTest->nFail;
if (pTest->pStream) {
fprintf(pTest->pStream, "%s failure: (%s), %s (line %ld)\n",
pTest->name, str, file, line);
}
}
long ct_getNumPassed(
Test * pTest)
{
assert(pTest);
return pTest->nPass;
}
long ct_getNumFailed(
Test * pTest)
{
assert(pTest);
return pTest->nFail;
}
long ct_run(
Test * pTest)
{
size_t testNum;
assert(pTest);
for (testNum = 0; testNum < pTest->nTests; ++testNum)
pTest->pTestFuns[testNum] (pTest);
return pTest->nFail;
}
void ct_reset(
Test * pTest)
{
assert(pTest);
pTest->nFail = pTest->nPass = 0;
}
const char *ct_getName(
Test * pTest)
{
assert(pTest);
return (pTest->name);
}
long ct_getNumTests(
Test * pTest)
{
assert(pTest);
return pTest->nTests;
}

84
test/ctest.h Normal file
View File

@@ -0,0 +1,84 @@
/* ctest.h
*
* Defines a test framework for C projects.
*/
#ifndef CTEST_H
#define CTEST_H
#include <stdio.h>
#include <stdbool.h>
#define ct_test(test, cond) \
ct_do_test(test, #cond, cond, __FILE__, __LINE__)
#define ct_fail(test, str) \
ct_do_fail(test, str, __FILE__, __LINE__)
typedef struct _Test Test;
typedef void (
*TestFunc) (
Test *);
struct _Test {
char *name;
FILE *pStream;
size_t nTests;
size_t maxTests;
TestFunc *pTestFuns;
long nPass;
long nFail;
};
#ifdef __cplusplus
extern "C" {
#endif
Test *ct_create(
const char *name,
void (*init) (Test *));
void ct_destroy(
Test * pTest);
const char *ct_getName(
Test * pTest);
long ct_getNumPassed(
Test * pTest);
long ct_getNumFailed(
Test * pTest);
long ct_getNumTests(
Test * pTest);
FILE *ct_getStream(
Test * pTest);
void ct_setStream(
Test * pTest,
FILE * stream);
bool ct_addTestFunction(
Test * pTest,
TestFunc tfun);
void ct_succeed(
Test * pTest);
long ct_run(
Test * pTest);
long ct_report(
Test * pTest);
void ct_reset(
Test * pTest);
/* Not intended for end-users: */
void ct_do_test(
Test * pTest,
const char *str,
bool cond,
const char *file,
long line);
void ct_do_fail(
Test * pTest,
const char *str,
const char *file,
long line);
#ifdef __cplusplus
}
#endif
#endif

BIN
test/datetime.ide Normal file

Binary file not shown.

38
test/datetime.mak Normal file
View File

@@ -0,0 +1,38 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_DATE_TIME
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/datetime.c \
$(SRC_DIR)/bacdcode.c \
$(SRC_DIR)/bacint.c \
$(SRC_DIR)/bacstr.c \
$(SRC_DIR)/bacreal.c \
$(SRC_DIR)/bacapp.c \
$(SRC_DIR)/bactext.c \
$(SRC_DIR)/indtext.c \
ctest.c
OBJS = ${SRCS:.c=.o}
TARGET = datetime
all: ${TARGET}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS) *.bak *.1 *.ini
include: .depend

35
test/dcc.mak Normal file
View File

@@ -0,0 +1,35 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_DEVICE_COMMUNICATION_CONTROL
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/bacdcode.c \
$(SRC_DIR)/bacint.c \
$(SRC_DIR)/bacstr.c \
$(SRC_DIR)/bacreal.c \
$(SRC_DIR)/dcc.c \
ctest.c
TARGET = dcc
all: ${TARGET}
OBJS = ${SRCS:.c=.o}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS) *.bak *.1 *.ini
include: .depend

44
test/event.mak Normal file
View File

@@ -0,0 +1,44 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I. -I../demo/object
DEFINES = -DBIG_ENDIAN=0 -DTEST -DBACAPP_ALL -DTEST_EVENT
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/bacdcode.c \
$(SRC_DIR)/bacint.c \
$(SRC_DIR)/bacstr.c \
$(SRC_DIR)/bacreal.c \
$(SRC_DIR)/bacerror.c \
$(SRC_DIR)/bacapp.c \
$(SRC_DIR)/bactext.c \
$(SRC_DIR)/indtext.c \
$(SRC_DIR)/datetime.c \
$(SRC_DIR)/memcopy.c \
$(SRC_DIR)/timestamp.c \
$(SRC_DIR)/bacpropstates.c \
$(SRC_DIR)/bacdevobjpropref.c \
$(SRC_DIR)/event.c \
ctest.c
TARGET = event
all: ${TARGET}
OBJS = ${SRCS:.c=.o}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS) *.bak *.1 *.ini
include: .depend

32
test/fifo.mak Normal file
View File

@@ -0,0 +1,32 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_FIFO_BUFFER
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/fifo.c \
ctest.c
TARGET = fifo
all: ${TARGET}
OBJS = ${SRCS:.c=.o}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS) *.bak *.1 *.ini
include: .depend

BIN
test/filename.ide Normal file

Binary file not shown.

32
test/filename.mak Normal file
View File

@@ -0,0 +1,32 @@
#Makefile to build filename tests
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_FILENAME
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/filename.c \
ctest.c
OBJS = ${SRCS:.c=.o}
TARGET = filename
all: ${TARGET}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS) *.bak *.1 *.ini
include: .depend

40
test/getevent.mak Normal file
View File

@@ -0,0 +1,40 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_GET_EVENT_INFORMATION
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/bacdcode.c \
$(SRC_DIR)/bacint.c \
$(SRC_DIR)/bacstr.c \
$(SRC_DIR)/bacreal.c \
$(SRC_DIR)/bacapp.c \
$(SRC_DIR)/datetime.c \
$(SRC_DIR)/bactext.c \
$(SRC_DIR)/indtext.c \
$(SRC_DIR)/timestamp.c \
$(SRC_DIR)/getevent.c \
ctest.c
TARGET = getevent
all: ${TARGET}
OBJS = ${SRCS:.c=.o}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS) *.bak *.1 *.ini
include: .depend

35
test/iam.mak Executable file
View File

@@ -0,0 +1,35 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I. -I../demo/object
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_IAM
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/bacdcode.c \
$(SRC_DIR)/bacint.c \
$(SRC_DIR)/bacstr.c \
$(SRC_DIR)/bacreal.c \
$(SRC_DIR)/iam.c \
ctest.c
OBJS = ${SRCS:.c=.o}
TARGET = iam
all: ${TARGET}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS) *.bak *.1 *.ini
include: .depend

35
test/ihave.mak Normal file
View File

@@ -0,0 +1,35 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_I_HAVE
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/bacdcode.c \
$(SRC_DIR)/bacint.c \
$(SRC_DIR)/bacstr.c \
$(SRC_DIR)/bacreal.c \
$(SRC_DIR)/ihave.c \
ctest.c
OBJS = ${SRCS:.c=.o}
TARGET = ihave
all: ${TARGET}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS) *.bak *.1 *.ini
include: .depend

31
test/indtext.mak Normal file
View File

@@ -0,0 +1,31 @@
#Makefile to build unit tests
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_INDEX_TEXT
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/indtext.c \
ctest.c
OBJS = ${SRCS:.c=.o}
TARGET = indtext
all: ${TARGET}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${OBJS} ${TARGET} *.bak
include: .depend

31
test/key.mak Normal file
View File

@@ -0,0 +1,31 @@
#Makefile to build unit tests
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_KEY
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/key.c \
ctest.c
TARGET = key
OBJS = ${SRCS:.c=.o}
all: ${TARGET}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS)
include: .depend

31
test/keylist.mak Normal file
View File

@@ -0,0 +1,31 @@
#Makefile to build unit tests
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_KEYLIST
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/keylist.c \
ctest.c
TARGET = keylist
OBJS = ${SRCS:.c=.o}
all: ${TARGET}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS)
include: .depend

41
test/lso.mak Normal file
View File

@@ -0,0 +1,41 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DBACAPP_ALL -DTEST_LSO
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/bacdcode.c \
$(SRC_DIR)/bacint.c \
$(SRC_DIR)/bacstr.c \
$(SRC_DIR)/bacreal.c \
$(SRC_DIR)/bacerror.c \
$(SRC_DIR)/bacapp.c \
$(SRC_DIR)/bactext.c \
$(SRC_DIR)/indtext.c \
$(SRC_DIR)/datetime.c \
$(SRC_DIR)/memcopy.c \
$(SRC_DIR)/lso.c \
ctest.c
TARGET = lso
all: ${TARGET}
OBJS = ${SRCS:.c=.o}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS) *.bak *.1 *.ini
include: .depend

32
test/memcopy.mak Normal file
View File

@@ -0,0 +1,32 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_MEM_COPY
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/memcopy.c \
ctest.c
TARGET = memcopy
all: ${TARGET}
OBJS = ${SRCS:.c=.o}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS) *.bak *.1 *.ini
include: .depend

BIN
test/mstp.ide Normal file

Binary file not shown.

35
test/mstp.mak Normal file
View File

@@ -0,0 +1,35 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I. -I../ports/linux
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_MSTP
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/mstp.c \
$(SRC_DIR)/mstptext.c \
$(SRC_DIR)/indtext.c \
$(SRC_DIR)/crc.c \
$(SRC_DIR)/ringbuf.c \
ctest.c
TARGET = mstp
all: ${TARGET}
OBJS = ${SRCS:.c=.o}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS)
include: .depend

37
test/npdu.mak Normal file
View File

@@ -0,0 +1,37 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_NPDU
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/bacdcode.c \
$(SRC_DIR)/bacint.c \
$(SRC_DIR)/bacstr.c \
$(SRC_DIR)/bacreal.c \
$(SRC_DIR)/npdu.c \
$(SRC_DIR)/apdu.c \
$(SRC_DIR)/dcc.c \
ctest.c
TARGET = npdu
all: ${TARGET}
OBJS = ${SRCS:.c=.o}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS) *.bak *.1 *.ini
include: .depend

51
test/objects.cbp Normal file
View File

@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="objects" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Release">
<Option output="bin\Release\objects" prefix_auto="1" extension_auto="1" />
<Option object_output="obj\Release\" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
<Add option="-DTEST" />
<Add option="-DTEST_OBJECT_LIST" />
<Add directory="..\include" />
<Add directory="." />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
</Compiler>
<Unit filename="..\include\key.h" />
<Unit filename="..\include\keylist.h" />
<Unit filename="..\include\objects.h" />
<Unit filename="..\src\key.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\src\keylist.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\src\objects.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="ctest.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="ctest.h" />
<Extensions>
<code_completion />
<envvars />
<debugger />
</Extensions>
</Project>
</CodeBlocks_project_file>

34
test/objects.mak Normal file
View File

@@ -0,0 +1,34 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_OBJECT_LIST
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/objects.c \
$(SRC_DIR)/keylist.c \
$(SRC_DIR)/key.c \
ctest.c
TARGET = rp
all: ${TARGET}
OBJS = ${SRCS:.c=.o}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS) *.bak *.1 *.ini
include: .depend

39
test/ptransfer.mak Normal file
View File

@@ -0,0 +1,39 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DPRINT_ENABLE=1 -DTEST -DTEST_PRIVATE_TRANSFER
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/bacdcode.c \
$(SRC_DIR)/bacapp.c \
$(SRC_DIR)/bactext.c \
$(SRC_DIR)/indtext.c \
$(SRC_DIR)/bacint.c \
$(SRC_DIR)/bacstr.c \
$(SRC_DIR)/bacreal.c \
$(SRC_DIR)/datetime.c \
$(SRC_DIR)/ptransfer.c \
ctest.c
TARGET = ptransfer
all: ${TARGET}
OBJS = ${SRCS:.c=.o}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS) *.bak *.1 *.ini
include: .depend

57
test/rd.cbp Normal file
View File

@@ -0,0 +1,57 @@
<?xml version="1.0"?>
<!DOCTYPE CodeBlocks_project_file>
<CodeBlocks_project_file>
<FileVersion major="1" minor="1"/>
<Project>
<Option title="Console application"/>
<Option makefile="rd.mak"/>
<Option makefile_is_custom="1"/>
<Option compiler="0"/>
<Build>
<Target title="default">
<Option output="C:\code\bacnet-stack\rd.exe"/>
<Option working_dir="."/>
<Option object_output=".objs"/>
<Option deps_output=".deps"/>
<Option type="1"/>
<Option compiler="0"/>
<Option projectResourceIncludeDirsRelation="1"/>
</Target>
</Build>
<Compiler>
<Add option="-Wall"/>
<Add option="-pg"/>
<Add option="-g"/>
<Add option="-DTEST"/>
<Add option="-DTEST_REINITIALIZE_DEVICE"/>
<Add directory="test"/>
</Compiler>
<Linker>
<Add option="-pg -lgmon"/>
</Linker>
<Unit filename="bacdcode.c">
<Option compilerVar="CC"/>
<Option target="default"/>
</Unit>
<Unit filename="bacstr.c">
<Option compilerVar="CC"/>
<Option target="default"/>
</Unit>
<Unit filename="bigend.c">
<Option compilerVar="CC"/>
<Option target="default"/>
</Unit>
<Unit filename="rd.c">
<Option compilerVar="CC"/>
<Option target="default"/>
<Breakpoint line="171" enabled="1" pass="0" />
<Breakpoint line="167" enabled="1" pass="0" />
<Breakpoint line="83" enabled="1" pass="0" />
<Breakpoint line="60" enabled="1" pass="0" />
</Unit>
<Unit filename="test\ctest.c">
<Option compilerVar="CC"/>
<Option target="default"/>
</Unit>
</Project>
</CodeBlocks_project_file>

35
test/rd.mak Normal file
View File

@@ -0,0 +1,35 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_REINITIALIZE_DEVICE
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/bacdcode.c \
$(SRC_DIR)/bacint.c \
$(SRC_DIR)/bacstr.c \
$(SRC_DIR)/bacreal.c \
$(SRC_DIR)/rd.c \
ctest.c
TARGET = rd
all: ${TARGET}
OBJS = ${SRCS:.c=.o}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS) *.bak *.1 *.ini
include: .depend

35
test/reject.mak Normal file
View File

@@ -0,0 +1,35 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_REJECT
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/bacdcode.c \
$(SRC_DIR)/bacint.c \
$(SRC_DIR)/bacstr.c \
$(SRC_DIR)/bacreal.c \
$(SRC_DIR)/reject.c \
ctest.c
TARGET = reject
all: ${TARGET}
OBJS = ${SRCS:.c=.o}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS) *.bak *.1 *.ini
include: .depend

32
test/ringbuf.mak Normal file
View File

@@ -0,0 +1,32 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_RING_BUFFER
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/ringbuf.c \
ctest.c
TARGET = ringbuf
all: ${TARGET}
OBJS = ${SRCS:.c=.o}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS) *.bak *.1 *.ini
include: .depend

35
test/rp.mak Normal file
View File

@@ -0,0 +1,35 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_READ_PROPERTY
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/bacdcode.c \
$(SRC_DIR)/bacint.c \
$(SRC_DIR)/bacstr.c \
$(SRC_DIR)/bacreal.c \
$(SRC_DIR)/rp.c \
ctest.c
TARGET = rp
all: ${TARGET}
OBJS = ${SRCS:.c=.o}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS) *.bak *.1 *.ini
include: .depend

41
test/rpm.mak Normal file
View File

@@ -0,0 +1,41 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DBACAPP_ALL -DTEST_READ_PROPERTY_MULTIPLE
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/bacdcode.c \
$(SRC_DIR)/bacint.c \
$(SRC_DIR)/bacstr.c \
$(SRC_DIR)/bacreal.c \
$(SRC_DIR)/bacerror.c \
$(SRC_DIR)/bacapp.c \
$(SRC_DIR)/bactext.c \
$(SRC_DIR)/indtext.c \
$(SRC_DIR)/datetime.c \
$(SRC_DIR)/memcopy.c \
$(SRC_DIR)/rpm.c \
ctest.c
TARGET = rpm
all: ${TARGET}
OBJS = ${SRCS:.c=.o}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS) *.bak *.1 *.ini
include: .depend

32
test/sbuf.mak Normal file
View File

@@ -0,0 +1,32 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_STATIC_BUFFER
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/sbuf.c \
ctest.c
TARGET = sbuf
all: ${TARGET}
OBJS = ${SRCS:.c=.o}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS) *.bak *.1 *.ini
include: .depend

32
test/timer.mak Normal file
View File

@@ -0,0 +1,32 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../ports/bdk-atxx4-mstp
INCLUDES = -I../include -I${SRC_DIR} -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_TIMER
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/timer.c \
ctest.c
TARGET = timer
all: ${TARGET}
OBJS = ${SRCS:.c=.o}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS) *.bak *.1 *.ini
include: .depend

126
test/timesync.cbp Normal file
View File

@@ -0,0 +1,126 @@
<?xml version="1.0"?>
<!DOCTYPE CodeBlocks_project_file>
<CodeBlocks_project_file>
<FileVersion major="1" minor="1"/>
<Project>
<Option title="Time Sync Unit Test"/>
<Option makefile="Makefile"/>
<Option makefile_is_custom="0"/>
<Option compiler="0"/>
<Build>
<Target title="default">
<Option output="C:\code\bacnet-stack\timesync.exe"/>
<Option working_dir="."/>
<Option object_output=".objs"/>
<Option deps_output=".deps"/>
<Option type="1"/>
<Option compiler="0"/>
<Option projectResourceIncludeDirsRelation="1"/>
</Target>
</Build>
<Compiler>
<Add option="-Wall"/>
<Add option="-pg"/>
<Add option="-g"/>
<Add option="-DTEST_TIMESYNC"/>
<Add option="-DTEST"/>
<Add directory="test"/>
</Compiler>
<Linker>
<Add option="-pg -lgmon"/>
</Linker>
<Unit filename="bacapp.c">
<Option compilerVar="CC"/>
<Option target="default"/>
</Unit>
<Unit filename="bacapp.h">
<Option compilerVar=""/>
<Option compile="0"/>
<Option link="0"/>
<Option target="default"/>
</Unit>
<Unit filename="bacdcode.c">
<Option compilerVar="CC"/>
<Option target="default"/>
</Unit>
<Unit filename="bacdcode.h">
<Option compilerVar=""/>
<Option compile="0"/>
<Option link="0"/>
<Option target="default"/>
</Unit>
<Unit filename="bacdef.h">
<Option compilerVar=""/>
<Option compile="0"/>
<Option link="0"/>
<Option target="default"/>
</Unit>
<Unit filename="bacenum.h">
<Option compilerVar=""/>
<Option compile="0"/>
<Option link="0"/>
<Option target="default"/>
</Unit>
<Unit filename="bacstr.c">
<Option compilerVar="CC"/>
<Option target="default"/>
</Unit>
<Unit filename="bacstr.h">
<Option compilerVar=""/>
<Option compile="0"/>
<Option link="0"/>
<Option target="default"/>
</Unit>
<Unit filename="bactext.c">
<Option compilerVar="CC"/>
<Option target="default"/>
</Unit>
<Unit filename="bactext.h">
<Option compilerVar=""/>
<Option compile="0"/>
<Option link="0"/>
<Option target="default"/>
</Unit>
<Unit filename="bigend.c">
<Option compilerVar="CC"/>
<Option target="default"/>
</Unit>
<Unit filename="bigend.h">
<Option compilerVar=""/>
<Option compile="0"/>
<Option link="0"/>
<Option target="default"/>
</Unit>
<Unit filename="indtext.c">
<Option compilerVar="CC"/>
<Option target="default"/>
</Unit>
<Unit filename="indtext.h">
<Option compilerVar=""/>
<Option compile="0"/>
<Option link="0"/>
<Option target="default"/>
</Unit>
<Unit filename="test\ctest.c">
<Option compilerVar="CC"/>
<Option target="default"/>
</Unit>
<Unit filename="test\ctest.h">
<Option compilerVar=""/>
<Option compile="0"/>
<Option link="0"/>
<Option target="default"/>
</Unit>
<Unit filename="timesync.c">
<Option compilerVar="CC"/>
<Option target="default"/>
<Breakpoint line="136" enabled="1" pass="0" />
</Unit>
<Unit filename="timesync.h">
<Option compilerVar=""/>
<Option compile="0"/>
<Option link="0"/>
<Option target="default"/>
</Unit>
</Project>
</CodeBlocks_project_file>

55
test/timesync.mak Normal file
View File

@@ -0,0 +1,55 @@
#Makefile to build test case
# tools - only if you need them.
# Most platforms have this already defined
# CC = gcc
# AR = ar
# MAKE = make
# SIZE = size
#
# Assumes rm and cp are available
SRC_DIR := ../src
INCLUDES := -I../include -I.
DEFINES := -DBIG_ENDIAN=0 -DTEST -DBACAPP_ALL -DTEST_TIMESYNC
CFLAGS := $(INCLUDES) $(DEFINES) -g
CFLAGS += -Wall
TARGET := timesync
SRCS := $(SRC_DIR)/bacdcode.c \
$(SRC_DIR)/bacint.c \
$(SRC_DIR)/bacstr.c \
$(SRC_DIR)/bacreal.c \
$(SRC_DIR)/bacerror.c \
$(SRC_DIR)/bacapp.c \
$(SRC_DIR)/bactext.c \
$(SRC_DIR)/indtext.c \
$(SRC_DIR)/datetime.c \
$(SRC_DIR)/timesync.c \
ctest.c
OBJS := ${SRCS:.c=.o}
all: ${TARGET}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS) *.bak *.1 *.ini
run:
./${TARGET}
include: .depend
.PHONY: all run clean

92
test/whohas.cbp Normal file
View File

@@ -0,0 +1,92 @@
<?xml version="1.0"?>
<!DOCTYPE CodeBlocks_project_file>
<CodeBlocks_project_file>
<FileVersion major="1" minor="1"/>
<Project>
<Option title="Who-Has Unit Test"/>
<Option makefile="Makefile"/>
<Option makefile_is_custom="0"/>
<Option compiler="0"/>
<Build>
<Target title="default">
<Option output="C:\code\bacnet-stack\whohas.exe"/>
<Option working_dir="."/>
<Option object_output=".objs"/>
<Option deps_output=".deps"/>
<Option type="1"/>
<Option compiler="0"/>
<Option projectResourceIncludeDirsRelation="1"/>
<Compiler>
<Add option="-Wall"/>
<Add option="-pg"/>
<Add option="-g"/>
</Compiler>
<Linker>
<Add option="-pg -lgmon"/>
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-DTEST"/>
<Add option="-DTEST_WHOHAS"/>
<Add directory="C:\code\bacnet-stack\"/>
<Add directory="test"/>
</Compiler>
<Unit filename="bacdcode.c">
<Option compilerVar="CC"/>
<Option target="default"/>
</Unit>
<Unit filename="bacdcode.h">
<Option compilerVar=""/>
<Option compile="0"/>
<Option link="0"/>
<Option target="default"/>
</Unit>
<Unit filename="bacdef.h">
<Option compilerVar=""/>
<Option compile="0"/>
<Option link="0"/>
<Option target="default"/>
</Unit>
<Unit filename="bacenum.h">
<Option compilerVar=""/>
<Option compile="0"/>
<Option link="0"/>
<Option target="default"/>
</Unit>
<Unit filename="bacstr.c">
<Option compilerVar="CC"/>
<Option target="default"/>
</Unit>
<Unit filename="bacstr.h">
<Option compilerVar=""/>
<Option compile="0"/>
<Option link="0"/>
<Option target="default"/>
</Unit>
<Unit filename="bigend.c">
<Option compilerVar="CC"/>
<Option target="default"/>
</Unit>
<Unit filename="test\ctest.c">
<Option compilerVar="CC"/>
<Option target="default"/>
</Unit>
<Unit filename="whohas.c">
<Option compilerVar="CC"/>
<Option target="default"/>
</Unit>
<Unit filename="whohas.h">
<Option compilerVar=""/>
<Option compile="0"/>
<Option link="0"/>
<Option target="default"/>
</Unit>
<Unit filename="whohas.mak">
<Option compilerVar=""/>
<Option compile="0"/>
<Option link="0"/>
<Option target="default"/>
</Unit>
</Project>
</CodeBlocks_project_file>

35
test/whohas.mak Normal file
View File

@@ -0,0 +1,35 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_WHOHAS
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/bacdcode.c \
$(SRC_DIR)/bacint.c \
$(SRC_DIR)/bacstr.c \
$(SRC_DIR)/bacreal.c \
$(SRC_DIR)/whohas.c \
ctest.c
TARGET = whohas
all: ${TARGET}
OBJS = ${SRCS:.c=.o}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS) *.bak *.1 *.ini
include: .depend

35
test/whois.mak Normal file
View File

@@ -0,0 +1,35 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_WHOIS
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/bacdcode.c \
$(SRC_DIR)/bacint.c \
$(SRC_DIR)/bacstr.c \
$(SRC_DIR)/bacreal.c \
$(SRC_DIR)/whois.c \
ctest.c
TARGET = whois
all: ${TARGET}
OBJS = ${SRCS:.c=.o}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS) *.bak *.1 *.ini
include: .depend

39
test/wp.mak Normal file
View File

@@ -0,0 +1,39 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DBACAPP_ALL -DTEST_WRITE_PROPERTY
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = $(SRC_DIR)/bacdcode.c \
$(SRC_DIR)/bacint.c \
$(SRC_DIR)/bacstr.c \
$(SRC_DIR)/bacreal.c \
$(SRC_DIR)/datetime.c \
$(SRC_DIR)/bacapp.c \
$(SRC_DIR)/bactext.c \
$(SRC_DIR)/indtext.c \
$(SRC_DIR)/wp.c \
ctest.c
TARGET = wp
all: ${TARGET}
OBJS = ${SRCS:.c=.o}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS) *.bak *.1 *.ini
include: .depend