Skip to content

Commit 5df471f

Browse files
authored
Disable Valgrind by default during testing (#3269)
Previously, the configure script automatically enables Valgrind during testing when the valgrind command is found. However, running tests with Valgrind is quite slow, so it is better to disable it by default, and to enable it only when the user specifies the `--enable-valgrind` flag.
1 parent c4e1fb0 commit 5df471f

File tree

8 files changed

+19
-29
lines changed

8 files changed

+19
-29
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ jobs:
8888
./configure \
8989
--host=${{ matrix.CC }} \
9090
--disable-docs \
91-
--disable-valgrind \
9291
--with-oniguruma=builtin \
9392
--enable-static \
9493
--enable-all-static \
@@ -154,7 +153,6 @@ jobs:
154153
./configure \
155154
--host="${{ matrix.target }}$(uname -r)" \
156155
--disable-docs \
157-
--disable-valgrind \
158156
--with-oniguruma=builtin \
159157
--enable-static \
160158
--enable-all-static \
@@ -230,7 +228,6 @@ jobs:
230228
autoreconf -i
231229
./configure \
232230
--disable-docs \
233-
--disable-valgrind \
234231
--with-oniguruma=builtin \
235232
--disable-shared \
236233
--enable-static \
@@ -276,7 +273,6 @@ jobs:
276273
autoreconf -i
277274
./configure \
278275
--disable-docs \
279-
--disable-valgrind \
280276
--with-oniguruma=builtin
281277
make distcheck
282278
make dist dist-zip

.github/workflows/oniguruma.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
autoreconf -i
2323
./configure \
2424
--disable-docs \
25+
--enable-valgrind \
2526
--with-oniguruma=yes
2627
make -j"$(nproc)"
2728
file ./jq
@@ -54,6 +55,7 @@ jobs:
5455
autoreconf -i
5556
./configure \
5657
--disable-docs \
58+
--enable-valgrind \
5759
--with-oniguruma=no
5860
make -j"$(nproc)"
5961
file ./jq

.github/workflows/scanbuild.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
MAKEVARS: ${{ matrix.makevars }}
5050
run: |
5151
autoreconf -i
52-
./configure --with-oniguruma=builtin $COVERAGE
52+
./configure --with-oniguruma=builtin --enable-valgrind $COVERAGE
5353
scan-build --keep-going make -j4
5454
- name: Test
5555
env:

.github/workflows/valgrind.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
autoreconf -i
2323
./configure \
2424
--disable-docs \
25+
--enable-valgrind \
2526
--with-oniguruma=builtin
2627
make -j"$(nproc)"
2728
file ./jq

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ COPY . /app
1919
RUN autoreconf -i \
2020
&& ./configure \
2121
--disable-docs \
22-
--disable-valgrind \
2322
--with-oniguruma=builtin \
2423
--enable-static \
2524
--enable-all-static \

Makefile.am

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,18 @@ endif
6565

6666
include_HEADERS = src/jv.h src/jq.h
6767

68-
if ENABLE_UBSAN
69-
AM_CFLAGS += -fsanitize=undefined
70-
endif
71-
7268
AM_CPPFLAGS = -I$(srcdir)/src -I$(srcdir)/vendor
7369

74-
### Running tests under Valgrind
70+
### Address sanitizer (ASan)
7571

7672
if ENABLE_ASAN
7773
AM_CFLAGS += -fsanitize=address
78-
NO_VALGRIND = 1
79-
else
80-
if ENABLE_VALGRIND
81-
NO_VALGRIND =
82-
else
83-
NO_VALGRIND = 1
8474
endif
75+
76+
### Undefined Behavior Sanitizer
77+
78+
if ENABLE_UBSAN
79+
AM_CFLAGS += -fsanitize=undefined
8580
endif
8681

8782
### Code coverage with gcov
@@ -127,7 +122,11 @@ TESTS = tests/mantest tests/jqtest tests/shtest tests/utf8test tests/base64test
127122
if !WIN32
128123
TESTS += tests/optionaltest
129124
endif
130-
AM_TESTS_ENVIRONMENT = JQ=$(abs_builddir)/jq NO_VALGRIND=$(NO_VALGRIND)
125+
126+
AM_TESTS_ENVIRONMENT = JQ=$(abs_builddir)/jq
127+
if ENABLE_VALGRIND
128+
AM_TESTS_ENVIRONMENT += ENABLE_VALGRIND=1
129+
endif
131130

132131
# This is a magic make variable that causes it to treat tests/man.test as a
133132
# DATA-type dependency for the check target. As a result, it will attempt to

configure.ac

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ if test "$USE_MAINTAINER_MODE" = yes; then
3939
AC_CHECK_PROGS(LEX, flex lex)
4040
fi
4141

42-
dnl Check for valgrind
43-
AC_CHECK_PROGS(valgrind_cmd, valgrind)
44-
if test "x$valgrind_cmd" = "x" ; then
45-
AC_MSG_WARN([valgrind is required to test jq.])
46-
fi
4742
AC_CHECK_FUNCS(memmem)
4843

4944
AC_CHECK_HEADER("sys/cygwin.h", [have_cygwin=1;])
@@ -54,10 +49,9 @@ dnl Running tests with Valgrind is slow. It is faster to iterate on
5449
dnl code without Valgrind until tests pass, then enable Valgrind and
5550
dnl fix leaks.
5651
AC_ARG_ENABLE([valgrind],
57-
AS_HELP_STRING([--disable-valgrind],[do not run tests under Valgrind]))
52+
AS_HELP_STRING([--enable-valgrind],[enable Valgrind during testing]))
5853

