Skip to content

Update error codes to be more specific.#73

Merged
dvalinrh merged 4 commits intomainfrom
rerun
Mar 16, 2026
Merged

Update error codes to be more specific.#73
dvalinrh merged 4 commits intomainfrom
rerun

Conversation

@dvalinrh
Copy link
Contributor

Description

Uses error_codes found in test_tools/error_codes to provide more specific error indication.

Before/After Comparison

Before: Returned a 0 or 1, making determination of having to rerun very course
After: Error codes are now bases on test_tools/error_codes, making it easier to limit when we do a rerun of the test.
Also, changed how we load in test_tools, we try curl, git, and wget, to avoid a failure due to the program not
being installed.

Clerical Stuff

This closes #72

Relates to JIRA: RPOPC-867

Testing

Ran through zathras, with following scenario file
global:
ssh_key_file: replace_your_ssh_key
terminate_cloud: 1
os_vendor: rhel
results_prefix: documentation
os_vendor: rhel
system_type: aws
cloud_os_id: ami-035032ea878eca201
systems:
system1:
tests: "coremark"
host_config: "m5.xlarge"

csv file produced.
iteration,threads,IterationsPerSec,Start_Date,End_Date
1,4,58708.414873,2026-03-13T12:11:27Z,2026-03-13T12:12:18Z
1,4,59802.651251,2026-03-13T12:11:27Z,2026-03-13T12:12:18Z
2,4,58927.519151,2026-03-13T12:12:33Z,2026-03-13T12:13:23Z
2,4,59769.885939,2026-03-13T12:12:33Z,2026-03-13T12:13:23Z
3,4,59017.360940,2026-03-13T12:13:38Z,2026-03-13T12:14:28Z
3,4,59488.399762,2026-03-13T12:13:38Z,2026-03-13T12:14:28Z
4,4,58783.188008,2026-03-13T12:14:43Z,2026-03-13T12:15:34Z
4,4,59627.329193,2026-03-13T12:14:43Z,2026-03-13T12:15:34Z
5,4,58924.625583,2026-03-13T12:15:48Z,2026-03-13T12:16:39Z
5,4,60003.000150,2026-03-13T12:15:48Z,2026-03-13T12:16:39Z

Returned 0 as expected. Testing on rerun verification handled in the appropriate zathras pr.

@github-actions
Copy link

This relates to RPOPC-867

@qodo-code-review
Copy link

Review Summary by Qodo

Replace hardcoded exit codes with specific error codes

✨ Enhancement 🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Replace hardcoded exit codes with specific error codes from test_tools
• Add multiple fallback methods to install test_tools (wget, curl, git)
• Use proper error code constants throughout script for better error handling
• Update usage exit to use E_USAGE and final exit to use E_SUCCESS
Diagram
flowchart LR
  A["Script execution"] --> B["Install test_tools"]
  B --> C["Try wget method"]
  C --> D["Try curl method"]
  D --> E["Try git clone method"]
  E --> F["Run coremark"]
  F --> G["Generate results"]
  G --> H["Exit with error code"]
  B -.->|fallback| C
  C -.->|fallback| D
  D -.->|fallback| E
Loading

Grey Divider

File Changes

1. coremark/coremark_run ✨ Enhancement +44/-14

Add error codes and multiple tool installation methods

• Added three new functions (attempt_tools_wget, attetmpt_tools_curl, attempt_tools_git) to
 install test_tools using multiple methods as fallbacks
• Replaced hardcoded exit code 1 with specific error code constants ($E_GENERAL, $E_USAGE,
 $E_SUCCESS) throughout the script
• Modified install_test_tools function to call all three installation methods sequentially instead
 of only attempting git clone
• Updated usage function to exit with $E_USAGE instead of 0
• Changed final script exit from 0 to $E_SUCCESS

coremark/coremark_run


Grey Divider

Qodo Logo

@qodo-code-review
Copy link

qodo-code-review bot commented Mar 13, 2026

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0) 📎 Requirement gaps (1)

Grey Divider


Action required

1. Unvalidated exit code vars 🐞 Bug ⛯ Reliability
Description
coremark_run now exits using $E_SUCCESS/$E_GENERAL/$E_USAGE but never defines or validates them
locally; if sourcing $TOOLS_BIN/general_setup fails, exit_out/exit can return the previous command’s
status and misreport success or the wrong error code. This can break callers relying on exit codes
for rerun/triage decisions.
Code

coremark/coremark_run[499]

+exit $E_SUCCESS
Evidence
The script’s exit behavior is entirely determined by the numeric argument passed to exit/exit_out.
After this PR, that argument is often an E_* variable (not defined anywhere in this repo), and the
script does not check whether sourcing general_setup succeeded before continuing; if the variables
are unset, bash will effectively execute exit with no numeric argument and use the previous
command’s status instead.

