Merge pull request #202 from badgerman/develop

valgrind test for travis, fix runtests script, fix bad tests
This commit is contained in:
Enno Rehling 2015-05-21 21:31:35 +02:00
commit 7a65658cc5
14 changed files with 119 additions and 17 deletions

View File

@ -5,7 +5,7 @@ compiler:
script: s/travis-build
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq libtolua-dev liblua5.1-dev libncurses5-dev libsqlite3-dev libxml2-dev
- sudo apt-get install -qq zlib1g-dev libtolua-dev liblua5.1-dev libncurses5-dev libsqlite3-dev libxml2-dev valgrind
os:
- linux
- osx

View File

@ -1,4 +1,7 @@
#!/bin/bash
set -e
ROOT=$(pwd)
while [ ! -d $ROOT/.git ]; do
ROOT=$(dirname $ROOT)
@ -21,4 +24,5 @@ cd $ROOT
$ROOT/$BIN_DIR/eressea/eressea -v0 scripts/run-tests.lua
$ROOT/$BIN_DIR/eressea/eressea -v0 scripts/run-tests-e2.lua
$ROOT/$BIN_DIR/eressea/eressea -v0 scripts/run-tests-e3.lua
cd $OLDWPD

View File

@ -1,18 +1,63 @@
#!/bin/sh
set -e
ROOT=`pwd`
MACHINE=`uname -m`
[ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc"
[ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc"
[ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc"
BUILD="$ROOT/build-$MACHINE-$CC-Debug"
inifile() {
cd $ROOT
if [ ! -e eressea.ini ]; then
cp conf/eressea.ini .
build/iniparser/inifile eressea.ini add lua:paths lunit:scripts
$BUILD/iniparser/inifile eressea.ini add lua:paths lunit:scripts
fi
}
[ -d build ] || mkdir build
cd build && cmake .. \
-DCMAKE_MODULE_PATH=$PWD/../cmake/Modules \
-DCMAKE_BUILD_TYPE=Debug .. && \
make && cd .. && inifile &&
build/eressea/test_eressea &&
build/eressea/eressea -v0 scripts/run-tests.lua
build/eressea/eressea -v0 scripts/run-tests-e2.lua
build/eressea/eressea -v0 scripts/run-tests-e3.lua
build() {
cd $BUILD
cmake -DCMAKE_MODULE_PATH=$ROOT/cmake/Modules -DCMAKE_BUILD_TYPE=Debug ..
make
}
test_valgrind_report () {
cd tests
ln -sf ../scripts/config.lua
valgrind --suppressions=ubuntu-12_04.supp --error-exitcode=1 $BUILD/eressea/eressea -v0 -t184 ../scripts/reports.lua
}
test_unittests() {
$BUILD/eressea/test_eressea
}
cleanup() {
cd $ROOT/tests
rm -rf reports score eressea.log* config.lua
}
test_server() {
cd $ROOT
inifile
$BUILD/eressea/eressea -v0 scripts/run-tests.lua
$BUILD/eressea/eressea -v0 scripts/run-tests-e2.lua
$BUILD/eressea/eressea -v0 scripts/run-tests-e3.lua
}
# information
echo "* base directory: $ROOT"
echo "* build directory: $BUILD"
echo "* lsb_release:"
lsb_release -a
echo "* zlib1g-dev package:"
dpkg -l zlib1g-dev
echo
# build the code
[ -d $BUILD ] || mkdir $BUILD
build
test_unittests
test_server
test_valgrind_report
cleanup

View File

@ -19,4 +19,4 @@ require 'lunit'
rules = require('eressea.' .. config.rules)
result = lunit.main()
return result.errors
return result.errors + result.failed

View File

@ -20,4 +20,4 @@ require 'lunit'
eressea.settings.set("rules.alliances", "0")
rules = require('eressea.' .. config.rules)
result = lunit.main()
return result.errors
return result.errors + result.failed

View File

@ -14,4 +14,4 @@ require 'eressea.path'
require 'tests'
require 'lunit'
result = lunit.main()
return result.errors
return result.errors + result.failed

View File

@ -8,6 +8,7 @@ function setup()
eressea.settings.set("rules.economy.food", "0")
eressea.settings.set("nmr.removenewbie", "0")
eressea.settings.set("nmr.timeout", "0")
eressea.settings.set("GiveRestriction", "0")
eressea.settings.set("rules.magic.playerschools", "")
conf = [[{
"races": {

View File

@ -204,7 +204,8 @@ static void test_build_building_no_materials(CuTest *tc) {
btype = bt_find("castle");
assert(btype);
set_level(u, SK_BUILDING, 1);
CuAssertIntEquals(tc, ENOMATERIALS, build_building(u, btype, 0, 4, 0));
u->orders = create_order(K_MAKE, u->faction->locale, 0);
CuAssertIntEquals(tc, ENOMATERIALS, build_building(u, btype, 0, 4, u->orders));
CuAssertPtrEquals(tc, 0, u->region->buildings);
CuAssertPtrEquals(tc, 0, u->building);
test_cleanup();
@ -222,7 +223,8 @@ static void test_build_building_with_golem(CuTest *tc) {
assert(btype->construction);
set_level(bf.u, SK_BUILDING, 1);
CuAssertIntEquals(tc, 1, build_building(u, btype, 0, 1, 0));
u->orders = create_order(K_MAKE, u->faction->locale, 0);
CuAssertIntEquals(tc, 1, build_building(u, btype, 0, 1, u->orders));
CuAssertPtrNotNull(tc, u->region->buildings);
CuAssertIntEquals(tc, 1, u->region->buildings->size);
CuAssertIntEquals(tc, 0, u->number);
@ -245,7 +247,8 @@ static void test_build_building_success(CuTest *tc) {
i_change(&bf.u->items, rtype->itype, 1);
set_level(u, SK_BUILDING, 1);
CuAssertIntEquals(tc, 1, build_building(u, btype, 0, 4, 0));
u->orders = create_order(K_MAKE, u->faction->locale, 0);
CuAssertIntEquals(tc, 1, build_building(u, btype, 0, 4, u->orders));
CuAssertPtrNotNull(tc, u->region->buildings);
CuAssertPtrEquals(tc, u->region->buildings, u->building);
CuAssertIntEquals(tc, 1, u->building->size);

View File

@ -65,6 +65,9 @@ static void release_data(order_data * data)
void replace_order(order ** dlist, order * orig, const order * src)
{
assert(src);
assert(orig);
assert(dlist);
while (*dlist != NULL) {
order *dst = *dlist;
if (dst->data == orig->data) {

View File

@ -143,6 +143,21 @@ static void test_skip_token(CuTest *tc) {
CuAssertStrEquals(tc, 0, getstrtoken());
}
static void test_replace_order(CuTest *tc) {
order *orders = 0, *orig, *repl;
struct locale * lang = get_or_create_locale("en");
orig = create_order(K_MAKE, lang, 0);
repl = create_order(K_ALLY, lang, 0);
replace_order(&orders, orig, repl);
CuAssertPtrEquals(tc, 0, orders);
orders = orig;
replace_order(&orders, orig, repl);
CuAssertPtrNotNull(tc, orders);
CuAssertPtrEquals(tc, 0, orders->next);
CuAssertIntEquals(tc, getkeyword(repl), getkeyword(orders));
}
CuSuite *get_order_suite(void)
{
CuSuite *suite = CuSuiteNew();
@ -152,6 +167,7 @@ CuSuite *get_order_suite(void)
SUITE_ADD_TEST(suite, test_parse_make_temp);
SUITE_ADD_TEST(suite, test_parse_maketemp);
SUITE_ADD_TEST(suite, test_init_order);
SUITE_ADD_TEST(suite, test_replace_order);
SUITE_ADD_TEST(suite, test_skip_token);
SUITE_ADD_TEST(suite, test_getstrtoken);
return suite;

BIN
tests/data/184.dat Normal file

Binary file not shown.

14
tests/eressea.ini Normal file
View File

@ -0,0 +1,14 @@
[eressea]
base = .
report = reports
verbose = 0
lomem = 0
debug = 0
memcheck = 0
locales = de,en
[lua]
install = ..
paths = lunit:scripts
maxnmrs = 20
rules = e2

0
tests/orders.184 Normal file
View File

16
tests/ubuntu-12_04.supp Normal file
View File

@ -0,0 +1,16 @@
{
zlib1g-dev-1:1.2.3.4.dfsg
Memcheck:Cond
fun:inflateReset2
fun:inflateInit2_
obj:/usr/lib/x86_64-linux-gnu/libxml2.so.2.8.0
fun:__libxml2_xzread
obj:/usr/lib/x86_64-linux-gnu/libxml2.so.2.8.0
fun:xmlParserInputBufferGrow
fun:xmlParserInputGrow
obj:/usr/lib/x86_64-linux-gnu/libxml2.so.2.8.0
fun:xmlParseDocument
obj:/usr/lib/x86_64-linux-gnu/libxml2.so.2.8.0
fun:read_xml
fun:init_data
}