1
This directory contains Google Test, described below. It is used by the
2
Protocol Buffer C++ unit tests. If you would like to use Google Test
3
yourself, you should probably download it from the URL mentioned below,
4
not attempt to use the sources in this package.
6
Two changes were made from the original sources:
7
* gtest.cc's #include of gtest-internal-inl.h was modified to reflect the
8
environment it is being built in (replaced "src/" with "gtest/").
9
* GetThreadCount() in gtest-port.h was hard-coded to return 1 rather than 0,
10
since the Protocol Buffer tests do not use threads.
12
The original Google Test README follows.
14
======================================================================
16
Google C++ Testing Framework
17
============================
18
http://code.google.com/p/googletest/
22
Google's framework for writing C++ tests on a variety of platforms (Linux, Mac
23
OS X, Windows, Windows CE, and Symbian). Based on the xUnit architecture.
24
Supports automatic test discovery, a rich set of assertions, user-defined
25
assertions, death tests, fatal and non-fatal failures, various options for
26
running the tests, and XML test report generation.
28
Please see the project page above for more information as well as mailing lists
29
for questions, discussions, and development. There is also an IRC channel on
30
OFTC (irc.oftc.net) #gtest available. Please join us!
34
Google Test is designed to have fairly minimal requirements to build and use
35
with your projects, but there are some. Currently, the only Operating System
36
(OS) on which Google Test is known to build properly is Linux, but we are
37
actively working on Windows and Mac support as well. The source code itself is
38
already portable across many other platforms, but we are still developing
39
robust build systems for each.
41
### Linux Requirements ###
42
These are the base requirements to build and use Google Test from a source
43
package (as described below):
44
* GNU-compatible Make or "gmake"
45
* POSIX-standard shell
46
* POSIX(-2) Regular Expressions (regex.h)
47
* A C++98 standards compliant compiler
49
Furthermore, if you are building Google Test from a VCS Checkout (also
50
described below), there are further requirements:
51
* Automake version 1.9 or newer
52
* Autoconf version 2.59 or newer
53
* Libtool / Libtoolize
54
* Python version 2.4 or newer
58
There are two primary ways of getting Google Test's source code: you can
59
download a source release in your preferred archive format, or directly check
60
out the source from a Version Control System (VCS, we use Google Code's
61
Subversion hosting). The VCS checkout requires a few extra steps and some extra
62
software packages on your system, but lets you track development, and make
63
patches to contribute much more easily, so we highly encourage it.
66
The first step is to select whether you want to check out the main line of
67
development on Google Test, or one of the released branches. The former will be
68
much more active and have the latest features, but the latter provides much
69
more stability and predictability. Choose whichever fits your needs best, and
70
proceed with the following Subversion commands:
72
$ svn checkout http://googletest.googlecode.com/svn/trunk/ gtest-svn
74
or for a release version X.Y.*'s branch:
76
$ svn checkout http://googletest.googlecode.com/svn/branches/release-X.Y/ gtest-X.Y-svn
78
Next you will need to prepare the GNU Autotools build system. Enter the
79
target directory of the checkout command you used ('gtest-svn' or
80
'gtest-X.Y-svn' above) and proceed with the following commands:
82
$ aclocal-1.9 # Where "1.9" must match the following automake command
85
$ automake-1.9 -ac # See Automake version requirements above
88
While this is a bit complicated, it will most often be automatically re-run by
89
your "make" invocations, so in practice you shouldn't need to worry too much.
90
Once you have completed these steps, your VCS checkout should be equivalent to
91
a source package, and you may continue with those directions, skipping over the
92
acquiring and unpacking of the source itself, as the VCS has done that for you.
94
### Source Package: ###
95
Google Test is also released in source packages which can be downloaded from
96
its Google Code download page[1]. Several different archive formats are
97
provided, but the only difference is the tools used to manipulate them, and the
98
size of the resulting file. Download whichever you are most comfortable with.
100
[1] Google Test Downloads: http://code.google.com/p/googletest/downloads/list
102
Once downloaded expand the archive using whichever tools you prefer for that
103
type. This will always result in a new directory with the name "gtest-X.Y.Z"
104
which contains all of the source code. Here are some examples in Linux:
106
$ tar -xvzf gtest-X.Y.Z.tar.gz
107
$ tar -xvjf gtest-X.Y.Z.tar.bz2
108
$ unzip gtest-X.Y.Z.zip
112
There are two primary options for building the source at this point: build it
113
inside the source code tree, or in a separate directory. We recommend building
114
in a separate directory as that tends to produce both more consistent results
115
and be easier to clean up should anything go wrong, but both patterns are
116
supported. The only hard restriction is that while the build directory can be
117
a subdirectory of the source directory, the opposite is not possible and will
118
result in errors. Once you have selected where you wish to build Google Test,
119
create the directory if necessary, and enter it. The following steps apply for
120
either approach by simply substituting the shell variable SRCDIR with "." for
121
building inside the source directory, and the relative path to the source
124
$ ${SRCDIR}/configure # Standard GNU configure script, --help for more info
125
$ make # Standard makefile following GNU conventions
127
Other programs will only be able to use Google Test's functionality if you
128
install it in a location which they can access, in Linux this is typically
129
under '/usr/local'. The following command will install all of the Google Test
130
libraries, public headers, and utilities necessary for other programs and
131
libraries to leverage it:
133
$ sudo make install # Not necessary, but allows use by other programs
135
TODO(chandlerc@google.com): This section needs to be expanded when the
136
'gtest-config' script is finished and Autoconf macro's are provided (or not
137
provided) in order to properly reflect the process for other programs to
138
locate, include, and link against Google Test.
140
Finally, should you need to remove Google Test from your system after having
141
installed it, run the following command, and it will back out its changes.
142
However, note carefully that you must run this command on the *same* Google
143
Test build that you ran the install from, or the results are not predictable.
144
If you install Google Test on your system, and are working from a VCS checkout,
145
make sure you run this *before* updating your checkout of the source in order
146
to uninstall the same version which you installed.
148
$ sudo make uninstall # Must be run against the exact same build as "install"