summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-xtools/ci/travis.sh67
-rwxr-xr-xtools/ci/uncomment.sh4
-rwxr-xr-xtools/validateinterfaces.py35
3 files changed, 82 insertions, 24 deletions
diff --git a/tools/ci/travis.sh b/tools/ci/travis.sh
index 10c653925..a1a3c7700 100755
--- a/tools/ci/travis.sh
+++ b/tools/ci/travis.sh
@@ -37,6 +37,8 @@ function usage {
echo " $0 build [configure args]"
echo " $0 test <dbname> [dbuser] [dbpassword] [dbhost]"
echo " $0 getplugins"
+ echo " $0 startmysql"
+ echo " $0 extratest"
exit 1
}
@@ -71,7 +73,8 @@ function run_server {
function run_test {
echo "Running: test_$1"
sysctl -w kernel.core_pattern=core || true
- ./test_$1 2>runlog.txt
+ rm -rf core* || true
+ CRASH_PLEASE=1 ./test_$1 2>runlog.txt
export errcode=$?
export teststr=$(head -c 10000 runlog.txt)
if [[ -n "${teststr}" ]]; then
@@ -83,6 +86,13 @@ function run_test {
fi
if [ ${errcode} -ne 0 ]; then
echo "test $1 terminated with exit code ${errcode}"
+ echo cat runlog.txt
+ cat runlog.txt
+ echo crash dump
+ COREFILE=$(find . -maxdepth 1 -name "core*" | head -n 1)
+ if [[ -f "$COREFILE" ]]; then
+ gdb -c "$COREFILE" $1 -ex "thread apply all bt" -ex "set pagination 0" -batch
+ fi
aborterror "Test failed"
fi
}
@@ -146,7 +156,14 @@ case "$MODE" in
;;
adduser)
echo "Adding user $NEWUSER as $DBUSER, with access to database $DBNAME..."
- mysql $DBUSER_ARG $DBPASS_ARG $DBHOST_ARG --execute="GRANT SELECT,INSERT,UPDATE,DELETE ON $DBNAME.* TO '$NEWUSER'@'$DBHOST' IDENTIFIED BY '$NEWPASS';"
+ mysql $DBUSER_ARG $DBPASS_ARG $DBHOST_ARG --execute="GRANT SELECT,INSERT,UPDATE,DELETE ON $DBNAME.* TO '$NEWUSER'@'$DBHOST' IDENTIFIED BY '$NEWPASS';" || true
+ mysql $DBUSER_ARG $DBPASS_ARG $DBHOST_ARG --execute="CREATE USER '$NEWUSER'@'$DBHOST' IDENTIFIED BY '$NEWPASS';" || true
+ mysql $DBUSER_ARG $DBPASS_ARG $DBHOST_ARG --execute="GRANT SELECT,INSERT,UPDATE,DELETE ON $DBNAME.* TO '$NEWUSER'@'$DBHOST';" || true
+ mysql $DBUSER_ARG $DBPASS_ARG $DBHOST_ARG --execute="ALTER USER '$NEWUSER'@'$DBHOST' IDENTIFIED BY '$NEWPASS';" || true
+ mysql --defaults-file=/etc/mysql/debian.cnf $DBPASS_ARG $DBHOST_ARG --execute="CREATE USER '$NEWUSER'@'$DBHOST' IDENTIFIED BY '$NEWPASS';" || true
+ mysql --defaults-file=/etc/mysql/debian.cnf $DBPASS_ARG $DBHOST_ARG --execute="GRANT SELECT,INSERT,UPDATE,DELETE ON $DBNAME.* TO '$NEWUSER'@'$DBHOST';" || true
+ mysql --defaults-file=/etc/mysql/debian.cnf $DBPASS_ARG $DBHOST_ARG --execute="ALTER USER '$NEWUSER'@'$DBHOST' IDENTIFIED BY '$NEWPASS';" || true
+
;;
build)
(cd tools && ./validateinterfaces.py silent) || aborterror "Interface validation error."
@@ -207,13 +224,13 @@ EOF
[ $? -eq 0 ] || aborterror "Unable to override inter-server configuration, aborting tests."
ARGS="--load-script npc/dev/test.txt "
ARGS="--load-plugin script_mapquit $ARGS --load-script npc/dev/ci_test.txt"
- PLUGINS="--load-plugin HPMHooking --load-plugin sample"
+ PLUGINS="--load-plugin HPMHooking"
echo "run tests"
if [[ $DBUSER == "travis" ]]; then
echo "Disable leak dection on travis"
- export ASAN_OPTIONS=detect_leaks=0:detect_stack_use_after_return=true:strict_init_order=true
+ export ASAN_OPTIONS=detect_leaks=0:detect_stack_use_after_return=true:strict_init_order=true:detect_odr_violation=0
else
- export ASAN_OPTIONS=detect_stack_use_after_return=true:strict_init_order=true
+ export ASAN_OPTIONS=detect_stack_use_after_return=true:strict_init_order=true:detect_odr_violation=0
fi
# run_test spinlock # Not running the spinlock test for the time being (too time consuming)
run_test libconfig
@@ -221,7 +238,38 @@ EOF
run_server ./login-server
run_server ./char-server
run_server ./map-server "$ARGS"
- echo "run all servers wit HPM"
+ echo "run all servers with HPM"
+ run_server ./login-server "$PLUGINS"
+ run_server ./char-server "$PLUGINS"
+ run_server ./map-server "$ARGS $PLUGINS"
+ echo "run all servers with sample plugin"
+ run_server ./login-server "$PLUGINS --load-plugin sample"
+ run_server ./char-server "$PLUGINS --load-plugin sample"
+ run_server ./map-server "$PLUGINS --load-plugin sample"
+ echo "run all servers with constdb2doc"
+ run_server ./map-server "$PLUGINS --load-plugin constdb2doc --constdb2doc"
+ echo "run all servers with db2sql"
+ run_server ./map-server "$PLUGINS --load-plugin db2sql --db2sql"
+ run_server ./map-server "$PLUGINS --load-plugin db2sql --itemdb2sql"
+ run_server ./map-server "$PLUGINS --load-plugin db2sql --mobdb2sql"
+# look like works on windows only
+# echo "run all servers with dbghelpplug"
+# run_server ./login-server "$PLUGINS --load-plugin dbghelpplug"
+# run_server ./char-server "$PLUGINS --load-plugin dbghelpplug"
+# run_server ./map-server "$PLUGINS --load-plugin dbghelpplug"
+ echo "run all servers with generate-translations"
+ run_server ./map-server "$PLUGINS --load-plugin generate-translations --generate-translations"
+ echo "run all servers with mapcache"
+# for other flags need grf or other files
+ run_server ./map-server "$PLUGINS --load-plugin mapcache --fix-md5"
+ echo "run all servers with script_mapquit"
+ run_server ./map-server "$PLUGINS --load-plugin script_mapquit"
+ ;;
+ extratest)
+ export ASAN_OPTIONS=detect_stack_use_after_return=true:strict_init_order=true:detect_odr_violation=0
+ PLUGINS="--load-plugin HPMHooking"
+ echo "run map server with uncommented old and custom scripts"
+ find ./npc -type f -name "*.conf" -exec ./tools/ci/uncomment.sh {} \;
run_server ./login-server "$PLUGINS"
run_server ./char-server "$PLUGINS"
run_server ./map-server "$ARGS $PLUGINS"
@@ -238,6 +286,13 @@ EOF
# echo "Plugin not found, skipping advanced tests."
#fi
;;
+ startmysql)
+ echo "Starting mysql..."
+ service mysql status || true
+ service mysql stop || true
+ service mysql start || true
+ service mysql status || true
+ ;;
*)
usage
;;
diff --git a/tools/ci/uncomment.sh b/tools/ci/uncomment.sh
new file mode 100755
index 000000000..22fe4e966
--- /dev/null
+++ b/tools/ci/uncomment.sh
@@ -0,0 +1,4 @@
+#!/usr/bin/env bash
+
+sed -i "s|//\"npc/|\"npc/|g" $1
+sed -i "s|\"npc/location/to/script.txt\"|//\"npc/location/to/script.txt\"|g" $1
diff --git a/tools/validateinterfaces.py b/tools/validateinterfaces.py
index e031c34ab..324a2aeec 100755
--- a/tools/validateinterfaces.py
+++ b/tools/validateinterfaces.py
@@ -23,7 +23,6 @@
import os
import re
import sys
-from sets import Set
interfaceRe = re.compile("struct (?P<name1>[a-z_]+)_interface (?P<name2>[a-z_]+)_s;")
@@ -44,7 +43,7 @@ def searchStructStart(r, ifname):
return False
def readCFile(tracker, cFile):
- methods = Set()
+ methods = set()
shortIfName = ""
with open(cFile, "r") as r:
for line in r:
@@ -78,7 +77,7 @@ def readCFile(tracker, cFile):
return (None, shortIfName, methods)
def readHFile(tracker, hFile, ifname):
- methods = Set()
+ methods = set()
with open(hFile, "r") as r:
if searchStructStart(r, ifname) == False:
return methods
@@ -108,7 +107,7 @@ def checkIfFile(tracker, cFile, hFile):
tracker.arr[ifname + "_" + method] = list()
tracker.methods.add(ifname + "_" + method)
if method not in cMethods:
- print "Missing initialisation in file {0}: {1}".format(cFile, method)
+ print("Missing initialisation in file {0}: {1}".format(cFile, method))
tracker.retCode = 1
# for method in cMethods:
# if method not in hMethods:
@@ -175,13 +174,13 @@ def processDir(tracker, srcDir):
checkFile(tracker, cPath)
def reportMethods(tracker):
- print "\n"
+ print("\n")
for method in tracker.methods:
if len(tracker.arr[method]) > 2:
- print method
+ print(method)
for t in tracker.arr[method]:
- print t
- print "\n"
+ print(t)
+ print("\n")
def checkLostFile(tracker, cFile):
@@ -198,7 +197,7 @@ def checkLostFile(tracker, cFile):
continue
if name not in tracker.fullmethods:
# print "src : " + line
- print name
+ print(name)
def processLostDir(tracker, srcDir):
files = os.listdir(srcDir)
@@ -232,9 +231,9 @@ def runLong():
tracker = Tracker()
tracker.arr = dict()
-tracker.methods = Set()
-tracker.fullmethods = Set()
-tracker.interfaces = Set()
+tracker.methods = set()
+tracker.fullmethods = set()
+tracker.interfaces = set()
tracker.retCode = 0
if len(sys.argv) > 1:
@@ -245,19 +244,19 @@ else:
if cmd == "silent":
runIf()
elif cmd == "init":
- print "Checking interfaces initialisation"
+ print("Checking interfaces initialisation")
runIf()
elif cmd == "lost":
- print "Checking not added functions to interfaces"
+ print("Checking not added functions to interfaces")
runLost();
elif cmd == "long":
- print "Checking interfaces usage"
+ print("Checking interfaces usage")
runLong();
else:
- print "Checking interfaces initialisation"
+ print("Checking interfaces initialisation")
runIf()
- print "Checking not added functions to interfaces"
+ print("Checking not added functions to interfaces")
runLost();
- print "Checking interfaces usage"
+ print("Checking interfaces usage")
runLong();
exit(tracker.retCode)