coremark/coremark_run[32-36]
coremark/coremark_run[379-383]
coremark/coremark_run[78-86]
coremark/coremark_run[194-201]
coremark/coremark_run[497-499]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`coremark_run` exits using `$E_SUCCESS/$E_GENERAL/$E_USAGE`, but those variables are not defined in this repo and the script doesn’t validate that sourcing `general_setup` succeeded. If sourcing fails or doesn’t set these variables, `exit`/`exit_out` can return an unintended status (often the previous command’s status), misreporting success or incorrect failure codes.
### Issue Context
- `exit_out` calls `exit $2` directly.
- `source "$TOOLS_BIN/general_setup" "$@"` is not checked for success.
- Multiple error/success exits now depend on `$E_*` values.
### Fix Focus Areas
- coremark/coremark_run[32-36]
- coremark/coremark_run[78-86]
- coremark/coremark_run[379-383]
- coremark/coremark_run[194-201]
- coremark/coremark_run[497-499]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Bootstrap ignores unzip/mv errors 🐞 Bug ⛯ Reliability
Description
The new wget/curl bootstrap path checks only the download exit code and ignores unzip/mv failures
while still deleting main.zip, which can leave $TOOLS_BIN missing or incomplete. This can cascade
into later failures (e.g., sourcing general_setup) with confusing symptoms and wrong exit statuses.
Code

coremark/coremark_run[R88-110]

+attempt_tools_wget()
+{
+        if [[ ! -d "$TOOLS_BIN" ]]; then
+                wget ${tools_git}/archive/refs/heads/main.zip
+                if [[ $? -eq 0 ]]; then
+                        unzip -q main.zip
+                        mv test_tools-wrappers-main ${TOOLS_BIN}
+                        rm main.zip
+                fi
+        fi
+}
+
+attetmpt_tools_curl()
+{
+        if [[ ! -d "$TOOLS_BIN" ]]; then
+                curl -L -O ${tools_git}/archive/refs/heads/main.zip
+                if [[ $? -eq 0 ]]; then
+                        unzip -q main.zip
+                        mv test_tools-wrappers-main ${TOOLS_BIN}
+                        rm main.zip
+                fi
+        fi
+}
Evidence
Both wget and curl paths perform unzip/mv/rm without checking any of those commands’ exit statuses.
The script then proceeds to source $TOOLS_BIN/general_setup later without verifying it exists, so
a partial/failed unzip/mv can cause hard-to-diagnose downstream failures.

coremark/coremark_run[88-98]
coremark/coremark_run[100-110]
coremark/coremark_run[152-155]
coremark/coremark_run[379-381]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The wget/curl bootstrap code treats download success as install success, but it does not check whether `unzip` succeeded or whether the extracted directory was moved correctly. It also deletes `main.zip` regardless of unzip/mv outcome. This can leave `$TOOLS_BIN` missing/incomplete and cause later `source "$TOOLS_BIN/general_setup"` to fail in confusing ways.
### Issue Context
The script tries wget, then curl, then git. If wget/curl download succeeds but unzip/mv fails, the install is still incomplete.
### Fix Focus Areas
- coremark/coremark_run[88-110]
- coremark/coremark_run[152-155]
- coremark/coremark_run[379-381]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

3. Hardcoded 101 exit code 📎 Requirement gap ✓ Correctness
Description
The new attempt_tools_git() error path uses a literal exit code (101) instead of a shared named
error-code constant, making error signaling inconsistent with the new error-code approach. This can
undermine the goal of standardizing on specific, centrally-defined error codes.
Code

coremark/coremark_run[117]

+                        exit_out "Error: pulling git $tools_git failed." 101
Evidence
PR Compliance ID 1 requires updating generic error codes to more specific ones and using them
consistently; the added code introduces a hardcoded numeric code rather than a named code variable
used elsewhere in the PR (e.g., $E_GENERAL, $E_USAGE, $E_SUCCESS).

Error codes updated to be more specific
coremark/coremark_run[114-118]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`attempt_tools_git()` exits via `exit_out ... 101` using a hardcoded numeric exit code, which is inconsistent with the PR's shift to named error-code variables.
## Issue Context
Other updated error paths use named variables like `E_USAGE`, `E_GENERAL`, and `E_SUCCESS`, implying exit codes should be centrally defined and consistently referenced.
## Fix Focus Areas
- coremark/coremark_run[112-120]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@dvalinrh dvalinrh requested a review from kdvalin March 13, 2026 12:28
@dvalinrh
Copy link
Contributor Author

The hardcoded 101 has to happen as at this our attempt to load test_tools has failed 3 different ways.

@dvalinrh dvalinrh requested a review from kdvalin March 13, 2026 15:18
Copy link
Member

@kdvalin kdvalin left a comment

Choose a reason for hiding this comment

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

LGTM

@dvalinrh dvalinrh merged commit 21439d5 into main Mar 16, 2026
3 checks passed
@dvalinrh dvalinrh deleted the rerun branch March 16, 2026 15:27
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.

Update error codes

2 participants