From: Vlad-Andrei BĂDOIU (78692) Date: Mon, 22 Jul 2019 16:29:57 +0000 (+0000) Subject: Initial port of googletest to Unikraft X-Git-Tag: RELEASE-0.4^0 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=71df308235c0d114a92ef0480245cd1dd8c57984;p=unikraft%2Flibs%2Fgoogletest.git Initial port of googletest to Unikraft This is our initial port of googletest to Unikraft as an external library. libcxx is required. This library should be added last to the dependency list, e.g.,: ...:$(UK_LIBS)/libunwind:$(UK_LIBS)/compiler-rt:$(UK_LIBS)/libcxxabi: $(UK_LIBS)/libcxx:$(UK_LIBS)/newlib:$(UK_LIBS)/googletest:... This library has a config option called LIBGOOGLETEST_BUILD_MAIN that builds the gtest_main.cc file; this is because some libraries do not have any main function in their unit tests and expect googletest to provide it. Signed-off-by: Vlad-Andrei Badoiu Reviewed-by: Felipe Huici --- diff --git a/COPYING.md b/COPYING.md index e28f3ef..9fb63be 100644 --- a/COPYING.md +++ b/COPYING.md @@ -1,7 +1,7 @@ License ======= -Unikraft fxdiv wrappers +Unikraft googletest wrapper ----------------------- This repository contains wrapper code to build googletest with Unikraft. diff --git a/Config.uk b/Config.uk new file mode 100644 index 0000000..862d4ee --- /dev/null +++ b/Config.uk @@ -0,0 +1,10 @@ +menuconfig LIBGOOGLETEST + bool "Google Testing and Mocking Framework" + select LIBCXX + default n + +if LIBGOOGLETEST + config LIBGOOGLETEST_BUILD_MAIN + bool "Build googletest with main" + default n +endif diff --git a/Makefile.uk b/Makefile.uk new file mode 100644 index 0000000..91f654e --- /dev/null +++ b/Makefile.uk @@ -0,0 +1,75 @@ +# libgoogletest Makefile.uk +# +# Authors: Vlad-Andrei Badoiu +# +# Copyright (c) 2019, Politehnica University of Bucharest. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY. +# + +################################################################################ +# Library registration +################################################################################ +$(eval $(call addlib_s,libgoogletest,$(CONFIG_LIBGOOGLETEST))) + +################################################################################ +# Sources +################################################################################ +LIBGOOGLETEST_VERSION=1.8.1 +LIBGOOGLETEST_URL=https://github.com/google/googletest/archive/release-$(LIBGOOGLETEST_VERSION).zip +$(eval $(call fetch,libgoogletest,$(LIBGOOGLETEST_URL))) + +################################################################################ +# Helpers +################################################################################ +LIBGOOGLETEST_SUBDIR=googletest-release-$(LIBGOOGLETEST_VERSION) +LIBGOOGLETEST_SRC = $(LIBGOOGLETEST_ORIGIN)/$(LIBGOOGLETEST_SUBDIR) + +################################################################################ +# Library includes +################################################################################ +CINCLUDES-$(CONFIG_LIBGOOGLETEST) += -I$(LIBGOOGLETEST_SRC)/googletest/ +CINCLUDES-$(CONFIG_LIBGOOGLETEST) += -I$(LIBGOOGLETEST_SRC)/googletest/include + +CXXINCLUDES-$(CONFIG_LIBGOOGLETEST) += -I$(LIBGOOGLETEST_SRC)/googletest/ +CXXINCLUDES-$(CONFIG_LIBGOOGLETEST) += -I$(LIBGOOGLETEST_SRC)/googletest/include + +################################################################################ +# Global flags +################################################################################ +CONFIG_FLAGS += -D GTEST_HAS_CXXABI_H_ -D GTEST_LANG_CXX11 +LIBGOOGLETEST_CFLAGS-y += $(CONFIG_FLAGS) +LIBGOOGLETEST_CXXFLAGS-y += $(CONFIG_FLAGS) + +################################################################################ +# Library sources +################################################################################ +ifdef CONFIG_LIBGOOGLETEST_BUILD_MAIN +LIBGOOGLETEST_SRCS-y += $(LIBGOOGLETEST_SRC)/googletest/src/gtest_main.cc +endif +LIBGOOGLETEST_SRCS-y += $(LIBGOOGLETEST_SRC)/googletest/src/gtest-all.cc diff --git a/README.md b/README.md index 769a3a6..d0344ef 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,19 @@ googletest for Unikraft =================== -Please refer to the `README.md` as well as the documentation in the `doc/` -subdirectory of the main unikraft repository. +This is the port of googletest to Unikraft as an external +library. libcxx is required. This library should come at the end of +the dependency list, e.g.,: + + ...:$(UK_LIBS)/libunwind:$(UK_LIBS)/compiler-rt:$(UK_LIBS)/libcxxabi: + $(UK_LIBS)/libcxx:$(UK_LIBS)/newlib:$(UK_LIBS)/googletest:... + +This library has a config option called LIBGOOGLETEST_BUILD_MAIN that +builds the gtest_main.cc file. This is because some libraries do not +have any main function in their unit tests and expect googletest to +provide it. + +Please refer to the `README.md` as well as the documentation in the +`doc/` subdirectory of the main unikraft repository for further +information. +