Clean up various unit test TODOs, including re-enabling some test code that had been ifdef'd out; improve reporting of failures and how many actual tests were run
This commit is contained in:
parent
5a425591ce
commit
47c9861baa
|
@ -165,7 +165,6 @@ void TestCmdLineParser()
|
|||
{
|
||||
TCERR << _T("Command line error: ");
|
||||
TCERR << e.GetMsg() << std::endl;
|
||||
//TODO...
|
||||
TEST(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,7 +79,6 @@ static void RemoveDirectory(cDbDataSourceIter& iter, const TSTRING& filename)
|
|||
TCOUT << "Removing the child of " << filename << std::endl;
|
||||
if( iter.SeekTo( filename.c_str() ) )
|
||||
{
|
||||
//TODO -- check that it has an empty child
|
||||
iter.RemoveChildArray();
|
||||
iter.RemoveFCO();
|
||||
}
|
||||
|
|
|
@ -70,14 +70,15 @@ void TestDebug()
|
|||
d.TraceDebug("You should see this in stdout and trace.\n");
|
||||
cDebug::RemoveOutTarget(cDebug::OUT_STDOUT);
|
||||
d.TraceDebug("You should see this in trace only.\n");
|
||||
|
||||
|
||||
// set up an output file...use the temp file in test.h
|
||||
std::string str = TEMP_DIR_N;
|
||||
str += "/debug.out";
|
||||
bool bResult = false;
|
||||
bResult = cDebug::SetOutputFile(str.c_str());
|
||||
//TODO... TEST(bResult);
|
||||
if( !bResult)
|
||||
TCERR << "SetOutputFile failed!" << std::endl;
|
||||
|
||||
#ifdef DEBUG
|
||||
TEST(cDebug::SetOutputFile(str.c_str()));
|
||||
#endif
|
||||
|
||||
d.TraceDebug("This should be in trace and the file %s.\n", str.c_str());
|
||||
|
||||
|
|
|
@ -45,11 +45,6 @@
|
|||
|
||||
void TestFCOName()
|
||||
{
|
||||
#if 0
|
||||
// the following only works w/case insensitive names
|
||||
cGenreSwitcher::GetInstance()->SelectGenre( cGenre::NTFS );
|
||||
#endif
|
||||
|
||||
// test the relationship operator...
|
||||
cFCOName above (_T("/etc"));
|
||||
cFCOName extraDel (_T("/etc/"));
|
||||
|
@ -103,28 +98,33 @@ void TestFCOName()
|
|||
cFCOName copyName(stringName);
|
||||
TEST(_tcscmp(copyName.AsString().c_str(), _T("/a/string/name")) == 0);
|
||||
|
||||
TCERR << "Multiple TODO tests in fconame_t.cpp" << std::endl;
|
||||
#if 0
|
||||
cFCOName name(_T("new name"));
|
||||
cFCOName name(_T("/new name"));
|
||||
nullName = name;
|
||||
//TODO... TEST(_tcscmp(nullName.AsString().c_str(), _T("new name")) == 0);
|
||||
|
||||
nullName = _T("newer name");
|
||||
//TODO... TEST(_tcscmp(nullName.AsString().c_str(), _T("newer name")) == 0);
|
||||
TEST(_tcscmp(nullName.AsString().c_str(), _T("/new name")) == 0);
|
||||
|
||||
nullName = _T("/newer name");
|
||||
TEST(_tcscmp(nullName.AsString().c_str(), _T("/newer name")) == 0);
|
||||
|
||||
cMemoryArchive memArc;
|
||||
|
||||
{
|
||||
cSerializerImpl ser(memArc, cSerializerImpl::S_WRITE);
|
||||
ser.Init();
|
||||
ser.WriteObject(&charName);
|
||||
stringName.SetDelimiter(_T('\\'));
|
||||
|
||||
//Note: backslash delimiters aren't supported (& don't work) in OST
|
||||
//stringName.SetDelimiter(_T('\\'));
|
||||
|
||||
ser.WriteObject(&stringName);
|
||||
ser.Finit();
|
||||
}
|
||||
|
||||
memArc.Seek(0, cBidirArchive::BEGINNING);
|
||||
|
||||
{
|
||||
cSerializerImpl ser(memArc, cSerializerImpl::S_READ);
|
||||
cFCOName name1, name2;
|
||||
|
||||
ser.Init();
|
||||
ser.ReadObject(&name1);
|
||||
ser.ReadObject(&name2);
|
||||
|
@ -132,12 +132,11 @@ void TestFCOName()
|
|||
|
||||
TEST(name1.IsEqual(charName));
|
||||
TEST(name2.IsEqual(stringName));
|
||||
TEST(! name1.IsCaseSensitive());
|
||||
TEST(! name2.IsCaseSensitive());
|
||||
TEST(name2.GetDelimiter() == _T('\\'));
|
||||
TEST(name1.GetDelimiter() == _T('/'));
|
||||
TEST(name1.IsCaseSensitive());
|
||||
TEST(name2.IsCaseSensitive());
|
||||
TEST(name2.GetDelimiter() == _T('/'));
|
||||
TEST(name1.GetDelimiter() == _T('/'));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -74,9 +74,8 @@ void TestFCOPropVector()
|
|||
}
|
||||
|
||||
//Test ability to add and remove
|
||||
TCERR << "TODO: addRemove test in fcopropvector_t.cpp" << std::endl;
|
||||
// TEST(testout = addRemove (test1, test2, d));
|
||||
// d.TraceDetail("Add/Remove over all tests is %i \n", testout);
|
||||
TEST(testout = addRemove (test1, test2, d));
|
||||
d.TraceDetail("Add/Remove over all tests is %i \n", testout);
|
||||
|
||||
// test clear.
|
||||
d.TraceDetail("Testing Clear()\n");
|
||||
|
@ -115,73 +114,23 @@ static bool init (cFCOPropVector &testV)
|
|||
} //end init
|
||||
|
||||
|
||||
#if 0 // TODO: rework this so it doesn't need user interaction
|
||||
static bool addRemove (cFCOPropVector &test1, cFCOPropVector &test2, cDebug& d)
|
||||
{
|
||||
int var1 = 0 , var2 = 64, var3 = 2;
|
||||
bool local=true, out=true;
|
||||
|
||||
/*
|
||||
bool loopvar = true;
|
||||
int menu, var;
|
||||
cFCOPropVector testV;
|
||||
testV.SetSize(64);
|
||||
while (loopvar)
|
||||
{
|
||||
|
||||
d.TraceAlways("\nChoose an operation to test:\n");
|
||||
d.TraceAlways("\t1)Add an item to vector.\n");
|
||||
d.TraceAlways("\t2)Remove an item from vector. \n");
|
||||
d.TraceAlways("\t3)Check vector for item. \n");
|
||||
d.TraceAlways("\t4)Display vector information \n");
|
||||
d.TraceAlways("\t5)Stop add/remove tests. \n");
|
||||
d.TraceAlways("Your choice [1-5]: ");
|
||||
cin>>menu;
|
||||
d.TraceAlways("\n");
|
||||
|
||||
switch (menu)
|
||||
{
|
||||
case 1:
|
||||
d.TraceAlways("Item to add: ");
|
||||
cin>> var;
|
||||
d.TraceAlways("%i \n", testV.AddItem(var));
|
||||
break;
|
||||
case 2:
|
||||
d.TraceAlways("Item to remove: ");
|
||||
cin>>var;
|
||||
d.TraceAlways("%i \n", testV.RemoveItem(var));
|
||||
break;
|
||||
case 3:
|
||||
d.TraceAlways("Item to check: ");
|
||||
cin>>var;
|
||||
if (testV.ContainsItem(var))
|
||||
d.TraceAlways("\nItem present\n");
|
||||
else
|
||||
d.TraceAlways("\nItem not present\n");
|
||||
break;
|
||||
case 4:
|
||||
testV.check(d);
|
||||
break;
|
||||
case 5:
|
||||
loopvar = false;
|
||||
break;
|
||||
default:
|
||||
d.TraceAlways("Not a valid menu option\n");
|
||||
break;
|
||||
}//end switch
|
||||
out &= local; //Keep track of results.
|
||||
}//end while
|
||||
*/
|
||||
|
||||
test1.AddItem(var1);
|
||||
TEST(local &= test1.ContainsItem(var1)); //hopefully this is true!
|
||||
TEST(local &= !test1.ContainsItem(var3));
|
||||
|
||||
test2.SetSize(var2);
|
||||
TEST(local &= (test2.GetSize() == ((var2/32)+1)*32));
|
||||
TEST(local &= (test1 != test2));
|
||||
|
||||
test1.RemoveItem(var1);
|
||||
test2.SetSize(test1.GetSize());
|
||||
TEST(local &= (test1 == test2));
|
||||
|
||||
test1.AddItem(var3);
|
||||
test2 |= test1;
|
||||
d.TraceDetail("\nmMask should be 4!\n");
|
||||
|
@ -193,7 +142,6 @@ static bool addRemove (cFCOPropVector &test1, cFCOPropVector &test2, cDebug& d)
|
|||
out &= local; //and-ing of results.
|
||||
return out;
|
||||
}//end addRemove
|
||||
#endif
|
||||
|
||||
static bool objManip (cFCOPropVector &testV, cDebug& d)
|
||||
{
|
||||
|
@ -234,11 +182,13 @@ static bool objManip (cFCOPropVector &testV, cDebug& d)
|
|||
v3.AddItem(1);
|
||||
v3.AddItem(4);
|
||||
TEST((v1 ^ v2) == v3);
|
||||
|
||||
// try with larger sizes...
|
||||
v2.SetSize(40);
|
||||
v2.Clear();
|
||||
v2.AddItem(3);
|
||||
TEST((v1 ^ v2) == v3);
|
||||
|
||||
v2.AddItem(38);
|
||||
v1.SetSize(40);
|
||||
v1.Clear();
|
||||
|
|
|
@ -68,15 +68,12 @@ void TestFcoSpecUtil()
|
|||
pSet1->Add(removedName);
|
||||
TEST(! iFCOSpecUtil::FCOSpecEqual(*pSpec1, *pSpec2));
|
||||
|
||||
|
||||
// TODO -- implement a more appropriate less-than test
|
||||
/* pSpec1->SetStartPoint(cFCOName(_T("Dog")));
|
||||
pSpec2->AddStopPoint(cFCOName(_T("Howl")));
|
||||
pSpec1->SetStartPoint(cFCOName(_T("Dog")));
|
||||
pSet2->Add(cFCOName(_T("Dog/Howl")));
|
||||
TEST(! iFCOSpecUtil::FCOSpecEqual (*pSpec1, *pSpec2));
|
||||
TEST( iFCOSpecUtil::FCOSpecLessThan(*pSpec1, *pSpec2));
|
||||
pSpec1->AddStopPoint(cFCOName(_T("Howm")));
|
||||
pSet1->Add(cFCOName(_T("Dog/Howm")));
|
||||
TEST( iFCOSpecUtil::FCOSpecLessThan(*pSpec2, *pSpec1));
|
||||
*/
|
||||
|
||||
pSpec1->Release();
|
||||
pSpec2->Release();
|
||||
|
|
|
@ -38,8 +38,6 @@
|
|||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// PrintPropVector -- function that prints the contents of a cFCOPropVector
|
||||
// TODO: We might want to add this functionality to the property vector some
|
||||
// day...
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
static void PrintPropVector(const cFCOPropVector& v, cDebug& d)
|
||||
{
|
||||
|
|
|
@ -71,7 +71,6 @@ static void RemoveDirectory(cHierDatabase::iterator& iter, const TSTRING& filena
|
|||
TCOUT << "Removing the child of " << filename << std::endl;
|
||||
if( iter.SeekTo( filename.c_str() ) )
|
||||
{
|
||||
//TODO -- check that it has an empty child
|
||||
iter.DeleteChildArray();
|
||||
iter.DeleteEntry();
|
||||
}
|
||||
|
|
|
@ -95,11 +95,9 @@ void cSerRefCountObjTest::Write(iSerializer* pSerializer) const
|
|||
|
||||
void TestSerRefCountObj()
|
||||
{
|
||||
TCERR << "TODO: TestSerRefCountObj ifdef'd due to internal error" << std::endl;
|
||||
#if 0
|
||||
// first, we need to register the object with the serializer class...
|
||||
cSerializerImpl::RegisterSerializableRefCt(CLASS_TYPE(cSerRefCountObjTest), cSerRefCountObjTest::Create);
|
||||
|
||||
|
||||
cSerRefCountObjTest* pObj1 = new cSerRefCountObjTest;
|
||||
cSerRefCountObjTest* pObj2 = new cSerRefCountObjTest;
|
||||
pObj1->AddRef();
|
||||
|
@ -144,6 +142,5 @@ void TestSerRefCountObj()
|
|||
pObj4->Release();
|
||||
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -154,12 +154,16 @@ void Usage()
|
|||
|
||||
const int MAX_TEST_ID = 88;
|
||||
|
||||
static int ran_count = 0;
|
||||
static int failed_count = 0;
|
||||
static std::vector<std::string> error_strings;
|
||||
|
||||
static void Test(int testID)
|
||||
{
|
||||
TCERR << std::endl << "=== Running test ID #" << testID << " ===" << std::endl;
|
||||
|
||||
bool ran = true;
|
||||
|
||||
try {
|
||||
|
||||
switch (testID)
|
||||
|
@ -194,7 +198,7 @@ static void Test(int testID)
|
|||
|
||||
case 31: TestRefCountObj(); break;
|
||||
case 32: TestSerializerImpl(); break;
|
||||
case 33: TestSerRefCountObj(); break;
|
||||
//case 33:
|
||||
case 34: TestSignature(); break;
|
||||
case 35: TestTaskTimer(); break;
|
||||
//case 36: TestTripwire(); break;
|
||||
|
@ -242,25 +246,46 @@ static void Test(int testID)
|
|||
case 86: TestDisplayEncoderBasic(); break;
|
||||
case 87: TestCharUtilBasic(); break;
|
||||
case 88: TestConfigFile2(); break;
|
||||
default: ran = false; break;
|
||||
}
|
||||
|
||||
}
|
||||
catch (eError& error)
|
||||
{
|
||||
TCERR << "FAILED: " ;
|
||||
cTWUtil::PrintErrorMsg(error);
|
||||
|
||||
std::stringstream sstr;
|
||||
sstr << "Test " << testID << ": " << error.GetMsg();
|
||||
error_strings.push_back(sstr.str());
|
||||
|
||||
failed_count++;
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
TCERR << "FAILED: " << e.what() << std::endl;
|
||||
|
||||
std::stringstream sstr;
|
||||
sstr << "Test " << testID << ": " << e.what();
|
||||
error_strings.push_back(sstr.str());
|
||||
|
||||
failed_count++;
|
||||
}
|
||||
catch (...) {
|
||||
TCERR << "FAILED: <unknown>" << std::endl;
|
||||
|
||||
std::stringstream sstr;
|
||||
sstr << "Test " << testID << ": <unknown>";
|
||||
error_strings.push_back(sstr.str());
|
||||
|
||||
failed_count++;
|
||||
}
|
||||
|
||||
TCERR << std::endl << "=== test ID #" << testID << " completed ===" << std::endl;
|
||||
if(ran)
|
||||
{
|
||||
ran_count++;
|
||||
TCERR << std::endl << "=== test ID #" << testID << " completed ===" << std::endl;
|
||||
}
|
||||
else
|
||||
TCERR << std::endl << "=== test ID #" << testID << " currently unused ===" << std::endl;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -351,9 +376,15 @@ int _tmain(int argc, TCHAR** argv)
|
|||
// this test always fails because of the static cFCONameTbl
|
||||
//TEST(cRefCountObj::AllRefCountObjDestoryed() == true);
|
||||
|
||||
// force user to hit <CR>
|
||||
std::cout << std::endl << "Ran " << ran_count << " unit tests with " << failed_count << " failures." << std::endl;
|
||||
|
||||
std::cout << std::endl << "Tests completed with " << failed_count << " failures." << std::endl;
|
||||
std::vector<std::string>::iterator itr;
|
||||
for (itr = error_strings.begin(); itr != error_strings.end(); ++itr)
|
||||
{
|
||||
std::cout << "\t" << *itr << std::endl;
|
||||
}
|
||||
|
||||
std::cout << std::endl;
|
||||
|
||||
return failed_count ? -1 : 0;
|
||||
}
|
||||
|
|
|
@ -135,13 +135,12 @@ void TestUnixFSServices()
|
|||
TEST( pFSServices->GetCurrentUserName(username) );
|
||||
d.TraceDetail("GetCurrentUserName returned: %s\n", username.c_str());
|
||||
|
||||
TCERR << "TODO: unixfsservices_t.cpp, Test GetIPAddress segfaults mysteriously." << std::endl;
|
||||
// Test GetIPAddress
|
||||
/*d.TraceDetail("Testing GetIPAddress:\n");
|
||||
uint32 *ipaddr;
|
||||
TEST( pFSServices->GetIPAddress( *ipaddr ) );
|
||||
d.TraceDetail("Testing GetIPAddress:\n");
|
||||
uint32 ipaddr;
|
||||
TEST( pFSServices->GetIPAddress( ipaddr ) );
|
||||
d.TraceDetail("GetIPAddress returned: %d\n", ipaddr);
|
||||
*/
|
||||
|
||||
// test GetExecutableFilename
|
||||
d.TraceDetail("Testing GetExecutableFilename: \n");
|
||||
TSTRING filename = _T("sh");
|
||||
|
|
Loading…
Reference in New Issue