int main(int argc, const char *argv[]) { copyTest(); readTest(); writeTest(); return 0; }
void writeTests(const struct device *dev){ printf("Write tests:\n"); size_t blockSize = SMALLEST_BLOCK; long firstChnk = 0; while (blockSize <= DISP){ firstChnk += PAGE_WRITE_REPS; writeTest(dev, firstChnk, blockSize); blockSize *= 2; } }
void onRead(int socket) { char buf[BUF_SIZE]; int received; // server accepted incoming socket, echo data printf("onRead\n"); received = netRead(socket, buf, BUF_SIZE); printf("received: %i\n", received); writeTest(socket); }
void PatternCompiler::visit(ValuePattern& pattern, int value) { // Evaluate the expected value. int expected = compiler_.makeTemp(); compiler_.compile(pattern.value(), expected); // Test if the value matches the expected one. compiler_.write(pattern.pos(), OP_EQUAL, value, expected, expected); writeTest(pattern, expected); compiler_.releaseTemp(); }
int __cdecl main(int argc, char *argv[]) { const char * testString = "The quick fox jumped over the lazy dog's back."; const int testStringLen = strlen(testString); DWORD dwByteCount[4] = {-1, 10, testStringLen, 0}; DWORD dwByteWritten[4] = {0, 10, testStringLen, 0}; BOOL bResults[] = {FALSE, TRUE, TRUE, TRUE}; const int BUFFER_SIZE = 2 * PAGESIZE; int j; BOOL bRc = FALSE; DWORD oldProt; if (0 != PAL_Initialize(argc,argv)) { return FAIL; } /* allocate read-write memery for writeBuffer */ if (!(writeBuffer = (char*) VirtualAlloc(NULL, BUFFER_SIZE, MEM_COMMIT, PAGE_READWRITE))) { Fail("VirtualAlloc failed: GetLastError returns %d\n", GetLastError()); return FAIL; } memset((void*) writeBuffer, '.', BUFFER_SIZE); strcpy(writeBuffer, testString); /* write protect the second page of writeBuffer */ if (!VirtualProtect(&writeBuffer[PAGESIZE], PAGESIZE, PAGE_NOACCESS, &oldProt)) { Fail("VirtualProtect failed: GetLastError returns %d\n", GetLastError()); return FAIL; } for (j = 0; j< 4; j++) { bRc = writeTest(dwByteCount[j], dwByteWritten[j], bResults[j]); if (bRc != TRUE) { Fail("WriteFile: ERROR -> Failed on test[%d]\n", j); } } PAL_Terminate(); return PASS; }
int __cdecl main(int argc, char *argv[]) { const char *pString = szStringTest; BOOL bRc = FALSE; if (0 != PAL_Initialize(argc,argv)) { return FAIL; } bRc = writeTest(pString); if (bRc != TRUE) { Fail("WriteFile: ERROR -> Failed\n"); } PAL_Terminate(); return PASS; }
int main(int argc, char** argv){ writeTest(); }
void onWrite(int socket) { printf("onWrite\n"); writeTest(socket); }
void sanity_check( int argc, char* argv[] ) { QString msg; QByteArray path = getenv("HOME"); QByteArray readOnly = getenv("KDE_HOME_READONLY"); if (path.isEmpty()) { msg = QLatin1String("$HOME not set!"); } if (msg.isEmpty() && access(path.data(), W_OK)) { if (errno == ENOENT) msg = QStringLiteral("$HOME directory (%1) does not exist."); else if (readOnly.isEmpty()) msg = QStringLiteral("No write access to $HOME directory (%1)."); } if (msg.isEmpty() && access(path.data(), R_OK)) { if (errno == ENOENT) msg = QStringLiteral("$HOME directory (%1) does not exist."); else msg = QStringLiteral("No read access to $HOME directory (%1)."); } if (msg.isEmpty() && readOnly.isEmpty() && !writeTest(path)) { if (errno == ENOSPC) msg = QStringLiteral("$HOME directory (%1) is out of disk space."); else msg = QStringLiteral("Writing to the $HOME directory (%1) failed with\n " "the error '")+QString::fromLocal8Bit(strerror(errno))+QStringLiteral("'"); } if (msg.isEmpty()) { path = getenv("ICEAUTHORITY"); if (path.isEmpty()) { path = getenv("HOME"); path += "/.ICEauthority"; } if (access(path.data(), W_OK) && (errno != ENOENT)) msg = QStringLiteral("No write access to '%1'."); else if (access(path.data(), R_OK) && (errno != ENOENT)) msg = QStringLiteral("No read access to '%1'."); } if (msg.isEmpty()) { path = getenv("KDETMP"); if (path.isEmpty()) path = "/tmp"; if (!writeTest(path)) { if (errno == ENOSPC) msg = QStringLiteral("Temp directory (%1) is out of disk space."); else msg = QStringLiteral("Writing to the temp directory (%1) failed with\n " "the error '")+QString::fromLocal8Bit(strerror(errno))+QStringLiteral("'"); } } if (msg.isEmpty() && (path != "/tmp")) { path = "/tmp"; if (!writeTest(path)) { if (errno == ENOSPC) msg = QStringLiteral("Temp directory (%1) is out of disk space."); else msg = QStringLiteral("Writing to the temp directory (%1) failed with\n " "the error '")+QString::fromLocal8Bit(strerror(errno))+QStringLiteral("'"); } } if (msg.isEmpty()) { path += "/.ICE-unix"; if (access(path.data(), W_OK) && (errno != ENOENT)) msg = QStringLiteral("No write access to '%1'."); else if (access(path.data(), R_OK) && (errno != ENOENT)) msg = QStringLiteral("No read access to '%1'."); } if (!msg.isEmpty()) { const char *msg_pre = "The following installation problem was detected\n" "while trying to start KDE:" "\n\n "; const char *msg_post = "\n\nKDE is unable to start.\n"; fputs(msg_pre, stderr); fprintf(stderr, "%s", qPrintable(msg.arg(QFile::decodeName(path)))); fputs(msg_post, stderr); QApplication a(argc, argv); QString qmsg = QString::fromLatin1(msg_pre) + msg.arg(QFile::decodeName(path)) + QString::fromLatin1(msg_post); KMessageBox::error(0, qmsg, QStringLiteral("KDE Workspace installation problem!")); exit(255); } }