searchengine/cpix/tsrc/cpixunittest/src/asynctests.cpp
changeset 24 65456528cac2
parent 14 8bd192d47aaa
equal deleted inserted replaced
23:d4d56f5e7c55 24:65456528cac2
  1221 
  1221 
  1222 
  1222 
  1223     
  1223     
  1224     void testSingleThreadIdx(Itk::TestMgr * testMgr)
  1224     void testSingleThreadIdx(Itk::TestMgr * testMgr)
  1225     {
  1225     {
  1226         char *xml_file = (char*)__FUNCTION__;
       
  1227         assert_failed = 0;
       
  1228         testMgr_ = testMgr;
  1226         testMgr_ = testMgr;
  1229 
  1227 
  1230         // cpix_setLogLevel(CPIX_LL_DEBUG);
  1228         // cpix_setLogLevel(CPIX_LL_DEBUG);
  1231 
  1229 
  1232         pthread_t
  1230         pthread_t
  1252                               &rv);
  1250                               &rv);
  1253         
  1251         
  1254         ITK_EXPECT(testMgr,
  1252         ITK_EXPECT(testMgr,
  1255                    result == 0,
  1253                    result == 0,
  1256                    "Could not join indexer thread");
  1254                    "Could not join indexer thread");
  1257         if(result != 0) 
  1255 
  1258             {
       
  1259             assert_failed = 1;
       
  1260             }
       
  1261         testResultXml(xml_file);
       
  1262         // cpix_setLogLevel(CPIX_LL_TRACE);
       
  1263 
  1256 
  1264         printStatistics();
  1257         printStatistics();
  1265     }
  1258     }
  1266     
  1259     
  1267 
  1260 
  1268 
  1261 
  1269     void testSingleThreadQry(Itk::TestMgr * testMgr)
  1262     void testSingleThreadQry(Itk::TestMgr * testMgr)
  1270     {
  1263     {
  1271         char *xml_file = (char*)__FUNCTION__;
       
  1272         assert_failed = 0;
       
  1273         testMgr_ = testMgr;
  1264         testMgr_ = testMgr;
  1274 
  1265 
  1275         // cpix_setLogLevel(CPIX_LL_DEBUG);
  1266         // cpix_setLogLevel(CPIX_LL_DEBUG);
  1276 
  1267 
  1277         pthread_t
  1268         pthread_t
  1297                               &rv);
  1288                               &rv);
  1298 
  1289 
  1299         ITK_EXPECT(testMgr,
  1290         ITK_EXPECT(testMgr,
  1300                    result == 0,
  1291                    result == 0,
  1301                    "Could not join searcher thread");
  1292                    "Could not join searcher thread");
  1302         if(result != 0) 
  1293 
  1303             {
  1294        
  1304             assert_failed = 1;
  1295         // cpix_setLogL       printStatistics();
  1305             }
       
  1306         testResultXml(xml_file);
       
  1307         // cpix_setLogLevel(CPIX_LL_TRACE);
       
  1308 
       
  1309         printStatistics();
       
  1310     }
  1296     }
  1311 
  1297 
  1312 
  1298 
  1313 
  1299 
  1314     void testMultiThreads(Itk::TestMgr * testMgr)
  1300     void testMultiThreads(Itk::TestMgr * testMgr)
  1315     {
  1301     {
  1316         char *xml_file = (char*)__FUNCTION__;
       
  1317         assert_failed = 0;
       
  1318         cleanup();
  1302         cleanup();
  1319         setup();
  1303         setup();
  1320 
  1304 
  1321         testMgr_ = testMgr;
  1305         testMgr_ = testMgr;
  1322 
  1306 
  1368                               &rv);
  1352                               &rv);
  1369         
  1353         
  1370         ITK_EXPECT(testMgr,
  1354         ITK_EXPECT(testMgr,
  1371                    result == 0,
  1355                    result == 0,
  1372                    "Could not join indexer thread");
  1356                    "Could not join indexer thread");
  1373         if(result != 0) 
  1357 
  1374             {
       
  1375             assert_failed = 1;
       
  1376             }
       
  1377         
  1358         
  1378         result = pthread_join(searcherThreadHndl,
  1359         result = pthread_join(searcherThreadHndl,
  1379                               &rv);
  1360                               &rv);
  1380 
  1361 
  1381         ITK_EXPECT(testMgr,
  1362         ITK_EXPECT(testMgr,
  1382                    result == 0,
  1363                    result == 0,
  1383                    "Could not join searcher thread");
  1364                    "Could not join searcher thread");
  1384         if(result != 0) 
  1365 
  1385             {
  1366        
  1386             assert_failed = 1;
       
  1387             }
       
  1388         testResultXml(xml_file);
       
  1389         // cpix_setLogLevel(CPIX_LL_TRACE);
  1367         // cpix_setLogLevel(CPIX_LL_TRACE);
  1390 
  1368 
  1391         printStatistics();
  1369  
  1392     }
  1370     }
  1393 
  1371 
  1394 
  1372 
  1395 private:
  1373 private:
  1396     void cleanup()
  1374     void cleanup()
  1562                             }
  1540                             }
  1563                     }
  1541                     }
  1564             }
  1542             }
  1565         catch (...)
  1543         catch (...)
  1566             {
  1544             {
  1567                 assert_failed = 1;
  1545                 
  1568                 ITK_EXPECT(testMgr_,
  1546                 ITK_EXPECT(testMgr_,
  1569                            false,
  1547                            false,
  1570                            "INDEXER: Failed indexing\n");
  1548                            "INDEXER: Failed indexing\n");
  1571                 throw;
  1549                 throw;
  1572             }
  1550             }
  1637                         ITK_DBGMSG(testMgr_, ":");
  1615                         ITK_DBGMSG(testMgr_, ":");
  1638                     }
  1616                     }
  1639             }
  1617             }
  1640         catch (...)
  1618         catch (...)
  1641             {
  1619             {
  1642                 assert_failed = 1;
  1620                 
  1643                 ITK_EXPECT(testMgr_,
  1621                 ITK_EXPECT(testMgr_,
  1644                            false,
  1622                            false,
  1645                            "SEARCHER: Failed searching\n");
  1623                            "SEARCHER: Failed searching\n");
  1646                 throw;
  1624                 throw;
  1647             }
  1625             }