• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2021 The Tint Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef FUZZERS_TINT_REGEX_FUZZER_CLI_H_
16 #define FUZZERS_TINT_REGEX_FUZZER_CLI_H_
17 
18 #include <cstdint>
19 
20 namespace tint {
21 namespace fuzzers {
22 namespace regex_fuzzer {
23 
24 /// The backend this fuzzer will test.
25 enum class FuzzingTarget {
26   kNone = 0,
27   kHlsl = 1 << 0,
28   kMsl = 1 << 1,
29   kSpv = 1 << 2,
30   kWgsl = 1 << 3,
31   kAll = kHlsl | kMsl | kSpv | kWgsl
32 };
33 
34 inline FuzzingTarget operator|(FuzzingTarget a, FuzzingTarget b) {
35   return static_cast<FuzzingTarget>(static_cast<int>(a) | static_cast<int>(b));
36 }
37 
38 inline FuzzingTarget operator&(FuzzingTarget a, FuzzingTarget b) {
39   return static_cast<FuzzingTarget>(static_cast<int>(a) & static_cast<int>(b));
40 }
41 
42 /// CLI parameters accepted by the fuzzer. Type -tint_help in the CLI to see the
43 /// help message
44 struct CliParams {
45   /// Compiler backends we want to fuzz.
46   FuzzingTarget fuzzing_target = FuzzingTarget::kAll;
47 };
48 
49 /// @brief Parses CLI parameters.
50 ///
51 /// This function will exit the process with non-zero return code if some
52 /// parameters are invalid. This function will remove recognized parameters from
53 /// `argv` and adjust `argc` accordingly.
54 ///
55 /// @param argc - the total number of parameters.
56 /// @param argv - array of all CLI parameters.
57 /// @return parsed parameters.
58 CliParams ParseCliParams(int* argc, char** argv);
59 
60 }  // namespace regex_fuzzer
61 }  // namespace fuzzers
62 }  // namespace tint
63 
64 #endif  // FUZZERS_TINT_REGEX_FUZZER_CLI_H_
65