/** * Just excersizes AIP. Unclear how to create pass/fail tests */ void testIterator() { OsStatus stat; OsProcess process; OsProcessIterator pi; stat = pi.findFirst(process); KNOWN_BUG("Unknown failure", "XPL-12"); CPPUNIT_ASSERT_MESSAGE("First process", stat == OS_SUCCESS); while (stat == OS_SUCCESS) { UtlString name; process.getProcessName(name); #if defined(WIN32) || defined(__hpux) /*on Windows and HP-UX, the system process is pid 0 */ CPPUNIT_ASSERT_MESSAGE("Valid PID",process.getPID() >= 0); #else CPPUNIT_ASSERT_MESSAGE("Valid PID", process.getPID() != 0); #endif CPPUNIT_ASSERT_MESSAGE("Valid Parent PID", process.getParentPID() >= 0); CPPUNIT_ASSERT_MESSAGE("Valid process name", name.data() != NULL); stat = pi.findNext(process); } }
void regInfoSubscribeWithJustUriTest() { UtlString regContactxml (" <uri>sip:[email protected]:45141</uri>\r\n" " <unknown-param name=\"+sip.instance\">\"<urn:uuid:f81d4fae" "-7dec-11d0-a765-00a0c91e6bf6>\"</unknown-param>\r\n"); KNOWN_BUG("INTERMITTENT failures", "XX-6383"); CPPUNIT_ASSERT(ContactSetTest(regContactxml, "sip:[email protected]:45141", "")); }
void regInfoSubscribeWithPathHeaderTest() { UtlString regContactxml (" <uri>sip:[email protected]:45141</uri>\r\n" " <unknown-param name=\"path\"><sip:127.0.0.1:45141></unknown-param>\r\n"); KNOWN_BUG("INTERMITTENT failures", "XX-6383"); CPPUNIT_ASSERT(ContactSetTest(regContactxml, "sip:[email protected]:45141", "<sip:127.0.0.1:45141;lr>")); }
/** * Start a client and server and send 2 messages over TCP thru them * * NOTE: This can/will fail if /etc/hosts defines localhost as ::1 (as * opposed to 127.0.0.1). */ void testWriteAndAcceptMsg() { // Create/Verify Sockets OsServerSocket* server = new OsServerSocket(50, 8021); KNOWN_BUG("This can fail if there is a port conflict on the test system", "XECS-1924"); CPPUNIT_ASSERT_MESSAGE("server socket failure", server->isOk()); OsSocket* client = new OsConnectionSocket(8021, "localhost"); CPPUNIT_ASSERT_MESSAGE("client socket failure", client->isOk()); OsSocket* serverClient = server->accept(1000); CPPUNIT_ASSERT_MESSAGE("socket server failed to accept connection", serverClient != NULL); // Begin read/write test const char* msg = "hello\n"; int len = strlen(msg) + 1; // +1 for NULL int bytesWritten = client->write(msg, len); CPPUNIT_ASSERT_EQUAL_MESSAGE("write correct number of bytes", bytesWritten, len); char recvBuf[1024]; int bytesRead = serverClient->read(recvBuf, sizeof(recvBuf) - 1); CPPUNIT_ASSERT_EQUAL_MESSAGE("read correct number of bytes", len, bytesRead); ASSERT_STR_EQUAL_MESSAGE("message same as was sent", msg, recvBuf); const char *resp = "bye"; len = strlen(resp) + 1; // +1 for NULL bytesWritten = serverClient->write(resp, len); CPPUNIT_ASSERT_EQUAL_MESSAGE("write correct number of bytes on 2nd msg", len, bytesWritten); bytesRead = client->read(recvBuf, sizeof(recvBuf) - 1); CPPUNIT_ASSERT_EQUAL_MESSAGE("read correct number of bytes on 2nd msg", len, bytesRead); CPPUNIT_ASSERT_EQUAL_MESSAGE("write correct number of bytes on 2nd msg", len, bytesWritten); ASSERT_STR_EQUAL_MESSAGE("2nd message same as was sent", resp, recvBuf); serverClient->close(); client->close(); server->close(); delete client; delete server; }
void OsTestUtilities::removeTestDir(OsPath &root) { OsStatus stat; if (OsFileSystem::exists(root)) { stat = OsFileSystem::remove(root, TRUE, TRUE); KNOWN_BUG("Fails randomly on build server and fails everytime, the first time its run on a new machine", "XPL-191"); CPPUNIT_ASSERT_MESSAGE("teardown root test dir", stat == OS_SUCCESS); } }
void testRemoveTree() { OsStatus stat; OsPath level1dir = mRootPath + OsPath::separator + "level1"; OsPath level2dir = level1dir + OsPath::separator + "level2"; OsPath level3dir = level2dir + OsPath::separator + "level3"; stat = OsFileSystem::createDir(level1dir); CPPUNIT_ASSERT(stat == OS_SUCCESS); stat = OsFileSystem::createDir(level2dir); CPPUNIT_ASSERT(stat == OS_SUCCESS); stat = OsFileSystem::createDir(level3dir); CPPUNIT_ASSERT(stat == OS_SUCCESS); OsPath filename; //now create the files under each dir for (int loop = 0; loop < 30;loop++) { UtlString levelStr = "level1_"; filename = level1dir + OsPath::separator + levelStr; if (loop > 9) { levelStr = "level2_"; filename = level2dir + OsPath::separator + levelStr; } if (loop > 19) { levelStr = "level3_"; filename = level3dir + OsPath::separator + levelStr; } char buf[10]; sprintf(buf,"%d",loop); filename.append(buf); OsFile *tmpfile = new OsFile(filename); tmpfile->touch(); delete tmpfile; } //now delete the tree OsPath delPath(level1dir); stat = OsFileSystem::remove(delPath, FALSE, TRUE); CPPUNIT_ASSERT_MESSAGE("Should fail to delete recursively", stat != OS_SUCCESS); KNOWN_BUG("INTERMITTENT failures", "XECS-1588"); stat = OsFileSystem::remove(delPath, TRUE, TRUE); CPPUNIT_ASSERT_MESSAGE("Should succeed to delete recursively", stat == OS_SUCCESS); }
void testLaunch() { OsStatus stat; UtlString appName = "ping"; UtlString params[10]; params[0] = "127.0.0.1"; #ifdef _WIN32 //need to do this only on win32, linux already does this by default params[1] = "-t"; #endif OsProcess process; UtlString envKey = "TESTKEY1"; UtlString envValue = "TESTVALUE1"; process.setEnv(envKey,envValue); envKey = "TESTKEY2"; envValue ="TESTVALUE2"; process.setEnv(envKey,envValue); envKey = "TESTKEY3"; envValue = "TESTVALUE3"; process.setEnv(envKey,envValue); OsPath startupDir = "."; //std::cout << "Launching process: " << appName.data() << std::endl; stat = process.launch(appName,params,startupDir); CPPUNIT_ASSERT_MESSAGE("Launched application", stat == OS_SUCCESS); CPPUNIT_ASSERT_MESSAGE("Application running", process.isRunning()); int priority; process.setPriority(1); process.getPriority(priority); KNOWN_BUG("INTERMITTENT on F8 with 64Bit changes", "XECS-480"); CPPUNIT_ASSERT_MESSAGE("Set priority ok", priority == 1); OsProcess newProcess; stat = OsProcess::getByPID(process.getPID(), newProcess); CPPUNIT_ASSERT_MESSAGE("Got process pid ok", stat == OS_SUCCESS); //std::cout << "Waiting 5 secs before killing process..." << std::endl; OsTask::delay(5000); stat = newProcess.kill(); CPPUNIT_ASSERT_MESSAGE("Able to kill process", stat == OS_SUCCESS); }
void Mksck_DecRefc(Mksck *mksck) { uint32 oldRefc; DMB(); do { while ((oldRefc = ATOMIC_GETO(mksck->refCount)) == 1) { MksckPage *mksckPage = Mksck_ToSharedPage(mksck); while (Mutex_Lock(&mksckPage->mutex, MutexModeEX) < 0) ; if (ATOMIC_SETIF(mksck->refCount, 0, 1)) { #if 0 KNOWN_BUG(MVP-1349); PRINTK("Mksck_DecRefc: %08X " \ "shutDown %u, foundEmpty %u, " \ "foundFull %u, blocked %u\n", mksck->addr.addr, mksck->shutDown, mksck->foundEmpty, mksck->foundFull, ATOMIC_GETO(mksck->mutex.blocked)); #endif ASSERT(mksck->peer == 0); Mutex_Unlock(&mksckPage->mutex, MutexModeEX); MksckPage_DecRefc(mksckPage); return; } Mutex_Unlock(&mksckPage->mutex, MutexModeEX); } ASSERT(oldRefc != 0); } while (!ATOMIC_SETIF(mksck->refCount, oldRefc - 1, oldRefc)); }
void testShutdownBlocking() { pid_t myPID = OsProcess::getCurrentPID(); int startingThreads = getNumThreads(myPID); // Simple invite message from siptest/src/siptest/invite.txt const char* SimpleMessage = "INVITE sip:[email protected] SIP/2.0\r\n" "Route: <sip:[email protected]:5064;lr>\r\n" "From: <sip:[email protected];user=phone>;tag=bbb\r\n" "To: <sip:[email protected]:3000;user=phone>\r\n" "Call-Id: 8\r\n" "Cseq: 1 INVITE\r\n" "Content-Length: 0\r\n" "\r\n"; SipMessage testMsg( SimpleMessage, strlen( SimpleMessage ) ); for(int i = 0; i < SHUTDOWN_TEST_ITERATIONS; ++i) { { SipLineMgr lineMgr; SipRefreshMgr refreshMgr; lineMgr.StartLineMgr(); lineMgr.initializeRefreshMgr( &refreshMgr ); SipUserAgent sipUA( 5090 ,5090 ,5091 ,NULL // default publicAddress ,NULL // default defaultUser ,"127.0.0.1" // default defaultSipAddress ,NULL // default sipProxyServers ,NULL // default sipDirectoryServers ,NULL // default sipRegistryServers ,NULL // default authenticationScheme ,NULL // default authenicateRealm ,NULL // default authenticateDb ,NULL // default authorizeUserIds ,NULL // default authorizePasswords ,&lineMgr ); sipUA.start(); refreshMgr.init(&sipUA); sipUA.send(testMsg); // Wait long enough for some stack timeouts/retansmits to occur OsTask::delay(10000); // 10 seconds // Shut down the tasks in reverse order. refreshMgr.requestShutdown(); sipUA.shutdown(TRUE); lineMgr.requestShutdown(); CPPUNIT_ASSERT(sipUA.isShutdownDone()); OsTimerTask::destroyTimerTask(); OsStunAgentTask::releaseInstance(); } // Test to see that all the threads created by the above operations // get properly shut down. int numThreads = getNumThreads(myPID); OsSysLog::add(FAC_SIP, PRI_NOTICE, "SipUserAgentTest::testShutdownBlocking " "numThreads=%d startingThreads=%d", numThreads, startingThreads); KNOWN_BUG("XECS-48", "Some threads are not cleaned up?"); CPPUNIT_ASSERT(numThreads <= startingThreads); } };