OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Fuzzer launcher script tests. | 5 // Fuzzer launcher script tests. |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 std::vector<std::string> fuzzer_args = base::SplitString( | 30 std::vector<std::string> fuzzer_args = base::SplitString( |
31 output, "\n\r", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | 31 output, "\n\r", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
32 | 32 |
33 EXPECT_EQ(3UL, fuzzer_args.size()); | 33 EXPECT_EQ(3UL, fuzzer_args.size()); |
34 | 34 |
35 EXPECT_THAT(fuzzer_args[0], EndsWith("print_args.py")); | 35 EXPECT_THAT(fuzzer_args[0], EndsWith("print_args.py")); |
36 EXPECT_THAT(fuzzer_args[1], StartsWith("-dict")); | 36 EXPECT_THAT(fuzzer_args[1], StartsWith("-dict")); |
37 EXPECT_THAT(fuzzer_args[1], EndsWith("test_dict")); | 37 EXPECT_THAT(fuzzer_args[1], EndsWith("test_dict")); |
38 EXPECT_EQ("-custom_option", fuzzer_args[2]); | 38 EXPECT_EQ("-custom_option", fuzzer_args[2]); |
39 } | 39 } |
| 40 |
| 41 TEST(FuzzerLauncherTest, Params) { |
| 42 base::FilePath exe_path; |
| 43 PathService::Get(base::FILE_EXE, &exe_path); |
| 44 std::string launcher_path = |
| 45 exe_path.DirName().Append("test_params_launcher.sh").value(); |
| 46 |
| 47 std::string output; |
| 48 base::CommandLine cmd({{launcher_path, "-custom_option"}}); |
| 49 bool success = base::GetAppOutputAndError(cmd, &output); |
| 50 EXPECT_TRUE(success); |
| 51 std::vector<std::string> fuzzer_args = base::SplitString( |
| 52 output, "\n\r", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| 53 |
| 54 EXPECT_EQ(3UL, fuzzer_args.size()); |
| 55 |
| 56 EXPECT_THAT(fuzzer_args[0], EndsWith("print_args.py")); |
| 57 EXPECT_EQ("-custom_option", fuzzer_args[1]); |
| 58 EXPECT_THAT(fuzzer_args[2], StartsWith("-test_param")); |
| 59 EXPECT_THAT(fuzzer_args[2], EndsWith("test_value")); |
| 60 } |
| 61 |
| 62 TEST(FuzzerLauncherTest, DictAndParams) { |
| 63 base::FilePath exe_path; |
| 64 PathService::Get(base::FILE_EXE, &exe_path); |
| 65 std::string launcher_path = |
| 66 exe_path.DirName().Append("test_dict_and_params_launcher.sh").value(); |
| 67 |
| 68 std::string output; |
| 69 base::CommandLine cmd({{launcher_path, "-custom_option"}}); |
| 70 bool success = base::GetAppOutputAndError(cmd, &output); |
| 71 EXPECT_TRUE(success); |
| 72 std::vector<std::string> fuzzer_args = base::SplitString( |
| 73 output, "\n\r", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| 74 |
| 75 EXPECT_EQ(4UL, fuzzer_args.size()); |
| 76 |
| 77 EXPECT_THAT(fuzzer_args[0], EndsWith("print_args.py")); |
| 78 EXPECT_THAT(fuzzer_args[1], StartsWith("-dict")); |
| 79 EXPECT_THAT(fuzzer_args[1], EndsWith("test_dict")); |
| 80 EXPECT_EQ("-custom_option", fuzzer_args[2]); |
| 81 EXPECT_THAT(fuzzer_args[3], StartsWith("-test_param")); |
| 82 EXPECT_THAT(fuzzer_args[3], EndsWith("test_value")); |
| 83 } |
OLD | NEW |