Skip to content

Commit

Permalink
Merge pull request #34 from Jyx/fix-list
Browse files Browse the repository at this point in the history
list: fix segmentation fault when using --list
  • Loading branch information
jasmcaus authored Jan 24, 2023
2 parents 99540bc + 6055588 commit 68d0408
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tau/tau.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ extern tau_u64 tauStatsNumWarnings;
static int tauShouldColourizeOutput = 1;
static int tauDisableSummary = 0;
static int tauDisplayOnlyFailedOutput = 0;
static int tauDisplayTests = 0;

static const char* tau_argv0_ = TAU_NULL;
static const char* cmd_filter = TAU_NULL;
Expand Down Expand Up @@ -415,10 +416,11 @@ tauColouredPrintf(const int colour, const char* const fmt, ...) {
}

#ifndef TAU_NO_TESTING
#define tauPrintf(...) \
#define tauPrintf(...) { \
if(tauTestContext.foutput) \
fprintf(tauTestContext.foutput, __VA_ARGS__); \
printf(__VA_ARGS__)
printf(__VA_ARGS__); \
}
#else
#define tauPrintf(...) \
printf(__VA_ARGS__)
Expand Down Expand Up @@ -1066,6 +1068,7 @@ static tau_bool tauCmdLineRead(const int argc, const char* const * const argv) {
else if(strncmp(argv[i], listStr, strlen(listStr)) == 0) {
for (i = 0; i < tauTestContext.numTestSuites; i++)
tauPrintf("%s\n", tauTestContext.tests[i].name);
tauDisplayTests = 1;
}

// Disable colouring
Expand Down Expand Up @@ -1164,6 +1167,9 @@ inline int tau_main(const int argc, const char* const * const argv) {
const double start = tauClock();

const tau_bool wasCmdLineReadSuccessful = tauCmdLineRead(argc, argv);
if (tauDisplayTests)
return tauCleanup();

if(!wasCmdLineReadSuccessful)
return tauCleanup();

Expand Down

0 comments on commit 68d0408

Please sign in to comment.