// The unit test that waits for EOS for the // transcoded file and repeate it again void TestSchedulePlay::testAlways() { klk::test::printOut( "\nTranscode test (schedule playback) ... "); m_scheduler.start(); // wait for awhile u_int count = 4; /* We can fail one time at startup and it can be not finished Thus getRunningCount() == count or getRunningCount() == count -1 or getRunningCount() == count -2 */ time_t duration = SCHEDULE_INTERVAL * (count + 2); sleep(duration); // stop all others m_scheduler.stop(); // check result in the started thread m_scheduler.checkResult(); // check running count // all should be in EOS state TaskInfoList tasks = getTaskList(); CPPUNIT_ASSERT(tasks.size() == 1); for (TaskInfoList::iterator task = tasks.begin(); task != tasks.end(); task++) { CPPUNIT_ASSERT((*task)->getRunningCount() >= count); } // test route BinaryData route = base::Utils::readWholeDataFromFile(trans::test::OUTPUTROUTE); CPPUNIT_ASSERT(route.empty() == false); }
// Recieves a data portion void TCPSocket::recv(BinaryData& data) { BOOST_ASSERT(m_sock.getDescriptor() >= 0); BOOST_ASSERT(data.empty() == false); try { int count = ::recv(m_sock.getDescriptor(), data.toVoid(), data.size(), 0); if (count < 0) { int saved_errno = errno; if (saved_errno == EPIPE) { throw ClosedConnection(__FILE__, __LINE__, getPeerName()); } else { throw Exception(__FILE__, __LINE__, "Error %d in recv(): %s", saved_errno, strerror(saved_errno)); } } else if (count == 0) { throw ClosedConnection(__FILE__, __LINE__, getPeerName()); } else if (count < static_cast<int>(data.size())) { data.resize(count); } m_rater.updateInput(static_cast<size_t>(count)); } catch(...) { disconnect(); throw; } }
BinaryData Helper::Sha1(const BinaryData& data) { ATLASSERT(!data.empty()); return Sha1(&data[0], data.size()); }
void HashDataSha1::Add(const BinaryData& data) { ATLASSERT(data.size() <= std::numeric_limits<unsigned int>::max()); if (!data.empty()) SHA1_Update(m_spContext.get(), &data[0], static_cast<unsigned int>(data.size())); }