Exemple #1
0
void KUrlCompletionTest::testLocalURL()
{
    // Completion from URL
    kDebug() ;
    KUrl url( m_dirURL.toLocalFile() + "file" );
    m_completion->makeCompletion( url.prettyUrl() );
    waitForCompletion();
    QStringList comp1all = m_completion->allMatches();
    kDebug() << comp1all;
    assert( comp1all.count() == 3 );
    kDebug() << "Looking for" << m_dirURL.prettyUrl() + "file1";
    assert( comp1all.contains( m_dirURL.prettyUrl() + "file1" ) );
    assert( comp1all.contains( m_dirURL.prettyUrl() + "file_subdir/" ) );
    QString filehash = m_dirURL.prettyUrl() + "file%23a";
    assert( comp1all.contains( filehash ) );
    QString filehashPath = m_completion->replacedPath( filehash ); // note that it returns a path!!
    kDebug() << filehashPath;
    assert( filehashPath == m_dirURL.toLocalFile() + "file#a" );

    // Completion from URL with no match
    url = KUrl( m_dirURL.toLocalFile() + "foobar" );
    kDebug() << "makeCompletion(" << url << ")";
    QString comp2 = m_completion->makeCompletion( url.prettyUrl() );
    assert( comp2.isEmpty() );
    waitForCompletion();
    assert( m_completion->allMatches().isEmpty() );

    // Completion from URL with a ref -> no match
    url = KUrl( m_dirURL.toLocalFile() + 'f' );
    url.setRef( "ref" );
    kDebug() << "makeCompletion(" << url << ")";
    m_completion->makeCompletion( url.prettyUrl() );
    waitForCompletion();
    assert( m_completion->allMatches().isEmpty() );
}
Exemple #2
0
void KUrlCompletionTest::testLocalRelativePath()
{
    kDebug() ;
    // Completion from relative path, with two matches
    m_completion->makeCompletion( "f" );
    waitForCompletion();
    QStringList comp1all = m_completion->allMatches();
    kDebug() << comp1all;
    assert( comp1all.count() == 3 );
    assert( comp1all.contains( "file1" ) );
    assert( comp1all.contains( "file#a" ) );
    assert( comp1all.contains( "file_subdir/" ) );
    QString comp1 = m_completion->replacedPath( "file1" ); // like KUrlRequester does
    assert( comp1 == "file1" );

    // Completion from relative path
    kDebug() << endl << "now completing on 'file#'";
    m_completion->makeCompletion( "file#" );
    waitForCompletion();
    QStringList compall = m_completion->allMatches();
    kDebug() << compall;
    assert( compall.count() == 1 );
    assert( compall.first() == "file#a" );
    QString comp2 = m_completion->replacedPath( compall.first() ); // like KUrlRequester does
    assert( comp2 == "file#a" );

    // Completion with empty string
    kDebug () << endl << "now completing on ''";
    m_completion->makeCompletion( "" );
    waitForCompletion();
    QStringList compEmpty = m_completion->allMatches();
    assert( compEmpty.count() == 0 );
}
SNextBlock* Filesystem::completionGetBlock(int64 pBlock)
{
	std::map<int64, SNextBlock*>::iterator it = queued_next_blocks.find(pBlock);
	if (it == queued_next_blocks.end())
	{
		do
		{
			overlapped_next_block = pBlock;
			queueOverlappedReads(true);
			it = queued_next_blocks.find(pBlock);
			if (it == queued_next_blocks.end())
			{
				waitForCompletion(100);
				it = queued_next_blocks.find(pBlock);
			}
		} while (it == queued_next_blocks.end());
	}
	else
	{
		queueOverlappedReads(false);
	}

	SNextBlock* next_block = it->second;
	queued_next_blocks.erase(it);

	size_t nwait = 0;
	while (next_block->state == ENextBlockState_Queued)
	{
		if (nwait > 0)
		{
			next_block_callback->waitingForBlockCallback(pBlock);
		}

		if (!waitForCompletion(1000))
		{
			++nwait;
		}

		if (nwait == slow_read_warning_seconds)
		{
			next_block_callback->slowReadWarning(nwait * 1000, pBlock);
		}
		if (nwait >= max_read_wait_seconds)
		{
			errcode = fs_error_read_timeout;
			has_error = true;
			return NULL;
		}
	}

	if (next_block->state != ENextBlockState_Ready)
	{
		free_next_blocks.push(next_block);
		return NULL;
	}

	return next_block;
}
Exemple #4
0
    void testWriteAll()
    {
        uint16_t addr;

        getReady();
        // Enable write
        writeOpAddr(EWEN_OPCODE, EWEN_OPCODE_BITS, 0, EWEN_ADDR_BITS);
        standby();
        // Fill all memory
        writeOpAddr(WRAL_OPCODE, WRAL_OPCODE_BITS, 0, WRAL_ADDR_BITS);
        writeData(0xABBA);
        standby();

        if (waitForCompletion()) {
            stop();
            getReady();
            // Write successful -- verify all memory
            for ( addr=0; addr < EEPROM93C46::SIZE; addr++ ) {
                CPPUNIT_ASSERT_EQUAL((uint16_t)0xABBA, readAt(addr));
            }
        }
        else {
            CPPUNIT_FAIL("EEPROM write was not completed");
        }
        stop();
    }
