Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 48 additions & 4 deletions Runner/suites/Kernel/Baseport/Timer/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,39 @@ fi
# shellcheck disable=SC1090,SC1091
. "$TOOLS/functestlib.sh"

# --- Parse CLI argument for custom binary path ---
show_help() {
cat <<EOF
Usage: $0 [OPTIONS]

Options:
--binary-path=PATH Specify a custom path to the posix_timers binary else run by default from /usr/bin.
-h, --help Show this help message and exit.

Example:
$0 --binary-path=/custom/path/posix_timers
$0

EOF
}


BINARY_PATH=""
while [ $# -gt 0 ]; do
case "$1" in
--binary-path=*)
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be helpful to include help and usage information when supporting new CLI parameters, so users can easily see what options are available.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated as per comments to add the help and usage information

BINARY_PATH="${1#*=}"
;;
-h|--help)
show_help
exit 0
;;
*)
;;
esac
shift
done

TESTNAME="Timer"
test_path=$(find_test_case_by_name "$TESTNAME")
cd "$test_path" || exit 1
Expand All @@ -39,13 +72,24 @@ log_info "----------------------------------------------------------------------
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
log_info "=== Test Initialization ==="

chmod -R 777 /APT/timers
# --- Determine binary to use ---
if [ -n "$BINARY_PATH" ]; then
BINARY="$BINARY_PATH"
else
BINARY="posix_timers"
fi

# Path to the binary
BINARY_PATH="/var/common/bins/timers/posix_timers"
# --- Check if binary exists in PATH or at custom path ---
check_dependencies "$BINARY"
if [ $? -ne 0 ]; then
log_skip "$TESTNAME : Binary '$BINARY' not found"
echo "$TESTNAME SKIP" > "$res_file"
exit 0
fi

# Run the binary and capture the output
OUTPUT=$($BINARY_PATH)
OUTPUT=$($BINARY)
echo $OUTPUT

# Check if "pass:7" is in the output
if echo "${OUTPUT}" | grep "pass:7"; then
Expand Down
Loading