Module: check_mk
Branch: master
Commit: 9882057d20a4473918f926688b6f903f08bc1d9a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9882057d20a447…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Tue Jul 31 09:53:29 2018 +0200
CMK-450: Make unit tests for Livestatus & Microcore possible
For now, this contains just a simple test for a header-only function, but
the rest of the machinery is there when you need it.
Fun fact: This test immediately uncovered a (harmless) bug, which will be
fixed in an upcoming commit.
Change-Id: I65686642e660e1aa15255fba8bc5f7de8caaf923
---
Makefile | 3 ++-
livestatus/iwyu-mappings/check_mk.imp | 4 ++++
omd/Makefile.omd | 5 +++++
omd/packages/googletest/.gitignore | 2 ++
omd/packages/googletest/Makefile | 33 +++++++++++++++++++++++++++++++++
omd/packages/googletest/README | 1 -
6 files changed, 46 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index e35e221..c4c43e2 100644
--- a/Makefile
+++ b/Makefile
@@ -106,7 +106,8 @@ FILES_TO_FORMAT := $(wildcard $(addprefix agents/,*.cc *.c *.h)) \
$(wildcard $(addprefix livestatus/src/,*.cc *.h)) \
$(wildcard $(addprefix bin/,*.cc *.c *.h)) \
$(wildcard $(addprefix enterprise/core/src/,*.cc *.h)) \
- $(wildcard $(addprefix enterprise/core/src/checkhelper/,*.cc *.h))
+ $(wildcard $(addprefix enterprise/core/src/checkhelper/,*.cc *.h))
\
+ $(wildcard $(addprefix enterprise/core/src/test/,*.cc *.h))
WERKS := $(wildcard .werks/[0-9]*)
diff --git a/livestatus/iwyu-mappings/check_mk.imp
b/livestatus/iwyu-mappings/check_mk.imp
index 3291f6d..a622b26 100644
--- a/livestatus/iwyu-mappings/check_mk.imp
+++ b/livestatus/iwyu-mappings/check_mk.imp
@@ -23,6 +23,10 @@
{ include: ["<pcap/bpf.h>", private, "<pcap.h>", public
] },
{ include: ["<pcap/dlt.h>", private, "<pcap.h>", public
] },
{ include: ["<pcap/pcap.h>", private, "<pcap.h>",
public ] },
+ { include: ['(a)"gmock/.*"'mock/.*"', private,
'"gmock/gmock.h"', public ] },
+ { include: ["(a)<gmock/.*>"ock/.*>", private, "<gmock/gmock.h>",
public ] },
+ { include: ['(a)"gtest/.*"'test/.*"', private,
'"gtest/gtest.h"', public ] },
+ { include: ["(a)<gtest/.*>"est/.*>", private, "<gtest/gtest.h>",
public ] },
{ symbol: ["int32_t", private, "<stdint.h>", public ] },
{ symbol: ["std::ofstream", private, "<fstream>", public ]
},
{ symbol: ["std::ostringstream", private, "<sstream>", public
] },
diff --git a/omd/Makefile.omd b/omd/Makefile.omd
index 1790eb8..4819e77 100644
--- a/omd/Makefile.omd
+++ b/omd/Makefile.omd
@@ -97,3 +97,8 @@ check-python-modules:
# perl #########################################################################
PACKAGE_BOOST_DESTDIR := $(PACKAGE_BASE)/boost/destdir
+
+
+# googletest ###################################################################
+
+PACKAGE_GOOGLETEST_DESTDIR := $(PACKAGE_BASE)/googletest/destdir
diff --git a/omd/packages/googletest/.gitignore b/omd/packages/googletest/.gitignore
new file mode 100644
index 0000000..7c44d19
--- /dev/null
+++ b/omd/packages/googletest/.gitignore
@@ -0,0 +1,2 @@
+destdir/
+googletest-??????????/
diff --git a/omd/packages/googletest/Makefile b/omd/packages/googletest/Makefile
new file mode 100644
index 0000000..dd087d5
--- /dev/null
+++ b/omd/packages/googletest/Makefile
@@ -0,0 +1,33 @@
+include ../../Makefile.omd
+
+# tar file generated by cloning
https://github.com/google/googletest and doing:
+# ( VERSION=0048647619; git archive --prefix=googletest-$VERSION/ -o
~/git/check_mk/omd/packages/googletest/googletest-$VERSION.tar.gz $VERSION )
+
+NAME := googletest
+VERSION := 0048647619
+DIR := $(NAME)-$(VERSION)
+
+.PHONY: build install skel clean
+
+# The rules below are not perfect, but good enough for now...
+build: $(DIR)/Makefile
+ $(MAKE) -C $(DIR)
+ mkdir -p $(PACKAGE_GOOGLETEST_DESTDIR)/lib
+# We do not ship the headers and libraries, we just need them at a known
+# location for testing.
+ cp -au $(DIR)/googletest/include $(DIR)/googlemock/include
$(PACKAGE_GOOGLETEST_DESTDIR)
+ cp -au $(DIR)/googletest/lib/.libs/lib*.a $(DIR)/googlemock/lib/.libs/lib*.a
$(PACKAGE_GOOGLETEST_DESTDIR)/lib
+
+$(DIR)/Makefile.in: $(DIR).tar.gz
+ tar xzf $(DIR).tar.gz
+ cd $(DIR) && autoreconf -i
+
+$(DIR)/Makefile: $(DIR)/Makefile.in
+ cd $(DIR) && ./configure --disable-shared
+
+install:
+
+skel:
+
+clean:
+ rm -rf $(DIR) $(PACKAGE_GOOGLETEST_DESTDIR)
diff --git a/omd/packages/googletest/README b/omd/packages/googletest/README
deleted file mode 100644
index 3277d0e..0000000
--- a/omd/packages/googletest/README
+++ /dev/null
@@ -1 +0,0 @@
-( VERSION=0048647619; git archive --prefix=googletest-$VERSION/ -o
~/git/check_mk/omd/packages/googletest/googletest-$VERSION.tar.gz $VERSION )