int main(int argc, const char *argv[]) { copyTest(); readTest(); writeTest(); return 0; }
bool muhkuh_wrap_xml::readTestDescription(wxXmlDocument *xmldoc) { wxXmlNode *xml_testdesc; tTesterXml_TestDescription *ptTestDesc; // look for the first root node named "TestDescription" xml_testdesc = xmldoc->GetRoot(); while( xml_testdesc!=NULL ) { if( xml_testdesc->GetType()==wxXML_ELEMENT_NODE && xml_testdesc->GetName()==wxT("TestDescription") ) { break; } xml_testdesc = xml_testdesc->GetNext(); } // not found (node is NULL) ? if( xml_testdesc==NULL ) { return false; } // create new test description ptTestDesc = new tTesterXml_TestDescription; // get the testdescription name if( xml_testdesc->GetAttribute(wxT("name"), &ptTestDesc->strName)==false ) { delete ptTestDesc; return false; } /* // read the code node if( readCodeNode(xml_testdesc, ptTestDesc->strCode)==false ) { delete ptTestDesc; return false; } */ // get the testdescription version // NOTE: this is optional to support older tests if( xml_testdesc->GetAttribute(wxT("version"), &ptTestDesc->strVersion)==false ) { // show a warning wxLogWarning(_("testdescription '%s' has no version information"), ptTestDesc->strName.c_str()); } // read in all tests if( readTest(xml_testdesc, ptTestDesc)==false ) { delete ptTestDesc; return false; } // publish the data m_ptTestDescription = ptTestDesc; return true; }
void rulesDialog::projectRead() { clearRules(); QgsProject* project = QgsProject::instance(); int testCount = QgsProject::instance()->readNumEntry( QStringLiteral( "Topol" ), QStringLiteral( "/testCount" ) ); mRulesTable->clearContents(); for ( int i = 0; i < testCount; ++i ) readTest( i, project ); }
void rulesDialog::projectRead() { clearRules(); QgsMapLayerRegistry* layerRegistry = QgsMapLayerRegistry::instance(); int testCount = QgsProject::instance()->readNumEntry( "Topol", "/testCount" ); mRulesTable->clearContents(); for ( int i = 0; i < testCount; ++i ) readTest( i, layerRegistry ); }
void readTests(const struct device *dev){ printf("Read tests:\n"); size_t blockSize = SMALLEST_BLOCK; long firstChnk = 0; while (blockSize <= DISP){ firstChnk += PAGE_READ_REPS; readTest(dev, firstChnk, blockSize); if (blockSize < DISP/16){ blockSize *= 2; } else { blockSize += DISP/16; } } }
const AudioFileModel& AnalyzeTask::analyzeFile(const QString &filePath, AudioFileModel &audioFile, int *const type) { *type = fileTypeNormal; QFile readTest(filePath); if (!readTest.open(QIODevice::ReadOnly)) { *type = fileTypeDenied; return audioFile; } if (checkFile_CDDA(readTest)) { *type = fileTypeCDDA; return audioFile; } readTest.close(); return analyzeMediaFile(filePath, audioFile); }
/** * FUNCTION NAME: mp2Run * * DESCRIPTION: This function performs all the key value store related functionalities * including: * 1) Ring operations * 2) CRUD operations */ void Application::mp2Run() { int i; // For all the nodes in the system for( i = 0; i <= par->EN_GPSZ-1; i++) { /* * 1) Update the ring * 2) Receive messages from the network and queue them in the KV store queue */ if ( par->getcurrtime() > (int)(par->STEP_RATE*i) && !mp2[i]->getMemberNode()->bFailed ) { if ( mp2[i]->getMemberNode()->inited && mp2[i]->getMemberNode()->inGroup ) { // Step 1 mp2[i]->updateRing(); } // Step 2 mp2[i]->recvLoop(); } } /** * Handle messages from the queue and update the DHT */ for ( i = par->EN_GPSZ-1; i >= 0; i-- ) { if ( par->getcurrtime() > (int)(par->STEP_RATE*i) && !mp2[i]->getMemberNode()->bFailed ) { mp2[i]->checkMessages(); } } /** * Insert a set of test key value pairs into the system */ if ( par->getcurrtime() == INSERT_TIME ) { insertTestKVPairs(); } /** * Test CRUD operations */ if ( par->getcurrtime() >= TEST_TIME ) { /************** * CREATE TEST **************/ /** * TEST 1: Checks if there are RF * NUMBER_OF_INSERTS CREATE SUCCESS message are in the log * */ if ( par->getcurrtime() == TEST_TIME && CREATE_TEST == par->CRUDTEST ) { cout<<endl<<"Doing create test at time: "<<par->getcurrtime()<<endl; } // End of create test /*************** * DELETE TESTS ***************/ /** * TEST 1: NUMBER_OF_INSERTS/2 Key Value pair are deleted. * Check whether RF * NUMBER_OF_INSERTS/2 DELETE SUCCESS message are in the log * TEST 2: Delete a non-existent key. Check for a DELETE FAIL message in the lgo * */ else if ( par->getcurrtime() == TEST_TIME && DELETE_TEST == par->CRUDTEST ) { deleteTest(); } // End of delete test /************* * READ TESTS *************/ /** * TEST 1: Read a key. Check for correct value being read in quorum of replicas * * Wait for some time after TEST 1 * * TEST 2: Fail a single replica of a key. Check for correct value of the key * being read in quorum of replicas * * Wait for STABILIZE_TIME after TEST 2 (stabilization protocol should ensure at least * 3 replicas for all keys at all times) * * TEST 3 part 1: Fail two replicas of a key. Read the key and check for READ FAIL message in the log. * READ should fail because quorum replicas of the key are not up * * Wait for another STABILIZE_TIME after TEST 3 part 1 (stabilization protocol should ensure at least * 3 replicas for all keys at all times) * * TEST 3 part 2: Read the same key as TEST 3 part 1. Check for correct value of the key * being read in quorum of replicas * * Wait for some time after TEST 3 part 2 * * TEST 4: Fail a non-replica. Check for correct value of the key * being read in quorum of replicas * * TEST 5: Read a non-existent key. Check for a READ FAIL message in the log * */ else if ( par->getcurrtime() >= TEST_TIME && READ_TEST == par->CRUDTEST ) { readTest(); } // end of read test /*************** * UPDATE TESTS ***************/ /** * TEST 1: Update a key. Check for correct new value being updated in quorum of replicas * * Wait for some time after TEST 1 * * TEST 2: Fail a single replica of a key. Update the key. Check for correct new value of the key * being updated in quorum of replicas * * Wait for STABILIZE_TIME after TEST 2 (stabilization protocol should ensure at least * 3 replicas for all keys at all times) * * TEST 3 part 1: Fail two replicas of a key. Update the key and check for READ FAIL message in the log * UPDATE should fail because quorum replicas of the key are not up * * Wait for another STABILIZE_TIME after TEST 3 part 1 (stabilization protocol should ensure at least * 3 replicas for all keys at all times) * * TEST 3 part 2: Update the same key as TEST 3 part 1. Check for correct new value of the key * being update in quorum of replicas * * Wait for some time after TEST 3 part 2 * * TEST 4: Fail a non-replica. Check for correct new value of the key * being updated in quorum of replicas * * TEST 5: Update a non-existent key. Check for a UPDATE FAIL message in the log * */ else if ( par->getcurrtime() >= TEST_TIME && UPDATE_TEST == par->CRUDTEST ) { updateTest(); } // End of update test } // end of if ( par->getcurrtime == TEST_TIME) }
const AudioFileModel AnalyzeTask::analyzeFile(const QString &filePath, int *type) { *type = fileTypeNormal; AudioFileModel audioFile(filePath); QFile readTest(filePath); if(!readTest.open(QIODevice::ReadOnly)) { *type = fileTypeDenied; return audioFile; } if(checkFile_CDDA(readTest)) { *type = fileTypeCDDA; return audioFile; } readTest.close(); bool skipNext = false; QPair<quint32, quint32> id_val(UINT_MAX, UINT_MAX); quint32 coverType = UINT_MAX; QByteArray coverData; QStringList params; params << QString("--Inform=file://%1").arg(QDir::toNativeSeparators(m_templateFile)); params << QDir::toNativeSeparators(filePath); QProcess process; MUtils::init_process(process, QFileInfo(m_mediaInfoBin).absolutePath()); process.start(m_mediaInfoBin, params); if(!process.waitForStarted()) { qWarning("MediaInfo process failed to create!"); qWarning("Error message: \"%s\"\n", process.errorString().toLatin1().constData()); process.kill(); process.waitForFinished(-1); return audioFile; } while(process.state() != QProcess::NotRunning) { if(*m_abortFlag) { process.kill(); qWarning("Process was aborted on user request!"); break; } if(!process.waitForReadyRead()) { if(process.state() == QProcess::Running) { qWarning("MediaInfo time out. Killing process and skipping file!"); process.kill(); process.waitForFinished(-1); return audioFile; } } QByteArray data; while(process.canReadLine()) { QString line = QString::fromUtf8(process.readLine().constData()).simplified(); if(!line.isEmpty()) { //qDebug("Line:%s", MUTILS_UTF8(line)); int index = line.indexOf('='); if(index > 0) { QString key = line.left(index).trimmed(); QString val = line.mid(index+1).trimmed(); if(!key.isEmpty()) { updateInfo(audioFile, skipNext, id_val, coverType, coverData, key, val); } } } } } if(audioFile.metaInfo().title().isEmpty()) { QString baseName = QFileInfo(filePath).fileName(); int index = baseName.lastIndexOf("."); if(index >= 0) { baseName = baseName.left(index); } baseName = baseName.replace("_", " ").simplified(); index = baseName.lastIndexOf(" - "); if(index >= 0) { baseName = baseName.mid(index + 3).trimmed(); } audioFile.metaInfo().setTitle(baseName); } process.waitForFinished(); if(process.state() != QProcess::NotRunning) { process.kill(); process.waitForFinished(-1); } if((coverType != UINT_MAX) && (!coverData.isEmpty())) { retrieveCover(audioFile, coverType, coverData); } if((audioFile.techInfo().audioType().compare("PCM", Qt::CaseInsensitive) == 0) && (audioFile.techInfo().audioProfile().compare("Float", Qt::CaseInsensitive) == 0)) { if(audioFile.techInfo().audioBitdepth() == 32) audioFile.techInfo().setAudioBitdepth(AudioFileModel::BITDEPTH_IEEE_FLOAT32); } return audioFile; }
int __cdecl main(int argc, char *argv[]) { HANDLE hFile = NULL; const int BUFFER_SIZE = 2 * PAGESIZE; DWORD dwByteCount[] = { 0, 10, strlen(szStringTest), PAGESIZE // Commented out two negative test cases : Refer VSW 312690 // 2 * PAGESIZE, // -1 }; DWORD oldProt; char szResults[] = "1111"; // Was "111100": Refer VSW 312690 int i; BOOL bRc = FALSE; DWORD dwBytesWritten = 0; if (0 != PAL_Initialize(argc,argv)) { return FAIL; } /* allocate read-write memery for readBuffer */ if (!(readBuffer = (char*) VirtualAlloc(NULL, BUFFER_SIZE, MEM_COMMIT, PAGE_READWRITE))) { Fail("VirtualAlloc failed: GetLastError returns %d\n", GetLastError()); return FAIL; } /* write protect the second page of readBuffer */ if (!VirtualProtect(&readBuffer[PAGESIZE], PAGESIZE, PAGE_NOACCESS, &oldProt)) { Fail("VirtualProtect failed: GetLastError returns %d\n", GetLastError()); return FAIL; } // create the test file hFile = CreateFile(szReadableFile, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if(hFile == INVALID_HANDLE_VALUE) { Fail("ReadFile: ERROR -> Unable to create file \"%s\" (%d).\n", szReadableFile, GetLastError()); } bRc = WriteFile(hFile, szStringTest, strlen(szStringTest), &dwBytesWritten, NULL); CloseHandle(hFile); for (i = 0; i< NOOFTESTS; i++) { bRc = readTest(dwByteCount[i], szResults[i]); if (bRc != TRUE) { Fail("ReadFile: ERROR -> Failed on test[%d]\n", i); } } VirtualFree(readBuffer, BUFFER_SIZE, MEM_RELEASE); PAL_Terminate(); return PASS; }