forked from AMDResearch/Riallto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check that kernel source code has extern C defined (AMDResearch#70)
* Verify that kernel code is wrapped in extern C * Remove curly braces * Add breakline * Change raise type * Fix checks * Return RunTime error * Check construct * Use Syntax error * Change way we do pytest * Only check if extern C exists * Remove unused check
- Loading branch information
1 parent
ca9ade7
commit 3549f52
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,27 @@ | ||
# Copyright 2024 Advanced Micro Devices, Inc. | ||
# SPDX-License-Identifier: MIT | ||
|
||
import pytest | ||
from npu.build.kernel import Kernel | ||
from npu.lib import Plus1 | ||
|
||
|
||
kernel_src = Plus1().srccode | ||
|
||
kernel_src1 = kernel_src.replace('\n\n}', '') | ||
|
||
|
||
def test_externc_good(): | ||
krnl_obj = Kernel(kernel_src) | ||
krnl_obj.build() | ||
assert krnl_obj | ||
|
||
|
||
@pytest.mark.parametrize('replacewith', ['']) | ||
def test_externc_bad(replacewith): | ||
src_code = kernel_src1.replace('extern "C" {', replacewith) | ||
|
||
with pytest.raises(SyntaxError) as excinfo: | ||
_ = Kernel(src_code) | ||
|
||
assert 'extern "C" not found.' in str(excinfo.value) |