Global test environment tear-down segfaults after adding Abstract Test Pattern

1,898 views
Skip to first unread message

Katy Huff

unread,
Jan 1, 2012, 1:55:37 PM1/1/12
to googletes...@googlegroups.com
Hi All,

I'm trying to implement an Abstract Test pattern for testing an interface (FacilityModel)  in my code (Cyclus).
I have followed the instructions at code.google.com/p/googletest/wiki/AdvancedGuide#Creating_Value-Parameterized_Abstract_Tests and have succeeded in running the FacilityModel abstract tests for my SourceFacility. Hooray! The instructions were very helpful and straightforward. Thank you! 

Unfortunately, the global test environment tear-down step is now failing with a segfault.
Can you tell if there there is a destructor or TearDown() method that I'm missing?
I'll very much appreciate your help.

All of my source code is at  cyclus.googlecode.com . Files pertinent to this change were committed in revision 566 (http://code.google.com/p/cyclus/source/detail?r=566). It is worth noting that in my code, gtest is implemented in conjunction with ctest (part of cmake) via a single header file. I'm a fan so far, though I haven't implemented many tests, as you can also see in the repository. There's a project I modeled this after (ITK). Here's a discussion which describes the use of their googletest framework and compares it with boost tests http://www.itk.org/Wiki/Proposals:Increasing_ITK_Code_Coverage .



Anyway, the troublesome gdb output follows:


Starting program: /Users/khuff/Documents/work/cyclus/wc/trunk/build/debug/Testing/CyclusUnitTestDriver 
[==========] Running 38 tests from 7 test cases.
[----------] Global test environment set-up.
[----------] 3 tests from MaterialTest
[ RUN      ] MaterialTest.ManualConstructor
[       OK ] MaterialTest.ManualConstructor (0 ms)
[ RUN      ] MaterialTest.ChangeComp
[       OK ] MaterialTest.ChangeComp (0 ms)
[ RUN      ] MaterialTest.Decay
[       OK ] MaterialTest.Decay (17 ms)
[----------] 3 tests from MaterialTest (17 ms total)

[----------] 10 tests from BookKeeperTest
[ RUN      ] BookKeeperTest.createDataBase
[       OK ] BookKeeperTest.createDataBase (2 ms)
[ RUN      ] BookKeeperTest.openDB
[       OK ] BookKeeperTest.openDB (0 ms)
[ RUN      ] BookKeeperTest.closeDB
[       OK ] BookKeeperTest.closeDB (0 ms)
[ RUN      ] BookKeeperTest.ReadWrite1DIntegers
[       OK ] BookKeeperTest.ReadWrite1DIntegers (1 ms)
[ RUN      ] BookKeeperTest.ReadWrite2DIntegers
[       OK ] BookKeeperTest.ReadWrite2DIntegers (1 ms)
[ RUN      ] BookKeeperTest.ReadWrite3DIntegers
[       OK ] BookKeeperTest.ReadWrite3DIntegers (0 ms)
[ RUN      ] BookKeeperTest.ReadWrite1DDoubles
[       OK ] BookKeeperTest.ReadWrite1DDoubles (1 ms)
[ RUN      ] BookKeeperTest.ReadWrite2DDoubles
[       OK ] BookKeeperTest.ReadWrite2DDoubles (1 ms)
[ RUN      ] BookKeeperTest.ReadWrite3DDoubles
[       OK ] BookKeeperTest.ReadWrite3DDoubles (1 ms)
[ RUN      ] BookKeeperTest.WriteModelLists
[       OK ] BookKeeperTest.WriteModelLists (2 ms)
[----------] 10 tests from BookKeeperTest (9 ms total)

[----------] 3 tests from LogicianTest
[ RUN      ] LogicianTest.AddRetrieveModels
[       OK ] LogicianTest.AddRetrieveModels (0 ms)
[ RUN      ] LogicianTest.AddRetrieveMaterial
[       OK ] LogicianTest.AddRetrieveMaterial (0 ms)
[ RUN      ] LogicianTest.ExecutionOrder
[       OK ] LogicianTest.ExecutionOrder (0 ms)
[----------] 3 tests from LogicianTest (24 ms total)

[----------] 5 tests from MessageTest
[ RUN      ] MessageTest.CleanThrough
[       OK ] MessageTest.CleanThrough (0 ms)
[ RUN      ] MessageTest.PassBeyondOrigin
[       OK ] MessageTest.PassBeyondOrigin (0 ms)
[ RUN      ] MessageTest.ForgetToSetDest
[       OK ] MessageTest.ForgetToSetDest (0 ms)
[ RUN      ] MessageTest.SendToSelf
[       OK ] MessageTest.SendToSelf (0 ms)
[ RUN      ] MessageTest.YoYo
[       OK ] MessageTest.YoYo (0 ms)
[----------] 5 tests from MessageTest (0 ms total)

[----------] 7 tests from SourceFacilityTest
[ RUN      ] SourceFacilityTest.InitialState
[       OK ] SourceFacilityTest.InitialState (0 ms)
[ RUN      ] SourceFacilityTest.CopyFacility
[       OK ] SourceFacilityTest.CopyFacility (1 ms)
[ RUN      ] SourceFacilityTest.CopyFreshModel
[       OK ] SourceFacilityTest.CopyFreshModel (0 ms)
[ RUN      ] SourceFacilityTest.Print
[       OK ] SourceFacilityTest.Print (0 ms)
[ RUN      ] SourceFacilityTest.ReceiveMessage
[       OK ] SourceFacilityTest.ReceiveMessage (0 ms)
[ RUN      ] SourceFacilityTest.Tick
[       OK ] SourceFacilityTest.Tick (0 ms)
[ RUN      ] SourceFacilityTest.Tock
[       OK ] SourceFacilityTest.Tock (0 ms)
[----------] 7 tests from SourceFacilityTest (42 ms total)

[----------] 6 tests from GenericRepositoryTest
[ RUN      ] GenericRepositoryTest.loadModel
[       OK ] GenericRepositoryTest.loadModel (4 ms)
[ RUN      ] GenericRepositoryTest.SendMessage
[       OK ] GenericRepositoryTest.SendMessage (0 ms)
[ RUN      ] GenericRepositoryTest.ReceiveMessage
[       OK ] GenericRepositoryTest.ReceiveMessage (0 ms)
[ RUN      ] GenericRepositoryTest.ReceiveMaterial
[       OK ] GenericRepositoryTest.ReceiveMaterial (0 ms)
[ RUN      ] GenericRepositoryTest.EmplaceWaste
[       OK ] GenericRepositoryTest.EmplaceWaste (0 ms)
[ RUN      ] GenericRepositoryTest.LoadComponents
[       OK ] GenericRepositoryTest.LoadComponents (0 ms)
[----------] 6 tests from GenericRepositoryTest (4 ms total)

[----------] 4 tests from SourceFac/FacilityModelTests
[ RUN      ] SourceFac/FacilityModelTests.Print/0
[       OK ] SourceFac/FacilityModelTests.Print/0 (0 ms)
[ RUN      ] SourceFac/FacilityModelTests.CopyFacility/0
[       OK ] SourceFac/FacilityModelTests.CopyFacility/0 (0 ms)
[ RUN      ] SourceFac/FacilityModelTests.Tick/0
[       OK ] SourceFac/FacilityModelTests.Tick/0 (0 ms)
[ RUN      ] SourceFac/FacilityModelTests.Tock/0
[       OK ] SourceFac/FacilityModelTests.Tock/0 (0 ms)
[----------] 4 tests from SourceFac/FacilityModelTests (50 ms total)

[----------] Global test environment tear-down

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000050
0x0000000100296ede in testing::UnitTest::impl (this=0x0) at gtest.h:16718
16718     const internal::UnitTestImpl* impl() const { return impl_; }
(gdb) bt
#0  0x0000000100296ede in testing::UnitTest::impl (this=0x0) at gtest.h:16718
#1  0x00000001002862d3 in testing::UnitTest::test_case_to_run_count (this=0x0) at /Users/khuff/Documents/work/cyclus/wc/trunk/src/Testing/GoogleTest/gtest/gtest-all.cc:4813
#2  0x00000001002946d2 in testing::internal::PrettyUnitTestResultPrinter::OnTestIterationEnd (this=0x100a3cac0, unit_test=@0x0) at /Users/khuff/Documents/work/cyclus/wc/trunk/src/Testing/GoogleTest/gtest/gtest-all.cc:4183
#3  0x0000000100285c3a in testing::internal::TestEventRepeater::OnTestIterationEnd (this=0x100a3ca80, unit_test=@0x0, iteration=0) at /Users/khuff/Documents/work/cyclus/wc/trunk/src/Testing/GoogleTest/gtest/gtest-all.cc:4326
#4  0x000000010029693a in testing::internal::UnitTestImpl::RunAllTests (this=0x100a3c860) at /Users/khuff/Documents/work/cyclus/wc/trunk/src/Testing/GoogleTest/gtest/gtest-all.cc:5378
#5  0x00000001002969f1 in testing::UnitTest::Run (this=0x1002ca420) at /Users/khuff/Documents/work/cyclus/wc/trunk/src/Testing/GoogleTest/gtest/gtest-all.cc:5027
#6  0x000000010000c9cd in main (argc=1, argv=0x7fff5fbff420) at /Users/khuff/Documents/work/cyclus/wc/trunk/src/Testing/CyclusUnitTestDriver.cpp:35




Thanks for giving it a look, 
Katy

--
http://homepages.cae.wisc.edu/~khuff/

Katy Huff

unread,
Jan 3, 2012, 9:22:29 AM1/3/12
to googletes...@googlegroups.com
Hi all, 
After slogging through plenty of valgrind, I found my problem. Not unsurprisingly, it was related to incomplete object initialization in my setup functions. 

So, please disregard my previous request for help!

Thanks,
Katy
Reply all
Reply to author
Forward
0 new messages