STDMETHODIMP CH263PayloadFormat::Reset() { // Called on Seeks DPRINTF(D_H263, ("CH263PayloadFormat::Reset()\n")); FlushInput(); FlushOutput(); m_state = NeedPSC; return HXR_OK; }
bool Inflator::IsolatedFlush(bool hardFlush, bool blocking) { if (!blocking) throw BlockingInputOnly("Inflator"); if (hardFlush) ProcessInput(true); FlushOutput(); return false; }
void CDirectory::WriteDirectoryBeginSummary() { Message("Running %s %s in directory %s", ModeNames[Mode], (Mode == RM_ASM) ? (IsBaseline() ? "baselines" : "diffs") : "tests", GetDirectoryName()); if (FSyncTest || FSyncVariation) { FlushOutput(); } }
void CDirectory::WriteDirectoryFinishSummary() { WriteSummary(GetDirectoryName(), IsBaseline(), NumVariations, NumDiffs, NumFailures); if (Timing & TIME_DIR) { Message("RL: Directory elapsed time (%s): %02d:%02d", GetDirectoryName(), elapsed_dir / 60, elapsed_dir % 60); } if (FSyncDir) { FlushOutput(); } }
// Flush remaining output, update header, and close file int WaveFile::CloseWaveFile() { FlushOutput(); bsUint32 byteTotal = sampleTotal * sizeof(SampleValue); wh.riff.chunkSize = byteTotal + sizeof(wh) - 8; // filesize - RIFF chunk wh.data.chunkSize = byteTotal; int err = 0; wfp.FileRewind(); // TODO: swap bytes in the header if (wfp.FileWrite(&wh, sizeof(wh)) != sizeof(wh)) err = -1; wfp.FileClose(); DeallocBuf(); return err; }
int WaveFileIEEE::CloseWaveFile() { FlushOutput(); bsUint32 byteTotal = sampleTotal * sizeof(float); wh.riff.chunkSize = byteTotal + sizeof(wh) - 8; // filesize - RIFF chunk wh.data.chunkSize = byteTotal; wh.sampleLength = sampleTotal / wh.fmtdata.channels; int err = 0; wfp.FileRewind(); if (wfp.FileWrite(&wh, sizeof(wh)) != sizeof(wh)) err = -1; wfp.FileClose(); DeallocBuf(); return err; }
void show_last_error(void) { int lines_of_msg; if (Term.status & TERM_IS_INIT) { lines_of_msg = (strlen(err_buffer) + COLS - 1) / COLS; ClearLine(LINES); if (lines_of_msg > 1) PutLine(LINES + 1 - lines_of_msg, 0, err_buffer); else CenterLine(LINES, err_buffer); } else { fputs(err_buffer, stderr); putc('\r', stderr); putc('\n', stderr); } FlushOutput(); }
static void* InternalThread(void* connection) { ConnectionThread* self = (ConnectionThread*)connection; for(u32 i = 0; i < 1000; i++) { if(rand() & 1) { SmallProcedure(self); } else { LargeProcedure(self); } FlushOutput(self); } pthread_exit(NULL); }
void SerialPortC::BreakConnection(void) { FlushOutput(); DropDtr(); RaiseDtr(); pause(50); if (cfg.dumbmodem == 6 || cfg.dumbmodem == 7) { OutString(cfg.hangup); OutString(br); if (cfg.hangupdelay) { pause(cfg.hangupdelay * 100); } else { pause(50); } } }
bool Inflator::DecodeBody() { bool blockEnd = false; switch (m_blockType) { case 0: // stored assert(m_reader.BitsBuffered() == 0); while (!m_inQueue.IsEmpty() && !blockEnd) { size_t size; const byte *block = m_inQueue.Spy(size); size = UnsignedMin(m_storedLen, size); OutputString(block, size); m_inQueue.Skip(size); m_storedLen -= (word16)size; if (m_storedLen == 0) blockEnd = true; } break; case 1: // fixed codes case 2: // dynamic codes static const unsigned int lengthStarts[] = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258 }; static const unsigned int lengthExtraBits[] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0 }; static const unsigned int distanceStarts[] = { 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577 }; static const unsigned int distanceExtraBits[] = { 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13 }; const HuffmanDecoder& literalDecoder = GetLiteralDecoder(); const HuffmanDecoder& distanceDecoder = GetDistanceDecoder(); switch (m_nextDecode) { case LITERAL: while (true) { if (!literalDecoder.Decode(m_reader, m_literal)) { m_nextDecode = LITERAL; break; } if (m_literal < 256) OutputByte((byte)m_literal); else if (m_literal == 256) // end of block { blockEnd = true; break; } else { if (m_literal > 285) throw BadBlockErr(); unsigned int bits; case LENGTH_BITS: bits = lengthExtraBits[m_literal-257]; if (!m_reader.FillBuffer(bits)) { m_nextDecode = LENGTH_BITS; break; } m_literal = m_reader.GetBits(bits) + lengthStarts[m_literal-257]; case DISTANCE: if (!distanceDecoder.Decode(m_reader, m_distance)) { m_nextDecode = DISTANCE; break; } case DISTANCE_BITS: bits = distanceExtraBits[m_distance]; if (!m_reader.FillBuffer(bits)) { m_nextDecode = DISTANCE_BITS; break; } m_distance = m_reader.GetBits(bits) + distanceStarts[m_distance]; OutputPast(m_literal, m_distance); } } } } if (blockEnd) { if (m_eof) { FlushOutput(); m_reader.SkipBits(m_reader.BitsBuffered()%8); if (m_reader.BitsBuffered()) { // undo too much lookahead SecBlockWithHint<byte, 4> buffer(m_reader.BitsBuffered() / 8); for (unsigned int i=0; i<buffer.size(); i++) buffer[i] = (byte)m_reader.GetBits(8); m_inQueue.Unget(buffer, buffer.size()); } m_state = POST_STREAM; } else m_state = WAIT_HEADER; } return blockEnd; }
BOOL DoOneSimpleTest( CDirectory *pDir, Test * pTest, TestVariant * pTestVariant, const char *optFlags, const char *inCCFlags, const char *inLinkFlags, BOOL fSyncVariationWhenFinished, BOOL fCleanAfter, BOOL fLinkOnly, // relink only BOOL fSuppressNoGPF, DWORD millisecTimeout ) { int rc; char *p = NULL; char cmdbuf[BUFFER_SIZE*2]; char ccFlags[BUFFER_SIZE]; char linkFlags[BUFFER_SIZE]; char nogpfFlags[BUFFER_SIZE]; char optReportBuf[BUFFER_SIZE]; char full[MAX_PATH]; char exebuf[BUFFER_SIZE]; char fullexebuf[BUFFER_SIZE]; char buf[BUFFER_SIZE]; char failDir[BUFFER_SIZE]; char copyName[BUFFER_SIZE]; char tmp_file1[MAX_PATH]; char tmp_file2[MAX_PATH]; time_t start_variation; UINT elapsed_variation; BOOL fFailed; void *envFlags = GetEnvFlags(pTestVariant); // Avoid conditionals by copying/creating ccFlags appropriately. if (inCCFlags) sprintf_s(ccFlags, " %s", inCCFlags); else ccFlags[0] = '\0'; switch (TargetMachine) { case TM_WVM: case TM_WVMX86: case TM_WVM64: strcat_s(ccFlags, " /BC "); break; } if (inLinkFlags) strcpy_s(linkFlags, inLinkFlags); else linkFlags[0] = '\0'; sprintf_s(optReportBuf, "%s%s%s", optFlags, *linkFlags ? ";" : "", linkFlags); // Figure out the exe name and path strcpy_s(exebuf, pTest->name); p = strrchr(exebuf, '.'); if (p != NULL) { strcpy_s(p + 1, REMAININGARRAYLEN(exebuf, p + 1), "exe"); } else { strcat_s(exebuf, ".exe"); } sprintf_s(fullexebuf, "%s\\%s", pDir->GetDirectoryPath(), exebuf); start_variation = time(NULL); // Build up the compile command string. sprintf_s(cmdbuf, "%s %s%s %s", REGR_CL, optFlags, ccFlags, EXTRA_CC_FLAGS); for (StringList * pFile = pTest->files; pFile != NULL; pFile = pFile->next) { strcat_s(cmdbuf, " "); strcat_s(cmdbuf, pFile->string); // If we're only relinking, hammer the extension to .obj if (fLinkOnly) { p = strrchr(cmdbuf, '.'); sprintf_s(p, REMAININGARRAYLEN(cmdbuf, p), ".obj"); } } // Build the link option string. if (LINKFLAGS && LINKFLAGS[0] != '\0') { strcat_s(linkFlags, " "); strcat_s(linkFlags, LINKFLAGS); } FillNoGPFFlags(nogpfFlags, fSuppressNoGPF); strcat_s(linkFlags, nogpfFlags); switch (TargetMachine) { case TM_X86: case TM_IA64: case TM_AMD64: case TM_AMD64SYS: case TM_AM33: case TM_ARM: case TM_ARM64: case TM_THUMB: case TM_M32R: case TM_MIPS: case TM_SH3: case TM_SH4: case TM_SH5M: case TM_SH5C: case TM_WVMX86: if (*linkFlags) { strcat_s(cmdbuf, " /link "); strcat_s(cmdbuf, linkFlags); } break; case TM_WVM: strcat_s(cmdbuf, " /c "); break; case TM_PPCWCE: if (*linkFlags) { strcat_s(cmdbuf, " "); strcat_s(cmdbuf, linkFlags); } break; } sprintf_s(buf, "%s (%s)", pTest->name, optReportBuf); ThreadInfo[ThreadId].SetCurrentTest(pDir->GetDirectoryName(), buf, pDir->IsBaseline()); UpdateTitleStatus(); // Remove exe if it's already there. We have to keep trying to delete it // until it's gone, or else the link will fail (if it is somehow still in // use). DeleteFileRetryMsg(fullexebuf); if (FTest) { Message("%s", cmdbuf); if (pTestVariant->testInfo.data[TIK_BASELINE]) { Message(" (baseline %s)", pTestVariant->testInfo.data[TIK_BASELINE]); } return 0; } // Do the compile. Message("Compiling:"); Message(" %s", cmdbuf); rc = ExecuteCommand(pDir->GetDirectoryPath(), cmdbuf); // Some machines require separate linking of the // compiler and/or assembler output. if (rc == 0) { switch (TargetMachine) { case TM_WVM: // Build up the linker command string. strcpy_s(cmdbuf, LINKER); for (StringList * pFile = pTest->files; pFile != NULL; pFile = pFile->next) { strcat_s(cmdbuf, " "); strcat_s(cmdbuf, pFile->string); p = strrchr(cmdbuf, '.'); strcpy_s(p + 1, REMAININGARRAYLEN(cmdbuf, p + 1), "obj"); } if (linkFlags) { strcat_s(cmdbuf, " "); strcat_s(cmdbuf, linkFlags); } // Do the link. Message("Linking:"); Message(" %s", cmdbuf); ExecuteCommand(pDir->GetDirectoryPath(), cmdbuf); break; default: break; } } // See if the compile succeeded by checking for the existence // of the executable. if ((rc != 0) || GetFileAttributes(fullexebuf) == INVALID_FILE_ATTRIBUTES) { LogOut("ERROR: Test failed to compile or link (%s):", optReportBuf); LogOut(" %s", cmdbuf); fFailed = TRUE; goto logFailure; } // Run the resulting exe. if (TargetVM) { strcpy_s(buf, TargetVM); strcat_s(buf, " "); strcat_s(buf, exebuf); // Copy the VM command to cmdbuf, so we get a useful error message // in the log file if test fails. strcpy_s(cmdbuf, buf); } else { strcpy_s(buf, exebuf); } // We need some temporary files. // Note: these are full pathnames, not relative pathnames. Also, note that // mytmpnam creates the file to be used. To avoid losing that file, and // risking another program using it, don't delete the file before use. // We currently delete the file before running the test, so we can see if // the test ever creates it. We should probably create the temp files in // the same directory as the test, since we guarantee that no other copies // of RL are running in the same directory. if (mytmpnam(pDir->GetDirectoryPath(), TMP_PREFIX, tmp_file1) == NULL || mytmpnam(pDir->GetDirectoryPath(), TMP_PREFIX, tmp_file2) == NULL) { Fatal("Unable to create temporary files"); } ThreadInfo[ThreadId].AddToTmpFileList(tmp_file1); ThreadInfo[ThreadId].AddToTmpFileList(tmp_file2); if (FVerbose) Message("INFO: tmp file 1 = %s, tmp file 2 = %s", tmp_file1, tmp_file2); Message("Running the test (%s)", buf); strcat_s(buf, " > "); strcat_s(buf, tmp_file1); // Make sure the output file isn't there. DeleteFileIfFound(tmp_file1); fFailed = FALSE; // Check for timeout. { int retval = ExecuteCommand(pDir->GetDirectoryPath(), buf, millisecTimeout, envFlags); if (retval == WAIT_TIMEOUT) { ASSERT(millisecTimeout != INFINITE); LogOut("ERROR: Test timed out after %ul seconds", millisecTimeout / 1000); fFailed = TRUE; goto logFailure; } } // Check the output. if (pTestVariant->testInfo.data[TIK_BASELINE]) { int spiff_ret; // Check to see if the exe ran at all. if (GetFileAttributes(tmp_file1) == INVALID_FILE_ATTRIBUTES) { LogOut("ERROR: Test failed to run. Couldn't find file '%s' (%s):", tmp_file1, optReportBuf); LogOut(" %s", cmdbuf); fFailed = TRUE; } else { sprintf_s(full, "%s\\%s", pDir->GetFullPathFromSourceOrDirectory(), pTestVariant->testInfo.data[TIK_BASELINE]); if (DoCompare(tmp_file1, full, pTestVariant->testInfo.hasData[TIK_EOL_NORMALIZATION])) { // Output differs, run spiff to see if it's just minor // floating point anomalies. DeleteFileIfFound(tmp_file2); sprintf_s(buf, "spiff -m -n -s \"command spiff\" %s %s > %s", tmp_file1, full, tmp_file2); spiff_ret = ExecuteCommand(pDir->GetDirectoryPath(), buf); if (GetFileAttributes(tmp_file2) == INVALID_FILE_ATTRIBUTES) { LogError("ERROR: spiff failed to run"); fFailed = TRUE; } else if (spiff_ret) { LogOut("ERROR: Test failed to run correctly. spiff returned %d (%s):", spiff_ret, optReportBuf); LogOut(" %s", cmdbuf); fFailed = TRUE; } } } } else { if (!CheckForPass(tmp_file1, optReportBuf, cmdbuf)) { fFailed = TRUE; } } logFailure: if (fFailed) { if (FCopyOnFail) { if (FVerbose) Message("INFO: Copying '%s' failure", optReportBuf); sprintf_s(failDir, "%s\\fail.%s", pDir->GetDirectoryPath(), optReportBuf); if ((GetFileAttributes(failDir) == INVALID_FILE_ATTRIBUTES) && !CreateDirectory(failDir, NULL)) { Message("ERROR: Couldn't create directory '%s'", failDir); } else { for (StringList * pFile = pTest->files; pFile != NULL; pFile = pFile->next) { sprintf_s(copyName, "%s\\%s", failDir, pFile->string); p = strrchr(copyName, '.') + 1; strcpy_s(p, REMAININGARRAYLEN(copyName, p + 1), "obj"); sprintf_s(buf, "%s\\%s", pDir->GetDirectoryPath(), pFile->string); p = strrchr(buf, '.') + 1; strcpy_s(p, REMAININGARRAYLEN(buf, p + 1), "obj"); if (!CopyFile(buf, copyName, FALSE)) { Message("ERROR: Couldn't copy '%s' to '%s'", buf, copyName); } } sprintf_s(copyName, "%s\\%s", failDir, exebuf); if (!CopyFile(fullexebuf, copyName, FALSE)) { Message("ERROR: Couldn't copy '%s' to '%s'", fullexebuf, copyName); } } } } if (FRLFE) { RLFETestStatus(pDir); } if (FVerbose) Message("INFO: cleaning up test run"); // Remove the exe. if (!FNoDelete) { DeleteFileRetryMsg(fullexebuf); } // Don't trash fullexebuf! strcpy_s(buf, fullexebuf); p = strrchr(buf, '.') + 1; // Remove the pdb(s) (if it exists). strcpy_s(p, REMAININGARRAYLEN(buf, p), "pdb"); DeleteFileIfFound(buf); DeleteMultipleFiles(pDir, "*.pdb"); // Remove the ilk (if it exists). strcpy_s(p, REMAININGARRAYLEN(buf, p), "ilk"); DeleteFileIfFound(buf); // Remove the objs. if (!FNoDelete) { for (StringList * pFile = pTest->files; pFile != NULL; pFile = pFile->next) { sprintf_s(buf, "%s\\%s", pDir->GetDirectoryPath(), pFile->string); p = strrchr(buf, '.') + 1; if (fCleanAfter) { strcpy_s(p, REMAININGARRAYLEN(buf, p), "obj"); DeleteFileRetryMsg(buf); } if (REGR_ASM) { strcpy_s(p, REMAININGARRAYLEN(buf, p), "asm"); DeleteFileRetryMsg(buf); } } } elapsed_variation = (int)(time(NULL) - start_variation); if (Timing & TIME_VARIATION) { Message("RL: Variation elapsed time (%s, %s, %s): %02d:%02d", pDir->GetDirectoryName(), pTest->name, optReportBuf, elapsed_variation / 60, elapsed_variation % 60); } if (FSyncVariation) { if (FRLFE && fFailed) RLFEAddLog(pDir, RLFES_FAILED, pTest->name, optReportBuf, ThreadOut->GetText()); if (fSyncVariationWhenFinished) FlushOutput(); } ThreadInfo[ThreadId].DeleteTmpFileList(); return fFailed ? -1 : 0; }
// Handle external test scripts. We support three kinds, makefiles (rl.mak), // command shell (dotest.cmd), and JScript (*.js). // // Standardized makefiles have the following targets: // clean: delete all generated files // build: build the test (OPT=compile options) // run: run the test // copy: copy the generated files to a subdirectory (COPYDIR=subdir) // int DoOneExternalTest( CDirectory* pDir, TestVariant *pTestVariant, const char *optFlags, const char *inCCFlags, const char *inLinkFlags, const char *testCmd, ExternalTestKind kind, BOOL fSyncVariationWhenFinished, BOOL fCleanBefore, BOOL fCleanAfter, BOOL fSuppressNoGPF, void *envFlags, DWORD millisecTimeout ) { #define NMAKE "nmake -nologo -R -f " char full[MAX_PATH]; char cmdbuf[BUFFER_SIZE]; char buf[BUFFER_SIZE]; char ccFlags[BUFFER_SIZE]; char linkFlags[BUFFER_SIZE]; char nogpfFlags[BUFFER_SIZE]; char optReportBuf[BUFFER_SIZE]; char nonZeroReturnBuf[BUFFER_SIZE]; const char *reason = NULL; time_t start_variation; UINT elapsed_variation; time_t start_build_variation; UINT elapsed_build_variation; LARGE_INTEGER start_run, end_run, frequency; UINT elapsed_run; BOOL fFailed = FALSE; BOOL fDumpOutputFile = FVerbose; BOOL fFileToDelete = FALSE; int cmdResult; static unsigned int testCount = 0; unsigned int localTestCount = InterlockedIncrement(&testCount); // Avoid conditionals by copying/creating ccFlags appropriately. if (inCCFlags) { if (pDir->HasTestInfoData(TIK_SOURCE_PATH)) { sprintf_s(ccFlags, " %s -baselinePath:%s", inCCFlags, pDir->GetDirectoryPath()); } else { sprintf_s(ccFlags, " %s", inCCFlags); } } else { ccFlags[0] = '\0'; } switch (TargetMachine) { case TM_WVM: case TM_WVMX86: case TM_WVM64: strcat_s(ccFlags, " /BC "); break; } if (inLinkFlags) strcpy_s(linkFlags, inLinkFlags); else linkFlags[0] = '\0'; sprintf_s(optReportBuf, "%s%s%s", optFlags, *linkFlags ? ";" : "", linkFlags); // Update the status. sprintf_s(buf, " (%s)", optReportBuf); ThreadInfo[ThreadId].SetCurrentTest(pDir->GetDirectoryName(), buf, pDir->IsBaseline()); UpdateTitleStatus(); // Make sure the file that will say pass or fail is not present. sprintf_s(full, "%s\\testout%d", pDir->GetDirectoryPath(), localTestCount); DeleteFileIfFound(full); start_variation = time(NULL); if (kind == TK_MAKEFILE) { Message(""); // newline Message("Processing %s with '%s' flags", testCmd, optReportBuf); Message(""); // newline if (FTest) { return 0; } if (fCleanBefore) { // Clean the directory. sprintf_s(cmdbuf, NMAKE"%s clean", testCmd); Message(cmdbuf); ExecuteCommand(pDir->GetDirectoryPath(), cmdbuf); } FillNoGPFFlags(nogpfFlags, fSuppressNoGPF); // Build the test. start_build_variation = time(NULL); sprintf_s(cmdbuf, NMAKE"%s build OPT=\"%s %s%s\" LINKFLAGS=\"%s %s %s\"", testCmd, optFlags, EXTRA_CC_FLAGS, ccFlags, LINKFLAGS, linkFlags, nogpfFlags); if (strlen(cmdbuf) > BUFFER_SIZE - 1) Fatal("Buffer overrun"); Message(cmdbuf); fFailed = ExecuteCommand(pDir->GetDirectoryPath(), cmdbuf); elapsed_build_variation = (int)(time(NULL) - start_build_variation); if (Timing & TIME_VARIATION) { Message("RL: Variation elapsed time (build) (%s, %s, %s): %02d:%02d", pDir->GetDirectoryName(), "rl.mak", optReportBuf, elapsed_build_variation / 60, elapsed_build_variation % 60); } if (fFailed) { reason = "build failure"; goto logFailure; } // Run the test. QueryPerformanceCounter(&start_run); sprintf_s(cmdbuf, NMAKE"%s run", testCmd); Message(cmdbuf); cmdResult = ExecuteCommand(pDir->GetDirectoryPath(), cmdbuf, millisecTimeout); QueryPerformanceCounter(&end_run); QueryPerformanceFrequency(&frequency); elapsed_run = (int) (((end_run.QuadPart - start_run.QuadPart) * 1000UI64) / frequency.QuadPart); if (Timing & TIME_VARIATION) { Message("RL: Variation elapsed time (run) (%s, %s, %s): %02d:%02d.%03d", pDir->GetDirectoryName(), "rl.mak", optReportBuf, elapsed_run / 60000, (elapsed_run % 60000)/1000, elapsed_run % 1000); } } else if (kind == TK_CMDSCRIPT) { // Build up the test command string sprintf_s(cmdbuf, "%s %s %s%s >testout%d", testCmd, optFlags, EXTRA_CC_FLAGS, ccFlags, localTestCount); Message("Running '%s'", cmdbuf); if (FTest) { return 0; } cmdResult = ExecuteCommand(pDir->GetDirectoryPath(), cmdbuf, millisecTimeout, envFlags); } else if (kind == TK_JSCRIPT || kind==TK_HTML || kind == TK_COMMAND) { char tempExtraCCFlags[MAX_PATH*2] = {0}; // Only append when EXTRA_CC_FLAGS isn't empty. if (EXTRA_CC_FLAGS[0]) { // Append test case unique identifier to the end of EXTRA_CC_FLAGS. if (FAppendTestNameToExtraCCFlags) { sprintf_s(tempExtraCCFlags, "%s.%s", EXTRA_CC_FLAGS, pTestVariant->testInfo.data[TIK_FILES]); } else { strcpy_s(tempExtraCCFlags, EXTRA_CC_FLAGS); } } const char* cmd = JCBinary; if (kind != TK_JSCRIPT && kind != TK_HTML) { cmd = pTestVariant->testInfo.data[TIK_COMMAND]; } sprintf_s(cmdbuf, "%s %s %s %s %s >%s 2>&1", cmd, optFlags, tempExtraCCFlags, ccFlags, testCmd, full); Message("Running '%s'", cmdbuf); if(FTest) { DeleteFileIfFound(full); return 0; } cmdResult = ExecuteCommand(pDir->GetFullPathFromSourceOrDirectory(), cmdbuf, millisecTimeout, envFlags); if (cmdResult && cmdResult != WAIT_TIMEOUT && !pTestVariant->testInfo.data[TIK_BASELINE]) // failure code, not baseline diffing { fFailed = TRUE; sprintf_s(nonZeroReturnBuf, "non-zero (%08X) return value from test command", cmdResult); reason = nonZeroReturnBuf; goto logFailure; } } else { ASSERTNR(UNREACHED); cmdResult = NOERROR; // calm compiler warning about uninitialized variable usage } // Check for timeout. if (cmdResult == WAIT_TIMEOUT) { ASSERT(millisecTimeout != INFINITE); sprintf_s(nonZeroReturnBuf, "timed out after %u second%s", millisecTimeout / 1000, millisecTimeout == 1000 ? "" : "s"); reason = nonZeroReturnBuf; fFailed = TRUE; goto logFailure; } // If we have a baseline test, we need to check the baseline file. if (pTestVariant->testInfo.data[TIK_BASELINE]) { char baseline_file[_MAX_PATH]; sprintf_s(baseline_file, "%s\\%s", pDir->GetFullPathFromSourceOrDirectory(), pTestVariant->testInfo.data[TIK_BASELINE]); if (DoCompare(baseline_file, full, pTestVariant->testInfo.hasData[TIK_EOL_NORMALIZATION])) { reason = "diffs from baseline"; sprintf_s(optReportBuf, "%s", baseline_file); fFailed = TRUE; CopyRebaseFile(full, baseline_file); } } else if ((kind == TK_JSCRIPT || kind == TK_HTML || kind == TK_COMMAND) && !pTestVariant->testInfo.hasData[TIK_BASELINE]) { if (!CheckForPass(full, optReportBuf, cmdbuf, fDumpOutputFile)) { fFailed = TRUE; goto SkipLogFailure; } } logFailure: if (fFailed) { LogOut("ERROR: Test failed to run correctly: %s (%s):", reason, optReportBuf); LogOut(" %s", cmdbuf); if (fDumpOutputFile) { DumpFileToLog(full); } } SkipLogFailure: if (fFileToDelete && !FNoDelete) { DeleteFileRetryMsg(full); } elapsed_variation = (int)(time(NULL) - start_variation); if (Timing & TIME_VARIATION) { Message("RL: Variation elapsed time (%s, %s, %s): %02d:%02d", pDir->GetDirectoryName(), kind == TK_MAKEFILE ? "rl.mak" : "dotest.cmd", optReportBuf, elapsed_variation / 60, elapsed_variation % 60); } if (kind == TK_MAKEFILE) { // If the test failed and we are asked to copy the failures, do so. if (fFailed && FCopyOnFail) { sprintf_s(cmdbuf, NMAKE"%s copy COPYDIR=\"fail.%s.%s\"", testCmd, optFlags, linkFlags); Message(cmdbuf); ExecuteCommand(pDir->GetDirectoryPath(), cmdbuf); } // Clean up after ourselves. if (!FNoDelete && (fFailed || fCleanAfter)) { sprintf_s(cmdbuf, NMAKE"%s clean", testCmd); Message(cmdbuf); ExecuteCommand(pDir->GetDirectoryPath(), cmdbuf); } } if (FSyncVariation) { if (FRLFE && fFailed) { RLFEAddLog(pDir, RLFES_FAILED, testCmd, optReportBuf, ThreadOut->GetText()); } if (fSyncVariationWhenFinished) FlushOutput(); } DeleteFileIfFound(full); return fFailed ? -1 : 0; }
int DoPogoSimpleTest( CDirectory *pDir, Test * pTest, TestVariant * pTestVariant, BOOL fSuppressNoGPF, DWORD millisecTimeout ) { static const char *pgc = "*.pgc"; static const char *pgd = POGO_PGD; char pgdFull[MAX_PATH]; char ccFlags[BUFFER_SIZE]; char linkFlags[BUFFER_SIZE]; BOOL fFailed; sprintf_s(pgdFull, "%s\\%s", pDir->GetDirectoryPath(), pgd); const char * inCCFlags = pTestVariant->testInfo.data[TIK_COMPILE_FLAGS]; const char * optFlags = pTestVariant->optFlags; DeleteFileIfFound(pgdFull); DeleteMultipleFiles(pDir, pgc); fFailed = FALSE; // Pogo requires LTCG ASSERT(strstr(optFlags, "GL") != NULL); sprintf_s(ccFlags, "%s %s", PogoForceErrors, optFlags); sprintf_s(linkFlags, "-ltcg:pgi -pgd:%s", pgd); if (DoOneSimpleTest(pDir, pTest, pTestVariant, ccFlags, inCCFlags, linkFlags, FALSE, FALSE, FALSE, fSuppressNoGPF, millisecTimeout)) { fFailed = TRUE; goto logFailure; } if (FTest) { return 0; } sprintf_s(ccFlags, "%s %s", PogoForceErrors, optFlags); sprintf_s(linkFlags, "-ltcg:pgo -pgd:%s", pgd); if (DoOneSimpleTest(pDir, pTest, pTestVariant, ccFlags, inCCFlags, linkFlags, FALSE, TRUE, TRUE, fSuppressNoGPF, millisecTimeout)) { fFailed = TRUE; } logFailure: if (FSyncVariation) { #if 0 if (FRLFE && fFailed) { sprintf_s(cmdbuf, "%s%s%s", ccFlags, *linkFlags ? ";" : "", linkFlags); RLFEAddLog(pDir, RLFES_FAILED, testCmd, cmdbuf, ThreadOut->GetText()); } #endif FlushOutput(); } if (!FNoDelete) { DeleteFileRetryMsg(pgdFull); DeleteMultipleFiles(pDir, pgc); } return fFailed ? -1 : 0; }
/* * save_copy() - Append a copy of the message contained in "filename" to * the file specified by "copy_file". This routine simply gets all of * the filenames right, and then invokes "save_mssg()" to do * the dirty work. */ int save_copy(const char *fname_dest, const char *fname_mssg, const SEND_HEADER *shdr, int form) { char buffer[SLEN], /* read buffer */ savename[SLEN], /* name of file saving into */ msg_buffer[SLEN]; char *return_alias; int is_ordinary_file; int err; /* presume fname_dest is okay as is for now */ strcpy(savename, fname_dest); /* if save_by_name or save_by_alias wanted */ if((strcmp(fname_dest, "=") == 0) || (strcmp(fname_dest, "=?") == 0)) { if ((save_by_alias && (return_alias = address_to_alias(shdr->expanded_to)) != NULL)) strcpy(buffer, return_alias); else if (save_by_name) get_return_name(shdr->expanded_to, buffer, TRUE); else get_return_name(shdr->to, buffer, TRUE); if (strlen(buffer) == 0) { /* can't get file name from 'to' -- use sent_mail instead */ dprint(3, (debugfile, "Warning: get_return_name couldn't break down %s\n", shdr->to)); show_error(catgets(elm_msg_cat, ElmSet, ElmCannotDetermineToName, "Cannot determine `to' name to save by! Saving to \"sent\" folder %s instead."), sent_mail); strcpy(savename, "<"); if (sleepmsg > 0) sleep(sleepmsg); } else sprintf(savename, "=%s", buffer); /* good! */ } expand_filename(savename); /* * If saving conditionally by logname but folder doesn't * exist save to sent folder instead. */ if((strcmp(fname_dest, "=?") == 0) && (access(savename, WRITE_ACCESS) != 0)) { dprint(5, (debugfile, "Conditional save by name: file %s doesn't exist - using \"<\".\n", savename)); strcpy(savename, "<"); expand_filename(savename); } /* * Allow options * confirm_files, confirm_folders, * confirm_append and confirm_create * to control where the actual copy * should be saved. */ is_ordinary_file = strncmp (savename, folders, strlen(folders)); if (elm_access(savename, ACCESS_EXISTS)== 0) { /* already there!! */ if (confirm_append || (confirm_files && is_ordinary_file)) { /* * OK in batch mode it may be impossible * to ask the user to confirm. So we have * to use sent_mail anyway. */ if (!OPMODE_IS_INTERACTIVE(opmode)) { strcpy(savename, sent_mail); } else { if (is_ordinary_file) sprintf(msg_buffer, catgets(elm_msg_cat, ElmSet, ElmConfirmFilesAppend, "Append to an existing file `%s'?"), savename); else sprintf(msg_buffer, catgets(elm_msg_cat, ElmSet, ElmConfirmFolderAppend, "Append to mail folder `%s'?"), savename); /* FOO - does this really need to be "clear-and-center" ? */ if (!enter_yn(msg_buffer, FALSE, LINES-2, TRUE)) { strcpy(savename, sent_mail); PutLine(LINES-2, 0, catgets(elm_msg_cat, ElmSet, ElmSavingToInstead, "Alright - saving to `%s' instead"), savename); FlushOutput(); if (sleepmsg > 0) sleep(sleepmsg); ClearLine (LINES-2); } } } } else { if (confirm_create || (confirm_folders && !is_ordinary_file)) { /* * OK in batch mode it may be impossible * to ask the user to confirm. So we have * to use sent_mail anyway. */ if (!OPMODE_IS_INTERACTIVE(opmode)) { strcpy(savename, sent_mail); } else { if (is_ordinary_file) sprintf(msg_buffer, catgets(elm_msg_cat, ElmSet, ElmConfirmFilesCreate, "Create a new file `%s'?"), savename); else sprintf(msg_buffer, catgets(elm_msg_cat, ElmSet, ElmConfirmFolderCreate, "Create a new mail folder `%s'?"), savename); /* FOO - does this really need to be "clear-and-center" ? */ if (!enter_yn(msg_buffer, FALSE, LINES-2, TRUE)) { strcpy(savename, sent_mail); PutLine(LINES-2, 0, catgets(elm_msg_cat, ElmSet, ElmSavingToInstead, "Alright - saving to `%s' instead"), savename); FlushOutput(); if (sleepmsg > 0) sleep(sleepmsg); ClearLine (LINES-2); } } } } if ((err = can_open(savename, "a"))) { dprint(2, (debugfile, "Error: attempt to autosave to a file that can't be appended to!\n")); dprint(2, (debugfile, "\tfilename = \"%s\"\n", savename)); dprint(2, (debugfile, "** %s **\n", strerror(err))); /* Lets try sent_mail before giving up */ if(strcmp(sent_mail, savename) == 0) { /* we are ALREADY using sent_mail! */ show_error(catgets(elm_msg_cat, ElmSet, ElmCannotSaveTo, "Cannot save to %s!"), savename); return(FALSE); } if ((err = can_open(sent_mail, "a"))) { dprint(2, (debugfile, "Error: attempt to autosave to a file that can't be appended to!\n")); dprint(2, (debugfile, "\tfilename = \"%s\"\n", sent_mail)); dprint(2, (debugfile, "** %s **\n", strerror(err))); show_error(catgets(elm_msg_cat, ElmSet, ElmCannotSaveToNorSent, "Cannot save to %s nor to \"sent\" folder %s!"), savename, sent_mail); return(FALSE); } show_error(catgets(elm_msg_cat, ElmSet, ElmCannotSaveToSavingInstead, "Cannot save to %s! Saving to \"sent\" folder %s instead."), savename, sent_mail); if (sleepmsg > 0) sleep(sleepmsg); strcpy(savename, sent_mail); } return save_mssg(savename, fname_mssg, shdr, form); }
/* FOO - should this routine use the file browser? */ int name_copy_file(char *fn) { /* * Prompt user for name of file for saving copy of outbound msg to. * Update "fn" with user's response. * Return TRUE if we need a redraw (i.e. help displayed). */ int redraw, i; char buffer[SLEN], origbuffer[SLEN], *ncf_prompt; redraw = FALSE; ncf_prompt = catgets(elm_msg_cat, ElmSet, ElmSaveCopyInPrompt, "Save copy in (use '?' for help/to list folders): "); /* convert the save cookie to readable explanation */ (void) strcpy(origbuffer, cf_english(fn)); for (;;) { /* load in the default value */ strcpy(buffer, origbuffer); /* prompt for save file name */ MoveCursor(LINES-2, 0); CleartoEOS(); PutLine(LINES-2, 0, ncf_prompt); if (enter_string(buffer, sizeof(buffer), -1, -1, ESTR_REPLACE) < 0) { /* aborted - restore value */ (void) strcpy(buffer, origbuffer); break; } /* break out if if we got an answer */ if (strcmp(buffer, "?") != 0) break; /* user asked for help */ redraw = TRUE; Raw(OFF | NO_TITE); ClearScreen(); printf(catgets(elm_msg_cat, ElmSet, ElmListFoldersHelp, "Enter: <nothing> to not save a copy of the message,\n\ \r '<' to save in your \"sent\" folder (%s),\n\ \r '=' to save by name (the folder name depends on whom the\n\ \r message is to, in the end),\n\ \r '=?' to save by name if the folder already exists,\n\ \r and if not, to your \"sent\" folder,\n\ \r or a filename (a leading '=' denotes your folder directory).\n\ \r\n\ \r"), sent_mail); printf(catgets(elm_msg_cat, ElmSet, ElmContentsOfYourFolderDir, "\n\rContents of your folder directory:\n\r\n\r")); sprintf(buffer, "cd %s;ls -C", folders); (void) system_call(buffer, 0); for (i = 0 ; i < 4 ; ++i) printf("\n\r"); Raw(ON | NO_TITE); } /* snarf any entry made by the user */ if (!streq(origbuffer, buffer)) strcpy(fn, buffer); /* display English expansion of new user input a while */ PutLine(LINES-2, strlen(ncf_prompt), cf_english(fn)); MoveCursor(LINES-1, 0); FlushOutput(); if (sleepmsg > 0) sleep((sleepmsg + 1) / 2); MoveCursor(LINES-2, 0); CleartoEOS(); return redraw; }
// Serves a page by interpreting command codes, processing script commands, // and handling variable substitution. Any variables provided in the override_list // will take precedence over variables of the same name defined in the page. int ServePageWithOverride(char *page, int page_size, PageVar *override_list) { // Initialize varlist PageVar *varlist = calloc(sizeof(PageVar), 1); VerifyPointerOrTerminate(varlist, "VarList initialization"); in_a_box = 0; cgc_memset(line, '\0', sizeof(line)); line_length = 0; #ifdef PATCHED if (page == NULL) { goto error; } #endif while ((*page != '\0')&&(page < page + page_size)) { if (*page == '~') { // Command character, process command page++; switch (*page) { case 't': { for (int i=0; i<4; i++) { OutputChar(' '); } break; } case 'n': { FlushOutput(); break; } case '[': { OutputChar('['); break; } case ']': { OutputChar(']'); break; } case '~': { OutputChar('~'); break; } case '#': { OutputChar('#'); break; } default: { printf("ERROR: Invalid control code\n"); goto error; } } page++; } else if (*page == '[') { // Script tag, find closing tag and process script char *close = ++page; while (*close != ']' && *close != '\0') close++; if (*close == '\0') { goto error; } // Process script commands if (strncmp(page, "line", cgc_strlen("line")) == 0) { page += cgc_strlen("line"); if (*page != ':') { goto error; } char c = *(++page); if (*(++page) != ':') { goto error; } int length = atoi(++page); for (int i = 0; i < length; i++) { OutputChar(c); } page = close + 1; } else if (strncmp(page, "var", cgc_strlen("var")) == 0) { AddPageVar(varlist, page); page = close + 1; } else if (strncmp(page, "box", cgc_strlen("box")) == 0) { in_a_box = 1; FlushOutput(); for (int i = 0; i < 80; i++) { putc('*'); } printf("\n"); page += 4; } } else if (*page == ']') { page++; if (in_a_box) { in_a_box = 0; FlushOutput(); for (int i = 0; i < 80; i++) { putc('*'); } printf("\n"); } else { goto error; } } else if (*page == '#') { // Variable substitution char *end = ++page; while (*end != '\0' && *end != '#') { end++; } if (*end != '#') { goto error; } PageVar *var = NULL; // Check for overridden variables if (override_list != NULL) { var = GetPageVar(override_list, page, end); } // Fall back to default values if override doesn't exist if (var == NULL) { var = GetPageVar(varlist, page, end); } // If a value has been found, output it if (var != NULL) { OutputStr(var->value); } page = end + 1; } else { // Normal character, send to output OutputChar(*page); page++; } } if (line_length != 0) { FlushOutput(); } DestroyVarList(varlist); DestroyVarList(override_list); return 0; error: printf("ERROR: Invalid syntax\n"); DestroyVarList(varlist); DestroyVarList(override_list); return -1; }
void COMXCoreComponent::FlushAll() { FlushInput(); FlushOutput(); }
int DoPogoExternalTest( CDirectory* pDir, TestVariant * pTestVariant, char *testCmd, ExternalTestKind kind, BOOL fSuppressNoGPF, DWORD millisecTimeout ) { static const char *pgc = "*.pgc"; static const char *pgd = POGO_PGD; char pgdFull[MAX_PATH]; char ccFlags[BUFFER_SIZE]; char linkFlags[BUFFER_SIZE]; char cmdbuf[BUFFER_SIZE]; BOOL fFailed; void *envFlags = GetEnvFlags(pTestVariant); sprintf_s(pgdFull, "%s\\%s", pDir->GetDirectoryPath(), pgd); const char * inCCFlags = pTestVariant->testInfo.data[TIK_COMPILE_FLAGS]; const char * optFlags = pTestVariant->optFlags; DeleteFileIfFound(pgdFull); DeleteMultipleFiles(pDir, pgc); fFailed = FALSE; // Pogo requires LTCG ASSERT(strstr(optFlags, "GL") != NULL); if (!kind == TK_MAKEFILE) { Warning("'%s\\%s' is not a makefile test; Pogo almost certainly won't work", pDir->GetDirectoryPath(), testCmd); } sprintf_s(ccFlags, "%s %s", PogoForceErrors, optFlags); sprintf_s(linkFlags, "-ltcg:pgi -pgd:%s", pgd); if (DoOneExternalTest(pDir, pTestVariant, ccFlags, inCCFlags, linkFlags, testCmd, kind, FALSE, TRUE, FALSE, fSuppressNoGPF, envFlags, millisecTimeout)) { fFailed = TRUE; goto logFailure; } sprintf_s(ccFlags, "%s %s", PogoForceErrors, optFlags); sprintf_s(linkFlags, "-ltcg:pgo -pgd:%s", pgd); // Manually erase EXE and DLL files to get makefile to relink. // Also erase ASM files because some makefiles try to rebuild from // them. DeleteMultipleFiles(pDir, "*.exe"); DeleteMultipleFiles(pDir, "*.dll"); DeleteMultipleFiles(pDir, "*.asm"); if (DoOneExternalTest(pDir, pTestVariant, ccFlags, inCCFlags, linkFlags, testCmd, kind, FALSE, FALSE, TRUE, fSuppressNoGPF, envFlags, millisecTimeout)) { fFailed = TRUE; } logFailure: if (FSyncVariation) { if (FRLFE && fFailed) { sprintf_s(cmdbuf, "%s%s%s", ccFlags, *linkFlags ? ";" : "", linkFlags); RLFEAddLog(pDir, RLFES_FAILED, testCmd, cmdbuf, ThreadOut->GetText()); } FlushOutput(); } if (FRLFE) RLFETestStatus(pDir); if (!FNoDelete) { DeleteFileRetryMsg(pgdFull); DeleteMultipleFiles(pDir, pgc); } return fFailed ? -1 : 0; }