diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3f594f244..1f03898df 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,8 +40,11 @@ jobs: # All integration tests - param: test --vm=u22 --param=build-package --param=module=mock --param=module=real - # All unit tests with coverage and alternate timezone - - param: test --vm=u22 --param=c-only --param=tz=America/New_York + # All unit tests with coverage, backtrace and alternate timezone + - param: test --vm=u22 --param=c-only --param=no-valgrind --param=tz=America/New_York + + # All unit tests with valgrind (disable coverage and backtrace for performance) + - param: test --vm=u22 --param=c-only --param=no-coverage --param=no-back-trace # All unit tests on the newest gcc available - param: test --vm=f36 --param=c-only --param=no-valgrind --param=no-coverage --param=no-performance diff --git a/test/lib/pgBackRestTest/Common/JobTest.pm b/test/lib/pgBackRestTest/Common/JobTest.pm index 2a584b654..ecbd36cc2 100644 --- a/test/lib/pgBackRestTest/Common/JobTest.pm +++ b/test/lib/pgBackRestTest/Common/JobTest.pm @@ -65,6 +65,7 @@ sub new $self->{bShowOutputAsync}, $self->{bNoCleanup}, $self->{iRetry}, + $self->{bBackTraceUnit}, $self->{bValgrindUnit}, $self->{bCoverageUnit}, $self->{bCoverageSummary}, @@ -97,6 +98,7 @@ sub new {name => 'bShowOutputAsync'}, {name => 'bNoCleanup'}, {name => 'iRetry'}, + {name => 'bBackTraceUnit'}, {name => 'bValgrindUnit'}, {name => 'bCoverageUnit'}, {name => 'bCoverageSummary'}, @@ -261,7 +263,7 @@ sub run ' --repo-path=' . $self->{strTestPath} . '/repo' . ' --test-path=' . $self->{strTestPath} . " --log-level=$self->{strLogLevel}" . ' --vm=' . $self->{oTest}->{&TEST_VM} . ' --vm-id=' . $self->{iVmIdx} . ($self->{bProfile} ? ' --profile' : '') . - ($bCoverage ? '' : ' --no-coverage') . ' test ' . + ($self->{bBackTraceUnit} ? '' : ' --no-back-trace') . ($bCoverage ? '' : ' --no-coverage') . ' test ' . $self->{oTest}->{&TEST_MODULE} . '/' . $self->{oTest}->{&TEST_NAME} . " && \\\n" . # Allow stderr to be copied to stderr and stdout "exec 3>&1 && \\\n" . diff --git a/test/src/build/config/config.yaml b/test/src/build/config/config.yaml index 60ab8483f..afdc03025 100644 --- a/test/src/build/config/config.yaml +++ b/test/src/build/config/config.yaml @@ -32,6 +32,13 @@ optionGroup: option: # General options #--------------------------------------------------------------------------------------------------------------------------------- + back-trace: + type: boolean + default: true + negate: true + command: + test: {} + buffer-size: type: size internal: true diff --git a/test/src/build/help/help.xml b/test/src/build/help/help.xml index 08a6cd695..37371f660 100644 --- a/test/src/build/help/help.xml +++ b/test/src/build/help/help.xml @@ -21,6 +21,16 @@ + + Enable back trace. + + + Back tracing helps with debugging by showing more detail about were an error happened. + + + false + + Buffer size for I/O operations. diff --git a/test/src/command/test/build.c b/test/src/command/test/build.c index 39a844341..f58084214 100644 --- a/test/src/command/test/build.c +++ b/test/src/command/test/build.c @@ -31,7 +31,7 @@ TestBuild * testBldNew( const String *const pathRepo, const String *const pathTest, const String *const vm, const unsigned int vmId, const TestDefModule *const module, const unsigned int test, const uint64_t scale, const LogLevel logLevel, const bool logTime, - const String *const timeZone, const bool coverage, const bool profile, const bool optimize) + const String *const timeZone, const bool coverage, const bool profile, const bool optimize, const bool backTrace) { FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_PARAM(STRING, pathRepo); @@ -47,6 +47,7 @@ testBldNew( FUNCTION_LOG_PARAM(BOOL, coverage); FUNCTION_LOG_PARAM(BOOL, profile); FUNCTION_LOG_PARAM(BOOL, optimize); + FUNCTION_LOG_PARAM(BOOL, backTrace); FUNCTION_LOG_END(); ASSERT(pathRepo != NULL); @@ -79,6 +80,7 @@ testBldNew( .coverage = coverage, .profile = profile, .optimize = optimize, + .backTrace = backTrace, }, }; @@ -377,6 +379,13 @@ testBldUnit(TestBuild *const this) // Comment out subdirs that are not used for testing strReplace(mesonBuild, STRDEF("subdir('"), STRDEF("# subdir('")); + if (!testBldBackTrace(this)) + { + strReplace( + mesonBuild, STRDEF(" configuration.set('HAVE_LIBBACKTRACE'"), + STRDEF("# configuration.set('HAVE_LIBBACKTRACE'")); + } + // Write build.auto.in strCatZ( mesonBuild, @@ -532,8 +541,18 @@ testBldUnit(TestBuild *const this) " '%s/src',\n" " '%s/test/src',\n" " ),\n" - " dependencies: [\n" - " lib_backtrace,\n" + " dependencies: [\n", + strZ(pathRepoRel), strZ(pathRepoRel)); + + if (testBldBackTrace(this)) + { + strCatZ( + mesonBuild, + " lib_backtrace,\n"); + } + + strCatZ( + mesonBuild, " lib_bz2,\n" " lib_openssl,\n" " lib_lz4,\n" @@ -543,8 +562,7 @@ testBldUnit(TestBuild *const this) " lib_z,\n" " lib_zstd,\n" " ],\n" - ")\n", - strZ(pathRepoRel), strZ(pathRepoRel)); + ")\n"); testBldWrite(storageUnit, storageUnitList, "meson.build", BUFSTR(mesonBuild)); diff --git a/test/src/command/test/build.h b/test/src/command/test/build.h index ac2663810..a44061508 100644 --- a/test/src/command/test/build.h +++ b/test/src/command/test/build.h @@ -21,7 +21,7 @@ Constructors TestBuild *testBldNew( const String *pathRepo, const String *pathTest, const String *const vm, unsigned int vmId, const TestDefModule *module, unsigned int test, uint64_t scale, LogLevel logLevel, bool logTime, const String *timeZone, bool coverage, bool profile, - bool optimize); + bool optimize, bool backTrace); /*********************************************************************************************************************************** Getters/Setters @@ -43,6 +43,7 @@ typedef struct TestBuildPub bool coverage; // Generate coverage? bool profile; // Generate profile report? bool optimize; // Optimize code? + bool backTrace; // Run with back trace? TestDef tstDef; // Test definitions } TestBuildPub; @@ -152,6 +153,13 @@ testBldScale(const TestBuild *const this) return THIS_PUB(TestBuild)->scale; } +// Run with back trace? +FN_INLINE_ALWAYS bool +testBldBackTrace(const TestBuild *const this) +{ + return THIS_PUB(TestBuild)->backTrace; +} + /*********************************************************************************************************************************** Functions ***********************************************************************************************************************************/ diff --git a/test/src/command/test/test.c b/test/src/command/test/test.c index e41f39535..16d48e94f 100644 --- a/test/src/command/test/test.c +++ b/test/src/command/test/test.c @@ -75,7 +75,7 @@ void cmdTest( const String *const pathRepo, const String *const pathTest, const String *const vm, const unsigned int vmId, const String *moduleName, const unsigned int test, const uint64_t scale, const LogLevel logLevel, const bool logTime, - const String *const timeZone, const bool coverage, const bool profile, const bool optimize) + const String *const timeZone, const bool coverage, const bool profile, const bool optimize, const bool backTrace) { FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_PARAM(STRING, pathRepo); @@ -91,6 +91,7 @@ cmdTest( FUNCTION_LOG_PARAM(BOOL, coverage); FUNCTION_LOG_PARAM(BOOL, profile); FUNCTION_LOG_PARAM(BOOL, optimize); + FUNCTION_LOG_PARAM(BOOL, backTrace); FUNCTION_LOG_END(); MEM_CONTEXT_TEMP_BEGIN() @@ -118,7 +119,8 @@ cmdTest( { // Build unit TestBuild *const testBld = testBldNew( - pathRepo, pathTest, vm, vmId, module, test, scale, logLevel, logTime, timeZone, coverage, profile, optimize); + pathRepo, pathTest, vm, vmId, module, test, scale, logLevel, logTime, timeZone, coverage, profile, optimize, + backTrace); testBldUnit(testBld); // Meson setup diff --git a/test/src/command/test/test.h b/test/src/command/test/test.h index 72c28fe27..961d64263 100644 --- a/test/src/command/test/test.h +++ b/test/src/command/test/test.h @@ -15,6 +15,6 @@ Functions void cmdTest( const String *pathRepo, const String *pathTest, const String *const vm, unsigned int vmId, const String *moduleName, unsigned int test, uint64_t scale, LogLevel logLevel, bool logTime, const String *timeZone, bool coverage, bool profile, - bool optimize); + bool optimize, bool backTrace); #endif diff --git a/test/src/main.c b/test/src/main.c index eb2ad9c13..a1245ac81 100644 --- a/test/src/main.c +++ b/test/src/main.c @@ -76,7 +76,7 @@ main(int argListSize, const char *argList[]) cfgOptionTest(cfgOptTest) ? cfgOptionUInt(cfgOptTest) : 0, cfgOptionUInt64(cfgOptScale), logLevelEnum(cfgOptionStrId(cfgOptLogLevelTest)), cfgOptionBool(cfgOptLogTimestamp), cfgOptionStrNull(cfgOptTz), cfgOptionBool(cfgOptCoverage), cfgOptionBool(cfgOptProfile), - cfgOptionBool(cfgOptOptimize)); + cfgOptionBool(cfgOptOptimize), cfgOptionBool(cfgOptBackTrace)); break; } diff --git a/test/src/module/test/testTest.c b/test/src/module/test/testTest.c index 0a2f7f037..cb0bebd18 100644 --- a/test/src/module/test/testTest.c +++ b/test/src/module/test/testTest.c @@ -260,7 +260,7 @@ testRun(void) TEST_RESULT_VOID( cmdTest( STRDEF(TEST_PATH "/repo"), storagePathP(storageTest, STRDEF("test")), STRDEF("none"), 3, - STRDEF("common/stack-trace"), 0, 1, logLevelDebug, true, NULL, false, false, false), + STRDEF("common/stack-trace"), 0, 1, logLevelDebug, true, NULL, false, false, false, true), "new build"); const Storage *storageUnit = storagePosixNewP(STRDEF(TEST_PATH "/test/unit-3/none")); @@ -379,7 +379,7 @@ testRun(void) TEST_RESULT_VOID( cmdTest( STRDEF(TEST_PATH "/repo"), storagePathP(storageTest, STRDEF("test")), STRDEF("none"), 3, - STRDEF("common/error"), 5, 1, logLevelDebug, true, NULL, false, false, false), + STRDEF("common/error"), 5, 1, logLevelDebug, true, NULL, false, false, false, true), "new build"); fileList = testStorageList(storageUnit); @@ -568,7 +568,7 @@ testRun(void) TEST_RESULT_VOID( cmdTest( STRDEF(TEST_PATH "/repo"), storagePathP(storageTest, STRDEF("test")), STRDEF("uXX"), 3, - STRDEF("test/shim"), 0, 1, logLevelDebug, true, NULL, true, true, true), + STRDEF("test/shim"), 0, 1, logLevelDebug, true, NULL, true, true, true, true), "new build"); storageUnit = storagePosixNewP(STRDEF(TEST_PATH "/test/unit-3/uXX")); @@ -706,12 +706,16 @@ testRun(void) TEST_RESULT_VOID( cmdTest( STRDEF(TEST_PATH "/repo"), storagePathP(storageTest, STRDEF("test")), STRDEF("uXX"), 3, - STRDEF("test/shim"), 0, 1, logLevelDebug, true, NULL, true, true, true), + STRDEF("test/shim"), 0, 1, logLevelDebug, true, NULL, true, true, true, true), "new build"); // ------------------------------------------------------------------------------------------------------------------------- TEST_TITLE("Test performance/type"); + strReplace( + mesonBuildRoot, STRDEF(" configuration.set('HAVE_LIBBACKTRACE'"), + STRDEF("# configuration.set('HAVE_LIBBACKTRACE'")); + HRN_STORAGE_PUT_Z( storageTest, "repo/test/src/module/performance/typeTest.c", "static void\n" @@ -731,7 +735,7 @@ testRun(void) TEST_RESULT_VOID( cmdTest( STRDEF(TEST_PATH "/repo"), storagePathP(storageTest, STRDEF("test")), STRDEF("uXX"), 3, - STRDEF("performance/type"), 0, 1, logLevelDebug, true, STRDEF("America/New_York"), false, true, false), + STRDEF("performance/type"), 0, 1, logLevelDebug, true, STRDEF("America/New_York"), false, true, false, false), "new build"); TEST_RESULT_LOG( @@ -801,7 +805,6 @@ testRun(void) " '../../../repo/test/src',\n" " ),\n" " dependencies: [\n" - " lib_backtrace,\n" " lib_bz2,\n" " lib_openssl,\n" " lib_lz4,\n" @@ -866,7 +869,7 @@ testRun(void) TEST_RESULT_VOID( cmdTest( STRDEF(TEST_PATH "/repo"), storagePathP(storageTest, STRDEF("test")), STRDEF("uXX"), 3, - STRDEF("performance/type"), 0, 1, logLevelDebug, true, STRDEF("America/New_York"), false, false, false), + STRDEF("performance/type"), 0, 1, logLevelDebug, true, STRDEF("America/New_York"), false, false, false, false), "new build"); storageUnit = storagePosixNewP(STRDEF(TEST_PATH "/test/unit-3/uXX")); @@ -900,7 +903,7 @@ testRun(void) TEST_ERROR( cmdTest( STRDEF(TEST_PATH "/repo"), storagePathP(storageTest, STRDEF("test")), STRDEF("uXX"), 3, - STRDEF("performance/type"), 0, 1, logLevelDebug, true, STRDEF("America/New_York"), false, false, false), + STRDEF("performance/type"), 0, 1, logLevelDebug, true, STRDEF("America/New_York"), false, false, false, false), FileOpenError, "build failed for unit performance/type: unable to open file '" TEST_PATH "/repo/meson.build' for read: [13] Permission" " denied"); diff --git a/test/test.pl b/test/test.pl index ef18fd4d7..137c750bf 100755 --- a/test/test.pl +++ b/test/test.pl @@ -80,6 +80,7 @@ test.pl [options] --min-gen only run required code generation --gen-check check that auto-generated files are correct (used in CI to detect changes) --code-count generate code counts + --no-back-trace don't run backrace on C unit tests (may be slow with valgrind) --no-valgrind don't run valgrind on C unit tests (saves time) --no-coverage don't run coverage on C unit tests (saves time) --no-coverage-report run coverage but don't generate coverage report (saves time) @@ -158,6 +159,7 @@ my $bGenCheck = false; my $bMinGen = false; my $bCodeCount = false; my $bProfile = false; +my $bNoBackTrace = false; my $bNoValgrind = false; my $bNoOptimize = false; my $bNoDebug = false; @@ -207,6 +209,7 @@ GetOptions ('q|quiet' => \$bQuiet, 'min-gen' => \$bMinGen, 'code-count' => \$bCodeCount, 'profile' => \$bProfile, + 'no-back-trace' => \$bNoBackTrace, 'no-valgrind' => \$bNoValgrind, 'no-optimize' => \$bNoOptimize, 'no-debug', => \$bNoDebug, @@ -266,6 +269,7 @@ eval ################################################################################################################################ if ($bProfile) { + $bNoBackTrace = true; $bNoValgrind = true; $bNoCoverage = true; } @@ -1054,8 +1058,8 @@ eval my $oJob = new pgBackRestTest::Common::JobTest( $oStorageTest, $strBackRestBase, $strTestPath, $$oyTestRun[$iTestIdx], $bDryRun, $bVmOut, $iVmIdx, $iVmMax, $strMakeCmd, $iTestIdx, $iTestMax, $strLogLevel, $strLogLevelTest, $strLogLevelTestFile, !$bNoLogTimestamp, - $bShowOutputAsync, $bNoCleanup, $iRetry, !$bNoValgrind, !$bNoCoverage, $bCoverageSummary, !$bNoOptimize, - $bProfile, $iScale, $strTimeZone, !$bNoDebug, $bDebugTestTrace, + $bShowOutputAsync, $bNoCleanup, $iRetry, !$bNoBackTrace, !$bNoValgrind, !$bNoCoverage, $bCoverageSummary, + !$bNoOptimize, $bProfile, $iScale, $strTimeZone, !$bNoDebug, $bDebugTestTrace, $iBuildMax / $iVmMax < 1 ? 1 : int($iBuildMax / $iVmMax)); $iTestIdx++;
Back tracing helps with debugging by showing more detail about were an error happened.