death tests on solaris

27 views
Skip to first unread message

Tor Didriksen

unread,
Nov 2, 2009, 4:52:27 AM11/2/09
to Google C++ Testing Framework
Hi

The patch below should allow death tests on solaris.
Seems like issues 170 and 171 can be closed.
Tested with
$gcc -v
Reading specs from /usr/sfw/lib/gcc/i386-pc-solaris2.11/3.4.3/specs
Configured with:
/builds2/sfwnv-111a/usr/src/cmd/gcc/gcc-3.4.3/configure
--prefix=/usr/sfw --with-as=/usr/sfw/bin/gas --with-gnu-as
--with-ld=/usr/ccs/bin/ld --without-gnu-ld
--enable-languages=c,c++,f77,objc --enable-shared
Thread model: posix
gcc version 3.4.3 (csl-sol210-3_4-20050802)

$uname -a
SunOS 5.11 snv_111b i86pc i386 i86pc

-- didrik

Index: include/gtest/internal/gtest-port.h
===================================================================
--- include/gtest/internal/gtest-port.h (revision 336)
+++ include/gtest/internal/gtest-port.h (working copy)
@@ -461,7 +461,7 @@
// 3. abort() in a VC 7.1 application compiled as GUI in debug config
// pops up a dialog window that cannot be suppressed programmatically.
#if GTEST_HAS_STD_STRING && \
- (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_CYGWIN || \
+ (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \
(GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || GTEST_OS_WINDOWS_MINGW)
#define GTEST_HAS_DEATH_TEST 1
#include <vector> // NOLINT

Vlad Losev

unread,
Nov 3, 2009, 1:16:31 AM11/3/09
to Tor Didriksen, Alexander Demin, Google C++ Testing Framework
Hi Tor,

This is a good news for Solaris users as others had run into problems trying to make gtest fully Solaris compatible.

Alexander - Does Tor's patch work for you on Solaris?
Thanks,
Vlad

Alexander Demin

unread,
Nov 3, 2009, 3:39:17 AM11/3/09
to Vlad Losev, Tor Didriksen, Google C++ Testing Framework
Yes, for me it works.

This patch just enables death tests functionality which was working even in 1.3.0 after some include files fiddling.

I've done this now to test on Solaris:

#include "gtest/gtest.h"
#include <stdlib.h>

int foo() { exit(0); return 1; }

TEST(Test, Simple) {
  EXPECT_EXIT(foo(), ::testing::ExitedWithCode(0), "");
}

int main(int argc, char* argv[]) {
  testing::InitGoogleTest(&argc, argv);
  testing::GTEST_FLAG(print_time) = true;
  testing::GTEST_FLAG(death_test_style) = "threadsafe";
  return RUN_ALL_TESTS();
}

CC -V
CC: Sun C++ 5.9 SunOS_sparc Patch 124863-12 2009/04/21

It compile without any warnings.

uname -a
SunOS sundev23 5.10 Generic_127111-09 sun4u sparc SUNW,Sun-Fire

It runs with:

[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from Test
[ RUN      ] Test.Simple
[       OK ] Test.Simple (19 ms)
[----------] 1 test from Test (20 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (20 ms total)
[  PASSED  ] 1 test.

But please note I use Sun Studio but not GCC.

Also it needs to set death_test_style = "threadsafe"; to avoid thread safety warnings.

Since "unistd.h" is now available in the headers starting from 1.4.0 I guess so Issue 171 seems to be fixed.

The patch I has suggested to Issue 170 does exactly the same what Tor says. So #170 also could be closed.

Unfortunately I am able to test on AIX and HP-UX anymore for a while (maybe for a long "while" ;-).

Regards,
Alexander

Tor Didriksen

unread,
Nov 3, 2009, 4:18:28 AM11/3/09
to Alexander Demin, Vlad Losev, Google C++ Testing Framework

I have done 'make check' with gcc and Sun Studio.
With the four patches I sent yesterday, there's only one failure left

Traceback (most recent call last):
File "./test/gtest_output_test.py", line 282, in testOutput
self.assert_(normalized_golden == normalized_actual)

It fails since it is testing typed tests (which isn't supported).
If I enable typed tests, it still fails, since it basically depends
on a certain name mangling of types.

-- didrik

Vlad Losev

unread,
Nov 3, 2009, 12:51:54 PM11/3/09
to Tor Didriksen, Alexander Demin, Google C++ Testing Framework
Interesting. gtest_output_test.py is supposed to detect whether typed tests are supported on the platform and to test them only if they are. Is it failing to do that on Solaris?
 

- Vlad

Hady Zalek

unread,
Nov 3, 2009, 5:28:01 PM11/3/09
to Vlad Losev, Tor Didriksen, Alexander Demin, Google C++ Testing Framework, Johnny Mkhael
Hello everyone,

A colleague and I actually ported gtest to Solaris (5.8) and AIX with death and typed tests enabled. All tests pass. There's really not much to do to get it working. Unfortunately, I'm on vacation till Thursday (in theory) and don't have access to the patches right now. Off the top of my head:

Solaris:
- Compilation errors caused by the death test macros regex param being copied and various others
- Typed tests fail since the SS preprocessor prefixes the registered_test names with spaces. Need a SkipWhitespace before subsequent SkipComma's
- On Solaris 5.8, unsetenv isn't there. The python fix is use a global var and pass that to the Subprocess function. For the C++ tests, a unsetenv impl using the 'environ' variable
- Python output/help test: normalize 'unsigned int' to 'unsigned' in both golden and reference since some compilers use the shothand form.
- Fix a crash in RE's dtor that frees an invalid regex's pattern (the standard doesn't guarantee that the memory is valid) just wrap the regex_free calls with a check on is_valid_

AIX:
- static dtors not called for the flag definitions. Changed the macros to functions returning references.

Both:
Compilation errors due to incorrect rtti and exception flags. Would be nice if the user can specify the NO_RTTI and NO_EXCEPTION flags. Would be even nicer if the build system is migrated to CMake.

That's all I can remember. I'll clean up and send in the patches we have in the next couple of days.

Cheers!
Hady

Alexander Demin

unread,
Nov 3, 2009, 5:52:31 PM11/3/09
to Hady Zalek, Vlad Losev, Tor Didriksen, Google C++ Testing Framework, Johnny Mkhael
Yep, correct. I have totally forgotten about RegExp object instantiation problem with Sun C++ compiler which was discussed here already. My recent test did not check it.

Alexander

Vlad Losev

unread,
Nov 3, 2009, 9:28:38 PM11/3/09
to Hady Zalek, Tor Didriksen, Alexander Demin, Google C++ Testing Framework, Johnny Mkhael
HI Hady,

Your patch will be very welcome by many people on this group!
Regards,
Vlad

Tor Didriksen

unread,
Nov 4, 2009, 5:18:07 AM11/4/09
to Vlad Losev, Alexander Demin, Google C++ Testing Framework

With gcc it asserts here
# We want the test to pass regardless of certain features being
# supported or not.
if CAN_GENERATE_GOLDEN_FILE:
self.assert_(golden == output)

The golden file is test/gtest_output_test_golden_lin.txt
Which is generated by gcc on linux I guess.
Running with gcc on solaris, the diff looks like this:
17c17
< [----------] 1 test from ATypedDeathTest/0, where TypeParam = i
---
> [----------] 1 test from ATypedDeathTest/0, where TypeParam = int
20c20
< [----------] 1 test from ATypedDeathTest/1, where TypeParam = d
---
> [----------] 1 test from ATypedDeathTest/1, where TypeParam = double
23c23
< [----------] 1 test from My/ATypeParamDeathTest/0, where TypeParam = i
---
> [----------] 1 test from My/ATypeParamDeathTest/0, where TypeParam = int
26c26
< [----------] 1 test from My/ATypeParamDeathTest/1, where TypeParam = d
---
.....
and some more similar diffs further down.


With Sun Studio (typed tests disabled) it asserts here:
self.assert_(normalized_golden == normalized_actual)

The diff is then (uncommented your debug code)
$diff ./test/_gtest_output_test_normalized_actual.txt
./test/_gtest_output_test_normalized_golden.txt
16a17,28
> [----------] 1 test from ATypedDeathTest/0, where TypeParam = int
> [ RUN ] ATypedDeathTest/0.ShouldRunFirst
> [ OK ] ATypedDeathTest/0.ShouldRunFirst
> [----------] 1 test from ATypedDeathTest/1, where TypeParam = double
> [ RUN ] ATypedDeathTest/1.ShouldRunFirst
> [ OK ] ATypedDeathTest/1.ShouldRunFirst
> [----------] 1 test from My/ATypeParamDeathTest/0, where TypeParam = int
> [ RUN ] My/ATypeParamDeathTest/0.ShouldRunFirst
> [ OK ] My/ATypeParamDeathTest/0.ShouldRunFirst
> [----------] 1 test from My/ATypeParamDeathTest/1, where TypeParam = double
> [ RUN ] My/ATypeParamDeathTest/1.ShouldRunFirst
> [ OK ] My/ATypeParamDeathTest/1.ShouldRunFirst
308a321,326
> [ RUN ] ExpectNonfatalFailureTest.FailsWhenStatementThrows
> (expecting a failure)
> gtest.cc:#: Failure
> Expected: 1 non-fatal failure
> Actual: 0 failures
> [ FAILED ] ExpectNonfatalFailureTest.FailsWhenStatementThrows
351a370,375
> [ RUN ] ExpectFatalFailureTest.FailsWhenStatementThrows
> (expecting a failure)
> gtest.cc:#: Failure
> Expected: 1 fatal failure
> Actual: 0 failures
> [ FAILED ] ExpectFatalFailureTest.FailsWhenStatementThrows
486a511
> [ FAILED ] ExpectNonfatalFailureTest.FailsWhenStatementThrows
490a516
> [ FAILED ] ExpectFatalFailureTest.FailsWhenStatementThrows


-- didrik

Vlad Losev

unread,
Nov 4, 2009, 5:27:12 AM11/4/09
to Tor Didriksen, Alexander Demin, Google C++ Testing Framework
I see. It looks like we'll need to factor out the actual type names on GCC/Solaris.
What is the output of 'gtest_output_test_ --gtest_list_tests' on SunStudio?
Thanks,
Vlad

Tor Didriksen

unread,
Nov 4, 2009, 6:13:38 AM11/4/09
to Vlad Losev, Alexander Demin, Google C++ Testing Framework

The non-test part of the code is expected to have 2 failures.

test/gtest_output_test_.cc:230: Failure
Value of: false
Actual: false
Expected: true
test/gtest_output_test_.cc:231: Failure
Value of: 3
Expected: 2
ADeathTest.
ShouldRunFirst
PassingTest.
PassingTest1
PassingTest2
FatalFailureTest.
FatalFailureInSubroutine
FatalFailureInNestedSubroutine
NonfatalFailureInSubroutine
LoggingTest.
InterleavingLoggingAndAssertions
SCOPED_TRACETest.
ObeysScopes
WorksInLoop
WorksInSubroutine
CanBeNested
CanBeRepeated
DisabledTestsWarningTest.
DISABLED_AlsoRunDisabledTestsFlagSuppressesWarning
NonFatalFailureInFixtureConstructorTest.
FailureInConstructor
FatalFailureInFixtureConstructorTest.
FailureInConstructor
NonFatalFailureInSetUpTest.
FailureInSetUp
FatalFailureInSetUpTest.
FailureInSetUp
MixedUpTestCaseTest.
FirstTestFromNamespaceFoo
SecondTestFromNamespaceFoo
ThisShouldFail
ThisShouldFailToo
MixedUpTestCaseWithSameTestNameTest.
TheSecondTestWithThisNameShouldFail
TheSecondTestWithThisNameShouldFail
TEST_F_before_TEST_in_same_test_case.
DefinedUsingTEST_F
DefinedUsingTESTAndShouldFail
TEST_before_TEST_F_in_same_test_case.
DefinedUsingTEST
DefinedUsingTEST_FAndShouldFail
ExpectNonfatalFailureTest.
CanReferenceGlobalVariables
CanReferenceLocalVariables
SucceedsWhenThereIsOneNonfatalFailure
FailsWhenThereIsNoNonfatalFailure
FailsWhenThereAreTwoNonfatalFailures
FailsWhenThereIsOneFatalFailure
FailsWhenStatementReturns
ExpectFatalFailureTest.
CanReferenceGlobalVariables
CanReferenceLocalStaticVariables
SucceedsWhenThereIsOneFatalFailure
FailsWhenThereIsNoFatalFailure
FailsWhenThereAreTwoFatalFailures
FailsWhenThereIsOneNonfatalFailure
FailsWhenStatementReturns
ExpectFailureTest.
ExpectFatalFailure
ExpectNonFatalFailure
ExpectFatalFailureOnAllThreads
ExpectNonFatalFailureOnAllThreads

Vlad Losev

unread,
Nov 4, 2009, 1:35:47 PM11/4/09
to Tor Didriksen, Alexander Demin, Google C++ Testing Framework
Thanks! This appears to be a genuine bug. I have logged issue 216 to track it.
 

Regards,
Vlad

Hady Zalek

unread,
Nov 8, 2009, 7:02:41 AM11/8/09
to Vlad Losev, Tor Didriksen, Alexander Demin, Google C++ Testing Framework, Johnny Mkhael
Hi Vlad,

Please find attached a patch (and the corresponding changelog) that adds Sun Studio (versions 11 and 12) support for Solaris 5.10. All 46 tests pass with type and death tests enabled. I also tested with and without STLPort (-library=stlport4). I rebuilt on Linux to verify that I haven't broken anything (I hope :-).

TODO:
--------------------------------------------
- Build file issues: Compilation fails due to unknown compiler flags. I attached the patch I use to fixup the Makefile everytime I configure. I guess it'll be much simpler once Chandler helps out.
- Solaris 5.8 support: Solaris 5.8 doesn't have unsetenv, so alot of tests fail. I already have a patch that I'm cleaning up.
- Not sure, but I think param tests could be tweaked to work with SS when using STLPort.
- Visual Age Support. I have a patch that I'm cleaning up.
- There might be a problem in RE's dtor when GTEST_USES_POSIX_RE and the regex is not valid: partial_regex_ and full_regex_ are not guaranteed to have valid data and therefore cannot be 'regfree'd. Might need to wrap regfree's with a check on is_valid_. Investigating....

From http://www.opengroup.org/onlinepubs/000095399/functions/regcomp.html:
Upon successful completion, the regcomp() function shall return 0. Otherwise, it shall return an integer value indicating an error as described in <regex.h>, and the content of preg is undefined.

Cheers,
Hady

2009/11/4 Vlad Losev <vlad...@gmail.com>
Changelog
sunstudio.patch
Makefile.patch

Hady Zalek

unread,
Nov 8, 2009, 7:47:45 PM11/8/09
to Vlad Losev, Tor Didriksen, Alexander Demin, Google C++ Testing Framework, Johnny Mkhael
Hi again Vlad,

I'm attaching the patches for IBM Visual Age support (on AIX). All 46 tests pass. The Changelog and Makefile patches are also in there. The patch builds on the previous changes I submitted. Don't hesitate to ask for an updated patch.

Cheers,
had

2009/11/8 Hady Zalek <hady....@gmail.com>
visualage.patch
Makefile.patch
Changelog

Vlad Losev

unread,
Nov 10, 2009, 2:14:34 AM11/10/09
to Hady Zalek, Vlad Losev, Tor Didriksen, Alexander Demin, Google C++ Testing Framework, Johnny Mkhael
Hi Hady,

Before we can accept the patch from you, we need to ask you to sign the CLA as described in http://code.google.com/p/googletest/wiki/GoogleTestDevGuide#Contributing_Code.

Also, could you upload the patches to the code review site so that I could
can make comments/ask questions easier? The instructions on uploading them are at
http://code.google.com/p/googletest/wiki/GoogleTestDevGuide#Submitting_Patches.

Thanks,
Vlad

Hady Zalek

unread,
Nov 10, 2009, 5:03:23 AM11/10/09
to Vlad Losev, Vlad Losev, Tor Didriksen, Alexander Demin, Google C++ Testing Framework, Johnny Mkhael
Hi Vlad,

Ok, I'll do that right away. I'm also going to upload the attached patch for Solaris 5.8 support. The tests were failing since the platform doesn't have unsetenv. Fixed and tested under NT, LInux, and AIX.

Cheers,
had

2009/11/10 Vlad Losev <vl...@google.com>
solaris5.8.patch
Changelog

Hady Zalek

unread,
Nov 10, 2009, 9:24:47 AM11/10/09
to Vlad Losev, Vlad Losev, Tor Didriksen, Alexander Demin, Google C++ Testing Framework, Johnny Mkhael
Hi Vlad,

I signed the CLA and submitted two patch sets for Sun Studio/Solaris support under http://codereview.appspot.com/153042. The first is for Sun Studio version 11 & 12 under Solaris 5.10. The second one is for Solaris 5.8.

Thanks!
Hady

2009/11/10 Hady Zalek <hady....@gmail.com>
Reply all
Reply to author
Forward
0 new messages