Comments (5)
This seems to be a collision between the macros defined by Google Test and
Chromium. Google Test defines its own macro called FAIL (see
http://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide#Explicit_Succes
s_and_Failure). Google Test's FAIL only records a failure but doesn't terminate
the
program. In fact, this test program should always fail unless you specify flags
such as
--gtest_break_on_failure or --gtest_throw on_failure. Are you compiling it with
Chromium headers included?
Original comment by vladlosev
on 8 Dec 2009 at 3:57
- Changed state: Accepted
from googletest.
The given program is compiled stand-alone, it uses FAIL from googletest.
I've tried it only on Windows.
http://codereview.chromium.org/462042/patch/1/3 was compiled this inside
Chromium and {DCheck,Check}DeathTest failed on Windows while passing on Linux
and Mac.
Chromium has its own CHECK which does which calls a hook which uses
googletest's FAIL
(names for these functions are given at
http://code.google.com/p/chromium/issues/detail?id=24885 comment #6)
If this is a misuse of FAIL, I'd really appreciate if you can help me explain
that to Chromium devs.
Original comment by [email protected]
on 8 Dec 2009 at 5:32
from googletest.
For ASSERT_DEATH(statement, test) to pass, the program has to die somewhere
inside statement.
The control should NOT reach the end of statement, either in a natural way, or
by using return.
Looking at the Chromium source code, the default implementation of CHECK
crashes the
program on false condition. But if one sets a custom hook, this behavior may
change and thus
tests may fail. In order for death tests to pass, please make sure that
whatever hook you are
using is crashing the program on all platforms. Putting the FAIL() invocation
into the hook makes
no sense as any side effects (except for writing to stdout/stderr) produced by
statement are
discarded.
An alternative would be to not use death tests but just verify that your hook
gets invoked when
CHECK is triggered.
WRT your test program, I've just tried this code and it is generating failures
on all three
platforms, as expected:
*** On Windows:
H:\vladl\dev\vladl-test\snipped\gtest>cl test.cc src\gtest-all.cc
src\gtest_main.cc -Iinclude -I.
-EHsc
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
test.cc
gtest-all.cc
gtest_main.cc
Generating Code...
Microsoft (R) Incremental Linker Version 8.00.50727.762
Copyright (C) Microsoft Corporation. All rights reserved.
/out:test.exe
test.obj
gtest-all.obj
gtest_main.obj
H:\vladl\dev\vladl-test\snipped\gtest>test.exe
Running main() from gtest_main.cc
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from DeathTest
[ RUN ] DeathTest.FailTest
Running main() from gtest_main.cc
test.cc(6): error: Death test: foo()
Result: failed to die.
Error msg:
[ FAILED ] DeathTest.FailTest (78 ms)
[----------] 1 test from DeathTest (78 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (78 ms total)
[ PASSED ] 0 tests.
[ FAILED ] 1 test, listed below:
[ FAILED ] DeathTest.FailTest
1 FAILED TEST
*** On Macintosh:
vladl-macbookpro:gtest vladl$ g++ --version
i686-apple-darwin9-g++-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5493)
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
vladl-macbookpro:gtest vladl$ g++ -Iinclude -I. -o test.out test.cc
src/gtest-all.cc
src/gtest_main.cc
vladl-macbookpro:gtest vladl$ ./test.out
Running main() from gtest_main.cc
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from DeathTest
[ RUN ] DeathTest.FailTest
test.cc:6: Failure
Death test: foo()
Result: failed to die.
Error msg:
[ FAILED ] DeathTest.FailTest (1 ms)
[----------] 1 test from DeathTest (2 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (2 ms total)
[ PASSED ] 0 tests.
[ FAILED ] 1 test, listed below:
[ FAILED ] DeathTest.FailTest
1 FAILED TEST
*** On Linux:
vladl@hungrymoose:~/dev/vladl-test/snipped/gtest$ g++ --version
g++ (GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu4)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
vladl@hungrymoose:~/dev/vladl-test/snipped/gtest$ g++ -Iinclude -I. -o test.out
test.cc
src/gtest-all.cc src/gtest_main.cc
vladl@hungrymoose:~/dev/vladl-test/snipped/gtest$ ./test.out
Running main() from gtest_main.cc
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from DeathTest
[ RUN ] DeathTest.FailTest
[WARNING] ./src/gtest-death-test.cc:741:: Death tests use fork(), which is
unsafe particularly in
a threaded context. For this test, Google Test couldn't detect the number of
threads.
test.cc:6: Failure
Death test: foo()
Result: failed to die.
Error msg:
[ FAILED ] DeathTest.FailTest (1 ms)
[----------] 1 test from DeathTest (1 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (1 ms total)
[ PASSED ] 0 tests.
[ FAILED ] 1 test, listed below:
[ FAILED ] DeathTest.FailTest
1 FAILED TEST
Are you using a particular set of flags to compile it?
Original comment by vladlosev
on 9 Dec 2009 at 10:21
from googletest.
Thanks, now I see the cause of the problem, it is Chromium-specific.
The hook I was talking about is only set on Windows, so that's a FAIL misuse:
http://src.chromium.org/viewvc/chrome/trunk/src/base/test/test_suite.h?revision=
33565
-> ctrl+f "SetLogAssertHandler"
Original comment by [email protected]
on 9 Dec 2009 at 7:51
from googletest.
Original comment by [email protected]
on 9 Dec 2009 at 11:05
- Changed state: Invalid
from googletest.
Related Issues (20)
- Netbeans IDE hates googletest macros HOT 1
- Hexadecimal Printing in Test Fail messages HOT 1
- Python testing scripts allow binaries under test to write XML output HOT 1
- Need to simplify Python test scripts to pass required env deltas into Subproces calls HOT 2
- Visual Studio 2010 Express does not compile googletest due to tuple issue HOT 3
- google test compilation fails on visual studio 2010 beta HOT 1
- gtest_break_on_failure does not honour EXPECT_FATAL_FAILURE HOT 3
- gtest compile error with STLPort Debug (MSVC++ 9.0) in death tests HOT 8
- define macros to simplify warning suppression HOT 1
- gtest may invoke an ANSI WIn32 API on a Unicode argument. HOT 2
- Enhancement: comparison between containers HOT 2
- Report failing tests to stderr instead of stdout HOT 1
- On SUN Warning: A non-POD object of type ... passed as a variable argument to function "testing::internal::IsNullLiteralHelper(...)". HOT 1
- 奇怪的tuple 编译错误 HOT 2
- configure.ac:29: error: possibly undefined macro: AC_PROG_LIBTOOL HOT 4
- EXPECT_DEATH test passes but leaves a dumped core from spawned process. HOT 2
- gtest-port_test.cc tries to use testing::Types without looking at GTEST_HAS_TYPED_TEST HOT 1
- gtest should treat - as _ when parsing command line flags HOT 1
- gtest-port.h use of #if prevents compilation with -Wundef HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from googletest.