mirror of https://github.com/YosysHQ/yosys.git
Improved unit test structure
Signed-off-by: rodrigosiqueira <rodrigosiqueiramelo@gmail.com> Signed-off-by: chaws <18oliveira.charles@gmail.com> * Merged run-all-unitest inside unit-test target * Fixed Makefile dependencies * Updated documentation about unit test
This commit is contained in:
parent
3f2f64f414
commit
b932e2355d
|
@ -436,8 +436,8 @@ test. However, it is strongly recommended that you take a look to the official
|
|||
repository (https://github.com/google/googletest) and refers to that if you
|
||||
have any problem to install it. Follow the steps below:
|
||||
|
||||
* Install: cmake
|
||||
* Clone google test project from: //github.com/rodrigosiqueira/logbook.git and
|
||||
* Install: cmake and pthread
|
||||
* Clone google test project from: https://github.com/google/googletest and
|
||||
enter in the project directory
|
||||
* Inside project directory, type:
|
||||
|
||||
|
|
3
Makefile
3
Makefile
|
@ -455,9 +455,6 @@ unit-test: libyosys.so
|
|||
@$(MAKE) -C $(UNITESTPATH) CXX="$(CXX)" CPPFLAGS="$(CPPFLAGS)" \
|
||||
CXXFLAGS="$(CXXFLAGS)" LDLIBS="$(LDLIBS)" ROOTPATH="$(CURDIR)"
|
||||
|
||||
run-all-unitest:
|
||||
@$(MAKE) -C $(UNITESTPATH) run-tests
|
||||
|
||||
clean-unit-test:
|
||||
@$(MAKE) -C $(UNITESTPATH) clean
|
||||
|
||||
|
|
|
@ -2,26 +2,33 @@ GTESTFLAG := -lgtest -lgtest_main
|
|||
RPATH := -Wl,-rpath
|
||||
EXTRAFLAGS := -lyosys
|
||||
|
||||
ALLTESTFILE := $(wildcard ./**/*Test.cc)
|
||||
OBJTEST := objtest
|
||||
BINTEST := bintest
|
||||
|
||||
all: prepare $(ALLTESTFILE:%Test.cc=%Test.o)
|
||||
ALLTESTFILE := $(shell find -name '*Test.cc' -printf '%P ')
|
||||
TESTDIRS := $(sort $(dir $(ALLTESTFILE)))
|
||||
TESTS := $(addprefix $(BINTEST)/, $(basename $(ALLTESTFILE:%Test.cc=%Test.o)))
|
||||
|
||||
%Test.o: %Test.cc
|
||||
$(CXX) -o $(OBJTEST)/$(notdir $@) -c -I$(ROOTPATH) $(CPPFLAGS) $(CXXFLAGS) $<
|
||||
$(CXX) -L$(ROOTPATH) $(RPATH)=$(ROOTPATH) -o \
|
||||
$(BINTEST)/$(basename $(notdir $@)) $(OBJTEST)/$(notdir $@) $(LDLIBS) \
|
||||
# Prevent make from removing our .o files
|
||||
.SECONDARY:
|
||||
|
||||
all: prepare $(TESTS) run-tests
|
||||
|
||||
$(BINTEST)/%: $(OBJTEST)/%.o
|
||||
$(CXX) -L$(ROOTPATH) $(RPATH)=$(ROOTPATH) -o $@ $^ $(LDLIBS) \
|
||||
$(GTESTFLAG) $(EXTRAFLAGS)
|
||||
|
||||
|
||||
$(OBJTEST)/%.o: $(basename $(subst $(OBJTEST),.,%)).cc
|
||||
$(CXX) -o $@ -c -I$(ROOTPATH) $(CPPFLAGS) $(CXXFLAGS) $^
|
||||
|
||||
.PHONY: prepare run-tests clean
|
||||
|
||||
run-tests:
|
||||
$(CURDIR)/$(BINTEST)/*
|
||||
run-tests: $(TESTS)
|
||||
$(subst Test ,Test; ,$^)
|
||||
|
||||
prepare:
|
||||
mkdir -p $(OBJTEST)
|
||||
mkdir -p $(BINTEST)
|
||||
mkdir -p $(addprefix $(BINTEST)/,$(TESTDIRS))
|
||||
mkdir -p $(addprefix $(OBJTEST)/,$(TESTDIRS))
|
||||
|
||||
clean:
|
||||
rm -rf $(OBJTEST)
|
||||
|
|
Loading…
Reference in New Issue