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 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 std::string launcher_path = | 42 std::string launcher_path = |
43 exe_path.DirName().Append("check_fuzzer_config.py").value(); | 43 exe_path.DirName().Append("check_fuzzer_config.py").value(); |
44 | 44 |
45 std::string output; | 45 std::string output; |
46 base::CommandLine cmd({{launcher_path, "test_config_only.options"}}); | 46 base::CommandLine cmd({{launcher_path, "test_config_only.options"}}); |
47 bool success = base::GetAppOutputAndError(cmd, &output); | 47 bool success = base::GetAppOutputAndError(cmd, &output); |
48 EXPECT_TRUE(success); | 48 EXPECT_TRUE(success); |
49 std::vector<std::string> fuzzer_args = base::SplitString( | 49 std::vector<std::string> fuzzer_args = base::SplitString( |
50 output, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | 50 output, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
51 | 51 |
52 EXPECT_EQ(3UL, fuzzer_args.size()); | 52 EXPECT_EQ(2UL, fuzzer_args.size()); |
53 | 53 |
54 EXPECT_EQ(fuzzer_args[0], "max_len=random(1337, 31337)"); | 54 EXPECT_EQ(fuzzer_args[0], "some_test_option=test_value"); |
55 EXPECT_EQ(fuzzer_args[1], "timeout=666"); | 55 EXPECT_EQ(fuzzer_args[1], "max_len=1024"); |
56 EXPECT_EQ(fuzzer_args[2], "use_traces=1"); | |
57 } | 56 } |
58 | 57 |
59 | 58 |
60 TEST(FuzzerConfigTest, ConfigAndDict) { | 59 TEST(FuzzerConfigTest, ConfigAndDict) { |
61 // Test of .options file for fuzzer with options file and dictionary. | 60 // Test of .options file for fuzzer with options file and dictionary. |
62 base::FilePath exe_path; | 61 base::FilePath exe_path; |
63 PathService::Get(base::FILE_EXE, &exe_path); | 62 PathService::Get(base::FILE_EXE, &exe_path); |
64 std::string launcher_path = | 63 std::string launcher_path = |
65 exe_path.DirName().Append("check_fuzzer_config.py").value(); | 64 exe_path.DirName().Append("check_fuzzer_config.py").value(); |
66 | 65 |
67 std::string output; | 66 std::string output; |
68 base::CommandLine cmd({{launcher_path, "test_config_and_dict.options"}}); | 67 base::CommandLine cmd({{launcher_path, "test_config_and_dict.options"}}); |
69 bool success = base::GetAppOutputAndError(cmd, &output); | 68 bool success = base::GetAppOutputAndError(cmd, &output); |
70 EXPECT_TRUE(success); | 69 EXPECT_TRUE(success); |
71 std::vector<std::string> fuzzer_args = base::SplitString( | 70 std::vector<std::string> fuzzer_args = base::SplitString( |
72 output, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | 71 output, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
73 | 72 |
74 EXPECT_EQ(4UL, fuzzer_args.size()); | 73 EXPECT_EQ(4UL, fuzzer_args.size()); |
75 | 74 |
76 EXPECT_EQ(fuzzer_args[0], "max_len=random(1337, 31337)"); | 75 EXPECT_EQ(fuzzer_args[0], "dict=test_config_and_dict.dict"); |
77 EXPECT_EQ(fuzzer_args[1], "timeout=666"); | 76 EXPECT_EQ(fuzzer_args[1], "max_len=random(1337, 31337)"); |
78 EXPECT_EQ(fuzzer_args[2], "use_traces=1"); | 77 EXPECT_EQ(fuzzer_args[2], "timeout=666"); |
79 EXPECT_EQ(fuzzer_args[3], "dict=test_config_and_dict.dict"); | 78 EXPECT_EQ(fuzzer_args[3], "use_traces=1"); |
80 } | 79 } |
81 | 80 |
82 | 81 |
83 TEST(FuzzerConfigTest, DictSubdir) { | 82 TEST(FuzzerConfigTest, DictSubdir) { |
84 // Test of auto-generated .options file for fuzzer with dict in sub-directory. | 83 // Test of auto-generated .options file for fuzzer with dict in sub-directory. |
85 base::FilePath exe_path; | 84 base::FilePath exe_path; |
86 PathService::Get(base::FILE_EXE, &exe_path); | 85 PathService::Get(base::FILE_EXE, &exe_path); |
87 std::string launcher_path = | 86 std::string launcher_path = |
88 exe_path.DirName().Append("check_fuzzer_config.py").value(); | 87 exe_path.DirName().Append("check_fuzzer_config.py").value(); |
89 | 88 |
90 std::string output; | 89 std::string output; |
91 base::CommandLine cmd({{launcher_path, "test_dict_from_subdir.options"}}); | 90 base::CommandLine cmd({{launcher_path, "test_dict_from_subdir.options"}}); |
92 bool success = base::GetAppOutputAndError(cmd, &output); | 91 bool success = base::GetAppOutputAndError(cmd, &output); |
93 EXPECT_TRUE(success); | 92 EXPECT_TRUE(success); |
94 std::vector<std::string> fuzzer_args = base::SplitString( | 93 std::vector<std::string> fuzzer_args = base::SplitString( |
95 output, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | 94 output, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
96 | 95 |
97 EXPECT_EQ(1UL, fuzzer_args.size()); | 96 EXPECT_EQ(1UL, fuzzer_args.size()); |
98 | 97 |
99 EXPECT_EQ(fuzzer_args[0], "dict=test_dict_from_subdir.dict"); | 98 EXPECT_EQ(fuzzer_args[0], "dict=test_dict_from_subdir.dict"); |
100 } | 99 } |
OLD | NEW |