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

ci: add_test: using maintainer.yml to add testcases #42662

Closed
wants to merge 1 commit into from

Conversation

hakehuang
Copy link
Collaborator

based on modified .c/.h file, check maintainer.yaml for
related sample/test application

e.g.

if modified file is dma_mcux_edma.c
three test cases will be added
['tests\drivers\dma\chan_blen_transfer',
'tests\drivers\dma\chan_link_transfer',
'tests\drivers\dma\loop_transfer']

Signed-off-by: Hake Huang hake.huang@oss.nxp.com

Copy link
Member

@PerMac PerMac left a comment

Choose a reason for hiding this comment

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

How did you test it? I would like to see some demo. I have troubles understanding what your code is doing. It starts with descriptive names, but down the line it ends with
if [ e for e in __f if e in target_files ]:. It would be also easier to review if you'd add some comments explaining what the code is trying to achieve. E.g. I think I spent quite some time (too much) trying to figure out what L47-72 is doing

Comment on lines +122 to +139
for _tp in test_apps_path:
_apps_path = os.path.join(zephyr_base_dir, _tp)
for path in Path(_apps_path).rglob("testcase.yaml"):
_tp = os.path.relpath(path, zephyr_base_dir)
test_path_list.append(os.path.dirname(_tp))
for path in Path(_apps_path).rglob("sample.yaml"):
_tp = os.path.relpath(path, zephyr_base_dir)
test_path_list.append(os.path.dirname(_tp))

Copy link
Member

Choose a reason for hiding this comment

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

Can you refactor this part, so the same code is not repeated?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok

Comment on lines 62 to 69
if '*' in item:
_files = Path(zephyr_base_dir).rglob(item)
_files = list(set(_files))
__f = [os.path.basename(i) for i in _files]
else:
_files = Path(os.path.join(zephyr_base_dir, item)).rglob("*")
_files = list(set(_files))
__f = [os.path.basename(i) for i in _files]
Copy link
Member

Choose a reason for hiding this comment

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

Can you refactor this part, to reduce repetitiveness?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok

Comment on lines 51 to 67
if re.match('^tests', item):
_test_apps_path.append(item)
continue
if re.match('^samples', item):
_test_apps_path.append(item)
continue
Copy link
Member

Choose a reason for hiding this comment

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

please reduce repetitiveness

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

How did you test it? I would like to see some demo. I have troubles understanding what your code is doing. It starts with descriptive names, but down the line it ends with if [ e for e in __f if e in target_files ]:. It would be also easier to review if you'd add some comments explaining what the code is trying to achieve. E.g. I think I spent quite some time (too much) trying to figure out what L47-72 is doing

ok, I will add some comments to exaplin the purpose, and I write a standalone code to test this function before I put the code into ci.

based on modified .c/.h file, check maintainer.yaml for
related sample/test application

e.g.

if modified file is dma_mcux_edma.c
three test cases will be added
['tests\\drivers\\dma\\chan_blen_transfer',
 'tests\\drivers\\dma\\chan_link_transfer',
 'tests\\drivers\\dma\\loop_transfer']

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
@nashif
Copy link
Member

nashif commented Mar 3, 2022

I tried this, but can't see how you get the tests just based on the driver being changed. Also, how would this work for any driver? What are the expectations from the entries in the MAINTAINERS file to be able to support this in the most efficient way?

Also see discussion here for something that is supposed to solve this problem: #38725 (comment)

@hakehuang
Copy link
Collaborator Author

hakehuang commented Mar 3, 2022

I tried this, but can't see how you get the tests just based on the driver being changed. Also, how would this work for any driver? What are the expectations from the entries in the MAINTAINERS file to be able to support this in the most efficient way?

Also see discussion here for something that is supposed to solve this problem: #38725 (comment)
@nashif
for example if the dma_mcux_edma.c is modified, it will check the files are in dma mode below

"Drivers: DMA":
    status: maintained
    maintainers:
        - teburd
    files:
        - drivers/dma/
        - tests/drivers/dma/
    labels:
        - "area: DMA"

and all test applications inside the test.drivers.dma will be added to test plan.

@hakehuang hakehuang closed this Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants