Skip to content

Commit

Permalink
Fix off by one out of range kernel filtering (#287)
Browse files Browse the repository at this point in the history
* Fi off by one out of range kernel filtering

Signed-off-by: JoseSantosAMD <[email protected]>

* reformat

Signed-off-by: JoseSantosAMD <[email protected]>

---------

Signed-off-by: JoseSantosAMD <[email protected]>
  • Loading branch information
JoseSantosAMD authored Feb 29, 2024
1 parent f42aa6c commit 4ad124a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/utils/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,10 +849,10 @@ def apply_filters(workload, dir, is_gui, debug):
# Verify valid kernel filter
kernels_df = pd.read_csv(os.path.join(dir, "pmc_kernel_top.csv"))
for kernel_id in workload.filter_kernel_ids:
if kernel_id > len(kernels_df["Kernel_Name"]):
if kernel_id >= len(kernels_df["Kernel_Name"]):
error(
"{} is an invalid kernel id. Please enter an id between 0-{}".format(
kernel_id, len(kernels_df["Kernel_Name"])
kernel_id, len(kernels_df["Kernel_Name"]) - 1
)
)
kernels = []
Expand Down
8 changes: 4 additions & 4 deletions tests/test_analyze_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def test_filter_kernel_2():
],
):
omniperf.main()
assert e.value.code == 0
assert e.value.code == 1

with pytest.raises(SystemExit) as e:
with patch(
Expand All @@ -436,7 +436,7 @@ def test_filter_kernel_2():
],
):
omniperf.main()
assert e.value.code == 0
assert e.value.code == 1


@pytest.mark.filter_kernel
Expand All @@ -455,7 +455,7 @@ def test_filter_kernel_3():
],
):
omniperf.main()
assert e.value.code == 0
assert e.value.code == 1

with pytest.raises(SystemExit) as e:
with patch(
Expand All @@ -471,7 +471,7 @@ def test_filter_kernel_3():
],
):
omniperf.main()
assert e.value.code == 0
assert e.value.code == 1


@pytest.mark.dispatch
Expand Down

0 comments on commit 4ad124a

Please sign in to comment.