Skip to content

Commit

Permalink
hashtest: randomize experiment execution order and print better names
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 687083568
  • Loading branch information
ncbray authored and copybara-github committed Oct 17, 2024
1 parent 3f61e7a commit 8369dc0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions fuzzer/hashtest/hashtest_runner_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "absl/flags/parse.h"
#include "absl/log/check.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_join.h"
#include "absl/time/clock.h"
#include "absl/time/time.h"
#include "absl/types/span.h"
Expand Down Expand Up @@ -219,6 +220,13 @@ struct CorpusConfig {
RunConfig run_config;
};

std::string TagsToName(const std::vector<std::string>& tags) {
if (tags.empty()) {
return "default";
}
return absl::StrJoin(tags, ":");
}

// The results of running a corpus.
struct CorpusStats {
// Time consumed generated the test code.
Expand Down Expand Up @@ -528,6 +536,15 @@ int TestMain(std::vector<char*> positional_args) {
filtered_corpus_config.instruction_pool = &ipool_no_128;
corpus_config.push_back(filtered_corpus_config);

// Name the corpus based on the tags.
for (CorpusConfig& config : corpus_config) {
config.name = TagsToName(config.tags);
}

// Run the experiments in a random order to avoid creating sampling bias when
// we halt testing at a specific time.
std::shuffle(corpus_config.begin(), corpus_config.end(), rng);

ResultReporter result(test_started);

absl::Duration testing_time = absl::GetFlag(FLAGS_time);
Expand Down

0 comments on commit 8369dc0

Please sign in to comment.