summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925>2008-12-11 05:58:57 +0000
committervladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925>2008-12-11 05:58:57 +0000
commit2c12230cc743179bad5ea49dcf0a63f8a85261fb (patch)
treebf3c0bcf9b9c7e9b182dded581cbba049265c4f9
parent129ee1bc94d0596005d9f3b6759a9a288ca36974 (diff)
downloadgoogletest-2c12230cc743179bad5ea49dcf0a63f8a85261fb.tar.gz
Merged revisions 146-159 from trunk for release 1.2.1
git-svn-id: http://googletest.googlecode.com/svn/branches/release-1.2@160 861a406c-534a-0410-8894-cb66d6ee9925
-rw-r--r--Makefile.am1
-rw-r--r--README129
-rw-r--r--build-aux/.keep (renamed from config_aux/.keep)0
-rw-r--r--configure.ac7
-rw-r--r--include/gtest/gtest-param-test.h3
-rw-r--r--include/gtest/gtest-param-test.h.pump3
-rw-r--r--include/gtest/internal/gtest-param-util-generated.h4
-rw-r--r--include/gtest/internal/gtest-param-util-generated.h.pump4
-rw-r--r--include/gtest/internal/gtest-port.h56
-rw-r--r--m4/gtest.m463
-rw-r--r--make/Makefile78
-rwxr-xr-xscripts/gtest-config.in163
-rw-r--r--src/gtest.cc4
-rw-r--r--test/gtest-param-test_test.cc4
14 files changed, 368 insertions, 151 deletions
diff --git a/Makefile.am b/Makefile.am
index 67c853e..4b0c935 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -9,6 +9,7 @@ EXTRA_DIST = \
include/gtest/gtest-param-test.h.pump \
include/gtest/internal/gtest-type-util.h.pump \
include/gtest/internal/gtest-param-util-generated.h.pump \
+ make/Makefile \
scons/SConscript \
scripts/gen_gtest_pred_impl.py \
src/gtest-all.cc
diff --git a/README b/README
index e34a026..4b3546f 100644
--- a/README
+++ b/README
@@ -68,26 +68,33 @@ much more active and have the latest features, but the latter provides much
more stability and predictability. Choose whichever fits your needs best, and
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:
- $ svn checkout http://googletest.googlecode.com/svn/branches/release-X.Y/ gtest-X.Y-svn
+ svn checkout http://googletest.googlecode.com/svn/branches/release-X.Y/ \
+ gtest-X.Y-svn
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
the checkout command you used ('gtest-svn' or 'gtest-X.Y-svn' above)
-and proceed with the following commands:
+and proceed with the following command:
- $ 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
+ autoreconf -fvi
-While this is a bit complicated, it will most often be automatically re-run by
-your "make" invocations, so in practice you shouldn't need to worry too much.
-Once you have completed these steps, you are ready to build the library.
+Once you have completed this step, you are ready to build the library. Note
+that you should only need to complete this step once. The subsequent `make'
+invocations will automatically re-generate the bits of the build system that
+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: ###
Google Test is also released in source packages which can be downloaded from
@@ -101,9 +108,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"
which contains all of the source code. Here are some examples in Linux:
- $ tar -xvzf gtest-X.Y.Z.tar.gz
- $ tar -xvjf gtest-X.Y.Z.tar.bz2
- $ unzip gtest-X.Y.Z.zip
+ tar -xvzf gtest-X.Y.Z.tar.gz
+ tar -xvjf gtest-X.Y.Z.tar.bz2
+ unzip gtest-X.Y.Z.zip
Building the Source
-------------------
@@ -120,9 +127,9 @@ either approach by simply substituting the shell variable SRCDIR with "." for
building inside the source directory, and the relative path to the source
directory otherwise.
- $ ${SRCDIR}/configure # Standard GNU configure script, --help for more info
- $ make # Standard makefile following GNU conventions
- $ make check # Builds and runs all tests - all should pass
+ ${SRCDIR}/configure # Standard GNU configure script, --help for more info
+ make # Standard makefile following GNU conventions
+ make check # Builds and runs all tests - all should pass
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
@@ -130,22 +137,31 @@ under '/usr/local'. The following command will install all of the Google Test
libraries, public headers, and utilities necessary for other programs and
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
+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.
+
+ sudo make uninstall # Must be run against the exact same build as "install"
-TODO(chandlerc@google.com): This section needs to be expanded when the
-'gtest-config' script is finished and Autoconf macro's are provided (or not
-provided) in order to properly reflect the process for other programs to
-locate, include, and link against Google Test.
+Your project can build against Google Test simply by leveraging the
+'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.
-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.
+ gtest-config --min-version=1.0 || echo "Insufficient Google Test version."
- $ sudo make uninstall # Must be run against the exact same build as "install"
+ 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 ###
Open the gtest.sln file in the msvc/ folder using Visual Studio, and
@@ -158,7 +174,7 @@ target. The universal binary framework will end up in your selected build
directory (selected in the Xcode "Preferences..." -> "Building" pane and
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
select the "Debug" configuration with a command line option. See the
@@ -170,31 +186,32 @@ 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
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
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
interest and then build and run.
-NOTE: Several tests use a Python script to run the test executable. They require
-a separate custom "Xcode Executable" to run the Python script within Xcode.
-These "Xcode Executables" are named with "run_" prepended to the test name.
-Also, the gtest_xml_outfiles_test requres two executable tests to be built.
-These executables are built in separate targets with a trailing underscore in
-the name.
+NOTE: Several tests use a Python script to run the test executable. These can be
+run from Xcode by creating a "Custom Executable". For example, to run the Python
+script which executes the gtest_color_test, select the Project->New Custom
+Executable... menu item. When prompted, set the "Executable Name" to something
+like "run_gtest_color_test" and set the "Executable Path" to the path of the
+gtest_color_test.py script. Finally, choose "Run" from the Run menu and check
+the Console for the results.
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
directory and then (in bash)
- $ export DYLD_FRAMEWORK_PATH=`pwd`
- $ ./<test_name> # (if it is not a python test, e.g. ./gtest_unittest)
- OR
- $ ./<test_name>.py # (if it is a python test, e.g. ./gtest_color_test.py)
+ export DYLD_FRAMEWORK_PATH=`pwd`
+ ./<test_name> # (if it is not a python test, e.g. ./gtest_unittest)
+ # OR
+ ./<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
project. Next, create a new executable target and add the framework to the
@@ -208,16 +225,34 @@ 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
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 ###
If none of the build solutions we provide works for you, or if you
prefer your own build system, you just need to compile
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:
- $ cd ${SRCDIR}
- $ g++ -I. -I./include -c src/gtest-all.cc
- $ ar -rv libgtest.a gtest-all.o
- $ g++ -I. -I./include path/to/your_test.cc libgtest.a -o your_test
+ cd ${SRCDIR}
+ g++ -I. -I./include -c src/gtest-all.cc
+ ar -rv libgtest.a gtest-all.o
+ g++ -I. -I./include path/to/your_test.cc libgtest.a -o your_test
Regenerating Source Files
-------------------------
diff --git a/config_aux/.keep b/build-aux/.keep
index e69de29..e69de29 100644
--- a/config_aux/.keep
+++ b/build-aux/.keep
diff --git a/configure.ac b/configure.ac
index bb21a60..52d7dbd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,15 +3,15 @@
# "[1.0.1]"). It also asumes that there won't be any closing parenthesis
# between "AC_INIT(" and the closing ")" including comments and strings.
AC_INIT([Google C++ Testing Framework],
- [1.2.0],
+ [1.2.1],
[googletestframework@googlegroups.com],
[gtest])
# Provide various options to initialize the Autoconf and configure processes.
AC_PREREQ([2.59])
AC_CONFIG_SRCDIR([./COPYING])
-AC_CONFIG_AUX_DIR([config_aux])
-AC_CONFIG_HEADERS([config_aux/config.h])
+AC_CONFIG_AUX_DIR([build-aux])
+AC_CONFIG_HEADERS([build-aux/config.h])
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([scripts/gtest-config], [chmod +x scripts/gtest-config])
@@ -31,7 +31,6 @@ AC_PROG_LIBTOOL
# 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"
# hashbang.
-#AM_PATH_PYTHON([2.3],,[:])
PYTHON= # We *do not* allow the user to specify a python interpreter
AC_PATH_PROG([PYTHON],[python],[:])
AS_IF([test "$PYTHON" != ":"],
diff --git a/include/gtest/gtest-param-test.h b/include/gtest/gtest-param-test.h
index 2f19c3b..2d63237 100644
--- a/include/gtest/gtest-param-test.h
+++ b/include/gtest/gtest-param-test.h
@@ -156,9 +156,6 @@ INSTANTIATE_TEST_CASE_P(AnotherInstantiationName, FooTest, ValuesIn(pets));
#include <gtest/internal/gtest-internal.h>
#include <gtest/internal/gtest-param-util.h>
#include <gtest/internal/gtest-param-util-generated.h>
-#ifdef GTEST_HAS_COMBINE
-#include <tr1/tuple>
-#endif // GTEST_HAS_COMBINE
namespace testing {
diff --git a/include/gtest/gtest-param-test.h.pump b/include/gtest/gtest-param-test.h.pump
index 0c9c3ba..858e917 100644
--- a/include/gtest/gtest-param-test.h.pump
+++ b/include/gtest/gtest-param-test.h.pump
@@ -157,9 +157,6 @@ INSTANTIATE_TEST_CASE_P(AnotherInstantiationName, FooTest, ValuesIn(pets));
#include <gtest/internal/gtest-internal.h>
#include <gtest/internal/gtest-param-util.h>
#include <gtest/internal/gtest-param-util-generated.h>
-#ifdef GTEST_HAS_COMBINE
-#include <tr1/tuple>
-#endif // GTEST_HAS_COMBINE
namespace testing {
diff --git a/include/gtest/internal/gtest-param-util-generated.h b/include/gtest/internal/gtest-param-util-generated.h
index b709517..17f3f7b 100644
--- a/include/gtest/internal/gtest-param-util-generated.h
+++ b/include/gtest/internal/gtest-param-util-generated.h
@@ -48,10 +48,6 @@
#ifdef GTEST_HAS_PARAM_TEST
-#ifdef GTEST_HAS_COMBINE
-#include <tr1/tuple>
-#endif // GTEST_HAS_COMBINE
-
#include <gtest/internal/gtest-param-util.h>
namespace testing {
diff --git a/include/gtest/internal/gtest-param-util-generated.h.pump b/include/gtest/internal/gtest-param-util-generated.h.pump
index 922311c..fe32a8e 100644
--- a/include/gtest/internal/gtest-param-util-generated.h.pump
+++ b/include/gtest/internal/gtest-param-util-generated.h.pump
@@ -49,10 +49,6 @@ $var maxtuple = 10 $$ Maximum number of Combine arguments we want to support.
#ifdef GTEST_HAS_PARAM_TEST
-#ifdef GTEST_HAS_COMBINE
-#include <tr1/tuple>
-#endif // GTEST_HAS_COMBINE
-
#include <gtest/internal/gtest-param-util.h>
namespace testing {
diff --git a/include/gtest/internal/gtest-port.h b/include/gtest/internal/gtest-port.h
index 2c1d17e..6a1593e 100644
--- a/include/gtest/internal/gtest-port.h
+++ b/include/gtest/internal/gtest-port.h
@@ -40,22 +40,24 @@
// control Google Test's behavior. If the user doesn't define a macro
// in this list, Google Test will define it.
//
-// GTEST_HAS_STD_STRING - Define it to 1/0 to indicate that
-// std::string does/doesn't work (Google Test can
-// be used where std::string is unavailable).
+// 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_STD_WSTRING - Define it to 1/0 to indicate that
-// std::wstring does/doesn't work (Google Test can
-// 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_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
+// std::string does/doesn't work (Google Test can
+// be used where std::string is unavailable).
+// GTEST_HAS_STD_WSTRING - Define it to 1/0 to indicate that
+// std::wstring does/doesn't work (Google Test can
+// be used where std::wstring is unavailable).
// GTEST_HAS_TR1_TUPLE 1 - Define it to 1/0 to indicate tr1::tuple
// is/isn't available.
@@ -299,10 +301,10 @@
#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
// 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.
#ifndef GTEST_HAS_TR1_TUPLE
// The user didn't tell us, so we need to figure it out.
@@ -315,8 +317,38 @@
#endif // __GNUC__
#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.
-#if GTEST_HAS_STD_STRING && defined(GTEST_OS_LINUX)
+#if GTEST_HAS_STD_STRING && GTEST_HAS_CLONE
#define GTEST_HAS_DEATH_TEST
// On some platforms, <regex.h> needs someone to define size_t, and
// won't compile otherwise. We can #include it here as we already
@@ -326,7 +358,7 @@
#include <vector>
#include <fcntl.h>
#include <sys/mman.h>
-#endif // GTEST_HAS_STD_STRING && defined(GTEST_OS_LINUX)
+#endif // GTEST_HAS_STD_STRING && GTEST_HAS_CLONE
// Determines whether to support value-parameterized tests.
diff --git a/m4/gtest.m4 b/m4/gtest.m4
index ebb488a..6598ba7 100644
--- a/m4/gtest.m4
+++ b/m4/gtest.m4
@@ -12,10 +12,10 @@ AC_DEFUN([GTEST_LIB_CHECK],
dnl Provide a flag to enable or disable Google Test usage.
AC_ARG_ENABLE([gtest],
[AS_HELP_STRING([--enable-gtest],
- [Enable tests using the Google C++ Testing Framework.]
- [(Default is enabled.)])],
+ [Enable tests using the Google C++ Testing Framework.
+ (Default is enabled.)])],
[],
- [enable_gtest=check])
+ [enable_gtest=])
AC_ARG_VAR([GTEST_CONFIG],
[The exact path of Google Test's 'gtest-config' script.])
AC_ARG_VAR([GTEST_CPPFLAGS],
@@ -29,33 +29,46 @@ AC_ARG_VAR([GTEST_LIBS],
AC_ARG_VAR([GTEST_VERSION],
[The version of Google Test available.])
HAVE_GTEST="no"
-AS_IF([test "x$enable_gtest" != "xno"],
- [AC_PATH_PROG([GTEST_CONFIG], [gtest-config])
- AS_IF([test -x "$GTEST_CONFIG"],
- [AS_IF([test "x$1" != "x"],
- [_min_version="--min-version=$1"
+AS_IF([test "x${enable_gtest}" != "xno"],
+ [AC_MSG_CHECKING([for 'gtest-config'])
+ AS_IF([test "x${enable_gtest}" != "xyes"],
+ [AS_IF([test -x "${enable_gtest}/scripts/gtest-config"],
+ [GTEST_CONFIG="${enable_gtest}/scripts/gtest-config"],
+ [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])],
- [_min_version="--min-version=0"
+ [_gtest_min_version="--min-version=0"
AC_MSG_CHECKING([for Google Test])])
- AS_IF([$GTEST_CONFIG $_min_version],
+ AS_IF([${GTEST_CONFIG} ${_gtest_min_version}],
[AC_MSG_RESULT([yes])
- HAVE_GTEST="yes"],
- [AC_MSG_RESULT([no])])])
- AS_IF([test "x$HAVE_GTEST" = "xyes"],
- [GTEST_CPPFLAGS=$($GTEST_CONFIG --cppflags)
- GTEST_CXXFLAGS=$($GTEST_CONFIG --cxxflags)
- GTEST_LDFLAGS=$($GTEST_CONFIG --ldflags)
- GTEST_LIBS=$($GTEST_CONFIG --libs)
- GTEST_VERSION=$($GTEST_CONFIG --version)
+ HAVE_GTEST='yes'],
+ [AC_MSG_RESULT([no])])],
+ [AC_MSG_RESULT([no])])
+ AS_IF([test "x${HAVE_GTEST}" = "xyes"],
+ [GTEST_CPPFLAGS=`${GTEST_CONFIG} --cppflags`
+ GTEST_CXXFLAGS=`${GTEST_CONFIG} --cxxflags`
+ GTEST_LDFLAGS=`${GTEST_CONFIG} --ldflags`
+ GTEST_LIBS=`${GTEST_CONFIG} --libs`
+ GTEST_VERSION=`${GTEST_CONFIG} --version`
AC_DEFINE([HAVE_GTEST],[1],[Defined when Google Test is available.])],
- [AS_IF([test "x$enable_gtest" = "xyes"],
- [AC_MSG_ERROR([
- The Google C++ Testing Framework was explicitly enabled, but a viable version
- could not be found on the system.
-])])])])
+ [AS_IF([test "x${enable_gtest}" = "xyes"],
+ [AC_MSG_ERROR([dnl
+Google Test was enabled, but no viable version could be found.])
+ ])])])
AC_SUBST([HAVE_GTEST])
AM_CONDITIONAL([HAVE_GTEST],[test "x$HAVE_GTEST" = "xyes"])
AS_IF([test "x$HAVE_GTEST" = "xyes"],
- [AS_IF([test "x$2" != "x"],[$2],[:])],
- [AS_IF([test "x$3" != "x"],[$3],[:])])
+ [m4_ifval([$2], [$2])],
+ [m4_ifval([$3], [$3])])
])
diff --git a/make/Makefile b/make/Makefile
new file mode 100644
index 0000000..bf7e978
--- /dev/null
+++ b/make/Makefile
@@ -0,0 +1,78 @@
+# 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 $@
diff --git a/scripts/gtest-config.in b/scripts/gtest-config.in
index 50b18c9..b82d5a1 100755
--- a/scripts/gtest-config.in
+++ b/scripts/gtest-config.in
@@ -1,56 +1,61 @@
#!/bin/sh
# These variables are automatically filled in by the configure script.
-prefix="@prefix@"
-exec_prefix="@exec_prefix@"
-libdir="@libdir@"
-includedir="@includedir@"
name="@PACKAGE_TARNAME@"
version="@PACKAGE_VERSION@"
-gtest_ldflags="-L${libdir}"
-gtest_libs="-l${name}"
-gtest_cppflags="-I${includedir}"
-gtest_cxxflags=""
-
show_usage()
{
- cat <<EOF
-Usage: gtest-config [OPTIONS...]
-EOF
+ echo "Usage: gtest-config [OPTIONS...]"
}
show_help()
{
show_usage
- cat <<EOF
-
-The \`gtest-config' script provides access to the necessary compile and linking
-flags to connect with Google C++ Testing framework. The installation queries
-may only be issued one at a time, and may not be issued with any other types of
-queries. The version queries and compiler flag queries may be combined as
-desired but not mixed. Different version queries are always combined with "and"
-logical semantics, and only the last of any particular query is used and 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.
+ cat <<\EOF
+
+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
+installation, and on the system proper after installation. The installation
+overrides may be issued in combination with any other queries, but will only
+affect installation queries if called on a built but not installed gtest. The
+installation queries may not be issued with any other types of queries, and
+only one installation query may be made at a time. The version queries and
+compiler flag queries may be combined as desired but not mixed. Different
+version queries are always combined with logical "and" semantics, and only the
+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:
gtest-config --min-version=1.0 || echo "Insufficient Google Test version."
-
- gcc \$(gtest-config --cppflags --cxxflags) -o foo.o -c foo.cpp
- gcc \$(gtest-config --ldflags --libs) -o foo foo.o
+
+ 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 ...) ...
+
+ # When using an installed Google Test, but with installation overrides:
+ export GTEST_PREFIX="/opt"
+ g++ $(gtest-config --libdir="/opt/lib64" ...) ...
Help:
--usage brief usage information
--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:
--prefix installation prefix
--exec-prefix executable installation prefix
--libdir library installation directory
--includedir header file installation directory
- --version the version of the INC installation
+ --version the version of the Google Test installation
Version Queries:
--min-version=VERSION return 0 if the version is at least VERSION
@@ -68,11 +73,13 @@ EOF
# 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
-# and avoid any dependency on a particular "sed" implementation. Notable is
-# that it will only ever compare the first 3 components of versions. Further
-# components will be cleanly stripped off. All versions must be unadorned, so
-# "v1.0" will *not* work. The minimum version must be in $1, and the max in
-# $2.
+# and avoid any dependency on a particular "sed" or "awk" implementation.
+# Notable is that it will only ever compare the first 3 components of versions.
+# Further components will be cleanly stripped off. All versions must be
+# unadorned, so "v1.0" will *not* work. The minimum version must be in $1, and
+# the max in $2. TODO(chandlerc@google.com): If this ever breaks, we should
+# investigate expanding this via autom4te from AS_VERSION_COMPARE rather than
+# continuing to maintain our own shell version.
check_versions()
{
major_version=${version%%.*}
@@ -140,13 +147,25 @@ fi
while test $# -gt 0; do
case $1 in
- --usage) show_usage; exit 0;;
- --help) show_help; exit 0;;
- --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;;
+ --usage) show_usage; exit 0;;
+ --help) show_help; exit 0;;
+
+ # Installation overrides
+ --prefix=*) GTEST_PREFIX=${1#--prefix=};;
+ --exec-prefix=*) GTEST_EXEC_PREFIX=${1#--exec-prefix=};;
+ --libdir=*) GTEST_LIBDIR=${1#--libdir=};;
+ --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=*)
do_check_versions=yes
min_version=${1#--min-version=}
@@ -159,17 +178,73 @@ while test $# -gt 0; do
do_check_versions=yes
exact_version=${1#--exact-version=}
;;
- --cppflags) echo_cppflags=yes;;
- --cxxflags) echo_cxxflags=yes;;
- --ldflags) echo_ldflags=yes;;
- --libs) echo_libs=yes;;
+
+ # Compiler flag output
+ --cppflags) echo_cppflags=yes;;
+ --cxxflags) echo_cxxflags=yes;;
+ --ldflags) echo_ldflags=yes;;
+ --libs) echo_libs=yes;;
# Everything else is an error
- *) show_usage; exit 1;;
+ *) show_usage; exit 1;;
esac
shift
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.
if test "$do_check_versions" = "yes"; then
# Make sure we didn't receive a bad combination of parameters.
diff --git a/src/gtest.cc b/src/gtest.cc
index b836391..a9ca334 100644
--- a/src/gtest.cc
+++ b/src/gtest.cc
@@ -61,11 +61,13 @@
#include <vector>
#elif defined(GTEST_OS_SYMBIAN)
-// No autoconf on Symbian
#define GTEST_HAS_GETTIMEOFDAY
#include <sys/time.h> // NOLINT
#elif defined(GTEST_OS_ZOS)
+#define GTEST_HAS_GETTIMEOFDAY
+#include <sys/time.h> // NOLINT
+
// On z/OS we additionally need strings.h for strcasecmp.
#include <strings.h>
diff --git a/test/gtest-param-test_test.cc b/test/gtest-param-test_test.cc
index 6d84dcf..22ba1a3 100644
--- a/test/gtest-param-test_test.cc
+++ b/test/gtest-param-test_test.cc
@@ -42,10 +42,6 @@
#include <list>
#include <vector>
-#ifdef GTEST_HAS_COMBINE
-#include <tr1/tuple>
-#endif // GTEST_HAS_COMBINE
-
// To include gtest-internal-inl.h.
#define GTEST_IMPLEMENTATION
#include "src/gtest-internal-inl.h" // for UnitTestOptions