diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..086c3d3 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,8 @@ +language: cpp +compiler: gcc +sudo: required +install: + - sudo apt-get update + - sudo ./install-deps.sh + - if [ -x /usr/bin/python2 ]; then test -e /usr/bin/python && echo Done || sudo ln -sfn python2 /usr/bin/python; fi +script: ./configure && make diff --git a/Makefile b/Makefile index 14802a2..f43080e 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ TOUCH=touch INSTALL_DIRS:= INSTALL_DSTS:= -CXX:=g++#./gstlfilt/gfilt +CXX?=g++ #./gstlfilt/gfilt LXXFLAGS:=-Lobj/ $(patsubst %,-l%,$(LIBS)) ifeq ($(OPT),) OPT := -O2 @@ -47,7 +47,7 @@ SYS_LIBS:=$(BOOST_SYSTEM) $(BOOST_THREAD) -lboost_signals -lpthread $(STATGRAB) all: $(DIR_DEPS) $(LIB_DEPS) $(BINS) tests ftests dpkg: - env DEB_BUILD_OPTIONS="nostrip" debuild -us -uc + env DEB_BUILD_OPTIONS="nostrip" debuild -us -uc @echo done build: $(DIR_DEPS) $(BINS) diff --git a/README.md b/README.md index 7ff375d..e9f1196 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ istatd ====== +[![Build Status](https://travis-ci.org/ambakshi/istatd.svg?branch=master)](https://travis-ci.org/ambakshi/istatd) + Check with jwatte@imvu.com for more information. Released under MIT license. All rights reserved. Copyright 2011-2014 IMVU, Inc. Some contributions in the contrib subdirectory may be released under diff --git a/configure b/configure index 0bb77d5..2a233ac 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #!/bin/bash # Simple configuration script for people who expect such a script to exist. -# Please do not convert istatd to autotools. We will likely not accept such +# Please do not convert istatd to autotools. We will likely not accept such # a conversion. Thanks for your interest in istatd, and good luck! set -e @@ -10,7 +10,7 @@ rm -f makevars.config rm -f config.h # Find Python version 2. -# If this fails, you need to create appropriate aliases or symlinks for +# If this fails, you need to create appropriate aliases or symlinks for # testing to work! /usr/bin/env python -V /usr/bin/env python2 -V @@ -20,6 +20,28 @@ if curl --help >/dev/null 2>&1; then echo "Found curl in path."; else exit 1 fi +if ! which jq >/dev/null 2>&1; then + case "`uname`" in + [Dd]arwin) + jqos=osx ;; + [Ll]inux) + jqos=linux ;; + *) + echo "You need to install the command-line tool 'jq'." + echo "Try http://stedolan.github.io/jq or your package manager." + exit 1 ;; + esac + if [ "`uname -m`" = "x86_64" ]; then + jqos="${jqos}64" + else + jqos="${jqos}32" + fi + mkdir -p bin + curl -sSL "http://stedolan.github.io/jq/download/${jqos}/jq" > jq.$$ + mv jq.$$ jq + chmod +x jq +fi + if cat /dev/null | zlib-flate -compress; then echo "Found zlib-flate in path."; else echo "You need to install the command-line tool 'zlib-flate'." echo "On debian systems run 'sudo apt-get install qpdf'" diff --git a/ftest/functions b/ftest/functions index 99fa999..a5ead50 100644 --- a/ftest/functions +++ b/ftest/functions @@ -14,7 +14,7 @@ export EXIT_HOOK="" # do a bit of a fail-safe to make sure we don't hang forever export ALARMPARENT=$$ -(sleep 30; echo "Test process timed out."; kill -9 $ALARMPARENT; [ -z "$DEBUG_ISTATD" ] && killall -q -9 istatd && killall -q -9 istatd_transplant; exit 1) & +(sleep 30; echo "Test process timed out."; kill -9 $ALARMPARENT; [ -z "$DEBUG_ISTATD" ] && killall -q -9 istatd && killall -q -9 istatd_transplant; exit 1) $DBDIR/$CONFIG-stdouterr 2>&1 + bin/istatd --debug segv --config ftest/$CONFIG.cfg $maybe_store --settings $DBDIR/$CONFIG-settings --pid-file $DBDIR/$CONFIG-pid.pid --log-file $DBDIR/$CONFIG-log.log --daemonize $* > $DBDIR/$CONFIG-stdouterr 2>&1 $TMPF1 + jq -r $EXP $FILE2 | sort > $TMPF2 + if ! diff $TMPF1 $TMPF2 > $TMPF 2>&1; then + echo "FAILURE: $TEST_NAME" + echo "test_output < $FILE1" + echo "test_expect > $FILE2" + cat $TMPF $TMPF1 $TMPF2 + rm -f $TMPF $TMPF1 $TMPF2 + exit 1 + fi + rm -f $TMPF $TMPF1 $TMPF2 +} + function assert_expected { RESULT_F=$1 EXPECT_F=ftest/expected/$FTEST_NAME/$TEST_NAME @@ -536,13 +556,21 @@ function assert_expected { assert_files_equal $RESULT_F $EXPECT_F } +function assert_expected_json { + RESULT_F=$1 + EXPECT_F=ftest/expected/$FTEST_NAME/$TEST_NAME + [ -d ftest/expected ] || failure "dir does not exist: ftest/expected" + [ -d ftest/expected/$FTEST_NAME ] || failure "dir does not exist: ftest/expected/$FTEST_NAME" + assert_json_equal $RESULT_F $EXPECT_F '.matching_names[]|[.name,.is_leaf,.type]' +} + TEST_NUM=0 TEST_OUT=/var/tmp/test_out_$$ EXPECT_OUT=/var/tmp/expect_out_$$ TEST_NAME="" function test_name { TEST_NAME=$1 - let TEST_NUM=$TEST_NUM+1 + let TEST_NUM=$TEST_NUM+1 TEST_NUM_STR=`printf "%03d" $TEST_NUM` TEST_OUT=$DBDIR/test_${TEST_NUM_STR} EXPECT_OUT=$DBDIR/expect_${TEST_NUM_STR} diff --git a/ftest/test_json_interface.sh b/ftest/test_json_interface.sh index cbd2767..3a32827 100755 --- a/ftest/test_json_interface.sh +++ b/ftest/test_json_interface.sh @@ -124,7 +124,7 @@ start_server single --fake-time 2600 test_name GET_counter_list_returns_counter_type curl -s "http://localhost:18011/?q=*" > $TEST_OUT -assert_expected $TEST_OUT +assert_expected_json $TEST_OUT cleanup_test diff --git a/ftest/test_transplant.sh b/ftest/test_transplant.sh index c81c901..707a0cc 100755 --- a/ftest/test_transplant.sh +++ b/ftest/test_transplant.sh @@ -79,7 +79,7 @@ function kill_transplant { echo "starting server" EXIT_HOOK="kill_transplant" echo "$TRANSPLANT" --listen 9156 --store "$MASTERDIR" --pidfile master-pid.pid --debug - "$TRANSPLANT" --listen 9156 --store "$MASTERDIR" --pidfile master-pid.pid --debug > "$DBDIR/master.log" 2>&1 & + "$TRANSPLANT" --listen 9156 --store "$MASTERDIR" --pidfile master-pid.pid --debug > "$DBDIR/master.log" 2>&1