--- a/searchengine/cpix/tsrc/cpixunittest/src/whiteboxtests.cpp Fri May 14 16:57:37 2010 +0300
+++ b/searchengine/cpix/tsrc/cpixunittest/src/whiteboxtests.cpp Thu May 27 13:59:44 2010 +0300
@@ -36,15 +36,19 @@
#include "cpixhits.h"
#include "idxdbdelta.h"
+#include "std_log_result.h"
+
void TestBaseAppClassCollision(Itk::TestMgr * testMgr)
{
cpix_Result
result;
-
+ char *xml_file = (char*)__FUNCTION__;
+ assert_failed = 0;
cpix_IdxDb_defineVolume(&result,
SMS_QBASEAPPCLASS,
NULL);
-
+ if(!cpix_Succeeded(&result))
+ assert_failed = 1;
ITK_ASSERT(testMgr,
cpix_Succeeded(&result),
"Definition of volume (%s, %s) failed.",
@@ -54,7 +58,8 @@
cpix_IdxDb_defineVolume(&result,
SMS_QBASEAPPCLASS,
NULL);
-
+ if(!cpix_Succeeded(&result))
+ assert_failed = 1;
ITK_ASSERT(testMgr,
cpix_Succeeded(&result),
"Re-definition of identical volume (%s, %s) failed.",
@@ -67,7 +72,8 @@
cpix_IdxDb_defineVolume(&result,
SMS_QBASEAPPCLASS,
dummyPath);
-
+ if(!cpix_Succeeded(&result))
+ assert_failed = 1;
ITK_ASSERT(testMgr,
cpix_Failed(&result),
"Volume (%s, %s) definition should have failed.",
@@ -75,6 +81,7 @@
dummyPath);
cpix_IdxDb_undefineVolume("@0:root foo bar");
+ testResultXml(xml_file);
}
@@ -87,10 +94,13 @@
{
cpix_Result
result;
-
+ char *xml_file = (char*)__FUNCTION__;
+ assert_failed = 0;
cpix_IdxDb_defineVolume(&result,
DUMMY_QBASEAPPCLASS,
DUMMY_IDXDBPATH);
+ if(!cpix_Succeeded(&result))
+ assert_failed = 1;
ITK_ASSERT(testMgr,
cpix_Succeeded(&result),
"Defining volume %s, %s failed.",
@@ -100,12 +110,14 @@
cpix_IdxDb_defineVolume(&result,
DUMMY2_QBASEAPPCLASS,
DUMMY_IDXDBPATH);
-
+ if(!cpix_Succeeded(&result))
+ assert_failed = 1;
ITK_ASSERT(testMgr,
cpix_Failed(&result),
"Defining volume %s, %s should have failed.",
DUMMY2_QBASEAPPCLASS,
DUMMY_IDXDBPATH);
+ testResultXml(xml_file);
}
@@ -114,6 +126,8 @@
{
cpix_Result
result;
+ char *xml_file = (char*)__FUNCTION__;
+ assert_failed = 0;
cpix_IdxDb_defineVolume(&result,
SMS_QBASEAPPCLASS,
@@ -127,6 +141,7 @@
if (cpix_Succeeded(&result))
{
+ assert_failed = 1;
cpix_IdxDb_releaseDb(idxDb);
}
}
@@ -148,11 +163,16 @@
{
cpix_IdxDb_releaseDb(idxDb);
}
+ else
+ {
+ assert_failed = 1;
+ }
ITK_ASSERT(testMgr,
cpix_Failed(&result),
"Opening IdxDb(%s) should have failed now.",
SMS_QBASEAPPCLASS);
+ testResultXml(xml_file);
}
const wchar_t * QryStrings[] = {
@@ -183,7 +203,8 @@
void TestUnifiedSearchParse(Itk::TestMgr * )
{
using namespace std;
-
+ char *xml_file = (char*)__FUNCTION__;
+ assert_failed = 0;
printf("Whitebox testing parsing of unified search syntax\n\n");
const wchar_t
@@ -216,12 +237,15 @@
qc.innerQryStr_.c_str());
} catch (CpixExc & cpixExc) {
+ assert_failed = 1;
printf("Failed to parse: %S\n",
cpixExc.wWhat());
} catch (...) {
+ assert_failed = 1;
printf("Failed t parse: for unknown reasons\n");
}
}
+ testResultXml(xml_file);
}
@@ -310,6 +334,8 @@
void testAddSome(Itk::TestMgr * mgr)
{
+ char *xml_file = (char*)__FUNCTION__;
+ assert_failed = 0;
std::wstring
firstBody,
secondBody;
@@ -336,6 +362,7 @@
}
}
util_->flush();
+ testResultXml(xml_file);
}
@@ -344,13 +371,15 @@
cpix_Hits
* hits = cpix_IdxDb_search(util_->idxDb(),
query_);
-
+ char *xml_file = (char*)__FUNCTION__;
+ assert_failed = 0;
if (cpix_Failed(util_->idxDb()))
{
ITK_EXPECT(mgr,
false,
"Failed to search index");
cpix_ClearError(util_->idxDb());
+ assert_failed = 1;
}
else
{
@@ -362,7 +391,10 @@
"Did not get expected hitcounts (%d), but %d",
expectedHitCount_,
hitsLength);
-
+ if(expectedHitCount_ != hitsLength)
+ {
+ assert_failed = 1;
+ }
printf("Got %d hits\n",
hitsLength);
@@ -390,6 +422,7 @@
}
cpix_Hits_destroy( hits );
+ testResultXml(xml_file);
}
@@ -989,7 +1022,8 @@
{
using namespace lucene::index;
using namespace std;
-
+ char *xml_file = (char*)__FUNCTION__;
+ assert_failed = 0;
printf("Start state of index:\n");
{
@@ -1014,6 +1048,7 @@
{
if (!reader_.isOpen())
{
+ assert_failed = 1;
ITK_PANIC("Reader should be open");
}
@@ -1031,11 +1066,13 @@
ITK_EXPECT(mgr,
result == 1,
"Should have deleted exactly one doc");
-
+ if(result != 0)
+ assert_failed = 1;
printf("... deleted doc %S\n",
DeltaSmsesToDelete[i]);
}
}
+ testResultXml(xml_file);
}
@@ -1085,7 +1122,8 @@
{
using namespace lucene::search;
using namespace Cpix::Impl;
-
+ char *xml_file = (char*)__FUNCTION__;
+ assert_failed = 0;
// The TestCommitStageAction instance we give is to emulate
// interrupting the committing-to-disk process at different
// stages, and see if we can recover whatever information can
@@ -1127,10 +1165,15 @@
"Complete, committed, updated idx dir should exist (%s): %s",
test_.c_str(),
deltaIdxDbPath.c_str());
+ if(!Cpt::directoryexists(deltaIdxDbPath.c_str()))
+ {
+ assert_failed = 1;
+ }
}
}
else
{
+ assert_failed = 1;
ITK_EXPECT(mgr,
false,
"Should have been interrupted at stage %d",
@@ -1139,6 +1182,7 @@
}
catch (TestCommitStageExc & exc)
{
+ assert_failed = 1;
if (exc.commitStage_ == targetCommitStage_)
{
properlyInterrupted = true;
@@ -1158,12 +1202,19 @@
|| insertBuf_->isEmpty()
|| targetCommitStage_ < CS_IBUF_COMMITTING),
"Expected the (test) insert buffer to be closed");
-
+ if(!properlyInterrupted || (haveReader_ || reader_.isOpen() ) || !((insertBuf_ == NULL
+ || insertBuf_->isEmpty() || targetCommitStage_ < CS_IBUF_COMMITTING)))
+ {
+ assert_failed = 1;
+ }
+ testResultXml(xml_file);
}
void testRecoveredStage(Itk::TestMgr * )
{
+ char *xml_file = (char*)__FUNCTION__;
+ assert_failed = 0;
if (reader_.isOpen())
{
printf("Reader (either the original or the re-created):\n");
@@ -1180,6 +1231,7 @@
printf("The recovered state of index:\n");
searchAndPrint(reader_.getReader());
+ testResultXml(xml_file);
}
@@ -1375,11 +1427,14 @@
* whiteBox = new SuiteTester("whitebox");
whiteBox->add("baccoll",
- &TestBaseAppClassCollision);
+ &TestBaseAppClassCollision,
+ "baccoll");
whiteBox->add("idpcoll",
- &TestIdxDbPathCollision);
+ &TestIdxDbPathCollision,
+ "idpcoll");
whiteBox->add("scrapall",
- &TestScrapAll);
+ &TestScrapAll,
+ "scrapall");
whiteBox->add("unifiedSearchParse",
&TestUnifiedSearchParse,