Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: testing/libfuzzer/tests/fuzzer_launcher_test.cc

Issue 2610323002: [libfuzzer] support multiple seed_corpus directories. (Closed)
Patch Set: Add missing scripts Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 EXPECT_EQ(4UL, fuzzer_args.size()); 73 EXPECT_EQ(4UL, fuzzer_args.size());
74 74
75 EXPECT_EQ(fuzzer_args[0], "dict=test_config_and_dict.dict"); 75 EXPECT_EQ(fuzzer_args[0], "dict=test_config_and_dict.dict");
76 EXPECT_EQ(fuzzer_args[1], "max_len=random(1337, 31337)"); 76 EXPECT_EQ(fuzzer_args[1], "max_len=random(1337, 31337)");
77 EXPECT_EQ(fuzzer_args[2], "timeout=666"); 77 EXPECT_EQ(fuzzer_args[2], "timeout=666");
78 EXPECT_EQ(fuzzer_args[3], "use_traces=1"); 78 EXPECT_EQ(fuzzer_args[3], "use_traces=1");
79 } 79 }
80 80
81 81
82 TEST(FuzzerConfigTest, ConfigAndSeedCorpus) {
83 // Test of .options file for fuzzer with libfuzzer_options and seed corpus.
84 base::FilePath exe_path;
85 PathService::Get(base::FILE_EXE, &exe_path);
86 std::string launcher_path =
87 exe_path.DirName().Append("check_fuzzer_config.py").value();
88
89 std::string output;
90 base::CommandLine cmd(
91 {{launcher_path, "test_config_and_seed_corpus.options"}});
92 bool success = base::GetAppOutputAndError(cmd, &output);
93 EXPECT_TRUE(success);
94 std::vector<std::string> fuzzer_args = base::SplitString(
95 output, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
96
97 EXPECT_EQ(2UL, fuzzer_args.size());
98
99 EXPECT_EQ(fuzzer_args[0], "some_test_option=test_value");
100 EXPECT_EQ(fuzzer_args[1], "max_len=1024");
101
102 // Test seed_corpus archive.
103 launcher_path =
104 exe_path.DirName().Append("check_seed_corpus_archive.py").value();
105
106 cmd = base::CommandLine(
107 {{launcher_path, "test_config_and_seed_corpus_seed_corpus.zip"}});
108 success = base::GetAppOutputAndError(cmd, &output);
109 EXPECT_TRUE(success);
110 std::vector<std::string> seed_corpus_info = base::SplitString(
111 output, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
112
113 EXPECT_EQ(1UL, seed_corpus_info.size());
114 EXPECT_EQ(seed_corpus_info[0], "3");
115 }
116
117
118 TEST(FuzzerConfigTest, ConfigAndSeedCorpuses) {
119 // Test of .options file for fuzzer with libfuzzer_options and seed corpuses.
120 base::FilePath exe_path;
121 PathService::Get(base::FILE_EXE, &exe_path);
122 std::string launcher_path =
123 exe_path.DirName().Append("check_fuzzer_config.py").value();
124
125 std::string output;
126 base::CommandLine cmd(
127 {{launcher_path, "test_config_and_seed_corpuses.options"}});
128 bool success = base::GetAppOutputAndError(cmd, &output);
129 EXPECT_TRUE(success);
130 std::vector<std::string> fuzzer_args = base::SplitString(
131 output, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
132
133 EXPECT_EQ(2UL, fuzzer_args.size());
134
135 EXPECT_EQ(fuzzer_args[0], "some_test_option=another_test_value");
136 EXPECT_EQ(fuzzer_args[1], "max_len=1337");
137
138 // Test seed_corpus archive.
139 launcher_path =
140 exe_path.DirName().Append("check_seed_corpus_archive.py").value();
141
142 cmd = base::CommandLine(
143 {{launcher_path, "test_config_and_seed_corpuses_seed_corpus.zip"}});
144 success = base::GetAppOutputAndError(cmd, &output);
145 EXPECT_TRUE(success);
146 std::vector<std::string> seed_corpus_info = base::SplitString(
147 output, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
148
149 EXPECT_EQ(1UL, seed_corpus_info.size());
150 EXPECT_EQ(seed_corpus_info[0], "5");
151 }
152
153
82 TEST(FuzzerConfigTest, DictSubdir) { 154 TEST(FuzzerConfigTest, DictSubdir) {
83 // Test of auto-generated .options file for fuzzer with dict in sub-directory. 155 // Test of auto-generated .options file for fuzzer with dict in sub-directory.
84 base::FilePath exe_path; 156 base::FilePath exe_path;
85 PathService::Get(base::FILE_EXE, &exe_path); 157 PathService::Get(base::FILE_EXE, &exe_path);
86 std::string launcher_path = 158 std::string launcher_path =
87 exe_path.DirName().Append("check_fuzzer_config.py").value(); 159 exe_path.DirName().Append("check_fuzzer_config.py").value();
88 160
89 std::string output; 161 std::string output;
90 base::CommandLine cmd({{launcher_path, "test_dict_from_subdir.options"}}); 162 base::CommandLine cmd({{launcher_path, "test_dict_from_subdir.options"}});
91 bool success = base::GetAppOutputAndError(cmd, &output); 163 bool success = base::GetAppOutputAndError(cmd, &output);
92 EXPECT_TRUE(success); 164 EXPECT_TRUE(success);
93 std::vector<std::string> fuzzer_args = base::SplitString( 165 std::vector<std::string> fuzzer_args = base::SplitString(
94 output, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); 166 output, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
95 167
96 EXPECT_EQ(1UL, fuzzer_args.size()); 168 EXPECT_EQ(1UL, fuzzer_args.size());
97 169
98 EXPECT_EQ(fuzzer_args[0], "dict=test_dict_from_subdir.dict"); 170 EXPECT_EQ(fuzzer_args[0], "dict=test_dict_from_subdir.dict");
99 } 171 }
OLDNEW
« no previous file with comments | « testing/libfuzzer/tests/check_seed_corpus_archive.py ('k') | testing/libfuzzer/tests/test_corpus/f1 » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698