Mercurial > hg
annotate contrib/fuzz/xdiff.cc @ 44768:9d441f820c8b stable
automation: support building Windows wheels for Python 3.7 and 3.8
The time has come to support Python 3 on Windows.
Let's teach our automation code to produce Windows wheels for
Python 3.7 and 3.8.
We could theoretically support 3.5 and 3.6. But I don't think
it is worth it. People on Windows generally use the Mercurial
installers, not wheels. And I'd prefer we limit variability
and not have to worry about supporting earlier Python versions
if it can be helped.
As part of this, we change the invocation of pip to `python.exe -m pip`,
as this is what is being recommended in Python docs these days. And
it seemed to be required to avoid a weird build error. Why, I'm not
sure. But it looks like pip was having trouble finding a Visual Studio
files when invoked as `pip.exe` but not when using `python.exe -m pip`.
Who knows.
Differential Revision: https://phab.mercurial-scm.org/D8478
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 23 Apr 2020 17:24:37 -0700 |
parents | d37658efbec2 |
children |
rev | line source |
---|---|
36679 | 1 /* |
2 * xdiff.cc - fuzzer harness for thirdparty/xdiff | |
3 * | |
4 * Copyright 2018, Google Inc. | |
5 * | |
6 * This software may be used and distributed according to the terms of | |
7 * the GNU General Public License, incorporated herein by reference. | |
8 */ | |
9 #include "thirdparty/xdiff/xdiff.h" | |
10 #include <inttypes.h> | |
11 #include <stdlib.h> | |
12 | |
43813
5a9e2ae9899b
fuzz: use a more standard approach to allow local builds of fuzzers
Augie Fackler <augie@google.com>
parents:
43809
diff
changeset
|
13 #include "FuzzedDataProvider.h" |
38173
fa0ddd5e8fff
fuzz: extract some common utilities and use modern C++ idioms
Augie Fackler <augie@google.com>
parents:
36765
diff
changeset
|
14 |
36679 | 15 extern "C" { |
16 | |
43809
51a99e09c54b
fuzz: always define LLVMFuzzerInitialize() even if we don't need it
Augie Fackler <augie@google.com>
parents:
43614
diff
changeset
|
17 int LLVMFuzzerInitialize(int *argc, char ***argv) |
51a99e09c54b
fuzz: always define LLVMFuzzerInitialize() even if we don't need it
Augie Fackler <augie@google.com>
parents:
43614
diff
changeset
|
18 { |
51a99e09c54b
fuzz: always define LLVMFuzzerInitialize() even if we don't need it
Augie Fackler <augie@google.com>
parents:
43614
diff
changeset
|
19 return 0; |
51a99e09c54b
fuzz: always define LLVMFuzzerInitialize() even if we don't need it
Augie Fackler <augie@google.com>
parents:
43614
diff
changeset
|
20 } |
51a99e09c54b
fuzz: always define LLVMFuzzerInitialize() even if we don't need it
Augie Fackler <augie@google.com>
parents:
43614
diff
changeset
|
21 |
36679 | 22 int hunk_consumer(long a1, long a2, long b1, long b2, void *priv) |
23 { | |
24 // TODO: probably also test returning -1 from this when things break? | |
25 return 0; | |
26 } | |
27 | |
28 int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) | |
29 { | |
41139
2e60a77b7058
xdiff: don't attempt to use fuzzer inputs larger than 100k
Augie Fackler <augie@google.com>
parents:
38173
diff
changeset
|
30 // Don't allow fuzzer inputs larger than 100k, since we'll just bog |
2e60a77b7058
xdiff: don't attempt to use fuzzer inputs larger than 100k
Augie Fackler <augie@google.com>
parents:
38173
diff
changeset
|
31 // down and not accomplish much. |
2e60a77b7058
xdiff: don't attempt to use fuzzer inputs larger than 100k
Augie Fackler <augie@google.com>
parents:
38173
diff
changeset
|
32 if (Size > 100000) { |
2e60a77b7058
xdiff: don't attempt to use fuzzer inputs larger than 100k
Augie Fackler <augie@google.com>
parents:
38173
diff
changeset
|
33 return 0; |
2e60a77b7058
xdiff: don't attempt to use fuzzer inputs larger than 100k
Augie Fackler <augie@google.com>
parents:
38173
diff
changeset
|
34 } |
43614
78df32a8b6f4
fuzz: migrate xdiff fuzzer to use FuzzedDataProvider
Augie Fackler <augie@google.com>
parents:
41139
diff
changeset
|
35 FuzzedDataProvider provider(Data, Size); |
78df32a8b6f4
fuzz: migrate xdiff fuzzer to use FuzzedDataProvider
Augie Fackler <augie@google.com>
parents:
41139
diff
changeset
|
36 std::string left = provider.ConsumeRandomLengthString(Size); |
78df32a8b6f4
fuzz: migrate xdiff fuzzer to use FuzzedDataProvider
Augie Fackler <augie@google.com>
parents:
41139
diff
changeset
|
37 std::string right = provider.ConsumeRemainingBytesAsString(); |
36679 | 38 mmfile_t a, b; |
39 | |
43614
78df32a8b6f4
fuzz: migrate xdiff fuzzer to use FuzzedDataProvider
Augie Fackler <augie@google.com>
parents:
41139
diff
changeset
|
40 a.ptr = (char *)left.c_str(); |
78df32a8b6f4
fuzz: migrate xdiff fuzzer to use FuzzedDataProvider
Augie Fackler <augie@google.com>
parents:
41139
diff
changeset
|
41 a.size = left.size(); |
78df32a8b6f4
fuzz: migrate xdiff fuzzer to use FuzzedDataProvider
Augie Fackler <augie@google.com>
parents:
41139
diff
changeset
|
42 b.ptr = (char *)right.c_str(); |
78df32a8b6f4
fuzz: migrate xdiff fuzzer to use FuzzedDataProvider
Augie Fackler <augie@google.com>
parents:
41139
diff
changeset
|
43 b.size = right.size(); |
36679 | 44 xpparam_t xpp = { |
45 XDF_INDENT_HEURISTIC, /* flags */ | |
46 }; | |
47 xdemitconf_t xecfg = { | |
48 XDL_EMIT_BDIFFHUNK, /* flags */ | |
49 hunk_consumer, /* hunk_consume_func */ | |
50 }; | |
51 xdemitcb_t ecb = { | |
52 NULL, /* priv */ | |
53 }; | |
54 xdl_diff(&a, &b, &xpp, &xecfg, &ecb); | |
55 return 0; // Non-zero return values are reserved for future use. | |
56 } | |
57 | |
58 } // extern "C" |