Skip to content

🧪 [testing] Add unit tests for RCON hex functions and fix trailing input bug#98

Merged
Ven0m0 merged 4 commits into
mainfrom
feat-rcon-tests-and-fix-15791535305284024798
Jun 23, 2026
Merged

🧪 [testing] Add unit tests for RCON hex functions and fix trailing input bug#98
Ven0m0 merged 4 commits into
mainfrom
feat-rcon-tests-and-fix-15791535305284024798

Conversation

@Ven0m0

@Ven0m0 Ven0m0 commented May 3, 2026

Copy link
Copy Markdown
Owner

🧪 [testing] Add unit tests for RCON hex functions and fix trailing input bug

🎯 What

Addressed the missing test coverage for the core hex manipulation functions in tools/rcon.sh. During implementation, a bug was identified where reverse_hex_endian would silently swallow any input shorter than 8 characters (or trailing data at the end of a stream); this has been fixed.

📊 Coverage

  • reverse_hex_endian: Now tested with standard 8-char hex, multi-block hex strings, and short inputs (ensuring they are preserved as-is).
  • decode_hex_int: Verified correct decoding of little-endian hex to decimal.
  • encode_int: Verified correct encoding of decimal integers to little-endian hex.

✨ Result

  • Improved reliability and maintainability of the pure-Bash RCON client.
  • tools/rcon.sh is now safely sourceable for testing without executing the command-line interface.
  • Bug fix ensures RCON packet processing is more robust against unexpected input lengths.

Tests can be run with: bash tools/tests/test_rcon.sh


PR created automatically by Jules for task 15791535305284024798 started by @Ven0m0

- Modified tools/rcon.sh to be sourceable by wrapping main execution in BASH_SOURCE check.
- Fixed bug in reverse_hex_endian where short/trailing inputs were swallowed.
- Added tools/tests/test_rcon.sh with comprehensive unit tests for hex utilities.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings May 3, 2026 01:43

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request improves the reverse_hex_endian function in tools/rcon.sh to handle non-null-terminated or short inputs and wraps the main execution logic to enable sourcing. It also introduces a new unit test suite, tools/tests/test_rcon.sh. The review feedback suggests aligning the new test script with the repository's Bash standards by adding the required boilerplate (strict mode, shell options) and utilizing shared utility functions from common.sh for consistent output formatting.

Comment thread tools/tests/test_rcon.sh Outdated
Comment thread tools/tests/test_rcon.sh
Comment thread tools/tests/test_rcon.sh Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds basic unit coverage for the pure-Bash RCON hex helpers and hardens reverse_hex_endian/tools/rcon.sh so it can be safely sourced without invoking the CLI entrypoint.

Changes:

  • Add tools/tests/test_rcon.sh unit tests for reverse_hex_endian, decode_hex_int, and encode_int.
  • Fix reverse_hex_endian to emit trailing input shorter than 8 hex chars instead of dropping it.
  • Wrap rcon_command invocation behind a BASH_SOURCE main-guard to allow sourcing tools/rcon.sh.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tools/tests/test_rcon.sh New unit test script covering core hex utilities and the trailing-input fix.
tools/rcon.sh Fix trailing-input handling in reverse_hex_endian and add a main guard for safe sourcing.

Comment thread tools/tests/test_rcon.sh Outdated

# Source the rcon.sh script
# Since we wrapped the main execution call, it should only load functions
source "$(dirname "$0")/../rcon.sh"
Comment thread tools/tests/test_rcon.sh Outdated
Comment on lines +19 to +21
printf "\e[32m[PASS]\e[0m %s\n" "$description"
else
printf "\e[31m[FAIL]\e[0m %s\n" "$description"
Comment thread tools/tests/test_rcon.sh
@@ -0,0 +1,77 @@
#!/usr/bin/env bash

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: Missing project-required shellcheck directive. Use # shellcheck enable=all shell=bash source-path=SCRIPTDIR to match repository conventions (see tools/backup.sh:2).

Comment thread tools/tests/test_rcon.sh
tests_failed=0

# Assertion function
assert_equals() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Missing project's required Bash boilerplate. Add set -euo pipefail, shopt -s nullglob globstar, IFS=$'\n\t' LC_ALL=C (see tools/backup.sh:4-7).

Comment thread tools/tests/test_rcon.sh
tests_failed=0

# Assertion function
assert_equals() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Not sourcing common.sh for shared utilities (print_header, print_success, etc.). Should source common.sh like other tools (see tools/monitor.sh:5-11).

@kilo-code-bot

kilo-code-bot Bot commented May 3, 2026

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

All previously identified issues have been resolved in the incremental changes:

  • test_rcon.sh: Shellcheck directive with source-path=SCRIPTDIR added ✓
  • test_rcon.sh: Bash boilerplate (set -euo pipefail, shopt -s nullglob globstar, IFS) added ✓
  • test_rcon.sh: common.sh is now sourced ✓
  • test_rcon.sh: Uses print_success/print_error from shared library ✓
  • rcon.sh: Bug fix for trailing input handling ✓
  • rcon.sh: Added conditional wrapper for safe sourcing ✓

The changes correctly implement the intended fixes and follow project conventions.

Files Reviewed (2 files)
  • tools/rcon.sh
  • tools/tests/test_rcon.sh
Previous Review Summary (commit de41729)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit de41729)

Status: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 3
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
tools/tests/test_rcon.sh 1 Missing project-required shellcheck directive source-path=SCRIPTDIR
tools/tests/test_rcon.sh 13 Missing Bash boilerplate (set -euo pipefail, shopt -s nullglob globstar, IFS)
tools/tests/test_rcon.sh 13 Not sourcing common.sh for shared utilities
Other Observations (not in diff)

Code Quality Notes

File Line Issue
tools/rcon.sh 2 Shellcheck directive missing source-path=SCRIPTDIR (minor)
Files Reviewed (3 files)
  • tools/rcon.sh - 0 issues (minor shellcheck directive note)
  • tools/tests/test_rcon.sh - 3 issues

Reviewed by laguna-m.1-20260312:free · Input: 243.6K · Output: 8.4K · Cached: 62.5K

Ven0m0 and others added 3 commits June 23, 2026 20:19
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@Ven0m0 Ven0m0 merged commit 9a91b7e into main Jun 23, 2026
0 of 2 checks passed
@Ven0m0 Ven0m0 deleted the feat-rcon-tests-and-fix-15791535305284024798 branch June 23, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants