| 658 | } |
| 659 | |
| 660 | void Fuzzer::WriteUnitToFileWithPrefix(const Unit &U, const char *Prefix) { |
| 661 | if (!Options.SaveArtifacts) |
| 662 | return; |
| 663 | std::time_t current_time = std::time(nullptr); |
| 664 | // Convert the timestamp to a string |
| 665 | std::string timestamp_str = std::to_string(current_time); |
| 666 | std::stringstream ss; |
| 667 | ss << std::setw(10) << std::setfill('0') << TotalNumberOfRuns; |
| 668 | std::string Iterations = ss.str(); |
| 669 | std::string Path = Options.ArtifactPrefix + Prefix + Iterations + '-' + Hash(U) + '-' + timestamp_str; |
| 670 | if (!Options.ExactArtifactPath.empty()) |
| 671 | Path = Options.ExactArtifactPath; // Overrides ArtifactPrefix. |
| 672 | WriteToFile(U, Path); |
| 673 | Printf("artifact_prefix='%s'; Test unit written to %s\n", |
| 674 | Options.ArtifactPrefix.c_str(), Path.c_str()); |
| 675 | if (U.size() <= kMaxUnitSizeToPrint) |
| 676 | Printf("Base64: %s\n", Base64(U).c_str()); |
| 677 | } |
| 678 | |
| 679 | void Fuzzer::PrintStatusForNewUnit(const Unit &U, const char *Text) { |
| 680 | if (!Options.PrintNEW) |