Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion .github/workflows/frontier/submit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ job_slug="`basename "$1" | sed 's/\.sh$//' | sed 's/[^a-zA-Z0-9]/-/g'`-$2"

sbatch <<EOT
#!/bin/bash
#SBATCH -JMFC-$job_slug # Job name
#SBATCH -J MFC-$job_slug # Job name
#SBATCH -A CFD154 # charge account
#SBATCH -N 1 # Number of nodes required
$sbatch_device_opts
Expand Down
12 changes: 9 additions & 3 deletions toolchain/mfc/test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
nFAIL = 0
nPASS = 0
nSKIP = 0
current_test_number = 0
total_test_count = 0
errors = []

# pylint: disable=too-many-branches, trailing-whitespace
Expand Down Expand Up @@ -95,7 +97,7 @@ def __filter(cases_) -> typing.List[TestCase]:

def test():
# pylint: disable=global-statement, global-variable-not-assigned
global nFAIL, nPASS, nSKIP
global nFAIL, nPASS, nSKIP, total_test_count
global errors

cases = list_cases()
Expand All @@ -113,6 +115,7 @@ def test():

cases, skipped_cases = __filter(cases)
cases = [ _.to_case() for _ in cases ]
total_test_count = len(cases)

if ARG("list"):
table = rich.table.Table(title="MFC Test Cases", box=rich.table.box.SIMPLE)
Expand Down Expand Up @@ -150,7 +153,7 @@ def test():

# Run cases with multiple threads (if available)
cons.print()
cons.print(" tests/[bold magenta]UUID[/bold magenta] (s) Summary")
cons.print(" Progress [bold magenta]UUID[/bold magenta] (s) Summary")
cons.print()

# Select the correct number of threads to use to launch test cases
Expand Down Expand Up @@ -185,6 +188,7 @@ def test():
# pylint: disable=too-many-locals, too-many-branches, too-many-statements, trailing-whitespace
def _handle_case(case: TestCase, devices: typing.Set[int]):
# pylint: disable=global-statement, global-variable-not-assigned
global current_test_number
start_time = time.time()
Copy link

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

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

The global variable current_test_number is being modified in _handle_case which appears to be called from multiple threads based on the comment 'Run cases with multiple threads'. This creates a race condition where multiple threads could increment the counter simultaneously, leading to incorrect progress reporting.

Suggested change
start_time = time.time()
start_time = time.time()
# Ensure thread-safe increment of current_test_number
with current_test_number_lock:
current_test_number += 1

Copilot uses AI. Check for mistakes.

tol = case.compute_tolerance()
Expand Down Expand Up @@ -269,7 +273,9 @@ def _handle_case(case: TestCase, devices: typing.Set[int]):
end_time = time.time()
duration = end_time - start_time

cons.print(f" [bold magenta]{case.get_uuid()}[/bold magenta] {duration:6.2f} {case.trace}")
current_test_number += 1
progress_str = f"({current_test_number:3d}/{total_test_count:3d})"
Comment on lines +276 to +277
Copy link

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

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

This increment operation is not thread-safe. When multiple test cases run concurrently, the progress counter will be inaccurate due to race conditions. Consider using a thread-safe counter or moving this logic to a synchronized section.

Suggested change
current_test_number += 1
progress_str = f"({current_test_number:3d}/{total_test_count:3d})"
with current_test_number_lock:
current_test_number += 1
progress_str = f"({current_test_number:3d}/{total_test_count:3d})"

Copilot uses AI. Check for mistakes.
cons.print(f" {progress_str} [bold magenta]{case.get_uuid()}[/bold magenta] {duration:6.2f} {case.trace}")


def handle_case(case: TestCase, devices: typing.Set[int]):
Expand Down
Loading