59-
dnl Running tests with Valgrind is slow; address sanitizer (ASAN) is
60-
dnl faster.
54+
dnl Address sanitizer (ASan)
6155
AC_ARG_ENABLE([asan],
6256
AS_HELP_STRING([--enable-asan],[enable address sanitizer]))
6357

@@ -114,7 +108,7 @@ AS_IF([test "x$enable_decnum" != "xno"],[
114108
AC_DEFINE([USE_DECNUM], 1, [Define to enable decnum support.])
115109
])
116110

117-
AM_CONDITIONAL([ENABLE_VALGRIND], [test "x$enable_valgrind" != xno])
111+
AM_CONDITIONAL([ENABLE_VALGRIND], [test "x$enable_valgrind" = xyes])
118112
AM_CONDITIONAL([ENABLE_ASAN], [test "x$enable_asan" = xyes])
119113
AM_CONDITIONAL([ENABLE_UBSAN], [test "x$enable_ubsan" = xyes])
120114
AM_CONDITIONAL([ENABLE_GCOV], [test "x$enable_gcov" = xyes])
@@ -291,7 +285,6 @@ AC_SUBST(onig_LDFLAGS)
291285

292286
AM_CONDITIONAL([BUILD_ONIGURUMA], [test "x$build_oniguruma" = xyes])
293287
AM_CONDITIONAL([WITH_ONIGURUMA], [test "x$with_oniguruma" != xno])
294-
AC_SUBST([BUNDLER], ["$bundle_cmd"])
295288

296289
AC_CONFIG_MACRO_DIRS([config/m4 m4])
297290
AC_CONFIG_HEADERS([src/config.h])

tests/setup

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ JQ=${JQ:-$JQBASEDIR/jq}
1616
LC_ALL=C
1717
export LC_ALL
1818

19-
if [ -z "${NO_VALGRIND-}" ] && which valgrind > /dev/null; then
19+
if [ -n "${ENABLE_VALGRIND-}" ] && which valgrind > /dev/null; then
2020
VALGRIND="valgrind --error-exitcode=1 --leak-check=full \
2121
--suppressions=$JQTESTDIR/onig.supp \
2222
--suppressions=$JQTESTDIR/local.supp"

0 commit comments

Comments
 (0)