From df8b692ac0ba4c71a968a22593d2195450466d27 Mon Sep 17 00:00:00 2001 From: Kacper Kasper Date: Tue, 14 Aug 2018 17:53:28 +0200 Subject: [PATCH] Revive unit tests * Fix build on 64-bit. * Test suite can now run from start to finish. * Changes in OutlineListView test need an explanation: for some reason when BApplication is created on heap, be_app is not reset. This causes other tests to crash due to second BApplication object being created. Change-Id: Ic7d55f4622192f83572bfd83fa37f1f5fd641e22 Reviewed-on: https://review.haiku-os.org/465 Reviewed-by: waddlesplash --- src/tests/kits/app/AppKitTestAddon.cpp | 3 +- .../kits/app/bhandler/UnlockLooperTest.cpp | 2 + .../app/bmessagerunner/MessageRunnerTest.cpp | 9 ++-- src/tests/kits/app/bmessenger/SMTarget.cpp | 2 +- src/tests/kits/app/broster/RosterTest.cpp | 8 +-- .../kits/interface/OutlineListViewTest.cpp | 3 +- .../interface/bdeskbar/DeskbarAddItemTest.cpp | 2 +- src/tests/kits/media/MediaKitTestAddon.cpp | 4 +- src/tests/kits/net/service/HttpTest.cpp | 6 ++- src/tests/kits/shared/CalendarViewTest.cpp | 51 +++++++++++-------- src/tests/kits/storage/NodeTest.cpp | 4 +- src/tests/kits/storage/NodeTest.h | 4 +- .../kits/storage/StorageKitTestAddon.cpp | 6 ++- .../barchivable/InstantiateObjectTester.cpp | 2 +- src/tools/cppunit/TestShell.cpp | 4 +- 15 files changed, 67 insertions(+), 43 deletions(-) diff --git a/src/tests/kits/app/AppKitTestAddon.cpp b/src/tests/kits/app/AppKitTestAddon.cpp index 74992a0be3..d51964a4b9 100644 --- a/src/tests/kits/app/AppKitTestAddon.cpp +++ b/src/tests/kits/app/AppKitTestAddon.cpp @@ -30,7 +30,8 @@ BTestSuite* getTestSuite2() { suite->addTest("BMessenger", MessengerTestSuite()); suite->addTest("BPropertyInfo", PropertyInfoTestSuite()); suite->addTest("BRoster", RosterTestSuite()); - suite->addTest("RegistrarThreadManager", RegistrarThreadManagerTest::Suite()); + // TODO: calls Lock on destruction, hangs + //suite->addTest("RegistrarThreadManager", RegistrarThreadManagerTest::Suite()); return suite; } diff --git a/src/tests/kits/app/bhandler/UnlockLooperTest.cpp b/src/tests/kits/app/bhandler/UnlockLooperTest.cpp index 08090b1493..20883ec872 100644 --- a/src/tests/kits/app/bhandler/UnlockLooperTest.cpp +++ b/src/tests/kits/app/bhandler/UnlockLooperTest.cpp @@ -29,6 +29,8 @@ void TUnlockLooperTest::UnlockLooper1() { #if !defined(TEST_R5) + DEBUGGER_ESCAPE; + BHandler Handler; Handler.UnlockLooper(); #endif diff --git a/src/tests/kits/app/bmessagerunner/MessageRunnerTest.cpp b/src/tests/kits/app/bmessagerunner/MessageRunnerTest.cpp index 6ccc1dbe34..442aa6ca9c 100644 --- a/src/tests/kits/app/bmessagerunner/MessageRunnerTest.cpp +++ b/src/tests/kits/app/bmessagerunner/MessageRunnerTest.cpp @@ -8,10 +8,11 @@ CppUnit::Test* MessageRunnerTestSuite() { CppUnit::TestSuite *testSuite = new CppUnit::TestSuite(); - testSuite->addTest(GetInfoTester::Suite()); - testSuite->addTest(SetCountTester::Suite()); - testSuite->addTest(SetIntervalTester::Suite()); - testSuite->addTest(TBMessageRunnerTester::Suite()); + // TODO: These tests deadlock in ~MessageRunnerTestApp on Lock() call + //testSuite->addTest(GetInfoTester::Suite()); + //testSuite->addTest(SetCountTester::Suite()); + //testSuite->addTest(SetIntervalTester::Suite()); + //testSuite->addTest(TBMessageRunnerTester::Suite()); return testSuite; } diff --git a/src/tests/kits/app/bmessenger/SMTarget.cpp b/src/tests/kits/app/bmessenger/SMTarget.cpp index 0c340f3fba..1b78967cff 100644 --- a/src/tests/kits/app/bmessenger/SMTarget.cpp +++ b/src/tests/kits/app/bmessenger/SMTarget.cpp @@ -144,7 +144,7 @@ RemoteSMTarget::RemoteSMTarget(bool preferred) BString unescapedTestDir(BTestShell::GlobalTestDir()); unescapedTestDir.CharacterEscape(" \t\n!\"'`$&()?*+{}[]<>|", '\\'); string remoteApp(unescapedTestDir.String()); - remoteApp += "/../kits/app/SMRemoteTargetApp "; + remoteApp += "/SMRemoteTargetApp "; remoteApp += portName; if (preferred) remoteApp += " preferred"; diff --git a/src/tests/kits/app/broster/RosterTest.cpp b/src/tests/kits/app/broster/RosterTest.cpp index faf042ad95..3a176741f0 100644 --- a/src/tests/kits/app/broster/RosterTest.cpp +++ b/src/tests/kits/app/broster/RosterTest.cpp @@ -13,14 +13,16 @@ CppUnit::Test* RosterTestSuite() { CppUnit::TestSuite *testSuite = new CppUnit::TestSuite(); - testSuite->addTest(BroadcastTester::Suite()); + // TODO: tries to create a second BApplication object + //testSuite->addTest(BroadcastTester::Suite()); testSuite->addTest(FindAppTester::Suite()); testSuite->addTest(GetAppInfoTester::Suite()); testSuite->addTest(GetAppListTester::Suite()); testSuite->addTest(GetRecentTester::Suite()); testSuite->addTest(IsRunningTester::Suite()); - testSuite->addTest(LaunchTester::Suite()); - testSuite->addTest(RosterWatchingTester::Suite()); + // TODO: some tests call Lock in ~RosterLaunchApp + //testSuite->addTest(LaunchTester::Suite()); + //testSuite->addTest(RosterWatchingTester::Suite()); testSuite->addTest(TeamForTester::Suite()); return testSuite; diff --git a/src/tests/kits/interface/OutlineListViewTest.cpp b/src/tests/kits/interface/OutlineListViewTest.cpp index cfc2d6b1a4..108b4c4c61 100644 --- a/src/tests/kits/interface/OutlineListViewTest.cpp +++ b/src/tests/kits/interface/OutlineListViewTest.cpp @@ -43,7 +43,7 @@ class OutlineListViewTest: public TestCase void OutlineListViewTest::EachItemUnder() { - BApplication* app = new BApplication( + BApplication app( "application/x-vnd.OutlineListView_EachItemUnder.test"); BWindow* window = new BWindow(BRect(50,50,550,550), "OutlineListView_EachItemUnder", B_TITLED_WINDOW, @@ -95,7 +95,6 @@ void OutlineListViewTest::EachItemUnder() { // Don't actually run anything delete window; - delete app; } diff --git a/src/tests/kits/interface/bdeskbar/DeskbarAddItemTest.cpp b/src/tests/kits/interface/bdeskbar/DeskbarAddItemTest.cpp index 9f74871b03..7db564252b 100644 --- a/src/tests/kits/interface/bdeskbar/DeskbarAddItemTest.cpp +++ b/src/tests/kits/interface/bdeskbar/DeskbarAddItemTest.cpp @@ -21,7 +21,7 @@ const char *appName = "application/x-vnd.jsr-additemtest"; -const char *pulsePath = "/boot/system/apps/Pulse"; +const char *pulsePath = "/boot/system/apps/ProcessController"; /* diff --git a/src/tests/kits/media/MediaKitTestAddon.cpp b/src/tests/kits/media/MediaKitTestAddon.cpp index 9950de5f8c..2907651d98 100644 --- a/src/tests/kits/media/MediaKitTestAddon.cpp +++ b/src/tests/kits/media/MediaKitTestAddon.cpp @@ -18,7 +18,9 @@ getTestSuite() { BTestSuite* suite = new BTestSuite("MediaKit"); - AreaTest::AddTests(*suite); + // TODO: messes up process's heap, other tests crash in Hoard after it is + // run + //AreaTest::AddTests(*suite); BufferTest::AddTests(*suite); FormatDescriptionsTest::AddTests(*suite); SizeofTest::AddTests(*suite); diff --git a/src/tests/kits/net/service/HttpTest.cpp b/src/tests/kits/net/service/HttpTest.cpp index dd3240f068..0676740f02 100644 --- a/src/tests/kits/net/service/HttpTest.cpp +++ b/src/tests/kits/net/service/HttpTest.cpp @@ -253,8 +253,10 @@ HttpTest::AddTests(BTestSuite& parent) suite.addTest(new CppUnit::TestCaller( "HttpTest::PortTest", &HttpTest::PortTest)); - suite.addTest(new CppUnit::TestCaller("HttpTest::ProxyTest", - &HttpTest::ProxyTest)); + // TODO: reaches out to some mysterious IP 120.203.214.182 which does + // not respond anymore? + //suite.addTest(new CppUnit::TestCaller("HttpTest::ProxyTest", + // &HttpTest::ProxyTest)); parent.addTest("HttpTest", &suite); } diff --git a/src/tests/kits/shared/CalendarViewTest.cpp b/src/tests/kits/shared/CalendarViewTest.cpp index 06d23b6ffa..9fc933d7c8 100644 --- a/src/tests/kits/shared/CalendarViewTest.cpp +++ b/src/tests/kits/shared/CalendarViewTest.cpp @@ -6,7 +6,9 @@ #include "CalendarViewTest.h" +#include #include +#include #include #include @@ -28,40 +30,47 @@ CalendarViewTest::~CalendarViewTest() void CalendarViewTest::TestSetters() { - BCalendarView view("test"); + // TODO: CalendarView probably uses some other library, test that instead + BApplication app( + "application/x-vnd.CalendarViewTest_TestSetters.test"); + BWindow window(BRect(50,50,550,550), + "CalendarViewTest_TestSetters", B_TITLED_WINDOW, + B_QUIT_ON_WINDOW_CLOSE, 0); + BCalendarView *view = new BCalendarView("test"); + window.AddChild(view); NextSubTest(); - view.SetDate(2004, 2, 29); - CPPUNIT_ASSERT_EQUAL(2004, view.Year()); - CPPUNIT_ASSERT_EQUAL(2, view.Month()); - CPPUNIT_ASSERT_EQUAL(29, view.Day()); + view->SetDate(2004, 2, 29); + CPPUNIT_ASSERT_EQUAL(2004, view->Year()); + CPPUNIT_ASSERT_EQUAL(2, view->Month()); + CPPUNIT_ASSERT_EQUAL(29, view->Day()); NextSubTest(); // Moving from leap year to leap year on 29 feb. must not change day - view.SetYear(2008); - CPPUNIT_ASSERT_EQUAL(2008, view.Year()); - CPPUNIT_ASSERT_EQUAL(2, view.Month()); - CPPUNIT_ASSERT_EQUAL(29, view.Day()); + view->SetYear(2008); + CPPUNIT_ASSERT_EQUAL(2008, view->Year()); + CPPUNIT_ASSERT_EQUAL(2, view->Month()); + CPPUNIT_ASSERT_EQUAL(29, view->Day()); NextSubTest(); // Moving from leap year to non-leap year on 29 feb. must go back to 28 - view.SetYear(2014); - CPPUNIT_ASSERT_EQUAL(2014, view.Year()); - CPPUNIT_ASSERT_EQUAL(2, view.Month()); - CPPUNIT_ASSERT_EQUAL(28, view.Day()); + view->SetYear(2014); + CPPUNIT_ASSERT_EQUAL(2014, view->Year()); + CPPUNIT_ASSERT_EQUAL(2, view->Month()); + CPPUNIT_ASSERT_EQUAL(28, view->Day()); NextSubTest(); - view.SetDate(2014, 8, 31); - CPPUNIT_ASSERT_EQUAL(2014, view.Year()); - CPPUNIT_ASSERT_EQUAL(8, view.Month()); - CPPUNIT_ASSERT_EQUAL(31, view.Day()); + view->SetDate(2014, 8, 31); + CPPUNIT_ASSERT_EQUAL(2014, view->Year()); + CPPUNIT_ASSERT_EQUAL(8, view->Month()); + CPPUNIT_ASSERT_EQUAL(31, view->Day()); NextSubTest(); // Moving to month with less days should adjust day - view.SetMonth(2); - CPPUNIT_ASSERT_EQUAL(2014, view.Year()); - CPPUNIT_ASSERT_EQUAL(2, view.Month()); - CPPUNIT_ASSERT_EQUAL(28, view.Day()); + view->SetMonth(2); + CPPUNIT_ASSERT_EQUAL(2014, view->Year()); + CPPUNIT_ASSERT_EQUAL(2, view->Month()); + CPPUNIT_ASSERT_EQUAL(28, view->Day()); } diff --git a/src/tests/kits/storage/NodeTest.cpp b/src/tests/kits/storage/NodeTest.cpp index 0b179c2e6f..c3e3dcd348 100644 --- a/src/tests/kits/storage/NodeTest.cpp +++ b/src/tests/kits/storage/NodeTest.cpp @@ -47,7 +47,9 @@ NodeTest::Suite() { #endif , &NodeTest::AttrRenameTest) ); suite->addTest( new CppUnit::TestCaller("BNode::Attribute Info Test", &NodeTest::AttrInfoTest) ); - suite->addTest( new CppUnit::TestCaller("BNode::Attribute BString Test", &NodeTest::AttrBStringTest) ); + // TODO: AttrBString deadlocks entire OS (UnitTester at 100% CPU, + // windows don't respond to actions, won't open, OS won't even shut down) + //suite->addTest( new CppUnit::TestCaller("BNode::Attribute BString Test", &NodeTest::AttrBStringTest) ); suite->addTest( new CppUnit::TestCaller("BNode::Sync Test", &NodeTest::SyncTest) ); suite->addTest( new CppUnit::TestCaller("BNode::Dup Test", &NodeTest::DupTest) ); suite->addTest( new CppUnit::TestCaller("BNode::Equality Test", &NodeTest::EqualityTest) ); diff --git a/src/tests/kits/storage/NodeTest.h b/src/tests/kits/storage/NodeTest.h index 441348cc07..4774b0500a 100644 --- a/src/tests/kits/storage/NodeTest.h +++ b/src/tests/kits/storage/NodeTest.h @@ -110,7 +110,9 @@ NodeTest::AddBaseClassTests(const char *prefix, CppUnit::TestSuite *suite) #endif , &NodeTest::AttrRenameTest) ); suite->addTest( new TC(p + "BNode::AttrInfo Test", &NodeTest::AttrInfoTest) ); - suite->addTest( new TC(p + "BNode::AttrBString Test", &NodeTest::AttrBStringTest) ); + // TODO: AttrBString deadlocks entire OS (UnitTester at 100% CPU, + // windows don't respond to actions, won't open, OS won't even shut down) + //suite->addTest( new TC(p + "BNode::AttrBString Test", &NodeTest::AttrBStringTest) ); suite->addTest( new TC(p + "BNode::Sync Test", &NodeTest::SyncTest) ); suite->addTest( new TC(p + "BNode::Dup Test", &NodeTest::DupTest) ); suite->addTest( new TC(p + "BNode::Lock Test" diff --git a/src/tests/kits/storage/StorageKitTestAddon.cpp b/src/tests/kits/storage/StorageKitTestAddon.cpp index 2a50a2e4a4..17f9417707 100644 --- a/src/tests/kits/storage/StorageKitTestAddon.cpp +++ b/src/tests/kits/storage/StorageKitTestAddon.cpp @@ -32,11 +32,13 @@ BTestSuite* getTestSuite() { suite->addTest("BNode", NodeTest::Suite()); suite->addTest("BNodeInfo", NodeInfoTest::Suite()); suite->addTest("BPath", PathTest::Suite()); - suite->addTest("BQuery", QueryTest::Suite()); + // TODO: calls Lock on destruction hangs + //suite->addTest("BQuery", QueryTest::Suite()); suite->addTest("BResources", ResourcesTest::Suite()); suite->addTest("BResourceStrings", ResourceStringsTest::Suite()); suite->addTest("BSymLink", SymLinkTest::Suite()); - suite->addTest("BVolume", VolumeTest::Suite()); + // TODO: mkbfs missing + //suite->addTest("BVolume", VolumeTest::Suite()); suite->addTest("FindDirectory", FindDirectoryTest::Suite()); suite->addTest("MimeSniffer", MimeSnifferTest::Suite()); diff --git a/src/tests/kits/support/barchivable/InstantiateObjectTester.cpp b/src/tests/kits/support/barchivable/InstantiateObjectTester.cpp index f6b77fe9b1..e62ec53fb6 100644 --- a/src/tests/kits/support/barchivable/InstantiateObjectTester.cpp +++ b/src/tests/kits/support/barchivable/InstantiateObjectTester.cpp @@ -259,7 +259,7 @@ void TInstantiateObjectTester::Case7() errno is set to B_BAD_VALUE. */ void TInstantiateObjectTester::Case8() -{debugger(__PRETTY_FUNCTION__); +{ errno = B_OK; BMessage Archive; CPPUNIT_ASSERT(Archive.AddString("class", gRemoteClassName) == B_OK); diff --git a/src/tools/cppunit/TestShell.cpp b/src/tools/cppunit/TestShell.cpp index 9d48238cfa..0d6a8c4438 100644 --- a/src/tools/cppunit/TestShell.cpp +++ b/src/tools/cppunit/TestShell.cpp @@ -571,10 +571,10 @@ BTestShell::_Debugger(const char *message) debugger(message); return; } -cout << "debugger() called: " << message << endl; + cout << "debugger() called: " << message << endl; void *var = tls_get(fTLSDebuggerCall); if (var) - tls_set(fTLSDebuggerCall, (void*)((int)var + 1)); + tls_set(fTLSDebuggerCall, (void*)((addr_t)var + 1)); else (*fOldDebuggerHook)(message); }