Add googletest, adapt port by @rite to 17.05
This commit is contained in:
committed by
Norman Feske
parent
9055c535e7
commit
1336376e2e
8
lib/import/import-gtest.mk
Normal file
8
lib/import/import-gtest.mk
Normal file
@@ -0,0 +1,8 @@
|
||||
GTEST_PORT_DIR := $(call select_from_ports,googletest)
|
||||
|
||||
INC_DIR += $(GTEST_PORT_DIR)/include
|
||||
|
||||
CC_OPT += -DGTEST_HAS_RTTI=0
|
||||
CC_OPT += -DGTEST_HAS_PTHREAD=0
|
||||
CC_OPT += -DGTEST_HAS_DEATH_TEST=0
|
||||
CC_OPT += -DGTEST_USE_OWN_FLAGFILE_FLAG_=0
|
||||
19
lib/mk/gmock.mk
Normal file
19
lib/mk/gmock.mk
Normal file
@@ -0,0 +1,19 @@
|
||||
GMOCK_DIR := $(call select_from_ports,googletest)/src/lib/googletest/googlemock
|
||||
GTEST_DIR := $(call select_from_ports,googletest)/src/lib/googletest/googletest
|
||||
|
||||
include $(REP_DIR)/lib/import/import-gtest.mk
|
||||
|
||||
SHARED_LIB = yes
|
||||
|
||||
SRC_CC = gmock-all.cc
|
||||
|
||||
vpath %.cc $(GMOCK_DIR)/src
|
||||
|
||||
INC_DIR += $(GMOCK_DIR)
|
||||
INC_DIR += $(GMOCK_DIR)/include
|
||||
INC_DIR += $(GMOCK_DIR)/include/internal
|
||||
|
||||
INC_DIR += $(GTEST_DIR)/include
|
||||
INC_DIR += $(GTEST_DIR)/include/internal
|
||||
|
||||
LIBS += stdcxx
|
||||
13
lib/mk/gtest.mk
Normal file
13
lib/mk/gtest.mk
Normal file
@@ -0,0 +1,13 @@
|
||||
GTEST_DIR := $(call select_from_ports,googletest)/src/lib/googletest/googletest
|
||||
|
||||
include $(REP_DIR)/lib/import/import-gtest.mk
|
||||
|
||||
SRC_CC = gtest-all.cc
|
||||
|
||||
vpath %.cc $(GTEST_DIR)/src
|
||||
|
||||
INC_DIR += $(GTEST_DIR)
|
||||
INC_DIR += $(GTEST_DIR)/include
|
||||
INC_DIR += $(GTEST_DIR)/include/internal
|
||||
|
||||
LIBS += libc libm stdcxx
|
||||
1
ports/googletest.hash
Normal file
1
ports/googletest.hash
Normal file
@@ -0,0 +1 @@
|
||||
6dbd3bd4791b02ea55f2b4985b2d6df16cd8e853
|
||||
18
ports/googletest.port
Normal file
18
ports/googletest.port
Normal file
@@ -0,0 +1,18 @@
|
||||
LICENSE := BSD-3-Clause
|
||||
VERSION := git
|
||||
DOWNLOADS := googletest.git
|
||||
|
||||
URL(googletest) := https://github.com/google/googletest.git
|
||||
REV(googletest) := 10799abad25aa9ec7dcd08d9a46cad093f8bb074
|
||||
DIR(googletest) := src/lib/googletest
|
||||
|
||||
DIRS += include/gtest
|
||||
DIR_CONTENT(include/gtest) := src/lib/googletest/googletest/include/gtest/**
|
||||
|
||||
DIRS += include/gmock
|
||||
DIR_CONTENT(include/gmock) := src/lib/googletest/googlemock/include/gmock/**
|
||||
|
||||
PATCHES += src/lib/googletest/gtest-port.h.patch
|
||||
|
||||
# quick and dirty solution to enable colored console output
|
||||
PATCHES += src/lib/googletest/gtest.patch
|
||||
83
run/gmock.run
Normal file
83
run/gmock.run
Normal file
@@ -0,0 +1,83 @@
|
||||
#
|
||||
# Build
|
||||
#
|
||||
|
||||
set build_components {
|
||||
core init
|
||||
drivers/timer
|
||||
drivers/rtc
|
||||
server/ram_fs
|
||||
test/gmock
|
||||
}
|
||||
|
||||
build $build_components
|
||||
|
||||
create_boot_directory
|
||||
|
||||
#
|
||||
# Generate config
|
||||
#
|
||||
|
||||
install_config {
|
||||
<config verbose="yes">
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="CAP"/>
|
||||
<service name="RM"/>
|
||||
<service name="PD"/>
|
||||
<service name="CPU"/>
|
||||
<service name="LOG"/>
|
||||
<service name="SIGNAL"/>
|
||||
<service name="IO_PORT"/>
|
||||
</parent-provides>
|
||||
<default-route>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</default-route>
|
||||
<default caps="100"/>
|
||||
|
||||
<start name="timer">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides> <service name="Timer"/> </provides>
|
||||
</start>
|
||||
|
||||
<start name="rtc_drv">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides> <service name="Rtc"/> </provides>
|
||||
</start>
|
||||
|
||||
<start name="ram_fs">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides> <service name="File_system"/> </provides>
|
||||
<config> <policy label="gmock -> " root="/" writeable="yes" /> </config>
|
||||
</start>
|
||||
|
||||
<start name="gmock">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<config>
|
||||
<vfs>
|
||||
<dir name="dev"> <log/> <rtc/> </dir>
|
||||
<fs/>
|
||||
</vfs>
|
||||
<libc stdout="/dev/log" stderr="/dev/log" rtc="/dev/rtc"/>
|
||||
<arg value="gmock"/>
|
||||
<arg value="--gtest_filter=-*Death*:*.*WhenVerbosityIs*:ExpectCallTest.TakesDefaultAction*:AssertTest.FailsFatally*:LogTest.*:*.LogsAnything*:*MockTest.*:*IsMandatory:*.DoesNotWarnOnAdequateActionCount:*.WarnsOn*:*.Reports*:*FunctionCallMessageTest.*:GMockVerboseFlagTest.*"/>
|
||||
</config>
|
||||
</start>
|
||||
</config>}
|
||||
|
||||
#
|
||||
# Boot image
|
||||
#
|
||||
|
||||
build_boot_image {
|
||||
core init ld.lib.so
|
||||
timer ram_fs
|
||||
libc.lib.so libm.lib.so posix.lib.so stdcxx.lib.so
|
||||
rtc_drv
|
||||
gmock.lib.so
|
||||
gmock
|
||||
}
|
||||
|
||||
append qemu_args " -nographic "
|
||||
|
||||
run_genode_until {.*child "gmock" exited with exit value 0} 1000
|
||||
72
run/gtest-samples.run
Normal file
72
run/gtest-samples.run
Normal file
@@ -0,0 +1,72 @@
|
||||
#
|
||||
# Build
|
||||
#
|
||||
|
||||
set build_components {
|
||||
core init
|
||||
drivers/timer
|
||||
drivers/rtc
|
||||
test/gtest-samples
|
||||
}
|
||||
|
||||
build $build_components
|
||||
|
||||
create_boot_directory
|
||||
|
||||
#
|
||||
# Generate config
|
||||
#
|
||||
|
||||
install_config {
|
||||
<config verbose="yes">
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="CAP"/>
|
||||
<service name="RM"/>
|
||||
<service name="PD"/>
|
||||
<service name="CPU"/>
|
||||
<service name="LOG"/>
|
||||
<service name="SIGNAL"/>
|
||||
<service name="IO_PORT"/>
|
||||
</parent-provides>
|
||||
<default-route>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</default-route>
|
||||
<default caps="100"/>
|
||||
|
||||
<start name="timer">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides> <service name="Timer"/> </provides>
|
||||
</start>
|
||||
|
||||
<start name="rtc_drv">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides> <service name="Rtc"/> </provides>
|
||||
</start>
|
||||
|
||||
<start name="gtest-samples">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<config>
|
||||
<vfs>
|
||||
<dir name="dev"> <log/> <rtc/> </dir>
|
||||
</vfs>
|
||||
<libc stdout="/dev/log" stderr="/dev/log" rtc="/dev/rtc" />
|
||||
</config>
|
||||
</start>
|
||||
</config>}
|
||||
|
||||
#
|
||||
# Boot image
|
||||
#
|
||||
|
||||
build_boot_image {
|
||||
core init ld.lib.so
|
||||
timer
|
||||
libc.lib.so libm.lib.so posix.lib.so stdcxx.lib.so
|
||||
rtc_drv
|
||||
gtest-samples
|
||||
}
|
||||
|
||||
append qemu_args " -nographic "
|
||||
|
||||
run_genode_until {.*child "gtest-samples" exited with exit value 0} 1000
|
||||
80
run/gtest.run
Normal file
80
run/gtest.run
Normal file
@@ -0,0 +1,80 @@
|
||||
#
|
||||
# Build
|
||||
#
|
||||
|
||||
set build_components {
|
||||
core init
|
||||
drivers/timer
|
||||
drivers/rtc
|
||||
server/ram_fs
|
||||
test/gtest
|
||||
}
|
||||
|
||||
build $build_components
|
||||
|
||||
create_boot_directory
|
||||
|
||||
#
|
||||
# Generate config
|
||||
#
|
||||
|
||||
install_config {
|
||||
<config verbose="yes">
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="CAP"/>
|
||||
<service name="RM"/>
|
||||
<service name="PD"/>
|
||||
<service name="CPU"/>
|
||||
<service name="LOG"/>
|
||||
<service name="SIGNAL"/>
|
||||
<service name="IO_PORT"/>
|
||||
</parent-provides>
|
||||
<default-route>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</default-route>
|
||||
<default caps="100"/>
|
||||
|
||||
<start name="timer">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides> <service name="Timer"/> </provides>
|
||||
</start>
|
||||
|
||||
<start name="rtc_drv">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides> <service name="Rtc"/> </provides>
|
||||
</start>
|
||||
|
||||
<start name="ram_fs">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides> <service name="File_system"/> </provides>
|
||||
<config> <policy label="gtest -> " root="/" writeable="yes" /> </config>
|
||||
</start>
|
||||
|
||||
<start name="gtest">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<config>
|
||||
<vfs>
|
||||
<dir name="dev"> <log/> <rtc/> </dir>
|
||||
<fs/>
|
||||
</vfs>
|
||||
<libc stdout="/dev/log" stderr="/dev/log" rtc="/dev/rtc" />
|
||||
</config>
|
||||
</start>
|
||||
</config>}
|
||||
|
||||
#
|
||||
# Boot image
|
||||
#
|
||||
|
||||
build_boot_image {
|
||||
core init ld.lib.so
|
||||
timer ram_fs
|
||||
libc.lib.so libm.lib.so posix.lib.so stdcxx.lib.so
|
||||
rtc_drv
|
||||
gtest
|
||||
}
|
||||
|
||||
append qemu_args " -nographic "
|
||||
|
||||
run_genode_until {.*child "gtest" exited with exit value 0} 1000
|
||||
29
src/lib/googletest/gtest-port.h.patch
Normal file
29
src/lib/googletest/gtest-port.h.patch
Normal file
@@ -0,0 +1,29 @@
|
||||
diff --git src/lib/googletest/googletest/include/gtest/internal/gtest-port.h src/lib/googletest/googletest/include/gtest/internal/gtest-port.h
|
||||
index 0094ed5..41aa33e 100644
|
||||
--- src/lib/googletest/googletest/include/gtest/internal/gtest-port.h
|
||||
+++ src/lib/googletest/googletest/include/gtest/internal/gtest-port.h
|
||||
@@ -786,6 +786,7 @@ using ::std::tuple_size;
|
||||
// Google Test does not support death tests for VC 7.1 and earlier as
|
||||
// abort() in a VC 7.1 application compiled as GUI in debug config
|
||||
// pops up a dialog window that cannot be suppressed programmatically.
|
||||
+#ifndef GTEST_HAS_DEATH_TEST
|
||||
#if (GTEST_OS_LINUX || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \
|
||||
(GTEST_OS_MAC && !GTEST_OS_IOS) || \
|
||||
(GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || \
|
||||
@@ -793,6 +794,7 @@ using ::std::tuple_size;
|
||||
GTEST_OS_OPENBSD || GTEST_OS_QNX || GTEST_OS_FREEBSD)
|
||||
# define GTEST_HAS_DEATH_TEST 1
|
||||
#endif
|
||||
+#endif
|
||||
|
||||
// We don't support MSVC 7.1 with exceptions disabled now. Therefore
|
||||
// all the compilers we care about are adequate for supporting
|
||||
@@ -963,7 +963,7 @@
|
||||
|
||||
// _LIBCPP_VERSION is defined by the libc++ library from the LLVM project.
|
||||
#if defined(__GLIBCXX__) || defined(_LIBCPP_VERSION)
|
||||
-# define GTEST_HAS_CXXABI_H_ 1
|
||||
+# define GTEST_HAS_CXXABI_H_ 0
|
||||
#else
|
||||
# define GTEST_HAS_CXXABI_H_ 0
|
||||
#endif
|
||||
24
src/lib/googletest/gtest.patch
Normal file
24
src/lib/googletest/gtest.patch
Normal file
@@ -0,0 +1,24 @@
|
||||
+++ src/lib/googletest/googletest/src/gtest.cc
|
||||
@@ -2922,21 +2922,7 @@ bool ShouldUseColor(bool stdout_is_tty) {
|
||||
// console there does support colors.
|
||||
return stdout_is_tty;
|
||||
#else
|
||||
- // On non-Windows platforms, we rely on the TERM variable.
|
||||
- const char* const term = posix::GetEnv("TERM");
|
||||
- const bool term_supports_color =
|
||||
- String::CStringEquals(term, "xterm") ||
|
||||
- String::CStringEquals(term, "xterm-color") ||
|
||||
- String::CStringEquals(term, "xterm-256color") ||
|
||||
- String::CStringEquals(term, "screen") ||
|
||||
- String::CStringEquals(term, "screen-256color") ||
|
||||
- String::CStringEquals(term, "tmux") ||
|
||||
- String::CStringEquals(term, "tmux-256color") ||
|
||||
- String::CStringEquals(term, "rxvt-unicode") ||
|
||||
- String::CStringEquals(term, "rxvt-unicode-256color") ||
|
||||
- String::CStringEquals(term, "linux") ||
|
||||
- String::CStringEquals(term, "cygwin");
|
||||
- return stdout_is_tty && term_supports_color;
|
||||
+ return stdout_is_tty;
|
||||
#endif // GTEST_OS_WINDOWS
|
||||
}
|
||||
|
||||
21
src/test/gmock/main.cc
Normal file
21
src/test/gmock/main.cc
Normal file
@@ -0,0 +1,21 @@
|
||||
/* Genode includes */
|
||||
#include <libc/component.h>
|
||||
|
||||
/* libc includes */
|
||||
#include <stdlib.h> /* 'exit' */
|
||||
|
||||
/* provided by the application */
|
||||
extern "C" int main(int argc, char const **argv);
|
||||
|
||||
void Libc::Component::construct(Libc::Env &env)
|
||||
{
|
||||
Libc::with_libc([&] {
|
||||
int argc = 2;
|
||||
char const *argv[] = {
|
||||
"gmock",
|
||||
"--gtest_filter=-*Death*:*.*WhenVerbosityIs*:ExpectCallTest.TakesDefaultAction*:AssertTest.FailsFatally*:LogTest.*:*.LogsAnything*:*MockTest.*:*IsMandatory:*.DoesNotWarnOnAdequateActionCount:*.WarnsOn*:*.Reports*:*FunctionCallMessageTest.*:GMockVerboseFlagTest.*",
|
||||
0
|
||||
};
|
||||
exit(main(argc, argv));
|
||||
});
|
||||
}
|
||||
13
src/test/gmock/target.mk
Normal file
13
src/test/gmock/target.mk
Normal file
@@ -0,0 +1,13 @@
|
||||
TARGET = gmock
|
||||
|
||||
GMOCK_DIR := $(call select_from_ports,googletest)/src/lib/googletest/googlemock
|
||||
GTEST_DIR := $(call select_from_ports,googletest)/src/lib/googletest/googletest
|
||||
|
||||
SRC_CC = gmock_all_test.cc
|
||||
|
||||
vpath gmock_all_test.cc $(GMOCK_DIR)/test
|
||||
|
||||
INC_DIR += $(GMOCK_DIR) $(GTEST_DIR)
|
||||
CC_OPT += -DGTEST_HAS_PTHREAD=0
|
||||
|
||||
LIBS = posix stdcxx gtest gmock
|
||||
20
src/test/gtest-samples/main.cc
Normal file
20
src/test/gtest-samples/main.cc
Normal file
@@ -0,0 +1,20 @@
|
||||
/* Genode includes */
|
||||
#include <libc/component.h>
|
||||
|
||||
/* libc includes */
|
||||
#include <stdlib.h> /* 'exit' */
|
||||
|
||||
/* provided by the application */
|
||||
extern "C" int main(int argc, char const **argv);
|
||||
|
||||
void Libc::Component::construct(Libc::Env &env)
|
||||
{
|
||||
Libc::with_libc([&] {
|
||||
int argc = 1;
|
||||
char const *argv[] = {
|
||||
"gtest-samples",
|
||||
0
|
||||
};
|
||||
exit(main(argc, argv));
|
||||
});
|
||||
}
|
||||
13
src/test/gtest-samples/target.mk
Normal file
13
src/test/gtest-samples/target.mk
Normal file
@@ -0,0 +1,13 @@
|
||||
TARGET = gtest-samples
|
||||
|
||||
GTEST_DIR := $(call select_from_ports,googletest)/src/lib/googletest/googletest
|
||||
|
||||
SRC_CC = main.cc gtest_main.cc sample1.cc sample1_unittest.cc
|
||||
|
||||
vpath gtest_main.cc $(GTEST_DIR)/src
|
||||
vpath sample1.cc $(GTEST_DIR)/samples
|
||||
vpath sample1_unittest.cc $(GTEST_DIR)/samples
|
||||
|
||||
INC_DIR += $(GTEST_DIR)/samples
|
||||
|
||||
LIBS = posix stdcxx gtest
|
||||
21
src/test/gtest/main.cc
Normal file
21
src/test/gtest/main.cc
Normal file
@@ -0,0 +1,21 @@
|
||||
/* Genode includes */
|
||||
#include <libc/component.h>
|
||||
|
||||
/* libc includes */
|
||||
#include <stdlib.h> /* 'exit' */
|
||||
|
||||
/* provided by the application */
|
||||
extern "C" int main(int argc, char const **argv);
|
||||
|
||||
void Libc::Component::construct(Libc::Env &env)
|
||||
{
|
||||
Libc::with_libc([&] {
|
||||
int argc = 2;
|
||||
char const *argv[] = {
|
||||
"gtest",
|
||||
"--gtest_filter=-OutputFile*:Directory*Test.*:*Death*:InitGoogleTestTest.*:CaptureTest.*:RETest*:Thread*:Mutex*:EXPECT_PRED1Test.Function*:ColoredOutputTest.UsesColorsWhenTermSupportsColors",
|
||||
0
|
||||
};
|
||||
exit(main(argc, argv));
|
||||
});
|
||||
}
|
||||
12
src/test/gtest/target.mk
Normal file
12
src/test/gtest/target.mk
Normal file
@@ -0,0 +1,12 @@
|
||||
TARGET = gtest
|
||||
|
||||
GTEST_DIR := $(call select_from_ports,googletest)/src/lib/googletest/googletest
|
||||
|
||||
SRC_CC = main.cc gtest_main.cc gtest_all_test.cc
|
||||
|
||||
vpath gtest_main.cc $(GTEST_DIR)/src
|
||||
vpath gtest_all_test.cc $(GTEST_DIR)/test
|
||||
|
||||
INC_DIR += $(GTEST_DIR)
|
||||
|
||||
LIBS = posix stdcxx gtest
|
||||
Reference in New Issue
Block a user