MCPcopy Create free account
hub / github.com/cameron314/concurrentqueue / main

Function main

tests/fuzztests/fuzztests.cpp:693–867  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

691#endif
692
693int main(int argc, char** argv)
694{
695 bool singleSeed = false;
696 uint64_t seed = 0;
697
698 // Disable buffering (so that when run in, e.g., Sublime Text, the output appears as it is written)
699 std::setvbuf(stdout, nullptr, _IONBF, 0);
700
701 // Isolate the executable name
702 std::string progName = argv[0];
703 auto slash = progName.find_last_of("/\\");
704 if (slash != std::string::npos) {
705 progName = progName.substr(slash + 1);
706 }
707
708 // Parse command line options
709 if (argc > 1) {
710 bool printHelp = false;
711 bool error = false;
712 for (int i = 1; i < argc; ++i) {
713 if (std::strcmp(argv[i], "--help") == 0) {
714 printHelp = true;
715 }
716 else if (std::strcmp(argv[i], "--seed") == 0) {
717 if (i + 1 == argc || argv[i + 1][0] == '-') {
718 std::printf("Expected seed number argument for --seed option.\n");
719 error = true;
720 continue;
721 }
722
723 ++i;
724 seed = 0;
725 // hex
726 for (int j = 0; argv[i][j] != '\0'; ++j) {
727 char ch = static_cast<char>(std::tolower(argv[i][j]));
728 if (j == 1 && seed == 0 && ch == 'x') {
729 continue; // Skip 0x, if any
730 }
731 else if (ch >= 'a' && ch <= 'f') {
732 seed = (seed << 4) | (10 + ch - 'a');
733 }
734 else if (ch >= '0' && ch <= '9') {
735 seed = (seed << 4) | (ch - '0');
736 }
737 else {
738 std::printf("Expected hex seed argument, found '%s' instead\n", argv[i]);
739 error = true;
740 }
741 }
742 singleSeed = true;
743 }
744 else {
745 std::printf("Unrecognized option '%s'.\n\n", argv[i]);
746 error = true;
747 }
748 }
749
750 if (error || printHelp) {

Callers

nothing calls this directly

Calls 5

tolowerFunction · 0.85
timestampFunction · 0.70
run_testFunction · 0.70
storeMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected