void test_gte_lte(void) { assert_int_equal(DoCompare("1.0-1", "1.0-1", PACKAGE_VERSION_COMPARATOR_GE), VERCMP_MATCH); assert_int_equal(DoCompare("1.0-1", "1.0-2", PACKAGE_VERSION_COMPARATOR_GE), VERCMP_NO_MATCH); assert_int_equal(DoCompare("1.0-2", "1.0-1", PACKAGE_VERSION_COMPARATOR_GE), VERCMP_MATCH); assert_int_equal(DoCompare("1.0-1", "1.0-1", PACKAGE_VERSION_COMPARATOR_LE), VERCMP_MATCH); assert_int_equal(DoCompare("1.0-1", "1.0-2", PACKAGE_VERSION_COMPARATOR_LE), VERCMP_MATCH); assert_int_equal(DoCompare("1.0-2", "1.0-1", PACKAGE_VERSION_COMPARATOR_LE), VERCMP_NO_MATCH); }
void test_gte_lte(void) { assert_int_equal(DoCompare("1.0-1", "1.0-1", PACKAGE_VERSION_COMPARATOR_GE), true); assert_int_equal(DoCompare("1.0-1", "1.0-2", PACKAGE_VERSION_COMPARATOR_GE), false); assert_int_equal(DoCompare("1.0-2", "1.0-1", PACKAGE_VERSION_COMPARATOR_GE), true); assert_int_equal(DoCompare("1.0-1", "1.0-1", PACKAGE_VERSION_COMPARATOR_LE), true); assert_int_equal(DoCompare("1.0-1", "1.0-2", PACKAGE_VERSION_COMPARATOR_LE), true); assert_int_equal(DoCompare("1.0-2", "1.0-1", PACKAGE_VERSION_COMPARATOR_LE), false); }
int MultiSortFilterProxy::Compare(const QVariant& left, const QVariant& right) const { // Copied from the QSortFilterProxyModel::lessThan implementation, but returns // -1, 0 or 1 instead of true or false. switch (left.userType()) { case QVariant::Invalid: return (right.type() != QVariant::Invalid) ? -1 : 0; case QVariant::Int: return DoCompare(left.toInt(), right.toInt()); case QVariant::UInt: return DoCompare(left.toUInt(), right.toUInt()); case QVariant::LongLong: return DoCompare(left.toLongLong(), right.toLongLong()); case QVariant::ULongLong: return DoCompare(left.toULongLong(), right.toULongLong()); case QMetaType::Float: return DoCompare(left.toFloat(), right.toFloat()); case QVariant::Double: return DoCompare(left.toDouble(), right.toDouble()); case QVariant::Char: return DoCompare(left.toChar(), right.toChar()); case QVariant::Date: return DoCompare(left.toDate(), right.toDate()); case QVariant::Time: return DoCompare(left.toTime(), right.toTime()); case QVariant::DateTime: return DoCompare(left.toDateTime(), right.toDateTime()); case QVariant::String: default: if (isSortLocaleAware()) return left.toString().localeAwareCompare(right.toString()); else return left.toString().compare(right.toString(), sortCaseSensitivity()); } return 0; }
typecmp_t TypeCmp (const Type* lhs, const Type* rhs) /* Compare two types and return the result */ { /* Assume the types are identical */ typecmp_t Result = TC_IDENTICAL; #if 0 printf ("Left : "); PrintRawType (stdout, lhs); printf ("Right: "); PrintRawType (stdout, rhs); #endif /* Recursively compare the types if they aren't identical */ if (rhs != lhs) { DoCompare (lhs, rhs, &Result); } /* Return the result */ return Result; }
void invalid_08(void) { assert_int_equal(DoCompare("1.0", "text-1.0", PACKAGE_VERSION_COMPARATOR_GT), VERCMP_ERROR); }
void uneven_lengths_20(void) { assert_int_equal(DoCompare("1.0", "1.0-1", PACKAGE_VERSION_COMPARATOR_LE), VERCMP_MATCH); }
void uneven_lengths_7(void) { assert_int_equal(DoCompare("1.0", "1.0.1", PACKAGE_VERSION_COMPARATOR_GT), VERCMP_NO_MATCH); }
void wrong_separators(void) { assert_int_equal(DoCompare("1.0", "1,0", PACKAGE_VERSION_COMPARATOR_EQ), VERCMP_ERROR); }
void CuDlgMain::OnButtonCompare() { DoCompare(); theApp.GetSessionManager().Cleanup(); // Disconnect all the DBMS sessions }
// 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; }
void uneven_lengths_19(void) { assert_int_equal(DoCompare("1.0", "1.0-1", PACKAGE_VERSION_COMPARATOR_GE), false); }
void uneven_lengths_18(void) { assert_int_equal(DoCompare("1.0", "1.0-1", PACKAGE_VERSION_COMPARATOR_LT), true); }
void test_eq(void) { assert_int_equal(DoCompare("1.0-1", "1.0-1", PACKAGE_VERSION_COMPARATOR_EQ), true); assert_int_equal(DoCompare("1.0-1", "1.0-1", PACKAGE_VERSION_COMPARATOR_NONE), true); assert_int_equal(DoCompare("1.0-1", "1.0-2", PACKAGE_VERSION_COMPARATOR_EQ), false); }
void compareHex(void) { DoCompare(); DialogUpdate(); setMenu(); }
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; }
void test_different_name(void) { EvalContext *ctx = EvalContextNew(); PromiseResult result; PackageItem pi = { .name = "pkgone", .version = "1", .arch = "arch" }; Attributes attr = { .packages = { .package_select = PACKAGE_VERSION_COMPARATOR_EQ } }; assert_int_equal(ComparePackages(ctx, "pkgtwo", "1", "arch", &pi, attr, NULL, "test", &result), VERCMP_NO_MATCH); EvalContextDestroy(ctx); } void test_wildcard_arch(void) { EvalContext *ctx = EvalContextNew(); PromiseResult result; PackageItem pi = { .name = "foobar", .version = "1", .arch = "arch" }; Attributes attr = { .packages = { .package_select = PACKAGE_VERSION_COMPARATOR_EQ } }; assert_int_equal(ComparePackages(ctx, "foobar", "1", "*", &pi, attr, NULL, "test", &result), VERCMP_MATCH); EvalContextDestroy(ctx); } void test_non_matching_arch(void) { EvalContext *ctx = EvalContextNew(); PromiseResult result; PackageItem pi = { .name = "foobar", .version = "1", .arch = "s390x" }; Attributes attr = { .packages = { .package_select = PACKAGE_VERSION_COMPARATOR_EQ } }; assert_int_equal(ComparePackages(ctx, "foobar", "1", "s390", &pi, attr, NULL, "test", &result), VERCMP_NO_MATCH); EvalContextDestroy(ctx); } VersionCmpResult DoCompare(const char *lhs, const char *rhs, PackageVersionComparator cmp) { EvalContext *ctx = EvalContextNew(); PromiseResult result; PackageItem pi = { .name = "foobar", .version = (char*)lhs, .arch = "somearch" }; Attributes a = { .packages = { .package_select = cmp, } }; VersionCmpResult cmp_result = ComparePackages(ctx, "foobar", rhs, "somearch", &pi, a, NULL, "test", &result); EvalContextDestroy(ctx); return cmp_result; } void test_wildcard_version(void) { assert_int_equal(DoCompare("1.0-1", "*", PACKAGE_VERSION_COMPARATOR_EQ), VERCMP_MATCH); }
void test_eq(void) { assert_int_equal(DoCompare("1.0-1", "1.0-1", PACKAGE_VERSION_COMPARATOR_EQ), VERCMP_MATCH); assert_int_equal(DoCompare("1.0-1", "1.0-1", PACKAGE_VERSION_COMPARATOR_NONE), VERCMP_MATCH); assert_int_equal(DoCompare("1.0-1", "1.0-2", PACKAGE_VERSION_COMPARATOR_EQ), VERCMP_NO_MATCH); }
void HandleElemProcs(){ vtype[1] = valnumb; // ID 1 is the line number startidarray(); valtype idtype; myscanner *scnr=new myscanner;; myparser prsr(3,2, scnr); prsr.startparser(); parseritem *item; unsigned prod, thisidpos, idpos = 2, startlocalids = 0; pgm *ppgm = new pgm; initpgm = ppgm; etd *segetd = 0, *thisetd, *fetd; varitem *w; unsigned asgnno; int /*boolean*/ itspop, segisopen, numbeles; int /*boolean*/ doingglobals = 1; int ifstk[24], ifptr=0; do { prod = prsr.doparse(item); // printf("Prod: %u, Item: %u, %s\n", prod, item->ItemNo(), item->IntStr()); switch (prod){ /* 11 <tactid type ::=> */ /* 12 <tactid type ::=> STRING */ case TACTIDTYPESTR1: case VARTYPESTR1: case TACTIDTYPESTR2: idtype = valstr; thisidpos = idpos++; break; /* 13 <tactid type ::=> NUMBER */ case TACTIDTYPENUMB: idtype = valnumb; thisidpos = idpos++; break; /* 14 <tactid type ::=> LINENO */ case TACTIDTYPELINE: idtype = valline; thisidpos = 1; break; /* 15 <tactid type ::=> WORD */ case TACTIDTYPEWORD: idtype = valword; thisidpos = 0; break; case TACTIDMAINNAME: NumbTACTIds = NumbGlobalvars = MaxNumbVars = idpos; if (!addmainid(item->IntStr(), idtype)){ ResFile->MsgData(item->DisplayPosition()); ResFile->MsgData(item->IntStr()); ResFile->PutResError( NAMEINUSE ); exit(100); } HandleDeclare(item, idtype, globalvars, thisidpos); vtype[thisidpos] = idtype; if (idtype==valstr)ppgm->Append(new pgminittids(thisidpos)); else ppgm->Append(new pgminittidn(thisidpos)); break; /* 19 <alt name list ::=> <alt name list> , <name> */ case TACTIDALTNAME1: /* 20 <alt name list ::=> <name> */ case TACTIDALTNAME2: if (!addotherid(item->IntStr())){ ResFile->MsgData(item->DisplayPosition()); ResFile->MsgData(item->IntStr()); ResFile->PutResError( NAMEINUSE ); exit(100); } HandleDeclare(item, idtype, globalvars, thisidpos); break; /* 30 <declare name ::=> <name> */ case DECLAREDGLOBALNAME: varnamestype *tvt; if (doingglobals){tvt = globalvars; NumbGlobalvars = idpos;} else tvt = localvars; if (idpos > MaxNumbVars) MaxNumbVars = idpos; HandleDeclare(item, idtype, tvt, thisidpos); vtype[thisidpos] = idtype; if (idtype==valstr){ ppgm->Append(new pgminitvars(thisidpos)); if(!doingglobals)localstrs[nolstrs++] = thisidpos; } else ppgm->Append(new pgminitvarn(thisidpos)); break; /* 36 <segment type ::=> OPEN */ case SEGMENTISOPEN: segisopen = 1; break; /* 36 <segment type ::=> CLOSE */ case SEGMENTISCLOSE: segisopen = 0; break; /* 37 <element list ::=> <element name> */ case FIRSTELEMENTNAME: if (!doingglobals)cleanuplocals(ppgm); // cleans up >previous< segment. doingglobals = 0; ppgm = new pgm; // break is intentionally missing here. j.b. numbeles = 0; /* 38 <element list ::=> <element list> , <element name> */ case OTHERELEMENTNAMES: segetd = ((etditem *)item)->MyEtd(); if (segisopen)segetd->startpgm = (void *)ppgm; else segetd->endpgm = (void *)ppgm; if (startlocalids == 0)startlocalids = idpos; else idpos = startlocalids; delete localvars; localvars = new varnamestype; numbeles++; break; /* 34 <actions ::=> <actions> <action statement> */ /* 35 <actions ::=> <action statement> */ case ACTIONSTATEMENT1: case ACTIONSTATEMENT2: if (sp != 0) printf("*program warning* sp = %d",sp); break; /* 66 <word op ::=> collect <logical expression> */ case HANDLECOLLECTCOMMAND: MkN(ppgm);sp--;ppgm->Append(new setpgmfmtopt(formatcollect));break; /* 67 <word op ::=> append <char expression> */ case HANDLEAPPENDCOMMAND: MkC(ppgm);sp--;ppgm->Append(new setpgmfmtwadj(wpost,formatwordpost)); break; /* 68 <word op ::=> prepend <char expression> */ case HANDLEPREPENDCOMMAND: MkC(ppgm);sp--;ppgm->Append(new setpgmfmtwadj(wpre,formatwordpre)); break; /* 69 <word op ::=> replace <char expression> */ case HANDLEREPLACECOMMAND: MkC(ppgm);sp--;ppgm->Append(new setpgmfmtwadj(wrep,formatwordrep)); break; /* 45 <simple action statement ::=> inc <declared name> */ /* 46 <simple action statement ::=> dec <declared name> */ case HANDLEINC: case HANDLEDEC: w = (varitem *)item; asgnno = w->Vardata()->pos(); ppgm->Append(new pgmvarld(asgnno,tstk[sp++]=w->Vardata()->type())); MkN(ppgm); StkN();ppgm->Append(new pgmintstk(1)); sp--; if (prod == HANDLEINC)ppgm->Append(new pgmbinop(add)); else ppgm->Append(new pgmbinop(subt)); if (vtype[asgnno]==valstr)MkC(ppgm); sp--; ppgm->Append(new pgmvarsv(asgnno)); break; /* 42 <simple action statement ::=> output <char expression> */ case HANDLEOUTPUTCOMMAND: MkC(ppgm); sp--; ppgm->Append(new pgmoutput);break; /* 46 <simple action statement ::=> output blines <arith expression> */ case DOBLANKLINES: MkN(ppgm); sp--;ppgm->Append(new pgminsblk);break; /* 43 <simple action statement ::=> error <char expression> */ case HANDLEERRORCOMMAND: MkC(ppgm); sp--; ppgm->Append(new pgmerror);break; /* 44 <simple action statement ::=> remark <char expression> */ case HANDLEREMARKCOMMAND: MkC(ppgm); sp--; ppgm->Append(new pgmremark);break; /* 38 <format option ::=> compress <logical expression> */ case SETFORMATCOMPRESS: MkN(ppgm);sp--;ppgm->Append(new setpgmfmtopt(formatcompress));break; /* 39 <format option ::=> centre <logical expression> */ case SETFORMATCENTRE: MkN(ppgm);sp--;ppgm->Append(new setpgmfmtopt(formatcentre));break; /* 40 <format option ::=> display <logical expression> */ case SETFORMATDISPLAY: MkN(ppgm);sp--;ppgm->Append(new setpgmfmtopt(formatdisplay));break; /* 41 <format option ::=> fill <logical expression> */ case SETFORMATFILL: MkN(ppgm);sp--;ppgm->Append(new setpgmfmtopt(formatfill));break; /* 42 <format option ::=> fold <arith expression> */ case SETFORMATFOLD: MkN(ppgm);sp--;ppgm->Append(new setpgmfmtfold);break; /* 43 <format option ::=> indent <arith expression> */ case SETFORMATINDENT: MkN(ppgm);sp--;ppgm->Append(new setpgmfmtindent);break; /* 75 <format option ::=> to <var name> */ case SETOUTTOVAR: w = (varitem *)item; if (VerifyVarForOut(w->Vardata())) ppgm->Append(new setpgmfmtout(w->Vardata()->pos())); else { /*RES OLD MSG 603 %0: Variable %1 has an incorrect type for "format to". */ ResFile->MsgData(w->DisplayPosition()); ResFile->MsgData(w->IntStr()); ResFile->PutResError(/*RES REM INS*/ 603); exit(100); } break; /* 76 <format option ::=> to tdb */ case SETOUTTOTDB: ppgm->Append(new setpgmfmtout(0)); break; /* 54 <popstack which ::=> POP */ case ITSPOP: itspop=1; break; /* 55 <popstack which ::=> STACK */ case ITSSTACK: itspop=0; break; /* 58 <ps item ::=> <var name> */ case POPSTACKVAR: w = (varitem *)item; if (itspop)ppgm->Append(new pgmpop(w->Vardata()->pos())); else ppgm->Append(new pgmpush(w->Vardata()->pos())); break; /* 54 <let statement ::=> let <destination> = <let expression> */ case DOTHEASSIGN: if ((vtype[asgnno]==valnumb)&&(tstk[sp-1] == valstr))MkN(ppgm); else if ((vtype[asgnno]==valstr)&&(tstk[sp-1] == valnumb))MkC(ppgm); sp--; ppgm->Append(new pgmvarsv(asgnno)); break; /* 55 <destination ::=> <var name> */ case GETASSIGNID: w = (varitem *)item; asgnno = w->Vardata()->pos(); break; /* 58 <char expression ::=> <char expression> | <char item> */ case CHAREXPAPPEND: Mk2C(ppgm); sp--;ppgm->Append(new pgmchbin(ccn));break; /* 60 <char item ::=> <string> */ case CHAREXPSTRING: StkC();ppgm->Append(new pgmchpush(item->IntStr()));break; /* 61 <char item ::=> nl */ case CHAREXPNEWLINE: StkC();ppgm->Append(new pgmchpush((UNCH *)"\n"));break; /* 64 <char item ::=> UPPER ( <char expression> ) */ case CHAREXPUPPER: MkC(ppgm);ppgm->Append(new pgmunop(unupp));break; /* 87 <char item ::=> THISGI */ case CHARTHISGI: StkC();ppgm->Append(new pgmelename);break; /* 89 <char item ::=> SUBSTR ( <sub operands> ) */ case CHARSUBSTR: sp -= 2; ppgm->Append(new pgmsubstr); break; /* 90 <char item ::=> PAD ( <pad operands> ) */ case CHARPAD: sp -= 4; StkC(); ppgm->Append(new pgmpad); break; /* 94 <main sub ops ::=> <sub item> , <start numb> */ case SUBSTRMISSLEN: StkN();ppgm->Append(new pgmintstk(9999));break; /* 95 <sub item ::=> <char expression> */ case SUBSTRITEM: MkC(ppgm); break; /* 96 <start numb ::=> <arith expression> */ case SUBSTRSTART: MkN(ppgm); break; /* 97 <len numb ::=> <arith expression> */ case SUBSTRLEN: MkN(ppgm); break; /* 98 <pad item ::=> <char expression> */ case PADITEM: MkC(ppgm); break; /* 99 <pad length ::=> <arith expression> */ case PADLEN: MkN(ppgm); break; /* 100 <pad pattern ::=> */ case PADNOPATTERN: StkC();ppgm->Append(new pgmchpush((UNCH *)" "));break; /* 101 <pad pattern ::=> , <char expression> */ case PADPATTERN: MkC(ppgm); break; /* 102 <pad position ::=> */ case PADBACK1: StkN();ppgm->Append(new pgmintstk(0)); break; /* 103 <pad position ::=> FRONT , */ case PADFRONT: StkN();ppgm->Append(new pgmintstk(1)); break; /* 104 <pad position ::=> BACK , */ case PADBACK2: StkN();ppgm->Append(new pgmintstk(0)); break; //* 67 <arith expression ::=> <arith expression> + <arith term> */ case ARITHEXPPLUS: Mk2N(ppgm); sp--;ppgm->Append(new pgmbinop(add));break; /* 68 <arith expression ::=> <arith expression> - <arith term> */ case ARITHEXPMINUS: Mk2N(ppgm); sp--;ppgm->Append(new pgmbinop(subt));break; /* 70 <signed term ::=> - <arith term> */ case ARITHEXPUMINUS: MkN(ppgm);ppgm->Append(new pgmunop(unneg));break; /* 73 <arith term ::=> <arith term> * <arith primary> */ case ARITHEXPTIMES: Mk2N(ppgm); sp--;ppgm->Append(new pgmbinop(mult));break; /* 74 <arith term ::=> <arith term> / <arith primary> */ case ARITHEXPDIV: Mk2N(ppgm); sp--;ppgm->Append(new pgmbinop(adiv));break; /* 77 <arith item ::=> <number> */ case ARITHEXPNUMB: StkN();ppgm->Append(new pgmintstk(atoi((char *)item->IntStr())));break; /* 121 <arith item ::=> FIND ( <char expression> , <char expression> ) */ case ARITHEXPFIND: Mk2C(ppgm); sp-=2; StkN();ppgm->Append(new pgmfind); break; /* 82 <arith item ::=> MAX ( <arith expression> , <arith expression> ) */ case ARITHEXPMAX: Mk2N(ppgm);sp--;ppgm->Append(new pgmbinop(amax));break; /* 83 <arith item ::=> MIN ( <arith expression> , <arith expression> ) */ case ARITHEXPMIN: Mk2N(ppgm);sp--;ppgm->Append(new pgmbinop(amin));break; /* 85 <arith item ::=> LENGTH ( <char expression> ) */ case ARITHEXPLEN: MkC(ppgm);tstk[sp-1] = valnumb;ppgm->Append(new pgmunop(unlen));break; /* 98 <name or attrib ::=> <var name> */ case GETTACTGLOBAL: w = (varitem *)item; ppgm->Append(new pgmvarld(w->Vardata()->pos(),tstk[sp++]=w->Vardata()->type())); break; /* 100 <attribute ::=> . <name> */ case LOADLOCALATTRIB: if (numbeles == 1)BuildAttrRef(ppgm, segetd, item->IntStr()); else BuildAttrRef2(ppgm, item->IntStr()); break; /* 101 <attribute ::=> <the element> . <name> */ case LOADELEMATTRIB: BuildAttrRef(ppgm, thisetd, item->IntStr()); break; /* 102 <the element ::=> <element name> */ case SAVEELEMENT: thisetd = ((etditem *)item)->MyEtd(); break; /* 124 <if start ::=> IF <logical expression> THEN <statement end> */ case IFSTART: ppgm->StartIf(); sp--; ifstk[++ifptr] = 1; // note first ifstk element is not used break; /* 132 <elsif line ::=> <elsif id> <logical expression> THEN <statement end> */ case ELSEIFCOND: ppgm->StartIf(); sp--; break; /* 133 <elsif id ::=> ELSE IF */ case ELSEIFSTART: ppgm->StartElse(); ++ifstk[ifptr]; break; /* 126 <ELSE ID ::=> ELSE <statement end> */ case IFELSESTART: ppgm->StartElse(); break; /* 127 <end if ::=> END <statement end> */ case IFEND: ppgm->EndIf(ifstk[ifptr--]); break; /* 129 <while test ::=> <WHILE ID> <logical expression> <statement end> */ case WHILECOND: ppgm->WhileCond(); sp--; break; /* 130 <WHILE ID ::=> WHILE */ case WHILESTART: ppgm->StartWhile(); break; /* 131 <end while ::=> END <statement end> */ case WHILEEND: ppgm->EndWhile(); break; /* 113 <logical expression ::=> <logical expression> OR <logical term> */ case LOGOR: Mk2N(ppgm);sp--;ppgm->Append(new pgmbinop(lor));break; /* 115 <logical term ::=> <logical term> AND <signed logical term> */ case LOGAND: Mk2N(ppgm);sp--;ppgm->Append(new pgmbinop(land));break; /* 117 <signed logical term ::=> NOT <logical primary> */ case LOGNOT: MkN(ppgm);ppgm->Append(new pgmunop(unlneg));break; /* 107 <logical primary ::=> ON */ case LOGEXPON: StkN();ppgm->Append(new pgmintstk(1));break; /* 108 <logical primary ::=> OFF */ case LOGEXPOFF: StkN();ppgm->Append(new pgmintstk(0));break; /* 166 <in funct elem ::=> <element name> */ case DOINFUNCT: /* 167 <is funct elem ::=> <element name> */ case DOISFUNCT: StkN(); fetd = ((etditem *)item)->MyEtd(); if (prod == DOINFUNCT)ppgm->Append(new pgminelem(fetd->etdgi)); else ppgm->Append(new pgmiselem(fetd->etdgi)); break; /* 122 <compare ::=> <exp 1> = <exp 2> */ case COMPEQU: DoCompare(ppgm,aeq,ceq); break; /* 123 <compare ::=> <exp 1> ~ = <exp 2> */ case COMPNOTEQU: DoCompare(ppgm,ane,cne); break; /* 124 <compare ::=> <exp 1> "> <exp 2> */ case COMPGT: DoCompare(ppgm,agt,cgt); break; /* 125 <compare ::=> <exp 1> "< <exp 2> */ case COMPLT: DoCompare(ppgm,alt,clt); break; /* 126 <compare ::=> <exp 1> "> = <exp 2> */ case COMPGE: DoCompare(ppgm,age,cge); break; /* 127 <compare ::=> <exp 1> "< = <exp 2> */ case COMPLE: DoCompare(ppgm,ale,cle); break; } } while ((prod != 1)&&(prod <= 1000)); if (prod > 1000) exit(1); delete scnr; };