Compare commits

..

1 Commits

Author SHA1 Message Date
Thomas Klaehn
66be59c7ee Add unit test framework and simple unit test example 2019-07-15 23:15:10 +02:00
2 changed files with 3 additions and 11 deletions

View File

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

View File

@ -2,6 +2,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h> #include <stdbool.h>
#include <time.h> #include <time.h>
#include <sys/syscall.h>
#include <fff.h> #include <fff.h>
#include <utest.h> #include <utest.h>
@ -16,10 +17,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_open, struct ftdi_context *, int, int);
FAKE_VALUE_FUNC(int, ftdi_usb_close, struct ftdi_context *); FAKE_VALUE_FUNC(int, ftdi_usb_close, struct ftdi_context *);
FAKE_VALUE_FUNC(struct ftdi_context *, ftdi_new); FAKE_VALUE_FUNC(struct ftdi_context *, ftdi_new);
FAKE_VALUE_FUNC(char *, ftdi_get_error_string, struct ftdi_context *); FAKE_VALUE_FUNC(const 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_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_read_data, struct ftdi_context *, unsigned char *, int);
FAKE_VALUE_FUNC(int, ftdi_write_data, struct ftdi_context *, unsigned char *, int); FAKE_VALUE_FUNC(int, ftdi_write_data, struct ftdi_context *, const unsigned char *, int);
UTEST_MAIN(); UTEST_MAIN();