From 2c3a37020b5035a3421ff610f5700edf769480f1 Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sun, 18 Mar 2018 14:34:04 +0000
Subject: [PATCH] test

---
 tests/tests_ts3server.sh | 225 +++++++++++++++++++++++++++++++++------
 1 file changed, 195 insertions(+), 30 deletions(-)

diff --git a/tests/tests_ts3server.sh b/tests/tests_ts3server.sh
index ebfbdb696..b6ee25f95 100644
--- a/tests/tests_ts3server.sh
+++ b/tests/tests_ts3server.sh
@@ -9,13 +9,6 @@
 
 travistest="1"
 
-# Debugging
-if [ -f ".dev-debug" ]; then
-	exec 5>dev-debug.log
-	BASH_XTRACEFD="5"
-	set -x
-fi
-
 version="171014"
 shortname="ts3"
 gameservername="ts3server"
@@ -467,16 +460,24 @@ echo "Server Tests"
 echo "Using: ${gamename}"
 echo "Testing Branch: $TRAVIS_BRANCH"
 echo "================================="
-echo ""
 
+echo ""
 echo "0.1 - Create log dir's"
 echo "================================="
 echo "Description:"
 echo "Create log dir's"
 echo ""
-(install_logs.sh)
-
+(
+	exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
+	BASH_XTRACEFD="5"
+	set -x
+	install_logs.sh
+)
+echo "run order"
+echo "================="
+grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log"|  sed 's/functionfile=//g'
 
+echo""
 echo "0.2 - Enable dev-debug"
 echo "================================="
 echo "Description:"
@@ -484,15 +485,27 @@ echo "Enable dev-debug"
 echo ""
 (command_dev_debug.sh)
 fn_test_result_pass
+echo "run order"
+echo "================="
+grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log"|  sed 's/functionfile=//g'
 
+echo""
 echo "1.0 - start - no files"
 echo "================================="
 echo "Description:"
 echo "test script reaction to missing server files."
 echo "Command: ./ts3server start"
 echo ""
-(command_start.sh)
+(
+	exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
+	BASH_XTRACEFD="5"
+	set -x
+	command_start.sh
+)
 fn_test_result_fail
+echo "run order"
+echo "================="
+grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log"|  sed 's/functionfile=//g'
 
 echo ""
 echo "1.1 - getopt"
@@ -501,8 +514,16 @@ echo "Description:"
 echo "displaying options messages."
 echo "Command: ./ts3server"
 echo ""
-(core_getopt.sh)
+(
+	exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
+	BASH_XTRACEFD="5"
+	set -x
+	core_getopt.sh
+)
 fn_test_result_pass
+echo "run order"
+echo "================="
+grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log"|  sed 's/functionfile=//g'
 
 echo ""
 echo "1.2 - getopt with incorrect args"
@@ -512,8 +533,16 @@ echo "displaying options messages."
 echo "Command: ./ts3server abc123"
 echo ""
 getopt="abc123"
-(core_getopt.sh)
+(
+	exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
+	BASH_XTRACEFD="5"
+	set -x
+	core_getopt.sh
+)
 fn_test_result_fail
+echo "run order"
+echo "================="
+grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log"|  sed 's/functionfile=//g'
 
 echo ""
 echo "2.0 - install"
@@ -521,8 +550,16 @@ echo "================================="
 echo "Description:"
 echo "install ${gamename} server."
 echo "Command: ./ts3server auto-install"
-(fn_autoinstall)
+(
+	exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
+	BASH_XTRACEFD="5"
+	set -x
+	fn_autoinstall
+)
 fn_test_result_pass
+echo "run order"
+echo "================="
+grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log"|  sed 's/functionfile=//g'
 
 echo ""
 echo "3.1 - start"
@@ -532,8 +569,16 @@ echo "start ${gamename} server."
 echo "Command: ./ts3server start"
 requiredstatus="OFFLINE"
 fn_setstatus
-(command_start.sh)
+(
+	exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
+	BASH_XTRACEFD="5"
+	set -x
+	command_start.sh
+)
 fn_test_result_pass
+echo "run order"
+echo "================="
+grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log"|  sed 's/functionfile=//g'
 
 echo ""
 echo "3.2 - start - online"
@@ -543,7 +588,12 @@ echo "start ${gamename} server while already running."
 echo "Command: ./ts3server start"
 requiredstatus="ONLINE"
 fn_setstatus
-(command_start.sh)
+(
+	exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
+	BASH_XTRACEFD="5"
+	set -x
+	command_start.sh
+)
 fn_test_result_fail
 
 echo ""
@@ -554,8 +604,16 @@ echo "will update server on start."
 echo "Command: ./ts3server start"
 requiredstatus="OFFLINE"
 fn_setstatus
-(updateonstart="on";command_start.sh)
+(
+	exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
+	BASH_XTRACEFD="5"
+	set -x
+	updateonstart="on";command_start.sh
+)
 fn_test_result_pass
+echo "run order"
+echo "================="
+grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log"|  sed 's/functionfile=//g'
 
 echo ""
 echo "3.4 - stop"
@@ -565,8 +623,16 @@ echo "stop ${gamename} server."
 echo "Command: ./ts3server stop"
 requiredstatus="ONLINE"
 fn_setstatus
-(command_stop.sh)
+(
+	exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
+	BASH_XTRACEFD="5"
+	set -x
+	command_stop.sh
+)
 fn_test_result_pass
+echo "run order"
+echo "================="
+grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log"|  sed 's/functionfile=//g'
 
 echo ""
 echo "3.5 - stop - offline"
@@ -576,8 +642,16 @@ echo "stop ${gamename} server while already stopped."
 echo "Command: ./ts3server stop"
 requiredstatus="OFFLINE"
 fn_setstatus
-(command_stop.sh)
+(
+	exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
+	BASH_XTRACEFD="5"
+	set -x
+	command_stop.sh
+)
 fn_test_result_fail
+echo "run order"
+echo "================="
+grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log"|  sed 's/functionfile=//g'
 
 echo ""
 echo "3.6 - restart"
@@ -587,8 +661,16 @@ echo "restart ${gamename}."
 echo "Command: ./ts3server restart"
 requiredstatus="ONLINE"
 fn_setstatus
-(command_restart.sh)
+(
+	exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
+	BASH_XTRACEFD="5"
+	set -x
+	command_restart.sh
+)
 fn_test_result_pass
+echo "run order"
+echo "================="
+grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log"|  sed 's/functionfile=//g'
 
 echo ""
 echo "3.7 - restart - offline"
@@ -598,8 +680,16 @@ echo "restart ${gamename} while already stopped."
 echo "Command: ./ts3server restart"
 requiredstatus="OFFLINE"
 fn_setstatus
-(command_restart.sh)
+(
+	exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
+	BASH_XTRACEFD="5"
+	set -x
+	command_restart.sh
+)
 fn_test_result_pass
+echo "run order"
+echo "================="
+grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log"|  sed 's/functionfile=//g'
 
 echo "4.1 - update"
 echo "================================="
@@ -608,8 +698,16 @@ echo "check for updates."
 echo "Command: ./ts3server update"
 requiredstatus="OFFLINE"
 fn_setstatus
-(command_update.sh)
+(
+	exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
+	BASH_XTRACEFD="5"
+	set -x
+	command_update.sh
+)
 fn_test_result_pass
+echo "run order"
+echo "================="
+grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log"|  sed 's/functionfile=//g'
 
 echo ""
 echo "5.1 - monitor - online"
@@ -619,8 +717,16 @@ echo "run monitor server while already running."
 echo "Command: ./ts3server monitor"
 requiredstatus="ONLINE"
 fn_setstatus
-(command_monitor.sh)
+(
+	exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
+	BASH_XTRACEFD="5"
+	set -x
+	command_monitor.sh
+)
 fn_test_result_pass
+echo "run order"
+echo "================="
+grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log"|  sed 's/functionfile=//g'
 
 echo ""
 echo "5.2 - monitor - offline - with lockfile"
@@ -632,8 +738,16 @@ requiredstatus="OFFLINE"
 fn_setstatus
 fn_print_info_nl "creating lockfile."
 date > "${rootdir}/${lockselfname}"
-(command_monitor.sh)
+(
+	exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
+	BASH_XTRACEFD="5"
+	set -x
+	command_monitor.sh
+)
 fn_test_result_pass
+echo "run order"
+echo "================="
+grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log"|  sed 's/functionfile=//g'
 
 echo ""
 echo "5.3 - monitor - offline - no lockfile"
@@ -643,8 +757,16 @@ echo "run monitor while server is offline with no lockfile."
 echo "Command: ./ts3server monitor"
 requiredstatus="OFFLINE"
 fn_setstatus
-(command_monitor.sh)
+(
+	exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
+	BASH_XTRACEFD="5"
+	set -x
+	command_monitor.sh
+)
 fn_test_result_fail
+echo "run order"
+echo "================="
+grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log"|  sed 's/functionfile=//g'
 
 echo ""
 echo "6.0 - details"
@@ -654,8 +776,16 @@ echo "display details."
 echo "Command: ./ts3server details"
 requiredstatus="ONLINE"
 fn_setstatus
-(command_details.sh)
+(
+	exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
+	BASH_XTRACEFD="5"
+	set -x
+	command_details.sh
+)
 fn_test_result_pass
+echo "run order"
+echo "================="
+grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log"|  sed 's/functionfile=//g'
 
 echo ""
 echo "6.1 - post details"
@@ -665,8 +795,16 @@ echo "post details."
 echo "Command: ./jc2server postdetails"
 requiredstatus="ONLINE"
 fn_setstatus
-(command_postdetails.sh)
+(
+	exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
+	BASH_XTRACEFD="5"
+	set -x
+	command_postdetails.sh
+)
 fn_test_result_pass
+echo "run order"
+echo "================="
+grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log"|  sed 's/functionfile=//g'
 
 echo ""
 echo "7.0 - backup"
@@ -679,6 +817,9 @@ fn_setstatus
 echo "test de-activated until issue #1839 fixed"
 #(command_backup.sh)
 fn_test_result_pass
+echo "run order"
+echo "================="
+grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log"|  sed 's/functionfile=//g'
 
 echo ""
 echo "8.0 - dev - detect glibc"
@@ -688,8 +829,16 @@ echo "detect glibc."
 echo "Command: ./jc2server detect-glibc"
 requiredstatus="ONLINE"
 fn_setstatus
-(command_dev_detect_glibc.sh)
+(
+	exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
+	BASH_XTRACEFD="5"
+	set -x
+	command_dev_detect_glibc.sh
+)
 fn_test_result_pass
+echo "run order"
+echo "================="
+grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log"|  sed 's/functionfile=//g'
 
 echo ""
 echo "8.1 - dev - detect ldd"
@@ -699,8 +848,16 @@ echo "detect ldd."
 echo "Command: ./jc2server detect-ldd"
 requiredstatus="ONLINE"
 fn_setstatus
-(command_dev_detect_ldd.sh)
+(
+	exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
+	BASH_XTRACEFD="5"
+	set -x
+	command_dev_detect_ldd.sh
+)
 fn_test_result_pass
+echo "run order"
+echo "================="
+grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log"|  sed 's/functionfile=//g'
 
 echo ""
 echo "8.2 - dev - detect deps"
@@ -710,8 +867,16 @@ echo "detect dependencies."
 echo "Command: ./jc2server detect-deps"
 requiredstatus="ONLINE"
 fn_setstatus
-(command_dev_detect_deps.sh)
+(
+	exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
+	BASH_XTRACEFD="5"
+	set -x
+	command_dev_detect_deps.sh
+)
 fn_test_result_pass
+echo "run order"
+echo "================="
+grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log"|  sed 's/functionfile=//g'
 
 echo ""
 echo "================================="