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

Side by Side Diff: testing/libfuzzer/unittest_main.cc

Issue 1578413002: [libfuzzer] unittest-style main driver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 4 years, 11 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
« no previous file with comments | « testing/libfuzzer/fuzzers/pdfium_fuzzer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // A simple unit-test style driver for libfuzzer tests.
6 // Usage: <fuzzer_test> <file>...
7
8 #include <fstream>
9 #include <iostream>
10 #include <iterator>
11 #include <vector>
12
13 extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data, size_t size);
14
15 std::vector<char> readFile(std::string path) {
16 std::ifstream in(path);
17 return std::vector<char>((std::istreambuf_iterator<char>(in)),
18 std::istreambuf_iterator<char>());
19 }
20
21 int main(int argc, char **argv) {
22 if (argc == 1) {
23 std::cerr << "Usage: " << argv[0] << " <file>..." << std::endl;
24 exit(1);
25 }
26
27 for (int i = 1; i < argc; ++i) {
28 std::cout << argv[i] << std::endl;
29 auto v = readFile(argv[i]);
30 LLVMFuzzerTestOneInput((const unsigned char *)v.data(), v.size());
mmoroz 2016/01/13 10:16:09 C++ type casts are preferable to C-style casts.
31 }
32 }
OLDNEW
« no previous file with comments | « testing/libfuzzer/fuzzers/pdfium_fuzzer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698