Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
7e7e3a6f
Unverified
Commit
7e7e3a6f
authored
Aug 15, 2018
by
Gennadiy Civil
Committed by
GitHub
Aug 15, 2018
Browse files
Merge branch 'master' into patch-1
parents
b50b2f77
997d343d
Changes
204
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
73 additions
and
66 deletions
+73
-66
googletest/samples/sample1.cc
googletest/samples/sample1.cc
+0
-2
googletest/samples/sample1.h
googletest/samples/sample1.h
+0
-2
googletest/samples/sample10_unittest.cc
googletest/samples/sample10_unittest.cc
+1
-2
googletest/samples/sample1_unittest.cc
googletest/samples/sample1_unittest.cc
+0
-3
googletest/samples/sample2.cc
googletest/samples/sample2.cc
+0
-2
googletest/samples/sample2.h
googletest/samples/sample2.h
+0
-2
googletest/samples/sample2_unittest.cc
googletest/samples/sample2_unittest.cc
+0
-3
googletest/samples/sample3-inl.h
googletest/samples/sample3-inl.h
+0
-2
googletest/samples/sample3_unittest.cc
googletest/samples/sample3_unittest.cc
+0
-3
googletest/samples/sample4.cc
googletest/samples/sample4.cc
+0
-2
googletest/samples/sample4.h
googletest/samples/sample4.h
+0
-3
googletest/samples/sample4_unittest.cc
googletest/samples/sample4_unittest.cc
+1
-2
googletest/samples/sample5_unittest.cc
googletest/samples/sample5_unittest.cc
+1
-2
googletest/samples/sample6_unittest.cc
googletest/samples/sample6_unittest.cc
+1
-2
googletest/samples/sample7_unittest.cc
googletest/samples/sample7_unittest.cc
+1
-2
googletest/samples/sample8_unittest.cc
googletest/samples/sample8_unittest.cc
+1
-2
googletest/samples/sample9_unittest.cc
googletest/samples/sample9_unittest.cc
+1
-2
googletest/scripts/upload.py
googletest/scripts/upload.py
+4
-4
googletest/src/gtest-all.cc
googletest/src/gtest-all.cc
+1
-2
googletest/src/gtest-death-test.cc
googletest/src/gtest-death-test.cc
+61
-22
No files found.
googletest/samples/sample1.cc
View file @
7e7e3a6f
...
...
@@ -28,8 +28,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// A sample program demonstrating using Google C++ testing framework.
//
// Author: wan@google.com (Zhanyong Wan)
#include "sample1.h"
...
...
googletest/samples/sample1.h
View file @
7e7e3a6f
...
...
@@ -28,8 +28,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// A sample program demonstrating using Google C++ testing framework.
//
// Author: wan@google.com (Zhanyong Wan)
#ifndef GTEST_SAMPLES_SAMPLE1_H_
#define GTEST_SAMPLES_SAMPLE1_H_
...
...
googletest/samples/sample10_unittest.cc
View file @
7e7e3a6f
...
...
@@ -25,8 +25,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: vladl@google.com (Vlad Losev)
// This sample shows how to use Google Test listener API to implement
// a primitive leak checker.
...
...
googletest/samples/sample1_unittest.cc
View file @
7e7e3a6f
...
...
@@ -28,9 +28,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// A sample program demonstrating using Google C++ testing framework.
//
// Author: wan@google.com (Zhanyong Wan)
// This sample shows how to write a simple unit test for a function,
// using Google C++ testing framework.
...
...
googletest/samples/sample2.cc
View file @
7e7e3a6f
...
...
@@ -28,8 +28,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// A sample program demonstrating using Google C++ testing framework.
//
// Author: wan@google.com (Zhanyong Wan)
#include "sample2.h"
...
...
googletest/samples/sample2.h
View file @
7e7e3a6f
...
...
@@ -28,8 +28,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// A sample program demonstrating using Google C++ testing framework.
//
// Author: wan@google.com (Zhanyong Wan)
#ifndef GTEST_SAMPLES_SAMPLE2_H_
#define GTEST_SAMPLES_SAMPLE2_H_
...
...
googletest/samples/sample2_unittest.cc
View file @
7e7e3a6f
...
...
@@ -28,9 +28,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// A sample program demonstrating using Google C++ testing framework.
//
// Author: wan@google.com (Zhanyong Wan)
// This sample shows how to write a more complex unit test for a class
// that has multiple member functions.
...
...
googletest/samples/sample3-inl.h
View file @
7e7e3a6f
...
...
@@ -28,8 +28,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// A sample program demonstrating using Google C++ testing framework.
//
// Author: wan@google.com (Zhanyong Wan)
#ifndef GTEST_SAMPLES_SAMPLE3_INL_H_
#define GTEST_SAMPLES_SAMPLE3_INL_H_
...
...
googletest/samples/sample3_unittest.cc
View file @
7e7e3a6f
...
...
@@ -28,9 +28,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// A sample program demonstrating using Google C++ testing framework.
//
// Author: wan@google.com (Zhanyong Wan)
// In this example, we use a more advanced feature of Google Test called
// test fixture.
...
...
googletest/samples/sample4.cc
View file @
7e7e3a6f
...
...
@@ -28,8 +28,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// A sample program demonstrating using Google C++ testing framework.
//
// Author: wan@google.com (Zhanyong Wan)
#include <stdio.h>
...
...
googletest/samples/sample4.h
View file @
7e7e3a6f
...
...
@@ -28,9 +28,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// A sample program demonstrating using Google C++ testing framework.
//
// Author: wan@google.com (Zhanyong Wan)
#ifndef GTEST_SAMPLES_SAMPLE4_H_
#define GTEST_SAMPLES_SAMPLE4_H_
...
...
googletest/samples/sample4_unittest.cc
View file @
7e7e3a6f
...
...
@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
#include "sample4.h"
#include "gtest/gtest.h"
...
...
googletest/samples/sample5_unittest.cc
View file @
7e7e3a6f
...
...
@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// This sample teaches how to reuse a test fixture in multiple test
// cases by deriving sub-fixtures from it.
...
...
googletest/samples/sample6_unittest.cc
View file @
7e7e3a6f
...
...
@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// This sample shows how to test common properties of multiple
// implementations of the same interface (aka interface tests).
...
...
googletest/samples/sample7_unittest.cc
View file @
7e7e3a6f
...
...
@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: vladl@google.com (Vlad Losev)
// This sample shows how to test common properties of multiple
// implementations of an interface (aka interface tests) using
...
...
googletest/samples/sample8_unittest.cc
View file @
7e7e3a6f
...
...
@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: vladl@google.com (Vlad Losev)
// This sample shows how to test code relying on some global flag variables.
// Combine() helps with generating all possible combinations of such flags,
...
...
googletest/samples/sample9_unittest.cc
View file @
7e7e3a6f
...
...
@@ -25,8 +25,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: vladl@google.com (Vlad Losev)
// This sample shows how to use Google Test listener API to implement
// an alternative console output and how to use the UnitTest reflection API
...
...
googletest/scripts/upload.py
View file @
7e7e3a6f
...
...
@@ -242,7 +242,7 @@ class AbstractRpcServer(object):
The authentication process works as follows:
1) We get a username and password from the user
2) We use ClientLogin to obtain an AUTH token for the user
(see http://
co
de.google.com/
apis/account
s/AuthForInstalledApps
.html
).
(see http
s
://de
velopers
.google.com/
identity/protocol
s/AuthForInstalledApps).
3) We pass the auth token to /_ah/login on the server to obtain an
authentication cookie. If login was successful, it tries to redirect
us to the URL we provided.
...
...
@@ -506,7 +506,7 @@ def EncodeMultipartFormData(fields, files):
(content_type, body) ready for httplib.HTTP instance.
Source:
http://
aspn.activestate.com/ASPN/Cookbook/Python/R
ecipe/146306
http
s
://
web.archive.org/web/20160116052001/code.activestate.com/r
ecipe
s
/146306
"""
BOUNDARY
=
'-M-A-G-I-C---B-O-U-N-D-A-R-Y-'
CRLF
=
'
\r\n
'
...
...
@@ -807,7 +807,7 @@ class SubversionVCS(VersionControlSystem):
# svn cat translates keywords but svn diff doesn't. As a result of this
# behavior patching.PatchChunks() fails with a chunk mismatch error.
# This part was originally written by the Review Board development team
# who had the same problem (http://reviews.review
-
board.org/r/276/).
# who had the same problem (http
s
://reviews.reviewboard.org/r/276/).
# Mapping of keywords to known aliases
svn_keywords
=
{
# Standard keywords
...
...
@@ -860,7 +860,7 @@ class SubversionVCS(VersionControlSystem):
status_lines
=
status
.
splitlines
()
# If file is in a cl, the output will begin with
# "\n--- Changelist 'cl_name':\n". See
# http://svn.collab.net/repos/svn/trunk/notes/changelist-design.txt
# http
s
://
web.archive.org/web/20090918234815/
svn.collab.net/repos/svn/trunk/notes/changelist-design.txt
if
(
len
(
status_lines
)
==
3
and
not
status_lines
[
0
]
and
status_lines
[
1
].
startswith
(
"--- Changelist"
)):
...
...
googletest/src/gtest-all.cc
View file @
7e7e3a6f
...
...
@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: mheule@google.com (Markus Heule)
//
// Google C++ Testing and Mocking Framework (Google Test)
//
...
...
googletest/src/gtest-death-test.cc
View file @
7e7e3a6f
...
...
@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan), vladl@google.com (Vlad Losev)
//
// This file implements death tests.
...
...
@@ -67,6 +66,7 @@
# include <lib/fdio/spawn.h>
# include <zircon/processargs.h>
# include <zircon/syscalls.h>
# include <zircon/syscalls/port.h>
# endif // GTEST_OS_FUCHSIA
#endif // GTEST_HAS_DEATH_TEST
...
...
@@ -232,10 +232,16 @@ static std::string DeathTestThreadWarning(size_t thread_count) {
Message
msg
;
msg
<<
"Death tests use fork(), which is unsafe particularly"
<<
" in a threaded context. For this test, "
<<
GTEST_NAME_
<<
" "
;
if
(
thread_count
==
0
)
if
(
thread_count
==
0
)
{
msg
<<
"couldn't detect the number of threads."
;
else
}
else
{
msg
<<
"detected "
<<
thread_count
<<
" threads."
;
}
msg
<<
" See "
"https://github.com/google/googletest/blob/master/googletest/docs/"
"advanced.md#death-tests-and-threads"
<<
" for more explanation and suggested solutions, especially if"
<<
" this is the last message you see before your test times out."
;
return
msg
.
GetString
();
}
# endif // !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA
...
...
@@ -260,7 +266,7 @@ static const int kFuchsiaReadPipeFd = 3;
// statement, which is not allowed; THREW means that the test statement
// returned control by throwing an exception. IN_PROGRESS means the test
// has not yet concluded.
//
TODO(vladl@google.com)
: Unify names and possibly values for
//
FIXME
: Unify names and possibly values for
// AbortReason, DeathTestOutcome, and flag characters above.
enum
DeathTestOutcome
{
IN_PROGRESS
,
DIED
,
LIVED
,
RETURNED
,
THREW
};
...
...
@@ -575,7 +581,6 @@ bool DeathTestImpl::Passed(bool status_ok) {
if
(
status_ok
)
{
# if GTEST_USES_PCRE
// PCRE regexes support embedded NULs.
// GTEST_USES_PCRE is defined only in google3 mode
const
bool
matched
=
RE
::
PartialMatch
(
error_message
,
*
regex
());
# else
const
bool
matched
=
RE
::
PartialMatch
(
error_message
.
c_str
(),
*
regex
());
...
...
@@ -805,6 +810,12 @@ class FuchsiaDeathTest : public DeathTestImpl {
const
char
*
file
,
int
line
)
:
DeathTestImpl
(
a_statement
,
a_regex
),
file_
(
file
),
line_
(
line
)
{}
virtual
~
FuchsiaDeathTest
()
{
zx_status_t
status
=
zx_handle_close
(
child_process_
);
GTEST_DEATH_TEST_CHECK_
(
status
==
ZX_OK
);
status
=
zx_handle_close
(
port_
);
GTEST_DEATH_TEST_CHECK_
(
status
==
ZX_OK
);
}
// All of these virtual functions are inherited from DeathTest.
virtual
int
Wait
();
...
...
@@ -816,7 +827,8 @@ class FuchsiaDeathTest : public DeathTestImpl {
// The line number on which the death test is located.
const
int
line_
;
zx_handle_t
child_process_
;
zx_handle_t
child_process_
=
ZX_HANDLE_INVALID
;
zx_handle_t
port_
=
ZX_HANDLE_INVALID
;
};
// Utility class for accumulating command-line arguments.
...
...
@@ -863,16 +875,38 @@ int FuchsiaDeathTest::Wait() {
if
(
!
spawned
())
return
0
;
//
W
ait for child process to terminate.
//
Register to w
ait for
the
child process to terminate.
zx_status_t
status_zx
;
zx_signals_t
signals
;
status_zx
=
zx_object_wait_one
(
child_process_
,
ZX_PROCESS_TERMINATED
,
ZX_TIME_INFINITE
,
&
signals
);
status_zx
=
zx_object_wait_async
(
child_process_
,
port_
,
0
/* key */
,
ZX_PROCESS_TERMINATED
,
ZX_WAIT_ASYNC_ONCE
);
GTEST_DEATH_TEST_CHECK_
(
status_zx
==
ZX_OK
);
// Wait for it to terminate, or an exception to be received.
zx_port_packet_t
packet
;
status_zx
=
zx_port_wait
(
port_
,
ZX_TIME_INFINITE
,
&
packet
);
GTEST_DEATH_TEST_CHECK_
(
status_zx
==
ZX_OK
);
if
(
ZX_PKT_IS_EXCEPTION
(
packet
.
type
))
{
// Process encountered an exception. Kill it directly rather than letting
// other handlers process the event.
status_zx
=
zx_task_kill
(
child_process_
);
GTEST_DEATH_TEST_CHECK_
(
status_zx
==
ZX_OK
);
// Now wait for |child_process_| to terminate.
zx_signals_t
signals
=
0
;
status_zx
=
zx_object_wait_one
(
child_process_
,
ZX_PROCESS_TERMINATED
,
ZX_TIME_INFINITE
,
&
signals
);
GTEST_DEATH_TEST_CHECK_
(
status_zx
==
ZX_OK
);
GTEST_DEATH_TEST_CHECK_
(
signals
&
ZX_PROCESS_TERMINATED
);
}
else
{
// Process terminated.
GTEST_DEATH_TEST_CHECK_
(
ZX_PKT_IS_SIGNAL_ONE
(
packet
.
type
));
GTEST_DEATH_TEST_CHECK_
(
packet
.
signal
.
observed
&
ZX_PROCESS_TERMINATED
);
}
ReadAndInterpretStatusByte
();
zx_info_process_t
buffer
;
...
...
@@ -936,13 +970,10 @@ DeathTest::TestRole FuchsiaDeathTest::AssumeRole() {
set_read_fd
(
status
);
// Set the pipe handle for the child.
fdio_spawn_action_t
add_handle_action
=
{
.
action
=
FDIO_SPAWN_ACTION_ADD_HANDLE
,
.
h
=
{
.
id
=
PA_HND
(
type
,
kFuchsiaReadPipeFd
),
.
handle
=
child_pipe_handle
}
};
fdio_spawn_action_t
add_handle_action
=
{};
add_handle_action
.
action
=
FDIO_SPAWN_ACTION_ADD_HANDLE
;
add_handle_action
.
h
.
id
=
PA_HND
(
type
,
kFuchsiaReadPipeFd
);
add_handle_action
.
h
.
handle
=
child_pipe_handle
;
// Spawn the child process.
status
=
fdio_spawn_etc
(
ZX_HANDLE_INVALID
,
FDIO_SPAWN_CLONE_ALL
,
...
...
@@ -950,6 +981,14 @@ DeathTest::TestRole FuchsiaDeathTest::AssumeRole() {
&
add_handle_action
,
&
child_process_
,
nullptr
);
GTEST_DEATH_TEST_CHECK_
(
status
==
ZX_OK
);
// Create an exception port and attach it to the |child_process_|, to allow
// us to suppress the system default exception handler from firing.
status
=
zx_port_create
(
0
,
&
port_
);
GTEST_DEATH_TEST_CHECK_
(
status
==
ZX_OK
);
status
=
zx_task_bind_exception_port
(
child_process_
,
port_
,
0
/* key */
,
0
/*options */
);
GTEST_DEATH_TEST_CHECK_
(
status
==
ZX_OK
);
set_spawned
(
true
);
return
OVERSEE_TEST
;
}
...
...
@@ -1419,7 +1458,7 @@ static int GetStatusFileDescriptor(unsigned int parent_process_id,
StreamableToString
(
parent_process_id
));
}
//
TODO(vladl@google.com)
: Replace the following check with a
//
FIXME
: Replace the following check with a
// compile-time assertion when available.
GTEST_CHECK_
(
sizeof
(
HANDLE
)
<=
sizeof
(
size_t
));
...
...
Prev
1
2
3
4
5
6
7
8
9
10
11
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment