| 200 | } |
| 201 | |
| 202 | FuzzStatus ParseFlags( |
| 203 | int argc, const char** argv, std::string* in_binary_file, |
| 204 | std::string* out_binary_file, std::string* donors_file, |
| 205 | std::string* replay_transformations_file, |
| 206 | std::vector<std::string>* interestingness_test, |
| 207 | std::string* shrink_transformations_file, |
| 208 | std::string* shrink_temp_file_prefix, |
| 209 | spvtools::fuzz::RepeatedPassStrategy* repeated_pass_strategy, |
| 210 | FuzzingTarget* fuzzing_target, spvtools::FuzzerOptions* fuzzer_options, |
| 211 | spvtools::ValidatorOptions* validator_options) { |
| 212 | uint32_t positional_arg_index = 0; |
| 213 | bool only_positional_arguments_remain = false; |
| 214 | bool force_render_red = false; |
| 215 | |
| 216 | *repeated_pass_strategy = |
| 217 | spvtools::fuzz::RepeatedPassStrategy::kLoopedWithRecommendations; |
| 218 | |
| 219 | for (int argi = 1; argi < argc; ++argi) { |
| 220 | const char* cur_arg = argv[argi]; |
| 221 | if ('-' == cur_arg[0] && !only_positional_arguments_remain) { |
| 222 | if (0 == strcmp(cur_arg, "--version")) { |
| 223 | spvtools::Logf(FuzzDiagnostic, SPV_MSG_INFO, nullptr, {}, "%s\n", |
| 224 | spvSoftwareVersionDetailsString()); |
| 225 | return {FuzzActions::STOP, 0}; |
| 226 | } else if (0 == strcmp(cur_arg, "--help") || 0 == strcmp(cur_arg, "-h")) { |
| 227 | PrintUsage(argv[0]); |
| 228 | return {FuzzActions::STOP, 0}; |
| 229 | } else if (0 == strcmp(cur_arg, "-o")) { |
| 230 | if (out_binary_file->empty() && argi + 1 < argc) { |
| 231 | *out_binary_file = std::string(argv[++argi]); |
| 232 | } else { |
| 233 | PrintUsage(argv[0]); |
| 234 | return {FuzzActions::STOP, 1}; |
| 235 | } |
| 236 | } else if (0 == strncmp(cur_arg, "--donors=", sizeof("--donors=") - 1)) { |
| 237 | const auto split_flag = spvtools::utils::SplitFlagArgs(cur_arg); |
| 238 | *donors_file = std::string(split_flag.second); |
| 239 | } else if (0 == strncmp(cur_arg, "--enable-all-passes", |
| 240 | sizeof("--enable-all-passes") - 1)) { |
| 241 | fuzzer_options->enable_all_passes(); |
| 242 | } else if (0 == strncmp(cur_arg, "--force-render-red", |
| 243 | sizeof("--force-render-red") - 1)) { |
| 244 | force_render_red = true; |
| 245 | } else if (0 == strncmp(cur_arg, "--fuzzer-pass-validation", |
| 246 | sizeof("--fuzzer-pass-validation") - 1)) { |
| 247 | fuzzer_options->enable_fuzzer_pass_validation(); |
| 248 | } else if (0 == strncmp(cur_arg, "--replay=", sizeof("--replay=") - 1)) { |
| 249 | const auto split_flag = spvtools::utils::SplitFlagArgs(cur_arg); |
| 250 | *replay_transformations_file = std::string(split_flag.second); |
| 251 | } else if (0 == strncmp(cur_arg, "--repeated-pass-strategy=", |
| 252 | sizeof("--repeated-pass-strategy=") - 1)) { |
| 253 | std::string strategy = spvtools::utils::SplitFlagArgs(cur_arg).second; |
| 254 | if (strategy == "looped") { |
| 255 | *repeated_pass_strategy = |
| 256 | spvtools::fuzz::RepeatedPassStrategy::kLoopedWithRecommendations; |
| 257 | } else if (strategy == "random") { |
| 258 | *repeated_pass_strategy = |
| 259 | spvtools::fuzz::RepeatedPassStrategy::kRandomWithRecommendations; |
no test coverage detected