Exemple #5
0
/**
 *  writeTo - Write a word to specified address
 *  @addr: address to write to
 *  @value: value to store
 *
 *  Returns false if write did not complete.
 *
 *  Note: Make sure EEPROM is selected and writable before attempting
 *        to write. Use getReady() and stop() to select/deselect
 *        EEPROM.
 **/
bool EEPROMTest::writeTo(uint16_t addr, uint16_t value)
{
    writeOpAddr(WRITE_OPCODE, WRITE_OPCODE_BITS, addr, WRITE_ADDR_BITS);
    writeData(value);
    standby();
    return waitForCompletion();
}
Exemple #6
0
STDMETHODIMP ProgressWrap::WaitForCompletion(LONG aTimeout)
{
    LogRelFlow(("{%p} %s:enter aTimeout=%RI32\n", this, "Progress::waitForCompletion", aTimeout));

    VirtualBoxBase::clearError();

    HRESULT hrc;

    try
    {

        AutoCaller autoCaller(this);
        if (FAILED(autoCaller.rc()))
            throw autoCaller.rc();

        hrc = waitForCompletion(aTimeout);
    }
    catch (HRESULT hrc2)
    {
        hrc = hrc2;
    }
    catch (...)
    {
        hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
    }

    LogRelFlow(("{%p} %s: leave hrc=%Rhrc\n", this, "Progress::waitForCompletion", hrc));
    return hrc;
}
void Simplify4x4QuadraticsThreaded_Test(int& testsRun)
{
    SkDebugf("%s\n", __FUNCTION__);
#ifdef SK_DEBUG
    gDebugMaxWindSum = 4; // FIXME: 3?
    gDebugMaxWindValue = 4;
#endif
    const char testStr[] = "testQuadratic";
    initializeTests(testStr, sizeof(testStr));
    int testsStart = testsRun;
    int a = 0;
#define SKIP_A 0
#if SKIP_A
    a = 2;
#endif
    for (; a < 16; ++a) {
        for (int b = a ; b < 16; ++b) {
            for (int c = b ; c < 16; ++c) {
                for (int d = c; d < 16; ++d) {
                    testsRun += dispatchTest4(testSimplify4x4QuadraticsMain,
                            a, b, c, d);
                }
                if (!gRunTestsInOneThread) SkDebugf(".");
            }
            if (!gRunTestsInOneThread) SkDebugf("%d", b);
        }
        if (!gRunTestsInOneThread) SkDebugf("\n%d", a);
    }
    testsRun += waitForCompletion();
    SkDebugf("%s tests=%d total=%d\n", __FUNCTION__, testsRun - testsStart, testsRun);
}
Exemple #8
0
asynStatus mar345::erase()
{
    int numErase;
    int i;
    asynStatus status=asynSuccess;
    //const char *functionName = "erase";

    getIntegerParam(mar345NumErase, &numErase);
    if (numErase < 1) numErase=1;
    setIntegerParam(ADStatus, mar345StatusErase);
    setIntegerParam(mar345NumErased, 0);
    callParamCallbacks();
    for (i=0; i<numErase; i++) {
        if (epicsEventTryWait(this->abortEventId) == epicsEventWaitOK) {
            status = asynError;
            break;
        }
        epicsSnprintf(this->toServer, sizeof(this->toServer), "COMMAND ERASE");
        writeServer(this->toServer);
        status = waitForCompletion("SCAN_DATA    Ended o.k.", MAR345_COMMAND_TIMEOUT);
        if (status) break;
        setIntegerParam(mar345NumErased, i+1);
        callParamCallbacks();
    }
    setIntegerParam(ADStatus, mar345StatusIdle);
    setIntegerParam(mar345Erase, 0);
    callParamCallbacks();
    return(status);
}
void ShapeOps4x4RectsThreaded_Test(int& testsRun)
{
    SkDebugf("%s\n", __FUNCTION__);
#ifdef SK_DEBUG
    gDebugMaxWindSum = 4;
    gDebugMaxWindValue = 4;
#endif
    const char testLineStr[] = "testOp";
    initializeTests(testLineStr, sizeof(testLineStr));
    int testsStart = testsRun;
    for (int a = 0; a < 6; ++a) { // outermost
        for (int b = a + 1; b < 7; ++b) {
            for (int c = 0 ; c < 6; ++c) {
                for (int d = c + 1; d < 7; ++d) {
                    testsRun += dispatchTest4(testShapeOps4x4RectsMain, a, b, c, d);
                }
                if (!gRunTestsInOneThread) SkDebugf(".");
            }
            if (!gRunTestsInOneThread) SkDebugf("%d", b);
        }
        if (!gRunTestsInOneThread) SkDebugf("\n%d", a);
    }
    testsRun += waitForCompletion();
    SkDebugf("%s tests=%d total=%d\n", __FUNCTION__, testsRun - testsStart, testsRun);
}
Exemple #10
0
int SonarSRF::getRange(char unit, bool andStart){
    if (andStart == true) { 
        startRanging(unit);
        waitForCompletion();
    }
    
	int result = 0; // the result is two bytes long
	// send I2C request for data
    
    Wire.beginTransmission(_address);             // start communicating with SRFmodule
    Wire.write(ResultRegister);                           // Call the register for start of ranging data
    Wire.endTransmission();

	Wire.requestFrom(_address, 2);
	// wait for two bytes to return
    int i = 0;
	while (Wire.available() < 2 )   {
    delay(1);
	}
	// read the two bytes, and combine them into one int
	result = Wire.read() * 256;
	result += Wire.read();
	// return the result:
	return result;
}  
boost::optional<Future<TransactionCoordinator::CommitDecision>>
TransactionCoordinatorService::coordinateCommit(OperationContext* opCtx,
                                                LogicalSessionId lsid,
                                                TxnNumber txnNumber,
                                                const std::set<ShardId>& participantList) {

    auto coordinator = _coordinatorCatalog->get(lsid, txnNumber);
    if (!coordinator) {
        return boost::none;
    }

    Action initialAction = coordinator->recvCoordinateCommit(participantList);
    if (initialAction != Action::kNone) {
        launchCoordinateCommitTask(_threadPool, coordinator, lsid, txnNumber, initialAction);
    }

    return coordinator->waitForCompletion().then([](auto finalState) {
        switch (finalState) {
            case TransactionCoordinator::StateMachine::State::kAborted:
                return TransactionCoordinator::CommitDecision::kAbort;
            case TransactionCoordinator::StateMachine::State::kCommitted:
                return TransactionCoordinator::CommitDecision::kCommit;
            default:
                MONGO_UNREACHABLE;
        }
    });
    // TODO (SERVER-37364): Re-enable the coordinator returning the decision as soon as the decision
    // is made durable. Currently the coordinator waits to hear acks because participants in prepare
    // reject requests with a higher transaction number, causing tests to fail.
    // return coordinator.get()->waitForDecision();
}
Exemple #12
0
AsyncIO::~AsyncIO() {
  if (*this) {
    if (CancelIoEx(m_fh, nullptr))
      waitForCompletion();
    CloseHandle(m_fh);
  }
}
Exemple #13
0
    void testEraseAll()
    {
        //unused: int i;
        uint16_t addr = 0x1F;

        getReady();
        // Enable write
        writeOpAddr(EWEN_OPCODE, EWEN_OPCODE_BITS, 0, EWEN_ADDR_BITS);
        standby();
        // Fill all memory
        writeOpAddr(WRITE_OPCODE, WRITE_OPCODE_BITS, addr, WRITE_ADDR_BITS);
        writeData(0);
        standby();

        if (waitForCompletion()) {
            stop();
            getReady();
            // Write successful -- verify random location
            CPPUNIT_ASSERT_EQUAL((uint16_t)0, readAt(addr));
            stop();
            getReady();

            writeOpAddr(ERAL_OPCODE, ERAL_OPCODE_BITS, addr, ERAL_ADDR_BITS);
            standby();

            if (!waitForCompletion()) {
                CPPUNIT_FAIL("EEPROM erase was not completed");
                stop();
                return;
            }

            standby();

            writeOpAddr(EWDS_OPCODE, EWDS_OPCODE_BITS, 0, EWDS_ADDR_BITS);
            stop();

            getReady();
            for ( addr=0; addr < EEPROM93C46::SIZE; addr++ ) {
                CPPUNIT_ASSERT_EQUAL((uint16_t)0xFFFF, readAt(addr));
            }
        }
        else {
            CPPUNIT_FAIL("EEPROM write was not completed");
        }
        stop();
    }
