Mercurial > hg
annotate tests/test-fuzz-targets.t @ 44261:04a3ae7aba14
chg: force-set LC_CTYPE on server start to actual value from the environment
Python 3.7+ will "coerce" the LC_CTYPE variable in many instances, and this can
cause issues with chg being able to start up. D7550 attempted to fix this, but a
combination of a misreading of the way that python3.7 does the coercion and an
untested state (LC_CTYPE being set to an invalid value) meant that this was
still not quite working.
This change will cause differences between chg and hg: hg will have the LC_CTYPE
environment variable coerced, while chg will not. This is unlikely to cause any
detectable behavior differences in what Mercurial itself outputs, but it does
have two known effects:
- When using hg, the coerced LC_CTYPE will be passed to subprocesses, even
non-python ones. Using chg will remove the coercion, and this will not
happen. This is arguably more correct behavior on chg's part.
- On macOS, if you set your region to Brazil but your language to English,
this isn't representable in locale strings, so macOS sets LC_CTYPE=UTF-8. If
this value is passed along when ssh'ing to a non-macOS machine, some
functions (such as locale.setlocale()) may raise an exception due to an
unsupported locale setting. This is most easily encountered when doing an
interactive commit/split/etc. when using ui.interface=curses.
Differential Revision: https://phab.mercurial-scm.org/D8039
author | Kyle Lippincott <spectral@google.com> |
---|---|
date | Wed, 29 Jan 2020 13:39:50 -0800 |
parents | 19da643dc10c |
children | b918494198f7 |
rev | line source |
---|---|
38236
a6347ae6168d
test-fuzz-targets: look for clang-6.0 binary as well
Yuya Nishihara <yuya@tcha.org>
parents:
38235
diff
changeset
|
1 #require test-repo |
a6347ae6168d
test-fuzz-targets: look for clang-6.0 binary as well
Yuya Nishihara <yuya@tcha.org>
parents:
38235
diff
changeset
|
2 |
35670
2b9e2415f5b5
contrib: add some basic scaffolding for some fuzz test targets
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
3 $ cd $TESTDIR/../contrib/fuzz |
43815
19da643dc10c
tests: finally fix up test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
42948
diff
changeset
|
4 $ OUT=$TESTTMP ; export OUT |
38236
a6347ae6168d
test-fuzz-targets: look for clang-6.0 binary as well
Yuya Nishihara <yuya@tcha.org>
parents:
38235
diff
changeset
|
5 |
40726
6c01fad8de32
tests: sniff for /usr/local/bin/gmake and use it in test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
38246
diff
changeset
|
6 which(1) could exit nonzero, but that's fine because we'll still end |
6c01fad8de32
tests: sniff for /usr/local/bin/gmake and use it in test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
38246
diff
changeset
|
7 up without a valid executable, so we don't need to check $? here. |
6c01fad8de32
tests: sniff for /usr/local/bin/gmake and use it in test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
38246
diff
changeset
|
8 |
6c01fad8de32
tests: sniff for /usr/local/bin/gmake and use it in test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
38246
diff
changeset
|
9 $ if which gmake >/dev/null 2>&1; then |
6c01fad8de32
tests: sniff for /usr/local/bin/gmake and use it in test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
38246
diff
changeset
|
10 > MAKE=gmake |
6c01fad8de32
tests: sniff for /usr/local/bin/gmake and use it in test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
38246
diff
changeset
|
11 > else |
6c01fad8de32
tests: sniff for /usr/local/bin/gmake and use it in test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
38246
diff
changeset
|
12 > MAKE=make |
6c01fad8de32
tests: sniff for /usr/local/bin/gmake and use it in test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
38246
diff
changeset
|
13 > fi |
6c01fad8de32
tests: sniff for /usr/local/bin/gmake and use it in test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
38246
diff
changeset
|
14 |
40727
d9fc51f77cc5
tests: sniff for libfuzzer actually being available in test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
40726
diff
changeset
|
15 $ havefuzz() { |
d9fc51f77cc5
tests: sniff for libfuzzer actually being available in test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
40726
diff
changeset
|
16 > cat > $TESTTMP/dummy.cc <<EOF |
d9fc51f77cc5
tests: sniff for libfuzzer actually being available in test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
40726
diff
changeset
|
17 > #include <stdlib.h> |
d9fc51f77cc5
tests: sniff for libfuzzer actually being available in test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
40726
diff
changeset
|
18 > #include <stdint.h> |
d9fc51f77cc5
tests: sniff for libfuzzer actually being available in test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
40726
diff
changeset
|
19 > int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; } |
d9fc51f77cc5
tests: sniff for libfuzzer actually being available in test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
40726
diff
changeset
|
20 > int main(int argc, char **argv) { |
d9fc51f77cc5
tests: sniff for libfuzzer actually being available in test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
40726
diff
changeset
|
21 > const char data[] = "asdf"; |
d9fc51f77cc5
tests: sniff for libfuzzer actually being available in test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
40726
diff
changeset
|
22 > return LLVMFuzzerTestOneInput((const uint8_t *)data, 4); |
d9fc51f77cc5
tests: sniff for libfuzzer actually being available in test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
40726
diff
changeset
|
23 > } |
d9fc51f77cc5
tests: sniff for libfuzzer actually being available in test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
40726
diff
changeset
|
24 > EOF |
d9fc51f77cc5
tests: sniff for libfuzzer actually being available in test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
40726
diff
changeset
|
25 > $CXX $TESTTMP/dummy.cc -o $TESTTMP/dummy \ |
d9fc51f77cc5
tests: sniff for libfuzzer actually being available in test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
40726
diff
changeset
|
26 > -fsanitize=fuzzer-no-link,address || return 1 |
d9fc51f77cc5
tests: sniff for libfuzzer actually being available in test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
40726
diff
changeset
|
27 > } |
d9fc51f77cc5
tests: sniff for libfuzzer actually being available in test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
40726
diff
changeset
|
28 |
38236
a6347ae6168d
test-fuzz-targets: look for clang-6.0 binary as well
Yuya Nishihara <yuya@tcha.org>
parents:
38235
diff
changeset
|
29 #if clang-libfuzzer |
40727
d9fc51f77cc5
tests: sniff for libfuzzer actually being available in test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
40726
diff
changeset
|
30 $ CXX=clang++ havefuzz || exit 80 |
43815
19da643dc10c
tests: finally fix up test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
42948
diff
changeset
|
31 $ $MAKE -s clean all PYTHON_CONFIG=`which python-config` |
38236
a6347ae6168d
test-fuzz-targets: look for clang-6.0 binary as well
Yuya Nishihara <yuya@tcha.org>
parents:
38235
diff
changeset
|
32 #endif |
a6347ae6168d
test-fuzz-targets: look for clang-6.0 binary as well
Yuya Nishihara <yuya@tcha.org>
parents:
38235
diff
changeset
|
33 #if no-clang-libfuzzer clang-6.0 |
40727
d9fc51f77cc5
tests: sniff for libfuzzer actually being available in test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
40726
diff
changeset
|
34 $ CXX=clang++-6.0 havefuzz || exit 80 |
43815
19da643dc10c
tests: finally fix up test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
42948
diff
changeset
|
35 $ $MAKE -s clean all CC=clang-6.0 CXX=clang++-6.0 PYTHON_CONFIG=`which python-config` |
38236
a6347ae6168d
test-fuzz-targets: look for clang-6.0 binary as well
Yuya Nishihara <yuya@tcha.org>
parents:
38235
diff
changeset
|
36 #endif |
a6347ae6168d
test-fuzz-targets: look for clang-6.0 binary as well
Yuya Nishihara <yuya@tcha.org>
parents:
38235
diff
changeset
|
37 #if no-clang-libfuzzer no-clang-6.0 |
a6347ae6168d
test-fuzz-targets: look for clang-6.0 binary as well
Yuya Nishihara <yuya@tcha.org>
parents:
38235
diff
changeset
|
38 $ exit 80 |
a6347ae6168d
test-fuzz-targets: look for clang-6.0 binary as well
Yuya Nishihara <yuya@tcha.org>
parents:
38235
diff
changeset
|
39 #endif |
a6347ae6168d
test-fuzz-targets: look for clang-6.0 binary as well
Yuya Nishihara <yuya@tcha.org>
parents:
38235
diff
changeset
|
40 |
43815
19da643dc10c
tests: finally fix up test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
42948
diff
changeset
|
41 $ cd $TESTTMP |
19da643dc10c
tests: finally fix up test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
42948
diff
changeset
|
42 |
19da643dc10c
tests: finally fix up test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
42948
diff
changeset
|
43 Run each fuzzer using dummy.cc as a fake input, to make sure it runs |
19da643dc10c
tests: finally fix up test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
42948
diff
changeset
|
44 at all. In the future we should instead unpack the corpus for each |
19da643dc10c
tests: finally fix up test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
42948
diff
changeset
|
45 fuzzer and use that instead. |
19da643dc10c
tests: finally fix up test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
42948
diff
changeset
|
46 |
19da643dc10c
tests: finally fix up test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
42948
diff
changeset
|
47 $ for fuzzer in `ls *_fuzzer | sort` ; do |
19da643dc10c
tests: finally fix up test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
42948
diff
changeset
|
48 > echo run $fuzzer... |
19da643dc10c
tests: finally fix up test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
42948
diff
changeset
|
49 > ./$fuzzer dummy.cc > /dev/null 2>&1 |
19da643dc10c
tests: finally fix up test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
42948
diff
changeset
|
50 > done |
19da643dc10c
tests: finally fix up test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
42948
diff
changeset
|
51 run bdiff_fuzzer... |
19da643dc10c
tests: finally fix up test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
42948
diff
changeset
|
52 run dirs_fuzzer... |
19da643dc10c
tests: finally fix up test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
42948
diff
changeset
|
53 run dirstate_fuzzer... |
19da643dc10c
tests: finally fix up test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
42948
diff
changeset
|
54 run fm1readmarkers_fuzzer... |
19da643dc10c
tests: finally fix up test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
42948
diff
changeset
|
55 run fncache_fuzzer... |
19da643dc10c
tests: finally fix up test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
42948
diff
changeset
|
56 run jsonescapeu8fast_fuzzer... |
19da643dc10c
tests: finally fix up test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
42948
diff
changeset
|
57 run manifest_fuzzer... |
19da643dc10c
tests: finally fix up test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
42948
diff
changeset
|
58 run mpatch_fuzzer... |
19da643dc10c
tests: finally fix up test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
42948
diff
changeset
|
59 run revlog_fuzzer... |
19da643dc10c
tests: finally fix up test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
42948
diff
changeset
|
60 run xdiff_fuzzer... |
42948
39cab871e880
tests: clean up built binaries after running test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
40727
diff
changeset
|
61 |
39cab871e880
tests: clean up built binaries after running test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
40727
diff
changeset
|
62 Clean up. |
43815
19da643dc10c
tests: finally fix up test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
42948
diff
changeset
|
63 $ cd $TESTDIR/../contrib/fuzz |
42948
39cab871e880
tests: clean up built binaries after running test-fuzz-targets.t
Augie Fackler <augie@google.com>
parents:
40727
diff
changeset
|
64 $ $MAKE -s clean |