diff options
Diffstat (limited to 'scripts/test_linux/service-test.sh')
| -rwxr-xr-x | scripts/test_linux/service-test.sh | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/scripts/test_linux/service-test.sh b/scripts/test_linux/service-test.sh index f91339e1b..7c573b036 100755 --- a/scripts/test_linux/service-test.sh +++ b/scripts/test_linux/service-test.sh @@ -20,6 +20,8 @@ SERVICE_NAME="ZenServerTest-$$" UNIT_NAME="com.epicgames.unreal.${SERVICE_NAME}" UNIT_FILE="/etc/systemd/system/${UNIT_NAME}.service" +zen_cmd() { "$ZEN_BINARY" --enable-execution-history=false "$@"; } + PASSED=0 FAILED=0 TESTS_RUN=0 @@ -122,7 +124,7 @@ SERVICE_USER="${SUDO_USER:-$(whoami)}" echo "--- Test: status before install ---" -OUTPUT=$("$ZEN_BINARY" service status "$SERVICE_NAME" 2>&1 || true) +OUTPUT=$(zen_cmd service status "$SERVICE_NAME" 2>&1 || true) if echo "$OUTPUT" | grep -qi "not installed"; then pass "status reports 'not installed' for non-existent service" else @@ -133,7 +135,7 @@ fi echo "--- Test: install ---" -OUTPUT=$("$ZEN_BINARY" service install "$ZENSERVER_BINARY" "$SERVICE_NAME" --user "$SERVICE_USER" 2>&1) +OUTPUT=$(zen_cmd service install "$ZENSERVER_BINARY" "$SERVICE_NAME" --user "$SERVICE_USER" 2>&1) EXIT_CODE=$? if [ "$EXIT_CODE" -eq 0 ]; then @@ -186,7 +188,7 @@ fi echo "--- Test: install again (idempotent) ---" -OUTPUT=$("$ZEN_BINARY" service install "$ZENSERVER_BINARY" "$SERVICE_NAME" --user "$SERVICE_USER" 2>&1) +OUTPUT=$(zen_cmd service install "$ZENSERVER_BINARY" "$SERVICE_NAME" --user "$SERVICE_USER" 2>&1) EXIT_CODE=$? if [ "$EXIT_CODE" -eq 0 ]; then @@ -205,7 +207,7 @@ fi echo "--- Test: status after install (stopped) ---" -OUTPUT=$("$ZEN_BINARY" service status "$SERVICE_NAME" 2>&1 || true) +OUTPUT=$(zen_cmd service status "$SERVICE_NAME" 2>&1 || true) # The status command throws if not running, so we expect an error message if echo "$OUTPUT" | grep -qi "not running"; then pass "status reports 'not running' for stopped service" @@ -217,7 +219,7 @@ fi echo "--- Test: start ---" -OUTPUT=$("$ZEN_BINARY" service start "$SERVICE_NAME" 2>&1) +OUTPUT=$(zen_cmd service start "$SERVICE_NAME" 2>&1) EXIT_CODE=$? if [ "$EXIT_CODE" -eq 0 ]; then @@ -237,7 +239,7 @@ if systemctl is-active --quiet "$UNIT_NAME" 2>/dev/null; then echo "--- Test: status (running) ---" - OUTPUT=$("$ZEN_BINARY" service status "$SERVICE_NAME" 2>&1 || true) + OUTPUT=$(zen_cmd service status "$SERVICE_NAME" 2>&1 || true) if echo "$OUTPUT" | grep -qi "Running"; then pass "status reports 'Running'" else @@ -254,7 +256,7 @@ if systemctl is-active --quiet "$UNIT_NAME" 2>/dev/null; then echo "--- Test: start again (already running) ---" - OUTPUT=$("$ZEN_BINARY" service start "$SERVICE_NAME" 2>&1) + OUTPUT=$(zen_cmd service start "$SERVICE_NAME" 2>&1) if echo "$OUTPUT" | grep -qi "already running"; then pass "start reports service already running" else @@ -265,7 +267,7 @@ if systemctl is-active --quiet "$UNIT_NAME" 2>/dev/null; then echo "--- Test: stop ---" - OUTPUT=$("$ZEN_BINARY" service stop "$SERVICE_NAME" 2>&1) + OUTPUT=$(zen_cmd service stop "$SERVICE_NAME" 2>&1) EXIT_CODE=$? if [ "$EXIT_CODE" -eq 0 ]; then @@ -293,7 +295,7 @@ echo "--- Test: stop when already stopped ---" systemctl stop "$UNIT_NAME" 2>/dev/null || true sleep 1 -OUTPUT=$("$ZEN_BINARY" service stop "$SERVICE_NAME" 2>&1 || true) +OUTPUT=$(zen_cmd service stop "$SERVICE_NAME" 2>&1 || true) if echo "$OUTPUT" | grep -qi "not running"; then pass "stop reports 'not running' when already stopped" else @@ -305,11 +307,11 @@ fi echo "--- Test: uninstall while running (should fail) ---" # Start the service so we can test uninstall-while-running -"$ZEN_BINARY" service start "$SERVICE_NAME" 2>&1 || true +zen_cmd service start "$SERVICE_NAME" 2>&1 || true sleep 1 if systemctl is-active --quiet "$UNIT_NAME" 2>/dev/null; then - OUTPUT=$("$ZEN_BINARY" service uninstall "$SERVICE_NAME" 2>&1 || true) + OUTPUT=$(zen_cmd service uninstall "$SERVICE_NAME" 2>&1 || true) EXIT_CODE=$? if [ "$EXIT_CODE" -ne 0 ] || echo "$OUTPUT" | grep -qi "running.*stop"; then @@ -319,7 +321,7 @@ if systemctl is-active --quiet "$UNIT_NAME" 2>/dev/null; then fi # Stop it for the real uninstall test - "$ZEN_BINARY" service stop "$SERVICE_NAME" 2>&1 || true + zen_cmd service stop "$SERVICE_NAME" 2>&1 || true systemctl stop "$UNIT_NAME" 2>/dev/null || true sleep 1 else @@ -334,7 +336,7 @@ echo "--- Test: uninstall ---" systemctl stop "$UNIT_NAME" 2>/dev/null || true sleep 1 -OUTPUT=$("$ZEN_BINARY" service uninstall "$SERVICE_NAME" 2>&1) +OUTPUT=$(zen_cmd service uninstall "$SERVICE_NAME" 2>&1) EXIT_CODE=$? if [ "$EXIT_CODE" -eq 0 ]; then @@ -353,7 +355,7 @@ fi echo "--- Test: status after uninstall ---" -OUTPUT=$("$ZEN_BINARY" service status "$SERVICE_NAME" 2>&1 || true) +OUTPUT=$(zen_cmd service status "$SERVICE_NAME" 2>&1 || true) if echo "$OUTPUT" | grep -qi "not installed"; then pass "status reports 'not installed' after uninstall" else @@ -364,7 +366,7 @@ fi echo "--- Test: uninstall when not installed ---" -OUTPUT=$("$ZEN_BINARY" service uninstall "$SERVICE_NAME" 2>&1) +OUTPUT=$(zen_cmd service uninstall "$SERVICE_NAME" 2>&1) EXIT_CODE=$? if [ "$EXIT_CODE" -eq 0 ]; then |