Compare commits

..
15 changed files with 152 additions and 378 deletions
-9
View File
@@ -1,12 +1,3 @@
Changes for 1.2.1:
* Compatibility fixes for Linux IA-64 and IBM z/OS.
* Added support for using Boost and other TR1 implementations.
* Changes to the build scripts to support upcoming release of Google C++
Mocking Framework.
* Added Makefile to the distribution package.
* Improved build instructions in README.
Changes for 1.2.0: Changes for 1.2.0:
* New feature: value-parameterized tests. * New feature: value-parameterized tests.
-1
View File
@@ -9,7 +9,6 @@ EXTRA_DIST = \
include/gtest/gtest-param-test.h.pump \ include/gtest/gtest-param-test.h.pump \
include/gtest/internal/gtest-type-util.h.pump \ include/gtest/internal/gtest-type-util.h.pump \
include/gtest/internal/gtest-param-util-generated.h.pump \ include/gtest/internal/gtest-param-util-generated.h.pump \
make/Makefile \
scons/SConscript \ scons/SConscript \
scripts/gen_gtest_pred_impl.py \ scripts/gen_gtest_pred_impl.py \
src/gtest-all.cc src/gtest-all.cc
+47 -82
View File
@@ -68,33 +68,26 @@ much more active and have the latest features, but the latter provides much
more stability and predictability. Choose whichever fits your needs best, and more stability and predictability. Choose whichever fits your needs best, and
proceed with the following Subversion commands: proceed with the following Subversion commands:
svn checkout http://googletest.googlecode.com/svn/trunk/ gtest-svn $ svn checkout http://googletest.googlecode.com/svn/trunk/ gtest-svn
or for a release version X.Y.*'s branch: or for a release version X.Y.*'s branch:
svn checkout http://googletest.googlecode.com/svn/branches/release-X.Y/ \ $ svn checkout http://googletest.googlecode.com/svn/branches/release-X.Y/ gtest-X.Y-svn
gtest-X.Y-svn
Next you will need to prepare the GNU Autotools build system, if you Next you will need to prepare the GNU Autotools build system, if you
are using Linux, Mac OS X, or Cygwin. Enter the target directory of are using Linux, Mac OS X, or Cygwin. Enter the target directory of
the checkout command you used ('gtest-svn' or 'gtest-X.Y-svn' above) the checkout command you used ('gtest-svn' or 'gtest-X.Y-svn' above)
and proceed with the following command: and proceed with the following commands:
autoreconf -fvi $ aclocal-1.9 # Where "1.9" must match the following automake command.
$ libtoolize -c # Use "glibtoolize -c" instead on Mac OS X.
$ autoheader
$ automake-1.9 -ac # See Automake version requirements above.
$ autoconf
Once you have completed this step, you are ready to build the library. Note While this is a bit complicated, it will most often be automatically re-run by
that you should only need to complete this step once. The subsequent `make' your "make" invocations, so in practice you shouldn't need to worry too much.
invocations will automatically re-generate the bits of the build system that Once you have completed these steps, you are ready to build the library.
need to be changed.
If your system uses older versions of the autotools, the above command will
fail. You may need to explicitly specify a version to use. For instance, if you
have both GNU Automake 1.4 and 1.9 installed and `automake' would invoke the
1.4, use instead:
AUTOMAKE=automake-1.9 ACLOCAL=aclocal-1.9 autoreconf -fvi
Make sure you're using the same version of automake and aclocal.
### Source Package: ### ### Source Package: ###
Google Test is also released in source packages which can be downloaded from Google Test is also released in source packages which can be downloaded from
@@ -108,9 +101,9 @@ Once downloaded expand the archive using whichever tools you prefer for that
type. This will always result in a new directory with the name "gtest-X.Y.Z" type. This will always result in a new directory with the name "gtest-X.Y.Z"
which contains all of the source code. Here are some examples in Linux: which contains all of the source code. Here are some examples in Linux:
tar -xvzf gtest-X.Y.Z.tar.gz $ tar -xvzf gtest-X.Y.Z.tar.gz
tar -xvjf gtest-X.Y.Z.tar.bz2 $ tar -xvjf gtest-X.Y.Z.tar.bz2
unzip gtest-X.Y.Z.zip $ unzip gtest-X.Y.Z.zip
Building the Source Building the Source
------------------- -------------------
@@ -127,9 +120,9 @@ either approach by simply substituting the shell variable SRCDIR with "." for
building inside the source directory, and the relative path to the source building inside the source directory, and the relative path to the source
directory otherwise. directory otherwise.
${SRCDIR}/configure # Standard GNU configure script, --help for more info $ ${SRCDIR}/configure # Standard GNU configure script, --help for more info
make # Standard makefile following GNU conventions $ make # Standard makefile following GNU conventions
make check # Builds and runs all tests - all should pass $ make check # Builds and runs all tests - all should pass
Other programs will only be able to use Google Test's functionality if you Other programs will only be able to use Google Test's functionality if you
install it in a location which they can access, in Linux this is typically install it in a location which they can access, in Linux this is typically
@@ -137,31 +130,22 @@ under '/usr/local'. The following command will install all of the Google Test
libraries, public headers, and utilities necessary for other programs and libraries, public headers, and utilities necessary for other programs and
libraries to leverage it: libraries to leverage it:
sudo make install # Not necessary, but allows use by other programs $ sudo make install # Not necessary, but allows use by other programs
Should you need to remove Google Test from your system after having installed TODO(chandlerc@google.com): This section needs to be expanded when the
it, run the following command, and it will back out its changes. However, note 'gtest-config' script is finished and Autoconf macro's are provided (or not
carefully that you must run this command on the *same* Google Test build that provided) in order to properly reflect the process for other programs to
you ran the install from, or the results are not predictable. If you install locate, include, and link against Google Test.
Google Test on your system, and are working from a VCS checkout, make sure you
run this *before* updating your checkout of the source in order to uninstall
the same version which you installed.
sudo make uninstall # Must be run against the exact same build as "install" Finally, should you need to remove Google Test from your system after having
installed it, run the following command, and it will back out its changes.
However, note carefully that you must run this command on the *same* Google
Test build that you ran the install from, or the results are not predictable.
If you install Google Test on your system, and are working from a VCS checkout,
make sure you run this *before* updating your checkout of the source in order
to uninstall the same version which you installed.
Your project can build against Google Test simply by leveraging the $ sudo make uninstall # Must be run against the exact same build as "install"
'gtest-config' script. This script can be invoked directly out of the 'scripts'
subdirectory of the build tree, and it will be installed in the binary
directory specified during the 'configure'. Here are some examples of its use,
see 'gtest-config --help' for more detailed information.
gtest-config --min-version=1.0 || echo "Insufficient Google Test version."
g++ $(gtest-config --cppflags --cxxflags) -o foo.o -c foo.cpp
g++ $(gtest-config --ldflags --libs) -o foo foo.o
# When using a built but not installed Google Test:
g++ $(../../my_gtest_build/scripts/gtest-config ...) ...
### Windows ### ### Windows ###
Open the gtest.sln file in the msvc/ folder using Visual Studio, and Open the gtest.sln file in the msvc/ folder using Visual Studio, and
@@ -174,7 +158,7 @@ target. The universal binary framework will end up in your selected build
directory (selected in the Xcode "Preferences..." -> "Building" pane and directory (selected in the Xcode "Preferences..." -> "Building" pane and
defaults to xcode/build). Alternatively, at the command line, enter: defaults to xcode/build). Alternatively, at the command line, enter:
xcodebuild $ xcodebuild
This will build the "Release" configuration of the gtest.framework, but you can This will build the "Release" configuration of the gtest.framework, but you can
select the "Debug" configuration with a command line option. See the select the "Debug" configuration with a command line option. See the
@@ -186,32 +170,31 @@ if you see some errors. Xcode reports all test failures (even the intentional
ones) as errors. However, you should see a "Build succeeded" message at the end ones) as errors. However, you should see a "Build succeeded" message at the end
of the build log. To run all of the tests from the command line, enter: of the build log. To run all of the tests from the command line, enter:
xcodebuid -target Check $ xcodebuid -target Check
It is also possible to build and execute individual tests within Xcode. Each It is also possible to build and execute individual tests within Xcode. Each
test has its own Xcode "Target" and Xcode "Executable". To build any of the test has its own Xcode "Target" and Xcode "Executable". To build any of the
tests, change the active target and the active executable to the test of tests, change the active target and the active executable to the test of
interest and then build and run. interest and then build and run.
NOTE: Several tests use a Python script to run the test executable. These can be NOTE: Several tests use a Python script to run the test executable. They require
run from Xcode by creating a "Custom Executable". For example, to run the Python a separate custom "Xcode Executable" to run the Python script within Xcode.
script which executes the gtest_color_test, select the Project->New Custom These "Xcode Executables" are named with "run_" prepended to the test name.
Executable... menu item. When prompted, set the "Executable Name" to something Also, the gtest_xml_outfiles_test requres two executable tests to be built.
like "run_gtest_color_test" and set the "Executable Path" to the path of the These executables are built in separate targets with a trailing underscore in
gtest_color_test.py script. Finally, choose "Run" from the Run menu and check the name.
the Console for the results.
Individual tests can be built from the command line using: Individual tests can be built from the command line using:
xcodebuild -target <test_name> $ xcodebuild -target <test_name>
These tests can be executed from the command line by moving to the build These tests can be executed from the command line by moving to the build
directory and then (in bash) directory and then (in bash)
export DYLD_FRAMEWORK_PATH=`pwd` $ export DYLD_FRAMEWORK_PATH=`pwd`
./<test_name> # (if it is not a python test, e.g. ./gtest_unittest) $ ./<test_name> # (if it is not a python test, e.g. ./gtest_unittest)
# OR OR
./<test_name>.py # (if it is a python test, e.g. ./gtest_color_test.py) $ ./<test_name>.py # (if it is a python test, e.g. ./gtest_color_test.py)
To use the gtest.framework for your own tests, first, add the framework to Xcode To use the gtest.framework for your own tests, first, add the framework to Xcode
project. Next, create a new executable target and add the framework to the project. Next, create a new executable target and add the framework to the
@@ -225,34 +208,16 @@ in the "Variables to be set in the environment:" list, where you replace
when you run your executable, it will load the framework and your test will when you run your executable, it will load the framework and your test will
run as expected. run as expected.
### Using GNU Make ###
The make/ directory contains a Makefile that you can use to build
Google Test on systems where GNU make is available (e.g. Linux, Mac OS
X, and Cygwin). It doesn't try to build Google Test's own tests.
Instead, it just builds the Google Test library and a sample test.
You can use it as a starting point for your own Makefile.
If the default settings are correct for your environment, the
following commands should succeed:
cd ${SRCDIR}/make
make
./sample1_unittest
If you see errors, try to tweak the contents of make/Makefile to make
them go away. There are instructions in make/Makefile on how to do
it.
### Using Your Own Build System ### ### Using Your Own Build System ###
If none of the build solutions we provide works for you, or if you If none of the build solutions we provide works for you, or if you
prefer your own build system, you just need to compile prefer your own build system, you just need to compile
src/gtest-all.cc into a library and link your tests with it. Assuming src/gtest-all.cc into a library and link your tests with it. Assuming
a Linux-like system and gcc, something like the following will do: a Linux-like system and gcc, something like the following will do:
cd ${SRCDIR} $ cd ${SRCDIR}
g++ -I. -I./include -c src/gtest-all.cc $ g++ -I. -I./include -c src/gtest-all.cc
ar -rv libgtest.a gtest-all.o $ ar -rv libgtest.a gtest-all.o
g++ -I. -I./include path/to/your_test.cc libgtest.a -o your_test $ g++ -I. -I./include path/to/your_test.cc libgtest.a -o your_test
Regenerating Source Files Regenerating Source Files
------------------------- -------------------------
+4 -3
View File
@@ -3,15 +3,15 @@
# "[1.0.1]"). It also asumes that there won't be any closing parenthesis # "[1.0.1]"). It also asumes that there won't be any closing parenthesis
# between "AC_INIT(" and the closing ")" including comments and strings. # between "AC_INIT(" and the closing ")" including comments and strings.
AC_INIT([Google C++ Testing Framework], AC_INIT([Google C++ Testing Framework],
[1.2.1], [1.2.0],
[googletestframework@googlegroups.com], [googletestframework@googlegroups.com],
[gtest]) [gtest])
# Provide various options to initialize the Autoconf and configure processes. # Provide various options to initialize the Autoconf and configure processes.
AC_PREREQ([2.59]) AC_PREREQ([2.59])
AC_CONFIG_SRCDIR([./COPYING]) AC_CONFIG_SRCDIR([./COPYING])
AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_AUX_DIR([config_aux])
AC_CONFIG_HEADERS([build-aux/config.h]) AC_CONFIG_HEADERS([config_aux/config.h])
AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([scripts/gtest-config], [chmod +x scripts/gtest-config]) AC_CONFIG_FILES([scripts/gtest-config], [chmod +x scripts/gtest-config])
@@ -31,6 +31,7 @@ AC_PROG_LIBTOOL
# HAVE_PYTHON by requiring "python" to be in the PATH, and that interpreter's # HAVE_PYTHON by requiring "python" to be in the PATH, and that interpreter's
# version to be >= 2.3. This will allow the scripts to use a "/usr/bin/env" # version to be >= 2.3. This will allow the scripts to use a "/usr/bin/env"
# hashbang. # hashbang.
#AM_PATH_PYTHON([2.3],,[:])
PYTHON= # We *do not* allow the user to specify a python interpreter PYTHON= # We *do not* allow the user to specify a python interpreter
AC_PATH_PROG([PYTHON],[python],[:]) AC_PATH_PROG([PYTHON],[python],[:])
AS_IF([test "$PYTHON" != ":"], AS_IF([test "$PYTHON" != ":"],
+3
View File
@@ -156,6 +156,9 @@ INSTANTIATE_TEST_CASE_P(AnotherInstantiationName, FooTest, ValuesIn(pets));
#include <gtest/internal/gtest-internal.h> #include <gtest/internal/gtest-internal.h>
#include <gtest/internal/gtest-param-util.h> #include <gtest/internal/gtest-param-util.h>
#include <gtest/internal/gtest-param-util-generated.h> #include <gtest/internal/gtest-param-util-generated.h>
#ifdef GTEST_HAS_COMBINE
#include <tr1/tuple>
#endif // GTEST_HAS_COMBINE
namespace testing { namespace testing {
+3
View File
@@ -157,6 +157,9 @@ INSTANTIATE_TEST_CASE_P(AnotherInstantiationName, FooTest, ValuesIn(pets));
#include <gtest/internal/gtest-internal.h> #include <gtest/internal/gtest-internal.h>
#include <gtest/internal/gtest-param-util.h> #include <gtest/internal/gtest-param-util.h>
#include <gtest/internal/gtest-param-util-generated.h> #include <gtest/internal/gtest-param-util-generated.h>
#ifdef GTEST_HAS_COMBINE
#include <tr1/tuple>
#endif // GTEST_HAS_COMBINE
namespace testing { namespace testing {
@@ -48,6 +48,10 @@
#ifdef GTEST_HAS_PARAM_TEST #ifdef GTEST_HAS_PARAM_TEST
#ifdef GTEST_HAS_COMBINE
#include <tr1/tuple>
#endif // GTEST_HAS_COMBINE
#include <gtest/internal/gtest-param-util.h> #include <gtest/internal/gtest-param-util.h>
namespace testing { namespace testing {
@@ -49,6 +49,10 @@ $var maxtuple = 10 $$ Maximum number of Combine arguments we want to support.
#ifdef GTEST_HAS_PARAM_TEST #ifdef GTEST_HAS_PARAM_TEST
#ifdef GTEST_HAS_COMBINE
#include <tr1/tuple>
#endif // GTEST_HAS_COMBINE
#include <gtest/internal/gtest-param-util.h> #include <gtest/internal/gtest-param-util.h>
namespace testing { namespace testing {
+14 -46
View File
@@ -40,24 +40,22 @@
// control Google Test's behavior. If the user doesn't define a macro // control Google Test's behavior. If the user doesn't define a macro
// in this list, Google Test will define it. // in this list, Google Test will define it.
// //
// GTEST_HAS_CLONE - Define it to 1/0 to indicate that clone(2)
// is/isn't available.
// GTEST_HAS_GLOBAL_STRING - Define it to 1/0 to indicate that ::string
// is/isn't available (some systems define
// ::string, which is different to std::string).
// GTEST_HAS_GLOBAL_WSTRING - Define it to 1/0 to indicate that ::string
// is/isn't available (some systems define
// ::wstring, which is different to std::wstring).
// GTEST_HAS_PTHREAD - Define it to 1/0 to indicate that <pthread.h>
// is/isn't available.
// GTEST_HAS_RTTI - Define it to 1/0 to indicate that RTTI is/isn't
// enabled.
// GTEST_HAS_STD_STRING - Define it to 1/0 to indicate that // GTEST_HAS_STD_STRING - Define it to 1/0 to indicate that
// std::string does/doesn't work (Google Test can // std::string does/doesn't work (Google Test can
// be used where std::string is unavailable). // be used where std::string is unavailable).
// GTEST_HAS_GLOBAL_STRING - Define it to 1/0 to indicate that ::string
// is/isn't available (some systems define
// ::string, which is different to std::string).
// GTEST_HAS_STD_WSTRING - Define it to 1/0 to indicate that // GTEST_HAS_STD_WSTRING - Define it to 1/0 to indicate that
// std::wstring does/doesn't work (Google Test can // std::wstring does/doesn't work (Google Test can
// be used where std::wstring is unavailable). // be used where std::wstring is unavailable).
// GTEST_HAS_GLOBAL_WSTRING - Define it to 1/0 to indicate that ::string
// is/isn't available (some systems define
// ::wstring, which is different to std::wstring).
// GTEST_HAS_RTTI - Define it to 1/0 to indicate that RTTI is/isn't
// enabled.
// GTEST_HAS_PTHREAD - Define it to 1/0 to indicate that <pthread.h>
// is/isn't available.
// GTEST_HAS_TR1_TUPLE 1 - Define it to 1/0 to indicate tr1::tuple // GTEST_HAS_TR1_TUPLE 1 - Define it to 1/0 to indicate tr1::tuple
// is/isn't available. // is/isn't available.
@@ -301,10 +299,10 @@
#endif // GTEST_HAS_PTHREAD #endif // GTEST_HAS_PTHREAD
// Determines whether tr1/tuple is available. If you have tr1/tuple // Determines whether <tr1/tuple> is available. If you have <tr1/tuple>
// on your platform, define GTEST_HAS_TR1_TUPLE=1 for both the Google // on your platform, define GTEST_HAS_TR1_TUPLE=1 for both the Google
// Test project and your tests. If you would like Google Test to detect // Test project and your tests. If you would like Google Test to detect
// tr1/tuple on your platform automatically, please open an issue // <tr1/tuple> on your platform automatically, please open an issue
// ticket at http://code.google.com/p/googletest. // ticket at http://code.google.com/p/googletest.
#ifndef GTEST_HAS_TR1_TUPLE #ifndef GTEST_HAS_TR1_TUPLE
// The user didn't tell us, so we need to figure it out. // The user didn't tell us, so we need to figure it out.
@@ -317,38 +315,8 @@
#endif // __GNUC__ #endif // __GNUC__
#endif // GTEST_HAS_TR1_TUPLE #endif // GTEST_HAS_TR1_TUPLE
// To avoid conditional compilation everywhere, we make it
// gtest-port.h's responsibility to #include the header implementing
// tr1/tuple.
#if GTEST_HAS_TR1_TUPLE
#if defined(__GNUC__)
// GCC implements tr1/tuple in the <tr1/tuple> header. This does not
// conform to the TR1 spec, which requires the header to be <tuple>.
#include <tr1/tuple>
#else
// If the compiler is not GCC, we assume the user is using a
// spec-conforming TR1 implementation.
#include <tuple>
#endif // __GNUC__
#endif // GTEST_HAS_TR1_TUPLE
// Determines whether clone(2) is supported.
// Usually it will only be available on Linux, excluding
// Linux on the Itanium architecture.
// Also see http://linux.die.net/man/2/clone.
#ifndef GTEST_HAS_CLONE
// The user didn't tell us, so we need to figure it out.
#if defined(GTEST_OS_LINUX) && !defined(__ia64__)
#define GTEST_HAS_CLONE 1
#else
#define GTEST_HAS_CLONE 0
#endif // defined(GTEST_OS_LINUX) && !defined(__ia64__)
#endif // GTEST_HAS_CLONE
// Determines whether to support death tests. // Determines whether to support death tests.
#if GTEST_HAS_STD_STRING && GTEST_HAS_CLONE #if GTEST_HAS_STD_STRING && defined(GTEST_OS_LINUX)
#define GTEST_HAS_DEATH_TEST #define GTEST_HAS_DEATH_TEST
// On some platforms, <regex.h> needs someone to define size_t, and // On some platforms, <regex.h> needs someone to define size_t, and
// won't compile otherwise. We can #include it here as we already // won't compile otherwise. We can #include it here as we already
@@ -358,7 +326,7 @@
#include <vector> #include <vector>
#include <fcntl.h> #include <fcntl.h>
#include <sys/mman.h> #include <sys/mman.h>
#endif // GTEST_HAS_STD_STRING && GTEST_HAS_CLONE #endif // GTEST_HAS_STD_STRING && defined(GTEST_OS_LINUX)
// Determines whether to support value-parameterized tests. // Determines whether to support value-parameterized tests.
+25 -38
View File
@@ -12,10 +12,10 @@ AC_DEFUN([GTEST_LIB_CHECK],
dnl Provide a flag to enable or disable Google Test usage. dnl Provide a flag to enable or disable Google Test usage.
AC_ARG_ENABLE([gtest], AC_ARG_ENABLE([gtest],
[AS_HELP_STRING([--enable-gtest], [AS_HELP_STRING([--enable-gtest],
[Enable tests using the Google C++ Testing Framework. [Enable tests using the Google C++ Testing Framework.]
(Default is enabled.)])], [(Default is enabled.)])],
[], [],
[enable_gtest=]) [enable_gtest=check])
AC_ARG_VAR([GTEST_CONFIG], AC_ARG_VAR([GTEST_CONFIG],
[The exact path of Google Test's 'gtest-config' script.]) [The exact path of Google Test's 'gtest-config' script.])
AC_ARG_VAR([GTEST_CPPFLAGS], AC_ARG_VAR([GTEST_CPPFLAGS],
@@ -29,46 +29,33 @@ AC_ARG_VAR([GTEST_LIBS],
AC_ARG_VAR([GTEST_VERSION], AC_ARG_VAR([GTEST_VERSION],
[The version of Google Test available.]) [The version of Google Test available.])
HAVE_GTEST="no" HAVE_GTEST="no"
AS_IF([test "x${enable_gtest}" != "xno"], AS_IF([test "x$enable_gtest" != "xno"],
[AC_MSG_CHECKING([for 'gtest-config']) [AC_PATH_PROG([GTEST_CONFIG], [gtest-config])
AS_IF([test "x${enable_gtest}" != "xyes"], AS_IF([test -x "$GTEST_CONFIG"],
[AS_IF([test -x "${enable_gtest}/scripts/gtest-config"], [AS_IF([test "x$1" != "x"],
[GTEST_CONFIG="${enable_gtest}/scripts/gtest-config"], [_min_version="--min-version=$1"
[GTEST_CONFIG="${enable_gtest}/bin/gtest-config"])
AS_IF([test -x "${GTEST_CONFIG}"], [],
[AC_MSG_RESULT([no])
AC_MSG_ERROR([dnl
Unable to locate either a built or installed Google Test.
The specific location '${enable_gtest}' was provided for a built or installed
Google Test, but no 'gtest-config' script could be found at this location.])
])],
[AC_PATH_PROG([GTEST_CONFIG], [gtest-config])])
AS_IF([test -x "${GTEST_CONFIG}"],
[AC_MSG_RESULT([${GTEST_CONFIG}])
m4_ifval([$1],
[_gtest_min_version="--min-version=$1"
AC_MSG_CHECKING([for Google Test at least version >= $1])], AC_MSG_CHECKING([for Google Test at least version >= $1])],
[_gtest_min_version="--min-version=0" [_min_version="--min-version=0"
AC_MSG_CHECKING([for Google Test])]) AC_MSG_CHECKING([for Google Test])])
AS_IF([${GTEST_CONFIG} ${_gtest_min_version}], AS_IF([$GTEST_CONFIG $_min_version],
[AC_MSG_RESULT([yes]) [AC_MSG_RESULT([yes])
HAVE_GTEST='yes'], HAVE_GTEST="yes"],
[AC_MSG_RESULT([no])])], [AC_MSG_RESULT([no])])])
[AC_MSG_RESULT([no])]) AS_IF([test "x$HAVE_GTEST" = "xyes"],
AS_IF([test "x${HAVE_GTEST}" = "xyes"], [GTEST_CPPFLAGS=$($GTEST_CONFIG --cppflags)
[GTEST_CPPFLAGS=`${GTEST_CONFIG} --cppflags` GTEST_CXXFLAGS=$($GTEST_CONFIG --cxxflags)
GTEST_CXXFLAGS=`${GTEST_CONFIG} --cxxflags` GTEST_LDFLAGS=$($GTEST_CONFIG --ldflags)
GTEST_LDFLAGS=`${GTEST_CONFIG} --ldflags` GTEST_LIBS=$($GTEST_CONFIG --libs)
GTEST_LIBS=`${GTEST_CONFIG} --libs` GTEST_VERSION=$($GTEST_CONFIG --version)
GTEST_VERSION=`${GTEST_CONFIG} --version`
AC_DEFINE([HAVE_GTEST],[1],[Defined when Google Test is available.])], AC_DEFINE([HAVE_GTEST],[1],[Defined when Google Test is available.])],
[AS_IF([test "x${enable_gtest}" = "xyes"], [AS_IF([test "x$enable_gtest" = "xyes"],
[AC_MSG_ERROR([dnl [AC_MSG_ERROR([
Google Test was enabled, but no viable version could be found.]) The Google C++ Testing Framework was explicitly enabled, but a viable version
])])]) could not be found on the system.
])])])])
AC_SUBST([HAVE_GTEST]) AC_SUBST([HAVE_GTEST])
AM_CONDITIONAL([HAVE_GTEST],[test "x$HAVE_GTEST" = "xyes"]) AM_CONDITIONAL([HAVE_GTEST],[test "x$HAVE_GTEST" = "xyes"])
AS_IF([test "x$HAVE_GTEST" = "xyes"], AS_IF([test "x$HAVE_GTEST" = "xyes"],
[m4_ifval([$2], [$2])], [AS_IF([test "x$2" != "x"],[$2],[:])],
[m4_ifval([$3], [$3])]) [AS_IF([test "x$3" != "x"],[$3],[:])])
]) ])
-78
View File
@@ -1,78 +0,0 @@
# A sample Makefile for building Google Test and using it in user
# tests. Please tweak it to suit your environment and project. You
# may want to move it to your project's root directory.
#
# SYNOPSIS:
#
# make [all] - makes everything.
# make TARGET - makes the given target.
# make clean - removes all files generated by make.
# Please tweak the following variable definitions as needed by your
# project, except GTEST_HEADERS, which you can use in your own targets
# but shouldn't modify.
# Points to the root of Google Test, relative to where this file is.
# Remember to tweak this if you move this file.
GTEST_DIR = ..
# Where to find user code.
USER_DIR = ../samples
# Flags passed to the preprocessor.
CPPFLAGS += -I$(GTEST_DIR) -I$(GTEST_DIR)/include
# Flags passed to the C++ compiler.
CXXFLAGS += -g
# All tests produced by this Makefile. Remember to add new tests you
# created to the list.
TESTS = sample1_unittest
# All Google Test headers. Usually you shouldn't change this
# definition.
GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \
$(GTEST_DIR)/include/gtest/internal/*.h
# House-keeping build targets.
all : $(TESTS)
clean :
rm -f $(TESTS) gtest.a gtest_main.a *.o
# Builds gtest.a and gtest_main.a.
# Usually you shouldn't tweak such internal variables, indicated by a
# trailing _.
GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS)
# For simplicity and to avoid depending on Google Test's
# implementation details, the dependencies specified below are
# conservative and not optimized. This is fine as Google Test
# compiles fast and for ordinary users its source rarely changes.
gtest-all.o : $(GTEST_SRCS_)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(GTEST_DIR)/src/gtest-all.cc
gtest_main.o : $(GTEST_SRCS_)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(GTEST_DIR)/src/gtest_main.cc
gtest.a : gtest-all.o
$(AR) $(ARFLAGS) $@ $^
gtest_main.a : gtest-all.o gtest_main.o
$(AR) $(ARFLAGS) $@ $^
# Builds a sample test. A test should link with either gtest.a or
# gtest_main.a, depending on whether it defines its own main()
# function.
sample1.o : $(USER_DIR)/sample1.cc $(USER_DIR)/sample1.h $(GTEST_HEADERS)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/sample1.cc
sample1_unittest.o : $(USER_DIR)/sample1_unittest.cc \
$(USER_DIR)/sample1.h $(GTEST_HEADERS)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/sample1_unittest.cc
sample1_unittest : sample1.o sample1_unittest.o gtest_main.a
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -o $@
+43 -118
View File
@@ -1,61 +1,56 @@
#!/bin/sh #!/bin/sh
# These variables are automatically filled in by the configure script. # These variables are automatically filled in by the configure script.
prefix="@prefix@"
exec_prefix="@exec_prefix@"
libdir="@libdir@"
includedir="@includedir@"
name="@PACKAGE_TARNAME@" name="@PACKAGE_TARNAME@"
version="@PACKAGE_VERSION@" version="@PACKAGE_VERSION@"
gtest_ldflags="-L${libdir}"
gtest_libs="-l${name}"
gtest_cppflags="-I${includedir}"
gtest_cxxflags=""
show_usage() show_usage()
{ {
echo "Usage: gtest-config [OPTIONS...]" cat <<EOF
Usage: gtest-config [OPTIONS...]
EOF
} }
show_help() show_help()
{ {
show_usage show_usage
cat <<\EOF cat <<EOF
The `gtest-config' script provides access to the necessary compile and linking The \`gtest-config' script provides access to the necessary compile and linking
flags to connect with Google C++ Testing Framework, both in a build prior to flags to connect with Google C++ Testing framework. The installation queries
installation, and on the system proper after installation. The installation may only be issued one at a time, and may not be issued with any other types of
overrides may be issued in combination with any other queries, but will only queries. The version queries and compiler flag queries may be combined as
affect installation queries if called on a built but not installed gtest. The desired but not mixed. Different version queries are always combined with "and"
installation queries may not be issued with any other types of queries, and logical semantics, and only the last of any particular query is used and all
only one installation query may be made at a time. The version queries and previous ones ignored. All versions must be specified as a sequence of numbers
compiler flag queries may be combined as desired but not mixed. Different separated by periods. Compiler flag queries output the union of the sets of
version queries are always combined with logical "and" semantics, and only the flags when combined.
last of any particular query is used while all previous ones ignored. All
versions must be specified as a sequence of numbers separated by periods.
Compiler flag queries output the union of the sets of flags when combined.
Examples: Examples:
gtest-config --min-version=1.0 || echo "Insufficient Google Test version." gtest-config --min-version=1.0 || echo "Insufficient Google Test version."
g++ $(gtest-config --cppflags --cxxflags) -o foo.o -c foo.cpp gcc \$(gtest-config --cppflags --cxxflags) -o foo.o -c foo.cpp
g++ $(gtest-config --ldflags --libs) -o foo foo.o gcc \$(gtest-config --ldflags --libs) -o foo foo.o
# When using a built but not installed Google Test:
g++ $(../../my_gtest_build/scripts/gtest-config ...) ...
# When using an installed Google Test, but with installation overrides:
export GTEST_PREFIX="/opt"
g++ $(gtest-config --libdir="/opt/lib64" ...) ...
Help: Help:
--usage brief usage information --usage brief usage information
--help display this help message --help display this help message
Installation Overrides:
--prefix=<dir> overrides the installation prefix
--exec-prefix=<dir> overrides the executable installation prefix
--libdir=<dir> overrides the library installation prefix
--includedir=<dir> overrides the header file installation prefix
Installation Queries: Installation Queries:
--prefix installation prefix --prefix installation prefix
--exec-prefix executable installation prefix --exec-prefix executable installation prefix
--libdir library installation directory --libdir library installation directory
--includedir header file installation directory --includedir header file installation directory
--version the version of the Google Test installation --version the version of the INC installation
Version Queries: Version Queries:
--min-version=VERSION return 0 if the version is at least VERSION --min-version=VERSION return 0 if the version is at least VERSION
@@ -73,13 +68,11 @@ EOF
# This function bounds our version with a min and a max. It uses some clever # This function bounds our version with a min and a max. It uses some clever
# POSIX-compliant variable expansion to portably do all the work in the shell # POSIX-compliant variable expansion to portably do all the work in the shell
# and avoid any dependency on a particular "sed" or "awk" implementation. # and avoid any dependency on a particular "sed" implementation. Notable is
# Notable is that it will only ever compare the first 3 components of versions. # that it will only ever compare the first 3 components of versions. Further
# Further components will be cleanly stripped off. All versions must be # components will be cleanly stripped off. All versions must be unadorned, so
# unadorned, so "v1.0" will *not* work. The minimum version must be in $1, and # "v1.0" will *not* work. The minimum version must be in $1, and the max in
# the max in $2. TODO(chandlerc@google.com): If this ever breaks, we should # $2.
# investigate expanding this via autom4te from AS_VERSION_COMPARE rather than
# continuing to maintain our own shell version.
check_versions() check_versions()
{ {
major_version=${version%%.*} major_version=${version%%.*}
@@ -147,25 +140,13 @@ fi
while test $# -gt 0; do while test $# -gt 0; do
case $1 in case $1 in
--usage) show_usage; exit 0;; --usage) show_usage; exit 0;;
--help) show_help; exit 0;; --help) show_help; exit 0;;
--prefix) echo $prefix; exit 0;;
# Installation overrides --exec-prefix) echo $exec_prefix; exit 0;;
--prefix=*) GTEST_PREFIX=${1#--prefix=};; --libdir) echo $libdir; exit 0;;
--exec-prefix=*) GTEST_EXEC_PREFIX=${1#--exec-prefix=};; --includedir) echo $includedir; exit 0;;
--libdir=*) GTEST_LIBDIR=${1#--libdir=};; --version) echo $version; exit 0;;
--includedir=*) GTEST_INCLUDEDIR=${1#--includedir=};;
# Installation queries
--prefix|--exec-prefix|--libdir|--includedir|--version)
if test -n "${do_query}"; then
show_usage
exit 1
fi
do_query=${1#--}
;;
# Version checking
--min-version=*) --min-version=*)
do_check_versions=yes do_check_versions=yes
min_version=${1#--min-version=} min_version=${1#--min-version=}
@@ -178,73 +159,17 @@ while test $# -gt 0; do
do_check_versions=yes do_check_versions=yes
exact_version=${1#--exact-version=} exact_version=${1#--exact-version=}
;; ;;
--cppflags) echo_cppflags=yes;;
# Compiler flag output --cxxflags) echo_cxxflags=yes;;
--cppflags) echo_cppflags=yes;; --ldflags) echo_ldflags=yes;;
--cxxflags) echo_cxxflags=yes;; --libs) echo_libs=yes;;
--ldflags) echo_ldflags=yes;;
--libs) echo_libs=yes;;
# Everything else is an error # Everything else is an error
*) show_usage; exit 1;; *) show_usage; exit 1;;
esac esac
shift shift
done done
# These have defaults filled in by the configure script but can also be
# overridden by environment variables or command line parameters.
prefix="${GTEST_PREFIX:-@prefix@}"
exec_prefix="${GTEST_EXEC_PREFIX:-@exec_prefix@}"
libdir="${GTEST_LIBDIR:-@libdir@}"
includedir="${GTEST_INCLUDEDIR:-@includedir@}"
# We try and detect if our binary is not located at its installed location. If
# it's not, we provide variables pointing to the source and build tree rather
# than to the install tree. This allows building against a just-built gtest
# rather than an installed gtest.
bindir="@bindir@"
this_relative_bindir=`dirname $0`
this_bindir=`cd ${this_relative_bindir}; pwd -P`
if test "${this_bindir}" = "${this_bindir%${bindir}}"; then
# The path to the script doesn't end in the bindir sequence from Autoconf,
# assume that we are in a build tree.
build_dir=`dirname ${this_bindir}`
src_dir=`cd ${this_bindir}/@top_srcdir@; pwd -P`
# TODO(chandlerc@google.com): This is a dangerous dependency on libtool, we
# should work to remove it, and/or remove libtool altogether, replacing it
# with direct references to the library and a link path.
gtest_libs="${build_dir}/lib/libgtest.la"
gtest_ldflags=""
# We provide hooks to include from either the source or build dir, where the
# build dir is always preferred. This will potentially allow us to write
# build rules for generated headers and have them automatically be preferred
# over provided versions.
gtest_cppflags="-I${build_dir}/include -I${src_dir}/include"
gtest_cxxflags=""
else
# We're using an installed gtest, although it may be staged under some
# prefix. Assume (as our own libraries do) that we can resolve the prefix,
# and are present in the dynamic link paths.
gtest_ldflags="-L${libdir}"
gtest_libs="-l${name}"
gtest_cppflags="-I${includedir}"
gtest_cxxflags=""
fi
# Do an installation query if requested.
if test -n "$do_query"; then
case $do_query in
prefix) echo $prefix; exit 0;;
exec-prefix) echo $exec_prefix; exit 0;;
libdir) echo $libdir; exit 0;;
includedir) echo $includedir; exit 0;;
version) echo $version; exit 0;;
*) show_usage; exit 1;;
esac
fi
# Do a version check if requested. # Do a version check if requested.
if test "$do_check_versions" = "yes"; then if test "$do_check_versions" = "yes"; then
# Make sure we didn't receive a bad combination of parameters. # Make sure we didn't receive a bad combination of parameters.
+1 -3
View File
@@ -61,13 +61,11 @@
#include <vector> #include <vector>
#elif defined(GTEST_OS_SYMBIAN) #elif defined(GTEST_OS_SYMBIAN)
// No autoconf on Symbian
#define GTEST_HAS_GETTIMEOFDAY #define GTEST_HAS_GETTIMEOFDAY
#include <sys/time.h> // NOLINT #include <sys/time.h> // NOLINT
#elif defined(GTEST_OS_ZOS) #elif defined(GTEST_OS_ZOS)
#define GTEST_HAS_GETTIMEOFDAY
#include <sys/time.h> // NOLINT
// On z/OS we additionally need strings.h for strcasecmp. // On z/OS we additionally need strings.h for strcasecmp.
#include <strings.h> #include <strings.h>
+4
View File
@@ -42,6 +42,10 @@
#include <list> #include <list>
#include <vector> #include <vector>
#ifdef GTEST_HAS_COMBINE
#include <tr1/tuple>
#endif // GTEST_HAS_COMBINE
// To include gtest-internal-inl.h. // To include gtest-internal-inl.h.
#define GTEST_IMPLEMENTATION #define GTEST_IMPLEMENTATION
#include "src/gtest-internal-inl.h" // for UnitTestOptions #include "src/gtest-internal-inl.h" // for UnitTestOptions