diff options
-rw-r--r-- | src/vpp-api/vapi/CMakeLists.txt | 49 | ||||
-rw-r--r-- | src/vpp-api/vapi/fake.api.json (renamed from test/ext/fake.api.json) | 0 | ||||
-rw-r--r-- | src/vpp-api/vapi/vapi_c_test.c (renamed from test/ext/vapi_c_test.c) | 0 | ||||
-rw-r--r-- | src/vpp-api/vapi/vapi_cpp_test.cpp (renamed from test/ext/vapi_cpp_test.cpp) | 0 | ||||
-rw-r--r-- | test/Makefile | 6 | ||||
-rw-r--r-- | test/ext/Makefile | 60 | ||||
-rw-r--r-- | test/test_vapi.py | 16 |
7 files changed, 58 insertions, 73 deletions
diff --git a/src/vpp-api/vapi/CMakeLists.txt b/src/vpp-api/vapi/CMakeLists.txt index 04e7edd5f2a..626971f9108 100644 --- a/src/vpp-api/vapi/CMakeLists.txt +++ b/src/vpp-api/vapi/CMakeLists.txt @@ -14,6 +14,7 @@ include_directories ( ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_BINARY_DIR}/.. + ${CMAKE_CURRENT_BINARY_DIR} ) add_vpp_library(vapiclient @@ -58,3 +59,51 @@ install( DESTINATION ${VPP_RUNTIME_DIR} COMPONENT vpp-dev ) + +vpp_find_path(SUBUNIT_INCLUDE_DIR NAMES subunit/child.h) +vpp_find_library(SUBUNIT_LIB NAMES subunit) + +if(SUBUNIT_INCLUDE_DIR AND SUBUNIT_LIB) + message (STATUS "Found subunit in ${SUBUNIT_INCLUDE_DIR} and ${SUBUNIT_LIB}") + + add_custom_command( + OUTPUT fake.api.vapi.h + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/vapi_c_gen.py + ARGS --remove-path ${CMAKE_CURRENT_SOURCE_DIR}/fake.api.json + DEPENDS fake.api.json + COMMENT "Generating fake VAPI C header ${output_name}" + ) + + add_custom_command( + OUTPUT fake.api.vapi.hpp + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/vapi_cpp_gen.py + ARGS --remove-path ${CMAKE_CURRENT_SOURCE_DIR}/fake.api.json + DEPENDS fake.api.json + COMMENT "Generating fake VAPI C++ header ${output_name}" + ) + + add_custom_target(fake_api_vapi_h DEPENDS fake.api.vapi.h) + add_custom_target(fake_api_vapi_hpp DEPENDS fake.api.vapi.hpp) + + set(libs vppinfra vlibmemoryclient svm pthread check rt m vapiclient ${SUBUNIT_LIB}) + + add_vpp_executable(vapi_c_test + SOURCES + vapi_c_test.c + DEPENDS fake_api_vapi_h + LINK_LIBRARIES ${libs} + ) + + enable_language(CXX) + add_vpp_executable(vapi_cpp_test + SOURCES + vapi_cpp_test.cpp + DEPENDS fake_api_vapi_hpp + LINK_LIBRARIES ${libs} + ) + +else() + message (WARNING "subunit library not found - vapi tests disabled") +endif() diff --git a/test/ext/fake.api.json b/src/vpp-api/vapi/fake.api.json index 24c9f4dbfa1..24c9f4dbfa1 100644 --- a/test/ext/fake.api.json +++ b/src/vpp-api/vapi/fake.api.json diff --git a/test/ext/vapi_c_test.c b/src/vpp-api/vapi/vapi_c_test.c index efa6a735611..efa6a735611 100644 --- a/test/ext/vapi_c_test.c +++ b/src/vpp-api/vapi/vapi_c_test.c diff --git a/test/ext/vapi_cpp_test.cpp b/src/vpp-api/vapi/vapi_cpp_test.cpp index 1dd58f85484..1dd58f85484 100644 --- a/test/ext/vapi_cpp_test.cpp +++ b/src/vpp-api/vapi/vapi_cpp_test.cpp diff --git a/test/Makefile b/test/Makefile index 82095883b55..6726ac3e1e2 100644 --- a/test/Makefile +++ b/test/Makefile @@ -194,10 +194,6 @@ sanity: test-dep echo \"*******************************************************************\" &&\ false)" -.PHONY: ext-test-apps -ext-test-apps: - make -C ext test-apps - $(FAILED_DIR): reset @mkdir -p $@ @@ -205,7 +201,7 @@ $(FAILED_DIR): reset test-dep: $(PAPI_INSTALL_DONE) $(FAILED_DIR) .PHONY: test -test: test-dep ext-test-apps sanity +test: test-dep sanity $(call retest-func) .PHONY: retest diff --git a/test/ext/Makefile b/test/ext/Makefile deleted file mode 100644 index bc2061446f4..00000000000 --- a/test/ext/Makefile +++ /dev/null @@ -1,60 +0,0 @@ -TEST_EXT_DIR=$(TEST_DIR)/ext -VAPI_BINDIR = $(TEST_BR)/vapi_test -VAPI_CBIN = $(addprefix $(VAPI_BINDIR), /vapi_c_test) -VAPI_CPPBIN = $(addprefix $(VAPI_BINDIR), /vapi_cpp_test) - -VAPI_LIBS = \ - -L$(VPP_INSTALL_PATH)/vpp/lib \ - -lvppinfra -lvlibmemoryclient -lsvm -lpthread -lcheck -lrt -lm -lvapiclient - -ifneq ($(filter centos,$(OS_ID)),$(OS_ID)) -VAPI_LIBS += -lsubunit -endif - -FLAGS = -g -Wall -lstdc++ -pthread -I$(WS_ROOT)/src -I$(VPP_INSTALL_PATH)/vpp/include -I$(VAPI_BINDIR) -CFLAGS = -std=gnu99 $(FLAGS) -CPPFLAGS = -std=c++11 $(FLAGS) - -$(VAPI_BINDIR): - @mkdir -p $(VAPI_BINDIR) - -CSRC = $(TEST_EXT_DIR)/vapi_c_test.c - -$(VAPI_BINDIR)/fake.api.vapi.h: fake.api.json $(WS_ROOT)/src/vpp-api/vapi/vapi_c_gen.py | $(VAPI_BINDIR) - $(WS_ROOT)/src/vpp-api/vapi/vapi_c_gen.py --prefix $(VAPI_BINDIR) $< - -$(VAPI_BINDIR)/fake.api.vapi.hpp: fake.api.json $(WS_ROOT)/src/vpp-api/vapi/vapi_cpp_gen.py | $(VAPI_BINDIR) - $(WS_ROOT)/src/vpp-api/vapi/vapi_cpp_gen.py --prefix $(VAPI_BINDIR) $< - -$(VAPI_CBIN): $(CSRC) $(VAPI_BINDIR)/fake.api.vapi.h | $(VAPI_BINDIR) - $(CC) -o $@ $(CFLAGS) $(CSRC) $(VAPI_LIBS) - -$(VAPI_CBIN).d: $(CSRC) $(VAPI_BINDIR)/fake.api.vapi.h - $(CC) -o $@ $(CFLAGS) -MM -MT '$(VAPI_CBIN)' $(CSRC) > $@ - - -ifeq ($(filter rhel centos,$(OS_ID)),$(OS_ID) AND $(OS_VERSION_ID),7) -VAPI_CPPBIN= -else -CPPSRC = $(TEST_EXT_DIR)/vapi_cpp_test.cpp - -$(VAPI_CPPBIN): $(CPPSRC) $(VAPI_BINDIR)/fake.api.vapi.hpp | $(VAPI_BINDIR) - $(CXX) -o $@ $(CPPFLAGS) $(CPPSRC) $(VAPI_LIBS) - -$(VAPI_CPPBIN).d: $(CPPSRC) $(VAPI_BINDIR)/fake.api.vapi.hpp - $(CXX) -o $@ $(CPPFLAGS) -MM -MT '$(VAPI_CPPBIN)' $(CPPSRC) > $@ -endif - -.PHONY: test-apps -test-apps: $(VAPI_CBIN) $(VAPI_CPPBIN) - -.PHONY: clean -clean: - @rm -rf $(VAPI_BINDIR) - -ifneq ($(MAKECMDGOALS),clean) --include $(VAPI_CBIN).d -ifneq ($(VAPI_CPPBIN),) --include $(VAPI_CPPBIN).d -endif -endif diff --git a/test/test_vapi.py b/test/test_vapi.py index d91099210d2..9b4cad090a0 100644 --- a/test/test_vapi.py +++ b/test/test_vapi.py @@ -20,11 +20,11 @@ class VAPITestCase(VppTestCase): def test_vapi_c(self): """ run C VAPI tests """ - var = "TEST_BR" - built_root = os.getenv(var, None) - self.assertIsNotNone(built_root, + var = "VPP_BUILD_DIR" + build_dir = os.getenv(var, None) + self.assertIsNotNone(build_dir, "Environment variable `%s' not set" % var) - executable = "%s/vapi_test/vapi_c_test" % built_root + executable = f"{build_dir}/vpp/bin/vapi_c_test" worker = Worker([executable, "vapi client", self.get_api_segment_prefix()], self.logger) worker.start() @@ -49,11 +49,11 @@ class VAPITestCase(VppTestCase): def test_vapi_cpp(self): """ run C++ VAPI tests """ - var = "TEST_BR" - built_root = os.getenv(var, None) - self.assertIsNotNone(built_root, + var = "VPP_BUILD_DIR" + build_dir = os.getenv(var, None) + self.assertIsNotNone(build_dir, "Environment variable `%s' not set" % var) - executable = "%s/vapi_test/vapi_cpp_test" % built_root + executable = f"{build_dir}/vpp/bin/vapi_cpp_test" worker = Worker([executable, "vapi client", self.get_api_segment_prefix()], self.logger) worker.start() |