Skip to content

Commit

Permalink
Check for valgrind and mercurial
Browse files Browse the repository at this point in the history
If valgrind isn't found, `make valgrind` will be disabled. Otherwise it
will run valgrind to make sure the parser doesn't leak any memory. If
mercurial isn't found an error will be displayed and configure will
abort.

Close #978
  • Loading branch information
jvshahid committed Nov 5, 2014
1 parent 6beed4f commit 4a3a286
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 92 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ daemon/version.go
parser/lex.yy.c
parser/y.tab.h
parser/y.tab.c
parser/test_memory_leaks
protocol/protocol.pb.go
build/

Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

### Bugfixes

- [Issue #978](https://github.com/influxdb/influxdb/issues/978). Check
for valgrind and mercurial in the configure script
- [Issue #671](https://github.com/influxdb/influxdb/issues/671). Fix
the Makefile package target for Mac OSX
- [Issue #925](https://github.com/influxdb/influxdb/issues/925). Don't
Expand Down
2 changes: 2 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ uname_S = $(shell sh -c "uname -s 2>/dev/null || echo not")

valgrind:
ifeq ($(uname_S),Linux)
ifneq ($(VALGRIND),notfound)
$(MAKE) -C parser valgrind
endif
endif

# packages
test_packages = $(shell sh -c "go list github.com/influxdb/influxdb/... | egrep -v 'integration|tools'")
Expand Down
92 changes: 92 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,9 @@ CPPFLAGS
LDFLAGS
CFLAGS
CC
HG
VALGRIND
sed_i
ROCKSDB_LIB
LRT_LDFLAG
with_flex
Expand Down Expand Up @@ -1807,6 +1810,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking sed -i" >&5
$as_echo_n "checking sed -i... " >&6; }
if ${ac_cv_influxdb_sed_i+:} false; then :
Expand Down Expand Up @@ -1884,6 +1889,48 @@ if test x"${PROTOC}" == x"notfound"; then
as_fn_error $? "Please install protobuf before trying to build InfluxDB" "$LINENO" 5
fi
# Extract the first word of "valgrind", so it can be a program name with args.
set dummy valgrind; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_VALGRIND+:} false; then :
$as_echo_n "(cached) " >&6
else
case $VALGRIND in
[\\/]* | ?:[\\/]*)
ac_cv_path_VALGRIND="$VALGRIND" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_VALGRIND="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
test -z "$ac_cv_path_VALGRIND" && ac_cv_path_VALGRIND=""notfound""
;;
esac
fi
VALGRIND=$ac_cv_path_VALGRIND
if test -n "$VALGRIND"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $VALGRIND" >&5
$as_echo "$VALGRIND" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
# Check whether --with-goroot was given.
if test "${with_goroot+set}" = set; then :
Expand Down Expand Up @@ -1981,6 +2028,51 @@ if test x"${GOFMT}" == x"notfound"; then
as_fn_error $? "Please install GO (or make sure it's on your path) before trying to build InfluxDB" "$LINENO" 5
fi
# Extract the first word of "hg", so it can be a program name with args.
set dummy hg; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_HG+:} false; then :
$as_echo_n "(cached) " >&6
else
case $HG in
[\\/]* | ?:[\\/]*)
ac_cv_path_HG="$HG" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_HG="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
test -z "$ac_cv_path_HG" && ac_cv_path_HG=""notfound""
;;
esac
fi
HG=$ac_cv_path_HG
if test -n "$HG"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $HG" >&5
$as_echo "$HG" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test x"${HG}" == x"notfound"; then
as_fn_error $? "Please install mercurial before trying to build InfluxDB" "$LINENO" 5
fi
# Check whether --with-flex was given.
if test "${with_flex+set}" = set; then :
Expand Down
8 changes: 8 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ AC_SUBST(with_flex)
AC_SUBST(LRT_LDFLAG)
AC_SUBST(ROCKSDB_LIB)
AC_SUBST(sed_i)
AC_SUBST(VALGRIND)

