summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2016-12-07 22:00:12 +0200
committerTor Lillqvist <tml@collabora.com>2016-12-08 00:09:47 +0200
commit472c07ca0dfd87602cd6199fa4d1d756f17edf14 (patch)
treebdec09effd2c2fc75b7fb4aeccda78d72a0743b7 /m4
parent1b6545d21815e8a033699ed5d6a49c80ea635949 (diff)
Introduce configure option fuzzing
When --enable-fuzz-options is given, those --enable or --with options that are separately so marked, and have not been specified explicitly at the configure command line (i.e. typically from autogen.input), are randomly set to either yes or no. This functionality is useful to make sure configure options don't bit-rot by randomly exercising uncommon settings and combinations. To enable fuzzing for an option, use libo_FUZZ_ARG_WITH instead of AC_ARG_WITH, or libo_FUZZ_ARG_ENABLE instead of AC_ARG_ENABLE. Also handle two cases of incompatibilty of options discovered by using --enable-fuzz-options. In general using incompatible options should cause an AC_MSG_ERROR(), but when one of the options in question has been set by fuzzing, it's simplest to just reset it to the compatible value. Obviously this is highly experimental. Change-Id: I76d250c148892951a7fda25ba4164de8bc693a26
Diffstat (limited to 'm4')
-rw-r--r--m4/libo_fuzz_configury.m442
1 files changed, 42 insertions, 0 deletions
diff --git a/m4/libo_fuzz_configury.m4 b/m4/libo_fuzz_configury.m4
new file mode 100644
index 000000000000..c243fed8f3d1
--- /dev/null
+++ b/m4/libo_fuzz_configury.m4
@@ -0,0 +1,42 @@
+dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; fill-column: 102 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+AC_DEFUN([libo_FUZZ_ARG_WITH], [
+ AC_ARG_WITH([$1],
+ [$2],
+ [$3],
+ if test "$enable_fuzz_options" = yes; then
+ if test `expr $RANDOM % 2` = 1; then
+ m4_translit([with-$1], [-+.], [___])=yes
+ else
+ m4_translit([with-$1], [-+.], [___])=no
+ fi
+ AC_MSG_NOTICE([Randomly set m4_translit([with-$1], [-+.], [___]) to $m4_translit([with-$1], [-+.], [___])])
+ libo_fuzzed_[]m4_translit([with-$1], [-+.], [___])=yes
+ fi
+ [$4]
+ )
+])
+
+AC_DEFUN([libo_FUZZ_ARG_ENABLE], [
+ AC_ARG_ENABLE([$1],
+ [$2],
+ [$3],
+ if test "$enable_fuzz_options" = yes; then
+ if test `expr $RANDOM % 2` = 1; then
+ m4_translit([enable-$1], [-+.], [___])=yes
+ else
+ m4_translit([enable-$1], [-+.], [___])=no
+ fi
+ AC_MSG_NOTICE([Randomly set m4_translit([enable-$1], [-+.], [___]) to $m4_translit([enable-$1], [-+.], [___])])
+ libo_fuzzed_[]m4_translit([enable-$1], [-+.], [___])=yes
+ fi
+ [$4])
+])
+
+dnl vim:set shiftwidth=4 softtabstop=4 expandtab: