tests_jc2server.sh 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327
  1. #!/bin/bash
  2. # Project: Game Server Managers - LinuxGSM
  3. # Author: Daniel Gibbs
  4. # License: MIT License, Copyright (c) 2020 Daniel Gibbs
  5. # Purpose: Travis CI Tests: Just Cause 2 | Linux Game Server Management Script
  6. # Contributors: https://linuxgsm.com/contrib
  7. # Documentation: https://docs.linuxgsm.com
  8. # Website: https://linuxgsm.com
  9. # DO NOT EDIT THIS FILE
  10. # LinuxGSM configuration is no longer edited here
  11. # To update your LinuxGSM config go to:
  12. # lgsm/config-lgsm
  13. # https://docs.linuxgsm.com/configuration/linuxgsm-config
  14. # Debugging
  15. if [ -f ".dev-debug" ]; then
  16. exec 5>dev-debug.log
  17. BASH_XTRACEFD="5"
  18. set -x
  19. fi
  20. version="v20.4.0"
  21. shortname="jc2"
  22. gameservername="jc2server"
  23. commandname="CORE"
  24. rootdir=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
  25. selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
  26. sessionname=$(echo "${selfname}" | cut -f1 -d".")
  27. lgsmdir="${rootdir}/lgsm"
  28. logdir="${rootdir}/log"
  29. lgsmlogdir="${logdir}/lgsm"
  30. steamcmddir="${HOME}/.steam/steamcmd"
  31. serverfiles="${rootdir}/serverfiles"
  32. functionsdir="${lgsmdir}/functions"
  33. tmpdir="${lgsmdir}/tmp"
  34. datadir="${lgsmdir}/data"
  35. lockdir="${lgsmdir}/lock"
  36. serverlist="${datadir}/serverlist.csv"
  37. serverlistmenu="${datadir}/serverlistmenu.csv"
  38. configdir="${lgsmdir}/config-lgsm"
  39. configdirserver="${configdir}/${gameservername}"
  40. configdirdefault="${lgsmdir}/config-default"
  41. userinput="${1}"
  42. # Allows for testing not on Travis CI.
  43. # if using travis for tests
  44. if [ -z "${TRAVIS}" ]; then
  45. TRAVIS_BRANCH="develop"
  46. TRAVIS_BUILD_DIR="${rootdir}"
  47. fi
  48. travistest="1"
  49. ## GitHub Branch Select
  50. # Allows for the use of different function files
  51. # from a different repo and/or branch.
  52. githubuser="GameServerManagers"
  53. githubrepo="LinuxGSM"
  54. githubbranch="${TRAVIS_BRANCH}"
  55. # Core function that is required first.
  56. core_functions.sh(){
  57. functionfile="${FUNCNAME[0]}"
  58. fn_bootstrap_fetch_file_github "lgsm/functions" "core_functions.sh" "${functionsdir}" "chmodx" "run" "noforcedl" "nomd5"
  59. }
  60. # Bootstrap
  61. # Fetches the core functions required before passed off to core_dl.sh.
  62. fn_bootstrap_fetch_file(){
  63. remote_fileurl="${1}"
  64. remote_fileurl_backup="${2}"
  65. remote_fileurl_name="${3}"
  66. remote_fileurl_backup_name="${4}"
  67. local_filedir="${5}"
  68. local_filename="${6}"
  69. chmodx="${7:-0}"
  70. run="${8:-0}"
  71. forcedl="${9:-0}"
  72. md5="${10:-0}"
  73. # Download file if missing or download forced.
  74. if [ ! -f "${local_filedir}/${local_filename}" ]||[ "${forcedl}" == "forcedl" ]; then
  75. # If backup fileurl exists include it.
  76. if [ -n "${remote_fileurl_backup}" ]; then
  77. # counter set to 0 to allow second try
  78. counter=0
  79. remote_fileurls_array=( remote_fileurl remote_fileurl_backup )
  80. else
  81. # counter set to 1 to not allow second try
  82. counter=1
  83. remote_fileurls_array=( remote_fileurl )
  84. fi
  85. for remote_fileurl_array in "${remote_fileurls_array[@]}"
  86. do
  87. if [ "${remote_fileurl_array}" == "remote_fileurl" ]; then
  88. fileurl="${remote_fileurl}"
  89. fileurl_name="${remote_fileurl_name}"
  90. elif [ "${remote_fileurl_array}" == "remote_fileurl_backup" ]; then
  91. fileurl="${remote_fileurl_backup}"
  92. fileurl_name="${remote_fileurl_backup_name}"
  93. fi
  94. counter=$((counter+1))
  95. if [ ! -d "${local_filedir}" ]; then
  96. mkdir -p "${local_filedir}"
  97. fi
  98. # Trap will remove part downloaded files if canceled.
  99. trap fn_fetch_trap INT
  100. # Larger files show a progress bar.
  101. echo -en "fetching ${fileurl_name} ${local_filename}...\c"
  102. curlcmd=$(curl -s --fail -L -o "${local_filedir}/${local_filename}" "${fileurl}" 2>&1)
  103. local exitcode=$?
  104. # Download will fail if downloads a html file.
  105. if [ -f "${local_filedir}/${local_filename}" ]; then
  106. if [ -n "$(head "${local_filedir}/${local_filename}" | grep "DOCTYPE" )" ]; then
  107. rm "${local_filedir:?}/${local_filename:?}"
  108. local exitcode=2
  109. fi
  110. fi
  111. # On first try will error. On second try will fail.
  112. if [ "${exitcode}" != 0 ]; then
  113. if [ ${counter} -ge 2 ]; then
  114. echo -e "FAIL"
  115. if [ -f "${lgsmlog}" ]; then
  116. fn_script_log_fatal "Downloading ${local_filename}"
  117. fn_script_log_fatal "${fileurl}"
  118. fi
  119. core_exit.sh
  120. else
  121. echo -e "ERROR"
  122. if [ -f "${lgsmlog}" ]; then
  123. fn_script_log_error "Downloading ${local_filename}"
  124. fn_script_log_error "${fileurl}"
  125. fi
  126. fi
  127. else
  128. echo -en "OK"
  129. sleep 0.3
  130. echo -en "\033[2K\\r"
  131. if [ -f "${lgsmlog}" ]; then
  132. fn_script_log_pass "Downloading ${local_filename}"
  133. fi
  134. # Make file executable if chmodx is set.
  135. if [ "${chmodx}" == "chmodx" ]; then
  136. chmod +x "${local_filedir}/${local_filename}"
  137. fi
  138. # Remove trap.
  139. trap - INT
  140. break
  141. fi
  142. done
  143. fi
  144. if [ -f "${local_filedir}/${local_filename}" ]; then
  145. # Execute file if run is set.
  146. if [ "${run}" == "run" ]; then
  147. # shellcheck source=/dev/null
  148. source "${local_filedir}/${local_filename}"
  149. fi
  150. fi
  151. }
  152. fn_bootstrap_fetch_file_github(){
  153. github_file_url_dir="${1}"
  154. github_file_url_name="${2}"
  155. if [ "${githubbranch}" == "master" ]&&[ "${commandname}" != "UPDATE-LGSM" ]; then
  156. remote_fileurl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${version}/${github_file_url_dir}/${github_file_url_name}"
  157. remote_fileurl_backup="https://bitbucket.org/${githubuser}/${githubrepo}/raw/${version}/${github_file_url_dir}/${github_file_url_name}"
  158. else
  159. remote_fileurl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
  160. remote_fileurl_backup="https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
  161. fi
  162. remote_fileurl_name="GitHub"
  163. remote_fileurl_backup_name="Bitbucket"
  164. local_filedir="${3}"
  165. local_filename="${github_file_url_name}"
  166. chmodx="${4:-0}"
  167. run="${5:-0}"
  168. forcedl="${6:-0}"
  169. md5="${7:-0}"
  170. # Passes vars to the file download function.
  171. fn_bootstrap_fetch_file "${remote_fileurl}" "${remote_fileurl_backup}" "${remote_fileurl_name}" "${remote_fileurl_backup_name}" "${local_filedir}" "${local_filename}" "${chmodx}" "${run}" "${forcedl}" "${md5}"
  172. }
  173. # Installer menu.
  174. fn_print_center() {
  175. columns=$(tput cols)
  176. line="$*"
  177. printf "%*s\n" $(( (${#line} + columns) / 2)) "${line}"
  178. }
  179. fn_print_horizontal(){
  180. printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' "="
  181. }
  182. # Bash menu.
  183. fn_install_menu_bash() {
  184. local resultvar=$1
  185. title=$2
  186. caption=$3
  187. options=$4
  188. fn_print_horizontal
  189. fn_print_center "${title}"
  190. fn_print_center "${caption}"
  191. fn_print_horizontal
  192. menu_options=()
  193. while read -r line || [[ -n "${line}" ]]; do
  194. var=$(echo -e "${line}" | awk -F "," '{print $2 " - " $3}')
  195. menu_options+=( "${var}" )
  196. done < "${options}"
  197. menu_options+=( "Cancel" )
  198. select option in "${menu_options[@]}"; do
  199. if [ "${option}" ]&&[ "${option}" != "Cancel" ]; then
  200. eval "$resultvar=\"${option/%\ */}\""
  201. fi
  202. break
  203. done
  204. }
  205. # Whiptail/Dialog menu.
  206. fn_install_menu_whiptail() {
  207. local menucmd=$1
  208. local resultvar=$2
  209. title=$3
  210. caption=$4
  211. options=$5
  212. height=${6:-40}
  213. width=${7:-80}
  214. menuheight=${8:-30}
  215. IFS=","
  216. menu_options=()
  217. while read -r line; do
  218. key=$(echo -e "${line}" | awk -F "," '{print $3}')
  219. val=$(echo -e "${line}" | awk -F "," '{print $2}')
  220. menu_options+=( "${val//\"}" "${key//\"}" )
  221. done < "${options}"
  222. OPTION=$(${menucmd} --title "${title}" --menu "${caption}" "${height}" "${width}" "${menuheight}" "${menu_options[@]}" 3>&1 1>&2 2>&3)
  223. if [ $? == 0 ]; then
  224. eval "$resultvar=\"${OPTION}\""
  225. else
  226. eval "$resultvar="
  227. fi
  228. }
  229. # Menu selector.
  230. fn_install_menu() {
  231. local resultvar=$1
  232. local selection=""
  233. title=$2
  234. caption=$3
  235. options=$4
  236. # Get menu command.
  237. for menucmd in whiptail dialog bash; do
  238. if [ "$(command -v "${menucmd}")" ]; then
  239. menucmd=$(command -v "${menucmd}")
  240. break
  241. fi
  242. done
  243. case "$(basename "${menucmd}")" in
  244. whiptail|dialog)
  245. fn_install_menu_whiptail "${menucmd}" selection "${title}" "${caption}" "${options}" 40 80 30;;
  246. *)
  247. fn_install_menu_bash selection "${title}" "${caption}" "${options}";;
  248. esac
  249. eval "$resultvar=\"${selection}\""
  250. }
  251. # Gets server info from serverlist.csv and puts in to array.
  252. fn_server_info(){
  253. IFS=","
  254. server_info_array=($(grep -aw "${userinput}" "${serverlist}"))
  255. shortname="${server_info_array[0]}" # csgo
  256. gameservername="${server_info_array[1]}" # csgoserver
  257. gamename="${server_info_array[2]}" # Counter Strike: Global Offensive
  258. }
  259. fn_install_getopt(){
  260. userinput="empty"
  261. echo -e "Usage: $0 [option]"
  262. echo -e ""
  263. echo -e "Installer - Linux Game Server Managers - Version ${version}"
  264. echo -e "https://linuxgsm.com"
  265. echo -e ""
  266. echo -e "Commands"
  267. echo -e "install\t\t| Select server to install."
  268. echo -e "servername\t| Enter name of game server to install. e.g $0 csgoserver."
  269. echo -e "list\t\t| List all servers available for install."
  270. exit
  271. }
  272. fn_install_file(){
  273. local_filename="${gameservername}"
  274. if [ -e "${local_filename}" ]; then
  275. i=2
  276. while [ -e "${local_filename}-${i}" ] ; do
  277. (( i++ ))
  278. done
  279. local_filename="${local_filename}-${i}"
  280. fi
  281. cp -R "${selfname}" "${local_filename}"
  282. sed -i -e "s/shortname=\"core\"/shortname=\"${shortname}\"/g" "${local_filename}"
  283. sed -i -e "s/gameservername=\"core\"/gameservername=\"${gameservername}\"/g" "${local_filename}"
  284. echo -e "Installed ${gamename} server as ${local_filename}"
  285. echo -e ""
  286. if [ ! -d "${serverfiles}" ]; then
  287. echo -e "./${local_filename} install"
  288. else
  289. echo -e "Remember to check server ports"
  290. echo -e "./${local_filename} details"
  291. fi
  292. echo -e ""
  293. exit
  294. }
  295. # Prevent LinuxGSM from running as root. Except if doing a dependency install.
  296. if [ "$(whoami)" == "root" ]; then
  297. if [ "${userinput}" == "install" ]||[ "${userinput}" == "auto-install" ]||[ "${userinput}" == "i" ]||[ "${userinput}" == "ai" ]; then
  298. if [ "${shortname}" == "core" ]; then
  299. echo -e "[ FAIL ] Do NOT run this script as root!"
  300. exit 1
  301. fi
  302. elif [ ! -f "${functionsdir}/core_functions.sh" ]||[ ! -f "${functionsdir}/check_root.sh" ]||[ ! -f "${functionsdir}/core_messages.sh" ]; then
  303. echo -e "[ FAIL ] Do NOT run this script as root!"
  304. exit 1
  305. else
  306. core_functions.sh
  307. check_root.sh
  308. fi
  309. fi
  310. # LinuxGSM installer mode.
  311. if [ "${shortname}" == "core" ]; then
  312. # Download the latest serverlist. This is the complete list of all supported servers.
  313. fn_bootstrap_fetch_file_github "lgsm/data" "serverlist.csv" "${datadir}" "nochmodx" "norun" "forcedl" "nomd5"
  314. if [ ! -f "${serverlist}" ]; then
  315. echo -e "[ FAIL ] serverlist.csv could not be loaded."
  316. exit 1
  317. fi
  318. if [ "${userinput}" == "list" ]||[ "${userinput}" == "l" ]; then
  319. {
  320. tail -n +2 "${serverlist}" | awk -F "," '{print $2 "\t" $3}'
  321. } | column -s $'\t' -t | more
  322. exit
  323. elif [ "${userinput}" == "install" ]||[ "${userinput}" == "i" ]; then
  324. tail -n +2 "${serverlist}" | awk -F "," '{print $1 "," $2 "," $3}' > "${serverlistmenu}"
  325. fn_install_menu result "LinuxGSM" "Select game server to install." "${serverlistmenu}"
  326. userinput="${result}"
  327. fn_server_info
  328. if [ "${result}" == "${gameservername}" ]; then
  329. fn_install_file
  330. elif [ "${result}" == "" ]; then
  331. echo -e "Install canceled"
  332. else
  333. echo -e "[ FAIL ] menu result does not match gameservername"
  334. echo -e "result: ${result}"
  335. echo -e "gameservername: ${gameservername}"
  336. fi
  337. elif [ "${userinput}" ]; then
  338. fn_server_info
  339. if [ "${userinput}" == "${gameservername}" ]||[ "${userinput}" == "${gamename}" ]||[ "${userinput}" == "${shortname}" ]; then
  340. fn_install_file
  341. else
  342. echo -e "[ FAIL ] unknown game server"
  343. fi
  344. else
  345. fn_install_getopt
  346. fi
  347. # LinuxGSM server mode.
  348. else
  349. core_functions.sh
  350. if [ "${shortname}" != "core-dep" ]; then
  351. # Load LinuxGSM configs.
  352. # These are required to get all the default variables for the specific server.
  353. # Load the default config. If missing download it. If changed reload it.
  354. if [ ! -f "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" ]; then
  355. mkdir -p "${configdirdefault}/config-lgsm/${gameservername}"
  356. fn_fetch_config "lgsm/config-default/config-lgsm/${gameservername}" "_default.cfg" "${configdirdefault}/config-lgsm/${gameservername}" "_default.cfg" "nochmodx" "norun" "noforcedl" "nomd5"
  357. fi
  358. if [ ! -f "${configdirserver}/_default.cfg" ]; then
  359. mkdir -p "${configdirserver}"
  360. echo -en "copying _default.cfg...\c"
  361. cp -R "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg"
  362. exitcode=$?
  363. if [ "${exitcode}" != 0 ]; then
  364. echo -e "FAIL"
  365. exit 1
  366. else
  367. echo -e "OK"
  368. fi
  369. else
  370. function_file_diff=$(diff -q "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg")
  371. if [ "${function_file_diff}" != "" ]; then
  372. fn_print_warn_nl "_default.cfg has been altered. reloading config."
  373. echo -en "copying _default.cfg...\c"
  374. cp -R "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg"
  375. exitcode=$?
  376. if [ "${exitcode}" != 0 ]; then
  377. echo -e "FAIL"
  378. exit 1
  379. else
  380. echo -e "OK"
  381. fi
  382. fi
  383. fi
  384. # shellcheck source=/dev/null
  385. source "${configdirserver}/_default.cfg"
  386. # Load the common.cfg config. If missing download it.
  387. if [ ! -f "${configdirserver}/common.cfg" ]; then
  388. fn_fetch_config "lgsm/config-default/config-lgsm" "common-template.cfg" "${configdirserver}" "common.cfg" "${chmodx}" "nochmodx" "norun" "noforcedl" "nomd5"
  389. # shellcheck source=/dev/null
  390. source "${configdirserver}/common.cfg"
  391. else
  392. # shellcheck source=/dev/null
  393. source "${configdirserver}/common.cfg"
  394. fi
  395. # Load the instance.cfg config. If missing download it.
  396. if [ ! -f "${configdirserver}/${selfname}.cfg" ]; then
  397. fn_fetch_config "lgsm/config-default/config-lgsm" "instance-template.cfg" "${configdirserver}" "${selfname}.cfg" "nochmodx" "norun" "noforcedl" "nomd5"
  398. # shellcheck source=/dev/null
  399. source "${configdirserver}/${selfname}.cfg"
  400. else
  401. # shellcheck source=/dev/null
  402. source "${configdirserver}/${selfname}.cfg"
  403. fi
  404. # Load the linuxgsm.sh in to tmpdir. If missing download it.
  405. if [ ! -f "${tmpdir}/linuxgsm.sh" ]; then
  406. fn_fetch_file_github "" "linuxgsm.sh" "${tmpdir}" "chmodx" "norun" "noforcedl" "nomd5"
  407. fi
  408. fi
  409. # Enables ANSI colours from core_messages.sh. Can be disabled with ansi=off.
  410. fn_ansi_loader
  411. # Prevents running of core_exit.sh for Travis-CI.
  412. if [ "${travistest}" != "1" ]; then
  413. getopt=$1
  414. core_getopt.sh
  415. fi
  416. fi
  417. fn_currentstatus_tmux(){
  418. check_status.sh
  419. if [ "${status}" != "0" ]; then
  420. currentstatus="ONLINE"
  421. else
  422. currentstatus="OFFLINE"
  423. fi
  424. }
  425. fn_setstatus(){
  426. fn_currentstatus_tmux
  427. echo""
  428. echo -e "Required status: ${requiredstatus}"
  429. counter=0
  430. echo -e "Current status: ${currentstatus}"
  431. while [ "${requiredstatus}" != "${currentstatus}" ]; do
  432. counter=$((counter+1))
  433. fn_currentstatus_tmux
  434. echo -en "New status: ${currentstatus}\\r"
  435. if [ "${requiredstatus}" == "ONLINE" ]; then
  436. (command_start.sh > /dev/null 2>&1)
  437. else
  438. (command_stop.sh > /dev/null 2>&1)
  439. fi
  440. if [ "${counter}" -gt "5" ]; then
  441. currentstatus="FAIL"
  442. echo -e "Current status: ${currentstatus}"
  443. echo -e ""
  444. echo -e "Unable to start or stop server."
  445. exit 1
  446. fi
  447. done
  448. echo -en "New status: ${currentstatus}\\r"
  449. echo -e "\n"
  450. echo -e "Test starting:"
  451. echo -e ""
  452. }
  453. # End of every test will expect the result to either pass or fail
  454. # If the script does not do as intended the whole test will fail
  455. # if expecting a pass
  456. fn_test_result_pass(){
  457. if [ $? != 0 ]; then
  458. echo -e "================================="
  459. echo -e "Expected result: PASS"
  460. echo -e "Actual result: FAIL"
  461. fn_print_fail_nl "TEST FAILED"
  462. exitcode=1
  463. core_exit.sh
  464. else
  465. echo -e "================================="
  466. echo -e "Expected result: PASS"
  467. echo -e "Actual result: PASS"
  468. fn_print_ok_nl "TEST PASSED"
  469. echo -e ""
  470. fi
  471. }
  472. # if expecting a fail
  473. fn_test_result_fail(){
  474. if [ $? == 0 ]; then
  475. echo -e "================================="
  476. echo -e "Expected result: FAIL"
  477. echo -e "Actual result: PASS"
  478. fn_print_fail_nl "TEST FAILED"
  479. exitcode=1
  480. core_exit.sh
  481. else
  482. echo -e "================================="
  483. echo -e "Expected result: FAIL"
  484. echo -e "Actual result: FAIL"
  485. fn_print_ok_nl "TEST PASSED"
  486. echo -e ""
  487. fi
  488. }
  489. # test result n/a
  490. fn_test_result_na(){
  491. echo -e "================================="
  492. echo -e "Expected result: N/A"
  493. echo -e "Actual result: N/A"
  494. fn_print_fail_nl "TEST N/A"
  495. }
  496. sleeptime="0"
  497. echo -e "================================="
  498. echo -e "Travis CI Tests"
  499. echo -e "Linux Game Server Manager"
  500. echo -e "by Daniel Gibbs"
  501. echo -e "Contributors: http://goo.gl/qLmitD"
  502. echo -e "https://linuxgsm.com"
  503. echo -e "================================="
  504. echo -e ""
  505. echo -e "================================="
  506. echo -e "Server Tests"
  507. echo -e "Using: ${gamename}"
  508. echo -e "Testing Branch: ${TRAVIS_BRANCH}"
  509. echo -e "================================="
  510. echo -e ""
  511. echo -e "Tests Summary"
  512. echo -e "================================="
  513. echo -e "0.0 - Pre-test Tasks"
  514. echo -e "0.1 - Create log dir's"
  515. echo -e "0.2 - Enable dev-debug"
  516. echo -e ""
  517. echo -e "1.0 - Pre-install tests"
  518. echo -e "1.1 - start - no files"
  519. echo -e "1.2 - getopt"
  520. echo -e "1.3 - getopt with incorrect args"
  521. echo -e ""
  522. echo -e "2.0 - Installation"
  523. echo -e "2.1 - install"
  524. echo -e ""
  525. echo -e "3.0 - Start/Stop/Restart Tests"
  526. echo -e "3.1 - start"
  527. echo -e "3.2 - start - online"
  528. echo -e "3.3 - start - updateonstart"
  529. echo -e "3.4 - stop"
  530. echo -e "3.5 - stop - offline"
  531. echo -e "3.6 - restart"
  532. echo -e "3.7 - restart - offline"
  533. echo -e ""
  534. echo -e "4.0 - Update Tests"
  535. echo -e "4.1 - update"
  536. echo -e "4.2 - update - change buildid"
  537. echo -e "4.3 - update - change buildid - online"
  538. echo -e "4.4 - update - remove appmanifest file"
  539. echo -e "4.5 - force-update"
  540. echo -e "4.6 - force-update - online"
  541. echo -e "4.7 - validate"
  542. echo -e "4.8 - validate - online"
  543. echo -e "4.9 - update-lgsm"
  544. echo -e ""
  545. echo -e "5.0 - Monitor Tests"
  546. echo -e "5.1 - monitor - online"
  547. echo -e "5.2 - monitor - offline - with lockfile"
  548. echo -e "5.3 - monitor - offline - no lockfile"
  549. echo -e "5.4 - test-alert"
  550. echo -e ""
  551. echo -e "6.0 - Details Tests"
  552. echo -e "6.1 - details"
  553. echo -e "6.2 - postdetails"
  554. echo -e ""
  555. echo -e "7.0 - Backup Tests"
  556. echo -e "7.1 - backup"
  557. echo -e ""
  558. echo -e "8.0 - Development Tools Tests"
  559. echo -e "8.1 - dev - detect glibc"
  560. echo -e "8.2 - dev - detect ldd"
  561. echo -e "8.3 - dev - detect deps"
  562. echo -e "8.4 - dev - query-raw"
  563. echo -e ""
  564. echo -e "9.0 - Donate"
  565. echo -e "9.1 - donate"
  566. echo -e ""
  567. echo -e "0.0 - Pre-test Tasks"
  568. echo -e "=================================================================="
  569. echo -e "Description:"
  570. echo -e "Create log dir's"
  571. echo -e ""
  572. echo -e ""
  573. echo -e "0.1 - Create log dir's"
  574. echo -e "================================="
  575. echo -e ""
  576. (
  577. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  578. BASH_XTRACEFD="5"
  579. set -x
  580. install_logs.sh
  581. )
  582. echo -e "run order"
  583. echo -e "================="
  584. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  585. echo -e ""
  586. echo -e "0.2 - Enable dev-debug"
  587. echo -e "================================="
  588. echo -e "Description:"
  589. echo -e "Enable dev-debug"
  590. echo -e ""
  591. (
  592. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  593. BASH_XTRACEFD="5"
  594. set -x
  595. command_dev_debug.sh
  596. )
  597. fn_test_result_pass
  598. echo -e "run order"
  599. echo -e "================="
  600. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  601. echo -e ""
  602. echo -e "1.0 - Pre-install tests"
  603. echo -e "=================================================================="
  604. echo -e ""
  605. echo -e "1.1 - start - no files"
  606. echo -e "================================="
  607. echo -e "Description:"
  608. echo -e "test script reaction to missing server files."
  609. echo -e "Command: ./${gameservername} start"
  610. echo -e ""
  611. # Allows for testing not on Travis CI
  612. if [ -z "${TRAVIS}" ]; then
  613. (
  614. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  615. BASH_XTRACEFD="5"
  616. set -x
  617. command_start.sh
  618. )
  619. fn_test_result_fail
  620. else
  621. echo -e "Test bypassed"
  622. fi
  623. echo -e "run order"
  624. echo -e "================="
  625. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  626. echo -e ""
  627. echo -e "1.2 - getopt"
  628. echo -e "================================="
  629. echo -e "Description:"
  630. echo -e "displaying options messages."
  631. echo -e "Command: ./${gameservername}"
  632. echo -e ""
  633. (
  634. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  635. BASH_XTRACEFD="5"
  636. set -x
  637. core_getopt.sh
  638. )
  639. fn_test_result_pass
  640. echo -e "run order"
  641. echo -e "================="
  642. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  643. echo -e ""
  644. echo -e "1.3 - getopt with incorrect args"
  645. echo -e "================================="
  646. echo -e "Description:"
  647. echo -e "displaying options messages."
  648. echo -e "Command: ./${gameservername} abc123"
  649. echo -e ""
  650. getopt="abc123"
  651. (
  652. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  653. BASH_XTRACEFD="5"
  654. set -x
  655. core_getopt.sh
  656. )
  657. fn_test_result_pass
  658. echo -e "run order"
  659. echo -e "================="
  660. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  661. echo -e ""
  662. echo -e "2.0 - Installation"
  663. echo -e "=================================================================="
  664. echo -e ""
  665. echo -e "2.1 - install"
  666. echo -e "================================="
  667. echo -e "Description:"
  668. echo -e "install ${gamename} server."
  669. echo -e "Command: ./${gameservername} auto-install"
  670. (
  671. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  672. BASH_XTRACEFD="5"
  673. set -x
  674. fn_autoinstall
  675. )
  676. fn_test_result_pass
  677. echo -e "run order"
  678. echo -e "================="
  679. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  680. echo -e ""
  681. echo -e "3.0 - Start/Stop/Restart Tests"
  682. echo -e "=================================================================="
  683. echo -e ""
  684. echo -e "3.1 - start"
  685. echo -e "================================="
  686. echo -e "Description:"
  687. echo -e "start ${gamename} server."
  688. echo -e "Command: ./${gameservername} start"
  689. requiredstatus="OFFLINE"
  690. fn_setstatus
  691. (
  692. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  693. BASH_XTRACEFD="5"
  694. set -x
  695. command_start.sh
  696. )
  697. fn_test_result_pass
  698. echo -e "run order"
  699. echo -e "================="
  700. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  701. echo -e ""
  702. echo -e "3.2 - start - online"
  703. echo -e "================================="
  704. echo -e "Description:"
  705. echo -e "start ${gamename} server while already running."
  706. echo -e "Command: ./${gameservername} start"
  707. requiredstatus="ONLINE"
  708. fn_setstatus
  709. (
  710. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  711. BASH_XTRACEFD="5"
  712. set -x
  713. command_start.sh
  714. )
  715. fn_test_result_fail
  716. echo -e "run order"
  717. echo -e "================="
  718. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  719. echo -e ""
  720. echo -e "3.3 - start - updateonstart"
  721. echo -e "================================="
  722. echo -e "Description:"
  723. echo -e "will update server on start."
  724. echo -e "Command: ./${gameservername} start"
  725. requiredstatus="OFFLINE"
  726. fn_setstatus
  727. (
  728. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  729. BASH_XTRACEFD="5"
  730. set -x
  731. updateonstart="on";command_start.sh
  732. )
  733. fn_test_result_pass
  734. echo -e "run order"
  735. echo -e "================="
  736. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  737. echo -e ""
  738. echo -e "3.4 - stop"
  739. echo -e "================================="
  740. echo -e "Description:"
  741. echo -e "stop ${gamename} server."
  742. echo -e "Command: ./${gameservername} stop"
  743. requiredstatus="ONLINE"
  744. fn_setstatus
  745. (
  746. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  747. BASH_XTRACEFD="5"
  748. set -x
  749. command_stop.sh
  750. )
  751. fn_test_result_pass
  752. echo -e "run order"
  753. echo -e "================="
  754. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  755. echo -e ""
  756. echo -e "3.5 - stop - offline"
  757. echo -e "================================="
  758. echo -e "Description:"
  759. echo -e "stop ${gamename} server while already stopped."
  760. echo -e "Command: ./${gameservername} stop"
  761. requiredstatus="OFFLINE"
  762. fn_setstatus
  763. (
  764. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  765. BASH_XTRACEFD="5"
  766. set -x
  767. command_stop.sh
  768. )
  769. fn_test_result_fail
  770. echo -e "run order"
  771. echo -e "================="
  772. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  773. echo -e ""
  774. echo -e "3.6 - restart"
  775. echo -e "================================="
  776. echo -e "Description:"
  777. echo -e "restart ${gamename}."
  778. echo -e "Command: ./${gameservername} restart"
  779. requiredstatus="ONLINE"
  780. fn_setstatus
  781. (
  782. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  783. BASH_XTRACEFD="5"
  784. set -x
  785. command_restart.sh
  786. )
  787. fn_test_result_pass
  788. echo -e "run order"
  789. echo -e "================="
  790. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  791. echo -e ""
  792. echo -e "3.7 - restart - offline"
  793. echo -e "================================="
  794. echo -e "Description:"
  795. echo -e "restart ${gamename} while already stopped."
  796. echo -e "Command: ./${gameservername} restart"
  797. requiredstatus="OFFLINE"
  798. fn_setstatus
  799. (
  800. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  801. BASH_XTRACEFD="5"
  802. set -x
  803. command_restart.sh
  804. )
  805. fn_test_result_pass
  806. echo -e "run order"
  807. echo -e "================="
  808. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  809. echo -e ""
  810. echo -e "4.0 - Update Tests"
  811. echo -e "=================================================================="
  812. echo -e ""
  813. echo -e "4.1 - update"
  814. echo -e "================================="
  815. echo -e "Description:"
  816. echo -e "check for updates."
  817. echo -e "Command: ./${gameservername} update"
  818. requiredstatus="OFFLINE"
  819. fn_setstatus
  820. (
  821. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  822. BASH_XTRACEFD="5"
  823. set -x
  824. command_update.sh
  825. )
  826. fn_test_result_pass
  827. echo -e "run order"
  828. echo -e "================="
  829. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  830. echo -e ""
  831. echo -e "4.2 - update - change buildid"
  832. echo -e "================================="
  833. echo -e "Description:"
  834. echo -e "change the buildid tricking SteamCMD to update."
  835. echo -e "Command: ./jc2server update"
  836. requiredstatus="OFFLINE"
  837. fn_setstatus
  838. fn_print_info_nl "changed buildid to 0."
  839. sed -i 's/[0-9]\+/0/' "${serverfiles}/steamapps/appmanifest_${appid}.acf"
  840. (
  841. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  842. BASH_XTRACEFD="5"
  843. set -x
  844. command_update.sh
  845. )
  846. fn_test_result_pass
  847. echo -e "run order"
  848. echo -e "================="
  849. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  850. echo -e ""
  851. echo -e "4.3 - update - change buildid - online"
  852. echo -e "================================="
  853. echo -e "Description:"
  854. echo -e "change the buildid tricking SteamCMD to update server while already running."
  855. echo -e "Command: ./jc2server update"
  856. requiredstatus="ONLINE"
  857. fn_setstatus
  858. fn_print_info_nl "changed buildid to 0."
  859. sed -i 's/[0-9]\+/0/' "${serverfiles}/steamapps/appmanifest_${appid}.acf"
  860. (
  861. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  862. BASH_XTRACEFD="5"
  863. set -x
  864. command_update.sh
  865. )
  866. fn_test_result_pass
  867. echo -e "run order"
  868. echo -e "================="
  869. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  870. echo -e ""
  871. echo -e "4.4 - update - remove appmanifest file"
  872. echo -e "================================="
  873. echo -e "Description:"
  874. echo -e "removing appmanifest file will cause script to repair."
  875. echo -e "Command: ./jc2server update"
  876. requiredstatus="OFFLINE"
  877. fn_setstatus
  878. fn_print_info_nl "removed appmanifest_${appid}.acf."
  879. rm --verbose "${serverfiles:?}/steamapps/appmanifest_${appid}.acf"
  880. (
  881. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  882. BASH_XTRACEFD="5"
  883. set -x
  884. command_update.sh
  885. )
  886. fn_test_result_pass
  887. echo -e "run order"
  888. echo -e "================="
  889. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  890. echo -e ""
  891. echo -e "4.5 - force-update"
  892. echo -e "================================="
  893. echo -e "Description:"
  894. echo -e "force-update bypassing update check."
  895. echo -e "Command: ./jc2server force-update"
  896. requiredstatus="OFFLINE"
  897. fn_setstatus
  898. (
  899. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  900. BASH_XTRACEFD="5"
  901. set -x
  902. forceupdate=1;command_update.sh
  903. )
  904. fn_test_result_pass
  905. echo -e "run order"
  906. echo -e "================="
  907. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  908. echo -e ""
  909. echo -e "4.6 - force-update - online"
  910. echo -e "================================="
  911. echo -e "Description:"
  912. echo -e "force-update bypassing update check server while already running."
  913. echo -e "Command: ./jc2server force-update"
  914. requiredstatus="ONLINE"
  915. fn_setstatus
  916. (
  917. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  918. BASH_XTRACEFD="5"
  919. set -x
  920. forceupdate=1;command_update.sh
  921. )
  922. fn_test_result_pass
  923. echo -e "run order"
  924. echo -e "================="
  925. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  926. echo -e ""
  927. echo -e "4.7 - validate"
  928. echo -e "================================="
  929. echo -e "Description:"
  930. echo -e "validate server files."
  931. echo -e "Command: ./jc2server validate"
  932. requiredstatus="OFFLINE"
  933. fn_setstatus
  934. (
  935. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  936. BASH_XTRACEFD="5"
  937. set -x
  938. command_validate.sh
  939. )
  940. fn_test_result_pass
  941. echo -e "run order"
  942. echo -e "================="
  943. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  944. echo -e ""
  945. echo -e "4.8 - validate - online"
  946. echo -e "================================="
  947. echo -e "Description:"
  948. echo -e "validate server files while server already running."
  949. echo -e ""
  950. echo -e "Command: ./jc2server validate"
  951. requiredstatus="ONLINE"
  952. fn_setstatus
  953. (
  954. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  955. BASH_XTRACEFD="5"
  956. set -x
  957. command_validate.sh
  958. )
  959. fn_test_result_pass
  960. echo -e "run order"
  961. echo -e "================="
  962. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  963. echo -e ""
  964. echo -e "4.9 - update-lgsm"
  965. echo -e "================================="
  966. echo -e "Description:"
  967. echo -e "update LinuxGSM."
  968. echo -e ""
  969. echo -e "Command: ./jc2server update-lgam"
  970. requiredstatus="ONLINE"
  971. fn_setstatus
  972. (
  973. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  974. BASH_XTRACEFD="5"
  975. set -x
  976. command_update_linuxgsm.sh
  977. )
  978. fn_test_result_pass
  979. echo -e "run order"
  980. echo -e "================="
  981. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  982. echo -e ""
  983. echo -e "Inserting IP address"
  984. echo -e "================================="
  985. echo -e "Description:"
  986. echo -e "Inserting Travis IP in to config."
  987. echo -e "Allows monitor to work"
  988. if [ "$(ip -o -4 addr|grep eth0)" ]; then
  989. travisip=$(ip -o -4 addr | grep eth0 | awk '{print $4}' | grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}' | grep -v 127.0.0)
  990. else
  991. travisip=$(ip -o -4 addr | grep ens | awk '{print $4}' | grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}' | sort -u | grep -v 127.0.0)
  992. fi
  993. sed -i "/BindIP/c\BindIP = \"${travisip}\"," "${serverfiles}/config.lua"
  994. echo -e "IP: ${travisip}"
  995. echo -e ""
  996. echo -e "5.0 - Monitor Tests"
  997. echo -e "=================================================================="
  998. echo -e ""
  999. info_config.sh
  1000. echo -e "Server IP - Port: ${ip}:${port}"
  1001. echo -e "Server IP - Query Port: ${ip}:${queryport}"
  1002. echo -e ""
  1003. echo -e "5.1 - monitor - online"
  1004. echo -e "================================="
  1005. echo -e "Description:"
  1006. echo -e "run monitor server while already running."
  1007. echo -e "Command: ./${gameservername} monitor"
  1008. requiredstatus="ONLINE"
  1009. fn_setstatus
  1010. (
  1011. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  1012. BASH_XTRACEFD="5"
  1013. set -x
  1014. command_monitor.sh
  1015. )
  1016. fn_test_result_pass
  1017. echo -e "run order"
  1018. echo -e "================="
  1019. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  1020. echo -e ""
  1021. echo -e "5.2 - monitor - offline - with lockfile"
  1022. echo -e "================================="
  1023. echo -e "Description:"
  1024. echo -e "run monitor while server is offline with lockfile."
  1025. echo -e "Command: ./${gameservername} monitor"
  1026. requiredstatus="OFFLINE"
  1027. fn_setstatus
  1028. fn_print_info_nl "creating lockfile."
  1029. date '+%s' > "${lockdir}/${selfname}.lock"
  1030. (
  1031. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  1032. BASH_XTRACEFD="5"
  1033. set -x
  1034. command_monitor.sh
  1035. )
  1036. fn_test_result_pass
  1037. echo -e "run order"
  1038. echo -e "================="
  1039. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  1040. echo -e ""
  1041. echo -e "5.3 - monitor - offline - no lockfile"
  1042. echo -e "================================="
  1043. echo -e "Description:"
  1044. echo -e "run monitor while server is offline with no lockfile."
  1045. echo -e "Command: ./${gameservername} monitor"
  1046. requiredstatus="OFFLINE"
  1047. fn_setstatus
  1048. (
  1049. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  1050. BASH_XTRACEFD="5"
  1051. set -x
  1052. command_monitor.sh
  1053. )
  1054. fn_test_result_fail
  1055. echo -e "run order"
  1056. echo -e "================="
  1057. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  1058. echo -e ""
  1059. echo -e "5.4 - test-alert"
  1060. echo -e "================================="
  1061. echo -e "Description:"
  1062. echo -e "run monitor while server is offline with no lockfile."
  1063. echo -e "Command: ./${gameservername} test-alert"
  1064. requiredstatus="OFFLINE"
  1065. fn_setstatus
  1066. cp "${servercfgfullpath}" "config.lua"
  1067. sed -i 's/[0-9]\+/0/' "${servercfgfullpath}"
  1068. (
  1069. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  1070. BASH_XTRACEFD="5"
  1071. set -x
  1072. command_test_alert.sh
  1073. )
  1074. fn_test_result_fail
  1075. echo -e "run order"
  1076. echo -e "================="
  1077. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  1078. echo -e ""
  1079. fn_print_info_nl "Re-generating ${servercfg}."
  1080. cp -v "config.lua" "${servercfgfullpath}"
  1081. echo -e "================================="
  1082. echo -e ""
  1083. echo -e "6.0 - Details Tests"
  1084. echo -e "=================================================================="
  1085. echo -e ""
  1086. echo -e "6.1 - details"
  1087. echo -e "================================="
  1088. echo -e "Description:"
  1089. echo -e "display details."
  1090. echo -e "Command: ./${gameservername} details"
  1091. requiredstatus="ONLINE"
  1092. fn_setstatus
  1093. (
  1094. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  1095. BASH_XTRACEFD="5"
  1096. set -x
  1097. command_details.sh
  1098. )
  1099. fn_test_result_pass
  1100. echo -e "run order"
  1101. echo -e "================="
  1102. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  1103. echo -e ""
  1104. echo -e "6.2 - postdetails"
  1105. echo -e "================================="
  1106. echo -e "Description:"
  1107. echo -e "post details."
  1108. echo -e "Command: ./${gameservername} postdetails"
  1109. requiredstatus="ONLINE"
  1110. fn_setstatus
  1111. (
  1112. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  1113. BASH_XTRACEFD="5"
  1114. set -x
  1115. command_postdetails.sh
  1116. )
  1117. fn_test_result_pass
  1118. echo -e "run order"
  1119. echo -e "================="
  1120. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  1121. echo -e ""
  1122. echo -e "7.0 - Backup Tests"
  1123. echo -e "=================================================================="
  1124. echo -e ""
  1125. echo -e "7.1 - backup"
  1126. echo -e "================================="
  1127. echo -e "Description:"
  1128. echo -e "run a backup."
  1129. echo -e "Command: ./${gameservername} backup"
  1130. requiredstatus="ONLINE"
  1131. fn_setstatus
  1132. echo -e "test de-activated until issue #1839 fixed"
  1133. #(command_backup.sh)
  1134. fn_test_result_pass
  1135. echo -e "run order"
  1136. echo -e "================="
  1137. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  1138. echo -e ""
  1139. echo -e "8.0 - Development Tools Tests"
  1140. echo -e "=================================================================="
  1141. echo -e ""
  1142. echo -e "8.1 - dev - detect glibc"
  1143. echo -e "================================="
  1144. echo -e "Description:"
  1145. echo -e "detect glibc."
  1146. echo -e "Command: ./${gameservername} detect-glibc"
  1147. requiredstatus="ONLINE"
  1148. fn_setstatus
  1149. (
  1150. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  1151. BASH_XTRACEFD="5"
  1152. set -x
  1153. command_dev_detect_glibc.sh
  1154. )
  1155. fn_test_result_pass
  1156. echo -e "run order"
  1157. echo -e "================="
  1158. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  1159. echo -e ""
  1160. echo -e "8.2 - dev - detect ldd"
  1161. echo -e "================================="
  1162. echo -e "Description:"
  1163. echo -e "detect ldd."
  1164. echo -e "Command: ./${gameservername} detect-ldd"
  1165. requiredstatus="ONLINE"
  1166. fn_setstatus
  1167. (
  1168. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  1169. BASH_XTRACEFD="5"
  1170. set -x
  1171. command_dev_detect_ldd.sh
  1172. )
  1173. fn_test_result_pass
  1174. echo -e "run order"
  1175. echo -e "================="
  1176. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  1177. echo -e ""
  1178. echo -e "8.3 - dev - detect deps"
  1179. echo -e "================================="
  1180. echo -e "Description:"
  1181. echo -e "detect dependencies."
  1182. echo -e "Command: ./${gameservername} detect-deps"
  1183. requiredstatus="ONLINE"
  1184. fn_setstatus
  1185. (
  1186. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  1187. BASH_XTRACEFD="5"
  1188. set -x
  1189. command_dev_detect_deps.sh
  1190. )
  1191. fn_test_result_pass
  1192. echo -e "run order"
  1193. echo -e "================="
  1194. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  1195. echo -e ""
  1196. echo -e "8.4 - dev - query-raw"
  1197. echo -e "================================="
  1198. echo -e "Description:"
  1199. echo -e "raw query output."
  1200. echo -e "Command: ./${gameservername} query-raw"
  1201. requiredstatus="ONLINE"
  1202. fn_setstatus
  1203. (
  1204. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  1205. BASH_XTRACEFD="5"
  1206. set -x
  1207. command_dev_query_raw.sh
  1208. )
  1209. fn_test_result_na
  1210. echo -e "run order"
  1211. echo -e "================="
  1212. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  1213. echo -e ""
  1214. echo -e "9.0 - Donate"
  1215. echo -e "=================================================================="
  1216. echo -e ""
  1217. echo -e "9.1 - donate"
  1218. echo -e "================================="
  1219. echo -e "Description:"
  1220. echo -e "donate."
  1221. echo -e "Command: ./${gameservername} donate"
  1222. requiredstatus="ONLINE"
  1223. fn_setstatus
  1224. (
  1225. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  1226. BASH_XTRACEFD="5"
  1227. set -x
  1228. command_donate.sh
  1229. )
  1230. fn_test_result_pass
  1231. echo -e "run order"
  1232. echo -e "================="
  1233. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  1234. echo -e ""
  1235. echo -e "================================="
  1236. echo -e "Server Tests - Complete!"
  1237. echo -e "Using: ${gamename}"
  1238. echo -e "================================="
  1239. requiredstatus="OFFLINE"
  1240. fn_setstatus
  1241. core_exit.sh