Compare commits

..

1 Commits

Author SHA1 Message Date
Thomas Klaehn
d6fe8ec934 Add unit test framework and simple unit test example 2019-07-15 22:51:52 +02:00
2 changed files with 11 additions and 3 deletions

View File

@ -13,12 +13,21 @@ UNIT_TEST_SRC_DIR = test/unit
UNIT_TEST_OBJ_DIR = $(OBJ_DIR)/$(UNIT_TEST_SRC_DIR)
INCLUDES := inc
#Alpine Linux names libftdi libftdi1
ifneq "$(findstring Alpine,$(shell head -1 /etc/issue))" ""
INCLUDES += /usr/include/libftdi1
endif
ifneq "$(findstring $(MAKECMDGOALS), build_unit_test exec_unit_test)" ""
INCLUDES += test/inc
else
#Alpine Linux names libftdi libftdi1
ifneq "$(findstring Alpine,$(shell head -1 /etc/issue))" ""
LIBS := ftdi1
else
LIBS := ftdi
endif
endif
LD_FLAGS :=

View File

@ -2,7 +2,6 @@
#include <stdlib.h>
#include <stdbool.h>
#include <time.h>
#include <sys/syscall.h>
#include <fff.h>
#include <utest.h>
@ -17,10 +16,10 @@ FAKE_VOID_FUNC(ftdi_free, struct ftdi_context *);
FAKE_VALUE_FUNC(int, ftdi_usb_open, struct ftdi_context *, int, int);
FAKE_VALUE_FUNC(int, ftdi_usb_close, struct ftdi_context *);
FAKE_VALUE_FUNC(struct ftdi_context *, ftdi_new);
FAKE_VALUE_FUNC(const char *, ftdi_get_error_string, struct ftdi_context *);
FAKE_VALUE_FUNC(char *, ftdi_get_error_string, struct ftdi_context *);
FAKE_VALUE_FUNC(int, ftdi_set_bitmode, struct ftdi_context *, unsigned char, unsigned char);
FAKE_VALUE_FUNC(int, ftdi_read_data, struct ftdi_context *, unsigned char *, int);
FAKE_VALUE_FUNC(int, ftdi_write_data, struct ftdi_context *, const unsigned char *, int);
FAKE_VALUE_FUNC(int, ftdi_write_data, struct ftdi_context *, unsigned char *, int);
UTEST_MAIN();