tests_jc2server.sh 37 KB

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