aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Levon <john.levon@nutanix.com>2020-11-25 17:33:25 +0000
committerGitHub <noreply@github.com>2020-11-25 17:33:25 +0000
commit76fb4e20298c7c41efb20a8a53ae81d2ce716303 (patch)
tree2055c804d241b4dd366d5c5ae1ee5be98761389c
parent48c55b26a05ab8d4bf7afdfed98bd8a71142848f (diff)
downloadlibvfio-user-76fb4e20298c7c41efb20a8a53ae81d2ce716303.zip
libvfio-user-76fb4e20298c7c41efb20a8a53ae81d2ce716303.tar.gz
libvfio-user-76fb4e20298c7c41efb20a8a53ae81d2ce716303.tar.bz2
add "make test"; run it in pre-commit (#127)
Also rename test.c to reflect it should cover unit tests. Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com> Signed-off-by: John Levon <john.levon@nutanix.com>
-rw-r--r--.travis.yml1
-rw-r--r--Makefile3
-rw-r--r--test/CMakeLists.txt7
-rw-r--r--test/unit-tests.c (renamed from test/test.c)0
4 files changed, 9 insertions, 2 deletions
diff --git a/.travis.yml b/.travis.yml
index 6f267b2..a75abce 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,3 +6,4 @@ before_install:
script:
- make
- make BUILD_TYPE=rel
+ - make test
diff --git a/Makefile b/Makefile
index 9e9f04b..872c975 100644
--- a/Makefile
+++ b/Makefile
@@ -53,6 +53,9 @@ PHONY_TARGETS := all realclean buildclean force_cmake export install-export tags
all $(filter-out $(PHONY_TARGETS), $(MAKECMDGOALS)): $(BUILD_DIR)/Makefile
+$(MAKE) -C $(BUILD_DIR) $@
+test: all
+ cd $(BUILD_DIR)/test; ctest --verbose
+
realclean:
rm -rf $(BUILD_DIR_BASE)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index e5fc7a0..a04e0f1 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -26,5 +26,8 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
-add_executable(test test.c )
-target_link_libraries(test cmocka json-c muser)
+add_executable(unit-tests unit-tests.c)
+target_link_libraries(unit-tests cmocka json-c muser)
+
+enable_testing()
+add_test(NAME unit-tests COMMAND unit-tests)
diff --git a/test/test.c b/test/unit-tests.c
index 6ad4e3b..6ad4e3b 100644
--- a/test/test.c
+++ b/test/unit-tests.c