Skip to content

Add --test-param CLI option for runtime parameters#1036

Open
rachael-george wants to merge 1 commit into
HCK-CI:masterfrom
rachael-george:functest-test-param-cli-option
Open

Add --test-param CLI option for runtime parameters#1036
rachael-george wants to merge 1 commit into
HCK-CI:masterfrom
rachael-george:functest-test-param-cli-option

Conversation

@rachael-george

Copy link
Copy Markdown
Contributor

Problem:
Functest test cases sometimes need runtime parameters that vary between runs (e.g. a path to an older installer for upgrade testing). There was no way to pass these without hardcoding them in the test JSON.

Fix:
Add a --test-param KEY=VALUE option to the CLI (repeatable). Each key-value pair is set as a context variable in setup_test_context, making it available as @KEY@ in test JSON files via the existing replacement map.

Example:
Pass an older installer path for upgrade testing:

  bin/auto_hck --id 53 functest -p Win2025x64_gui -d virtio-win-installer
    --driver-path /path/to/virtio-win-1.9.58/usr/share/virtio-win
    --test-param old_installer_path=/path/to/virtio-win-1.9.52/usr/share/virtio-win
    --testcase installer/bundle_update

In the test JSON, @old_installer_path@ resolves and is used to upload the old installer:

{
    "desc": "Validate old installer path",
    "host_run": "test -f '@old_installer_path@/installer/virtio-win-guest-tools.exe' || { echo 'ERROR: Old installer not found. Use --test-param
old_installer_path=/path/to/old/virtio-win'; exit 1; }",
    "timeout": 10
},
{
    "local_path": "@old_installer_path@/installer/virtio-win-guest-tools.exe",
    "remote_path": "C:\\AutoHCK\\virtio-win-guest-tools-old.exe",
    "direction": "local-to-remote"
}

@rachael-george rachael-george self-assigned this Jul 15, 2026

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

Copy link
Copy Markdown

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 introduces a new --test-param KEY=VALUE command-line option to allow users to pass custom test parameters, which are then set as variables in the test context. A review comment points out that the current validation unless key && value is insufficient because empty strings are truthy in Ruby, and suggests a more robust check to prevent empty keys.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread lib/cli.rb Outdated
Comment on lines +284 to +285
key, value = kv.split('=', 2)
raise AutoHCKError, "Invalid --test-param format: #{kv}" unless key && value

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The current validation unless key && value is insufficient because in Ruby, empty strings are truthy. If a user passes --test-param =value or --test-param =, key will be parsed as an empty string "", which is truthy, and the validation will pass. This would result in setting an empty key in the test parameters hash.

We should explicitly check that the key is not empty and that the value is not nil.

        key, value = kv.split('=', 2)
        raise AutoHCKError, "Invalid --test-param format: #{kv}" if key.to_s.empty? || value.nil?

@rachael-george
rachael-george force-pushed the functest-test-param-cli-option branch 2 times, most recently from edecc60 to 9193aa3 Compare July 17, 2026 08:08
Comment thread lib/cli.rb Fixed
Comment thread lib/cli.rb Fixed
Comment thread lib/cli.rb Fixed
Comment thread lib/cli.rb Fixed
Comment thread lib/cli.rb Fixed
Signed-off-by: rachael-george <rgeorge@redhat.com>
@rachael-george
rachael-george force-pushed the functest-test-param-cli-option branch from 9193aa3 to 7839f21 Compare July 17, 2026 08:10
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