Repository navigation
docs(amdsmi): fix /* within comment warning in AMPP profile doxygen
#13848
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
Merged
oliveiradan
merged 2 commits into
develop
from
users/daolivei/ampp_profile_doc_warnings
Oct 21, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
projects/amdsmi/tests/python/unit/system/test_amdsmi_header_comments.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| #!/usr/bin/env python3 | ||
| # Copyright Advanced Micro Devices, Inc. | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
| """A ``/*`` inside a block comment of amdsmi.h triggers -Wcomment in every includer.""" | ||
|
|
||
| import unittest | ||
| from pathlib import Path | ||
|
|
||
| _HEADER_REL = Path("include") / "amd_smi" / "amdsmi.h" | ||
|
|
||
| _BLOCK_OPEN = "/*" | ||
| _BLOCK_CLOSE = "*/" | ||
| _LINE_OPEN = "//" | ||
| _DELIM_LEN = len(_BLOCK_OPEN) | ||
| _QUOTES = "\"'" | ||
|
|
||
| _CODE, _BLOCK, _LINE, _LITERAL = range(4) | ||
|
|
||
|
|
||
| def find_nested_comment_openers(text: str) -> list: | ||
| """Return the 1-based line of every ``/*`` that appears inside a block comment.""" | ||
| hits = [] | ||
| state = _CODE | ||
| quote = "" | ||
| pos = 0 | ||
| line = 1 | ||
| while pos < len(text): | ||
| pair = text[pos : pos + _DELIM_LEN] | ||
| char = text[pos] | ||
| if state == _CODE: | ||
| if pair in (_BLOCK_OPEN, _LINE_OPEN): | ||
| state = _BLOCK if pair == _BLOCK_OPEN else _LINE | ||
| pos += _DELIM_LEN | ||
| continue | ||
| if char in _QUOTES: | ||
| state, quote = _LITERAL, char | ||
| elif state == _BLOCK: | ||
| if pair == _BLOCK_CLOSE: | ||
| state = _CODE | ||
| pos += _DELIM_LEN | ||
| continue | ||
| if pair == _BLOCK_OPEN: | ||
| hits.append(line) | ||
| elif state == _LINE: | ||
| if char == "\n" and text[pos - 1] != "\\": | ||
| state = _CODE | ||
| elif char == "\\": | ||
| pos += _DELIM_LEN | ||
| continue | ||
| elif char in (quote, "\n"): | ||
| state = _CODE | ||
| if char == "\n": | ||
| line += 1 | ||
| pos += 1 | ||
| return hits | ||
|
|
||
|
|
||
| def find_header() -> Path: | ||
| """Locate amdsmi.h by walking up from this file. | ||
|
|
||
| The same walk resolves ``<repo>/include/...`` in the source tree and | ||
| ``<rocm>/include/...`` when the tests run from ``share/amd_smi/tests``. | ||
| """ | ||
| for parent in Path(__file__).resolve().parents: | ||
| candidate = parent / _HEADER_REL | ||
| if candidate.is_file(): | ||
| return candidate | ||
| raise unittest.SkipTest("amdsmi.h not found in the source tree or the install prefix") | ||
|
|
||
|
|
||
| class NestedCommentOpenersTest(unittest.TestCase): | ||
| def test_reports_line_of_nested_opener(self): | ||
| text = "/* a\n * b/* c\n */\n" | ||
| self.assertEqual(find_nested_comment_openers(text), [2]) | ||
|
|
||
| def test_ignores_opener_in_line_comment(self): | ||
| text = "// path/* here\n/* a\n */\n" | ||
| self.assertEqual(find_nested_comment_openers(text), []) | ||
|
|
||
| def test_ignores_opener_in_string_literal(self): | ||
| text = 'const char *s = "/*";\n/* a\n */\n' | ||
| self.assertEqual(find_nested_comment_openers(text), []) | ||
|
|
||
| def test_clean_block_reports_nothing(self): | ||
| self.assertEqual(find_nested_comment_openers("/* a\n * b\n */\n"), []) | ||
|
|
||
|
|
||
| class AmdsmiHeaderNestedCommentTest(unittest.TestCase): | ||
| def test_header_has_no_nested_comment_opener(self): | ||
| header = find_header() | ||
| text = header.read_text(encoding="utf-8", errors="replace") | ||
| self.assertEqual(find_nested_comment_openers(text), [], msg=str(header)) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.