AC_DEFUN([INFLUXDB_SED], [
AC_MSG_CHECKING([sed -i])
Expand Down Expand Up @@ -42,6 +43,8 @@ if test x"${PROTOC}" == x"notfound"; then
AC_MSG_ERROR([Please install protobuf before trying to build InfluxDB])
fi

AC_PATH_PROG(VALGRIND, valgrind, "notfound")

AC_ARG_WITH([goroot],
[AS_HELP_STRING([--with-goroot],
[Set goroot to use])],
Expand All @@ -58,6 +61,11 @@ if test x"${GOFMT}" == x"notfound"; then
AC_MSG_ERROR([Please install GO (or make sure it's on your path) before trying to build InfluxDB])
fi

AC_PATH_PROG(HG, hg, "notfound")
if test x"${HG}" == x"notfound"; then
AC_MSG_ERROR([Please install mercurial before trying to build InfluxDB])
fi

AC_ARG_WITH([flex],
[AS_HELP_STRING([--with-flex],
[Use flex given at that path])],
Expand Down
8 changes: 6 additions & 2 deletions parser/Makefile.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
VALGRIND = @VALGRIND@

BISON = @with_bison@
FLEX = @with_flex@

Expand All @@ -7,7 +9,7 @@ files = y.tab.c y.tab.h lex.yy.c
all: $(files)

clean:
rm -f y.tab.c y.tab.h lex.yy.c
rm -f y.tab.c y.tab.h lex.yy.c test_memory_leaks

y.tab.c y.tab.h: query.yacc
$(BISON) -t -d query.yacc -o y.tab.c --defines=y.tab.h
Expand All @@ -16,4 +18,6 @@ lex.yy.c: query.lex
$(FLEX) -o lex.yy.c -i query.lex

valgrind: all
./test_memory_leaks.sh
gcc -g y.tab.c lex.yy.c frees.c test_memory_leaks.c -o a.out
$(VALGRIND) --error-exitcode=1 --leak-check=full ./a.out
rm a.out
44 changes: 44 additions & 0 deletions parser/test_memory_leaks.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// +build ignore

#include "query_types.h"
#include <stdio.h>

int
main(int argc, char **argv)
{
char *qs[] = {
"select count(*) from users.events group_by user_email,time(1h) where time>now()-1d;",
"explain select users.events group_by user_email,time(1h) where time>now()-1d;",
"select * from foo where time < -1s",
"select * from merge(/.*/) where time < -1s",
"list series /",
"select count(*) from users.events group_by user_email,time(1h) where time >> now()-1d;",
"select value from t where c == 5 and b == 6;",
"select value from t where c == '5';",
"select value from cpu.idle where value > 90 and (time > now() - 1d or value > 80) and time < now() - 1w;",
"select email from users.events where email =~ /gmail\\\\.com/i and time>now()-2d;",
"select email from users.events where email in ('[email protected]')",
"select * from foobar limit",
"list continuous queries;",
"list series /foo/ bar",
"select -1 * value from t where c == 5 and b == 6;",
"select value from cpu.idle where value > 90 and (time > now() - 1d or value > 80) and time < now() - 1w last 10;",
"drop series foobar",
"drop continuous query 5;",
"select count(bar) as the_count from users.events group_by user_email,time(1h);",
"select email from users.events as events where email === /gmail\\\\.com/i and time>now()-2d;",
"select value from t where c = '5';",
"select * from foo into bar;",
};

int i;
for (i = 0; i < sizeof(qs) / sizeof(char*); i++) {
// test freeing on close for different types of queries
queries q = parse_query(qs[i]);
close_queries(&q);
}

printf("Checked %d queries for memory leak\n", i);

return 0;
}
90 changes: 0 additions & 90 deletions parser/test_memory_leaks.sh

This file was deleted.

0 comments on commit 4a3a286

Please sign in to comment.