Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test] Fix infinite loop when we run out of input #1396

Merged
merged 1 commit into from
Mar 5, 2024

Conversation

ldrumm
Copy link
Contributor

@ldrumm ldrumm commented Feb 28, 2024

d6930c7 introduced Status.INPUT_END but didn't introduce the means to handle that eventuality. It looks like the intention might have been to exit with success if we've got to the end of input. However, if we run out of input and still have matches pending, I'm treating this as a failure.

Infinite loop reproducer:
_matchtmpfile.txt
input.txt

@ldrumm ldrumm requested a review from a team as a code owner February 28, 2024 18:47
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 12.51%. Comparing base (78ef1ca) to head (c549757).
Report is 83 commits behind head on main.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1396      +/-   ##
==========================================
- Coverage   14.82%   12.51%   -2.31%     
==========================================
  Files         250      239      -11     
  Lines       36220    35942     -278     
  Branches     4094     4076      -18     
==========================================
- Hits         5369     4498     -871     
- Misses      30800    31440     +640     
+ Partials       51        4      -47     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kbenzie
Copy link
Contributor

kbenzie commented Feb 29, 2024

Looks like the CUDA match file needs updated after this patch?

@ldrumm
Copy link
Contributor Author

ldrumm commented Feb 29, 2024

Looks like the CUDA match file needs updated after this patch?

Yeah. I'll see what I can do

cmake/match.py Outdated
@@ -93,6 +93,12 @@ def main():
print_incorrect_match(match_idx + 1, input_lines[input_idx].strip(), "");
print_content(input_lines, match_lines, ignored_lines)
sys.exit(1)
elif status == Status.INPUT_END:
# If we get to the end of the input, but still have pending matches,
Copy link
Contributor

@kswiecicki kswiecicki Mar 1, 2024

Choose a reason for hiding this comment

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

There might be a scenario where we get to the end of the input, and the remaining matches are marked with {{OPT}}. In that case we expect a success.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe something like this could work:

elif status == Status.INPUT_END and input_idx >= len(match_lines) + len(ignored_lines):
            print_incorrect_match(match_idx + 1, "", match_lines[match_idx]);
            print_content(input_lines, match_lines, ignored_lines)
            sys.exit(1)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's good. Just ran into the ignored lines problem. I'll add that

Copy link
Contributor Author

@ldrumm ldrumm Mar 1, 2024

Choose a reason for hiding this comment

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

I went with a loop to consume remaining matches rather than just arithmetic because non-optional matches might still remain e.g.
matchfile:

{{OPT}} foo
bar
{{OPT}}baz

input:

foo

Thanks for the suggestion

d6930c7 introduced Status.INPUT_END but didn't introduce the means
to handle that eventuality. It looks like the intention might have been
to exit with success if we've got to the end of input.
However, if we run out of input and still have matches pending, I'm
treating this as a failure
@pbalcer pbalcer merged commit 06fe20e into oneapi-src:main Mar 5, 2024
52 checks passed
@ldrumm ldrumm deleted the INPUT_END branch March 5, 2024 16: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.

5 participants