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 <waddlesplash@gmail.com>
This commit is contained in:
Kacper Kasper 2018-08-14 17:53:28 +02:00 committed by waddlesplash
parent 6d99295f41
commit df8b692ac0
15 changed files with 67 additions and 43 deletions

View File

@ -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;
}

View File

@ -29,6 +29,8 @@
void TUnlockLooperTest::UnlockLooper1()
{
#if !defined(TEST_R5)
DEBUGGER_ESCAPE;
BHandler Handler;
Handler.UnlockLooper();
#endif

View File

@ -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;
}

View File

@ -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";

View File

@ -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;

View File

@ -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;
}

View File

@ -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";
/*

View File

@ -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);

View File

@ -253,8 +253,10 @@ HttpTest::AddTests(BTestSuite& parent)
suite.addTest(new CppUnit::TestCaller<HttpTest>(
"HttpTest::PortTest", &HttpTest::PortTest));
suite.addTest(new CppUnit::TestCaller<HttpTest>("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>("HttpTest::ProxyTest",
// &HttpTest::ProxyTest));
parent.addTest("HttpTest", &suite);
}

View File

@ -6,7 +6,9 @@
#include "CalendarViewTest.h"
#include <Application.h>
#include <CalendarView.h>
#include <Window.h>
#include <cppunit/TestCaller.h>
#include <cppunit/TestSuite.h>
@ -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());
}

View File

@ -47,7 +47,9 @@ NodeTest::Suite() {
#endif
, &NodeTest::AttrRenameTest) );
suite->addTest( new CppUnit::TestCaller<NodeTest>("BNode::Attribute Info Test", &NodeTest::AttrInfoTest) );
suite->addTest( new CppUnit::TestCaller<NodeTest>("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<NodeTest>("BNode::Attribute BString Test", &NodeTest::AttrBStringTest) );
suite->addTest( new CppUnit::TestCaller<NodeTest>("BNode::Sync Test", &NodeTest::SyncTest) );
suite->addTest( new CppUnit::TestCaller<NodeTest>("BNode::Dup Test", &NodeTest::DupTest) );
suite->addTest( new CppUnit::TestCaller<NodeTest>("BNode::Equality Test", &NodeTest::EqualityTest) );

View File

@ -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"

View File

@ -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());

View File

@ -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);

View File

@ -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);
}