void Thread::kill(Handle& thread)
{
#ifdef HAVE_PTHREAD_CANCEL
	int state = pthread_cancel(thread);
	if (state)
		Firebird::system_call_failed::raise("pthread_cancel", state);
	waitForCompletion(thread);
#endif
}
// EXCEPTIONS: CProcessFailure
// TO DO:	clean up error reporting
//			use dialog to say we're busy and give a cancel button
void CToneGenProcess::processANAFile(CProcessStatus& status)
{
  LPCTSTR kOutputExt = ".txz";
  LPCTSTR kLogExt = ".tgp";
  LPCTSTR kCMDExt = ".cmt";

  try
	{
	  ASSERTX(status.getOutputLang());
	  CString sBase = status.getInputMFS()->getAbrev() + status.getOutputMFS()->getAbrev() + "-tgen";
	  m_sOutputTextPath = status.makeTempPath(status.sANAPath.getFileName(), kOutputExt);
	  m_sLOGPath = status.makeTempPath(sBase,	".log" );

	  m_sCMDPath =status.makeTempPath(sBase, ".cmd");

	  outputSupportFiles(status);

	  m_sOutputTextPath.deleteFile();	// don't care if it is found or not
	  m_sLOGPath.deleteFile();	// don't care if it is found or not

	  if(!executeTool(status))
	{
	  throw(CProcessFailure(this, "Unknown execution problem"));
	}
	  waitForCompletion(&status, &m_sLOGPath, &m_sOutputTextPath);


	  // register ana output so the user can view it
	  CString sLabel(status.getOutputMFS()->getAbrev());
	  sLabel += " Text";
	  CResultStreamFile* textStream =
	new CResultStreamFile(
			   new CResultStreamDescriptor(this,
					   "Synthesized Text",
					   "Target text synthesized by ToneGen (ToneGen synthesis)",
					   sLabel // language specific
					   ),
		   m_sOutputTextPath.getFullPath(),
		   status.getOutputLang());
	  status.registerResultStream(textStream);


	  registerLog(status, m_sLOGPath, status.getOutputLang());
	  status.sRAWPath = m_sOutputTextPath;
	}
  catch(CProcessFailure failure)
	{
	  registerLog(status, m_sLOGPath);
	  throw(failure);
	}
  catch(CString sError)
	{
	  registerLog(status, m_sLOGPath);
	  throw(CProcessFailure(this, sError));
	}
}
Exemple #16
0
void KUrlCompletionTest::testEmptyCwd()
{
    kDebug() ;
    // Completion with empty string (with a KUrlCompletion whose cwd is "")
    kDebug () << endl << "now completing on '' with empty cwd";
    m_completionEmptyCwd->makeCompletion( "" );
    waitForCompletion();
    QStringList compEmpty = m_completionEmptyCwd->allMatches();
    assert( compEmpty.count() == 0 );
}
Exemple #17
0
AsyncIO& AsyncIO::operator=(AsyncIO&& other) {
  if (*this) {
    if (CancelIoEx(m_fh, nullptr))
      waitForCompletion();
    CloseHandle(m_fh);
  }
  m_fh = other.m_fh;
  other.m_fh = INVALID_HANDLE_VALUE;
  m_queue = std::move(other.m_queue);
  m_maxBlock = other.m_maxBlock;
  return *this;
}
Exemple #18
0
bool UPTDestroyCallback::operator()(void *handle)
{
  lock->_Lock(FILE__, __LINE__);
  handle_ = handle;
  getMailbox()->executeOrRegisterCallback(this);
  if (synchronous) {
    dbi_printf("%s[%d]:  waiting for completion of callback\n", FILE__, __LINE__);
    waitForCompletion();
  }
  lock->_Unlock(FILE__, __LINE__);
  return true;
}
Exemple #19
0
bool DestroyUnwindAddressSpaceCallback::operator()(unw_addr_space *as)
{
  lock->_Lock(FILE__, __LINE__);
  as_ = as;
  getMailbox()->executeOrRegisterCallback(this);
  if (synchronous) {
    dbi_printf("%s[%d]:  waiting for completion of callback\n", FILE__, __LINE__);
    waitForCompletion();
  }
  lock->_Unlock(FILE__, __LINE__);
  return true;
}
Exemple #20
0
bool UPTCreateCallback::operator()(pid_t pid)
{
  lock->_Lock(FILE__, __LINE__);
  pid_ = pid;
  getMailbox()->executeOrRegisterCallback(this);
  if (synchronous) {
    dbi_printf("%s[%d]:  waiting for completion of callback\n", FILE__, __LINE__);
    waitForCompletion();
  }
  lock->_Unlock(FILE__, __LINE__);
  return true;
}
Exemple #21
0
bool IsSignalFrameCallback::operator()(unw_cursor_t *cp)
{
  lock->_Lock(FILE__, __LINE__);
  cp_ = cp;
  getMailbox()->executeOrRegisterCallback(this);
  if (synchronous) {
    dbi_printf("%s[%d]:  waiting for completion of callback\n", FILE__, __LINE__);
    waitForCompletion();
  }
  lock->_Unlock(FILE__, __LINE__);
  return true;
}
Exemple #22
0
bool CreateUnwindAddressSpaceCallback::operator()(unw_accessors_t *ap, 
                                                  int byteorder) 
{
  lock->_Lock(FILE__, __LINE__);
  ap_ = ap;
  byteorder_ = byteorder;
  getMailbox()->executeOrRegisterCallback(this);
  if (synchronous) {
    dbi_printf("%s[%d]:  waiting for completion of callback\n", FILE__, __LINE__);
    waitForCompletion();
  }
  lock->_Unlock(FILE__, __LINE__);
  return true;
}
Exemple #23
0
bool WaitpidCallback::operator()(pid_t pid, int *status, int options)
{
  lock->_Lock(FILE__, __LINE__);
  pid_ = pid;
  status_ = status;
  options_ = options;
  getMailbox()->executeOrRegisterCallback(this);
  if (synchronous) {
    dbi_printf("%s[%d]:  waiting for completion of callback\n", FILE__, __LINE__);
    waitForCompletion();
  }
  lock->_Unlock(FILE__, __LINE__);
  return true;
}
Exemple #24
0
bool InitFrameCallback::operator()(unw_cursor_t *cp, unw_addr_space_t as, void *arg)
{
  lock->_Lock(FILE__, __LINE__);
  cp_ = cp;
  as_ = as;
  arg_ = arg;
  getMailbox()->executeOrRegisterCallback(this);
  if (synchronous) {
    dbi_printf("%s[%d]:  waiting for completion of callback\n", FILE__, __LINE__);
    waitForCompletion();
  }
  lock->_Unlock(FILE__, __LINE__);
  return true;
}
Exemple #25
0
void KUrlCompletionTest::testLocalAbsolutePath()
{
    // Completion from absolute path
    kDebug() << m_dir+"file#";
    m_completion->makeCompletion( m_dir + "file#" );
    waitForCompletion();
    QStringList compall = m_completion->allMatches();
    kDebug() << compall;
    assert( compall.count() == 1 );
    QString comp = compall.first();
    assert( comp == m_dir + "file#a" );
    comp = m_completion->replacedPath( comp ); // like KUrlRequester does
    assert( comp == m_dir + "file#a" );
}
Exemple #26
0
bool SetFrameRegisterCallback::operator()(unw_cursor_t *cp, 
                                          unw_regnum_t reg, 
                                          unw_word_t val)
{
  lock->_Lock(FILE__, __LINE__);
  cp_ = cp;
  reg_ = reg;
  val_ = val;
  getMailbox()->executeOrRegisterCallback(this);
  if (synchronous) {
    dbi_printf("%s[%d]:  waiting for completion of callback\n", FILE__, __LINE__);
    waitForCompletion();
  }
  lock->_Unlock(FILE__, __LINE__);
  return true;
}
// Destroy threads and delete sharedThreadData.
vHavokCpuJobThreadPool::~vHavokCpuJobThreadPool()
{
    waitForCompletion();

    for (int i = 0; i < m_sharedThreadData.m_numThreads; i++)
    {
        WorkerThreadData& data = m_workerThreads[i];
        data.m_killThread = true;
        data.m_semaphore.release(); // sets the thread off to enable it to finish
    }

    for (int i = 0; i < m_sharedThreadData.m_numThreads; i++)
    {
        m_sharedThreadData.m_workerThreadFinished.acquire(); // wait for the N threads to actually end
    }
    hkReferencedObject::setLockMode( hkReferencedObject::LOCK_MODE_NONE);
}
int main(int argc, char** argv)
{
  
  if (openUSBDevice() < 0) return -1;
  printf("openUSBDevice complete...\n"); 
 
  if (allocateTransfers() < 0) return -1;
  printf("allocateTransfers() complete...\n");

  submitTransfers();
  printf("submitTransfers() complete..\n");
  
  waitForCompletion();

  deallocateUSBDevice();

  return 0;
}
// EXCEPTIONS: CProcessFailure
// TO DO:	clean up error reporting
//			use dialog to say we're busy and give a cancel button
void CToneParseProcess::processANAFile(CProcessStatus& status)
{
  try
	{
	  CString sBase = status.m_sFileNameRoot +"-tpars";
	  m_sOutputANAPath = status.makeTempPath(sBase,".ana");
	  m_sLOGPath = status.makeTempPath(sBase,	".log" );


	  m_sCMDPath =status.makeTempPath(sBase, ".cmd");

	  outputSupportFiles(status);

	  m_sOutputANAPath.deleteFile();	// don't care if it is found or not
	  m_sLOGPath.deleteFile();	// don't care if it is found or not

	  if(!executeTool(status))
	{
	  throw(CProcessFailure(this, "Failed to process the file with ToneParse"));
	}

	  waitForCompletion(&status, &m_sOutputANAPath);

	  // register itx output so the user can view it
	  CResultStreamFile* anaStream =
	new CResultStreamFile(
				  new CResultStreamDescriptor(this,
							  "TPARS ANA", //short description
							  "ANA Output of ToneParse", // long description
							  "TPARS ANA" // tab label
							  ),
				  m_sOutputANAPath,
				  status.getInputLang());

	  status.registerResultStream(anaStream);
	  registerLog(status, m_sLOGPath, status.getInputLang());

	  status.sANAPath = m_sOutputANAPath;
	}
  catch(CString sError)
	{
	  throw(CProcessFailure(this, sError));
	}
}
Exemple #30
0
int main( int argc, char** argv )
{
    if ( argc < 2 )
    {
        std::cerr << "usage: " << argv[0] << " <entrypoint>" << std::endl;
        return 1;
    }

    auto testCb = std::make_unique<TestCb>();
    std::unique_ptr<medialibrary::IMediaLibrary> ml( NewMediaLibrary() );

    ml->setVerbosity( medialibrary::LogLevel::Info );
    ml->initialize( "/tmp/test.db", "/tmp/ml_thumbnails", testCb.get() );
    ml->setDiscoverNetworkEnabled( true );
    ml->start();
    ml->discover( argv[1] );

    auto res = testCb->waitForCompletion();
    return res == true ? 0 : 1;
}