tests_jc2server.sh 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329
  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.6.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[@]}"; do
  86. if [ "${remote_fileurl_array}" == "remote_fileurl" ]; then
  87. fileurl="${remote_fileurl}"
  88. fileurl_name="${remote_fileurl_name}"
  89. elif [ "${remote_fileurl_array}" == "remote_fileurl_backup" ]; then
  90. fileurl="${remote_fileurl_backup}"
  91. fileurl_name="${remote_fileurl_backup_name}"
  92. fi
  93. counter=$((counter+1))
  94. if [ ! -d "${local_filedir}" ]; then
  95. mkdir -p "${local_filedir}"
  96. fi
  97. # Trap will remove part downloaded files if canceled.
  98. trap fn_fetch_trap INT
  99. # Larger files show a progress bar.
  100. echo -en "fetching ${fileurl_name} ${local_filename}...\c"
  101. curlcmd=$(curl -s --fail -L -o "${local_filedir}/${local_filename}" "${fileurl}" 2>&1)
  102. local exitcode=$?
  103. # Download will fail if downloads a html file.
  104. if [ -f "${local_filedir}/${local_filename}" ]; then
  105. if [ -n "$(head "${local_filedir}/${local_filename}" | grep "DOCTYPE" )" ]; then
  106. rm "${local_filedir:?}/${local_filename:?}"
  107. local exitcode=2
  108. fi
  109. fi
  110. # On first try will error. On second try will fail.
  111. if [ "${exitcode}" != 0 ]; then
  112. if [ ${counter} -ge 2 ]; then
  113. echo -e "FAIL"
  114. if [ -f "${lgsmlog}" ]; then
  115. fn_script_log_fatal "Downloading ${local_filename}"
  116. fn_script_log_fatal "${fileurl}"
  117. fi
  118. core_exit.sh
  119. else
  120. echo -e "ERROR"
  121. if [ -f "${lgsmlog}" ]; then
  122. fn_script_log_error "Downloading ${local_filename}"
  123. fn_script_log_error "${fileurl}"
  124. fi
  125. fi
  126. else
  127. echo -en "OK"
  128. sleep 0.3
  129. echo -en "\033[2K\\r"
  130. if [ -f "${lgsmlog}" ]; then
  131. fn_script_log_pass "Downloading ${local_filename}"
  132. fi
  133. # Make file executable if chmodx is set.
  134. if [ "${chmodx}" == "chmodx" ]; then
  135. chmod +x "${local_filedir}/${local_filename}"
  136. fi
  137. # Remove trap.
  138. trap - INT
  139. break
  140. fi
  141. done
  142. fi
  143. if [ -f "${local_filedir}/${local_filename}" ]; then
  144. # Execute file if run is set.
  145. if [ "${run}" == "run" ]; then
  146. # shellcheck source=/dev/null
  147. source "${local_filedir}/${local_filename}"
  148. fi
  149. fi
  150. }
  151. fn_bootstrap_fetch_file_github(){
  152. github_file_url_dir="${1}"
  153. github_file_url_name="${2}"
  154. # If master branch will currently running LinuxGSM version to prevent "version mixing". This is ignored if a fork.
  155. if [ "${githubbranch}" == "master" ]&&[ "${githubuser}" == "GameServerManager" ]&&[ "${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. echo "${version}" >> "${lockdir}/${selfname}.lock"
  1031. echo "${port}" >> "${lockdir}/${selfname}.lock"
  1032. (
  1033. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  1034. BASH_XTRACEFD="5"
  1035. set -x
  1036. command_monitor.sh
  1037. )
  1038. fn_test_result_pass
  1039. echo -e "run order"
  1040. echo -e "================="
  1041. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  1042. echo -e ""
  1043. echo -e "5.3 - monitor - offline - no lockfile"
  1044. echo -e "================================="
  1045. echo -e "Description:"
  1046. echo -e "run monitor while server is offline with no lockfile."
  1047. echo -e "Command: ./${gameservername} monitor"
  1048. requiredstatus="OFFLINE"
  1049. fn_setstatus
  1050. (
  1051. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  1052. BASH_XTRACEFD="5"
  1053. set -x
  1054. command_monitor.sh
  1055. )
  1056. fn_test_result_fail
  1057. echo -e "run order"
  1058. echo -e "================="
  1059. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  1060. echo -e ""
  1061. echo -e "5.4 - test-alert"
  1062. echo -e "================================="
  1063. echo -e "Description:"
  1064. echo -e "run monitor while server is offline with no lockfile."
  1065. echo -e "Command: ./${gameservername} test-alert"
  1066. requiredstatus="OFFLINE"
  1067. fn_setstatus
  1068. cp "${servercfgfullpath}" "config.lua"
  1069. sed -i 's/[0-9]\+/0/' "${servercfgfullpath}"
  1070. (
  1071. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  1072. BASH_XTRACEFD="5"
  1073. set -x
  1074. command_test_alert.sh
  1075. )
  1076. fn_test_result_fail
  1077. echo -e "run order"
  1078. echo -e "================="
  1079. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  1080. echo -e ""
  1081. fn_print_info_nl "Re-generating ${servercfg}."
  1082. cp -v "config.lua" "${servercfgfullpath}"
  1083. echo -e "================================="
  1084. echo -e ""
  1085. echo -e "6.0 - Details Tests"
  1086. echo -e "=================================================================="
  1087. echo -e ""
  1088. echo -e "6.1 - details"
  1089. echo -e "================================="
  1090. echo -e "Description:"
  1091. echo -e "display details."
  1092. echo -e "Command: ./${gameservername} details"
  1093. requiredstatus="ONLINE"
  1094. fn_setstatus
  1095. (
  1096. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  1097. BASH_XTRACEFD="5"
  1098. set -x
  1099. command_details.sh
  1100. )
  1101. fn_test_result_pass
  1102. echo -e "run order"
  1103. echo -e "================="
  1104. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  1105. echo -e ""
  1106. echo -e "6.2 - postdetails"
  1107. echo -e "================================="
  1108. echo -e "Description:"
  1109. echo -e "post details."
  1110. echo -e "Command: ./${gameservername} postdetails"
  1111. requiredstatus="ONLINE"
  1112. fn_setstatus
  1113. (
  1114. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  1115. BASH_XTRACEFD="5"
  1116. set -x
  1117. command_postdetails.sh
  1118. )
  1119. fn_test_result_pass
  1120. echo -e "run order"
  1121. echo -e "================="
  1122. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  1123. echo -e ""
  1124. echo -e "7.0 - Backup Tests"
  1125. echo -e "=================================================================="
  1126. echo -e ""
  1127. echo -e "7.1 - backup"
  1128. echo -e "================================="
  1129. echo -e "Description:"
  1130. echo -e "run a backup."
  1131. echo -e "Command: ./${gameservername} backup"
  1132. requiredstatus="ONLINE"
  1133. fn_setstatus
  1134. echo -e "test de-activated until issue #1839 fixed"
  1135. #(command_backup.sh)
  1136. fn_test_result_pass
  1137. echo -e "run order"
  1138. echo -e "================="
  1139. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  1140. echo -e ""
  1141. echo -e "8.0 - Development Tools Tests"
  1142. echo -e "=================================================================="
  1143. echo -e ""
  1144. echo -e "8.1 - dev - detect glibc"
  1145. echo -e "================================="
  1146. echo -e "Description:"
  1147. echo -e "detect glibc."
  1148. echo -e "Command: ./${gameservername} detect-glibc"
  1149. requiredstatus="ONLINE"
  1150. fn_setstatus
  1151. (
  1152. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  1153. BASH_XTRACEFD="5"
  1154. set -x
  1155. command_dev_detect_glibc.sh
  1156. )
  1157. fn_test_result_pass
  1158. echo -e "run order"
  1159. echo -e "================="
  1160. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  1161. echo -e ""
  1162. echo -e "8.2 - dev - detect ldd"
  1163. echo -e "================================="
  1164. echo -e "Description:"
  1165. echo -e "detect ldd."
  1166. echo -e "Command: ./${gameservername} detect-ldd"
  1167. requiredstatus="ONLINE"
  1168. fn_setstatus
  1169. (
  1170. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  1171. BASH_XTRACEFD="5"
  1172. set -x
  1173. command_dev_detect_ldd.sh
  1174. )
  1175. fn_test_result_pass
  1176. echo -e "run order"
  1177. echo -e "================="
  1178. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  1179. echo -e ""
  1180. echo -e "8.3 - dev - detect deps"
  1181. echo -e "================================="
  1182. echo -e "Description:"
  1183. echo -e "detect dependencies."
  1184. echo -e "Command: ./${gameservername} detect-deps"
  1185. requiredstatus="ONLINE"
  1186. fn_setstatus
  1187. (
  1188. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  1189. BASH_XTRACEFD="5"
  1190. set -x
  1191. command_dev_detect_deps.sh
  1192. )
  1193. fn_test_result_pass
  1194. echo -e "run order"
  1195. echo -e "================="
  1196. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  1197. echo -e ""
  1198. echo -e "8.4 - dev - query-raw"
  1199. echo -e "================================="
  1200. echo -e "Description:"
  1201. echo -e "raw query output."
  1202. echo -e "Command: ./${gameservername} query-raw"
  1203. requiredstatus="ONLINE"
  1204. fn_setstatus
  1205. (
  1206. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  1207. BASH_XTRACEFD="5"
  1208. set -x
  1209. command_dev_query_raw.sh
  1210. )
  1211. fn_test_result_na
  1212. echo -e "run order"
  1213. echo -e "================="
  1214. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  1215. echo -e ""
  1216. echo -e "9.0 - Donate"
  1217. echo -e "=================================================================="
  1218. echo -e ""
  1219. echo -e "9.1 - donate"
  1220. echo -e "================================="
  1221. echo -e "Description:"
  1222. echo -e "donate."
  1223. echo -e "Command: ./${gameservername} donate"
  1224. requiredstatus="ONLINE"
  1225. fn_setstatus
  1226. (
  1227. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  1228. BASH_XTRACEFD="5"
  1229. set -x
  1230. command_donate.sh
  1231. )
  1232. fn_test_result_pass
  1233. echo -e "run order"
  1234. echo -e "================="
  1235. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  1236. echo -e ""
  1237. echo -e "================================="
  1238. echo -e "Server Tests - Complete!"
  1239. echo -e "Using: ${gamename}"
  1240. echo -e "================================="
  1241. requiredstatus="OFFLINE"
  1242. fn_setstatus
  1243. core_exit.sh