-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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: twister: testplan.py use normpath #64272
test: twister: testplan.py use normpath #64272
Conversation
@@ -562,7 +562,7 @@ def load_from_file(self, file, filter_platform=[]): | |||
instance_list = [] | |||
for ts in jtp.get("testsuites", []): | |||
logger.debug(f"loading {ts['name']}...") | |||
testsuite = ts["name"] | |||
testsuite = os.path.normpath(ts["name"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will work when you generate plan on Linux and load it on Windows:
>>> os.path.normpath('twister-out/twister.log')
'twister-out\\twister.log'
When you generate plan on Windows and try to load it on Linux, it will not work:
>>> os.path.normpath('twister-out\\twister.log')
'twister-out\\twister.log'
IMO testcase name should be also changed in TestSuite
class (e.g. to use only /
separator).
Or, if we do not need to support that case (generate test plan on Windows and load on Linux), then this change will be enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strange, why I get different result, see my log
`
ubuntu@ubuntu-OptiPlex-7050:/home/shared/disk/zephyr_project/zephyr_test/zephyr$ ipython3
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0]
Type 'copyright', 'credits' or 'license' for more information
ubuntu@ubuntu-OptiPlex-7050:~$ ipython3
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.31.1 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import os
In [2]: print(os.path.normpath('twister-out\twister.log'))
twister-out\twister.log
In [3]:
`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My first log was from Windows, second from Linux. When you use path with backslashes (generated in Windows) and test it on Linux, then you still have backslashes in the result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gchwier thank a lot to point this scenario out, I add a check as below to specially handle it
if testsuite not in self.testsuites:
# this could be a path issue in testplan and run envrionment
# try convert it
# so far we know window plan to linux envirnmont has such problem
if "\\" in testsuite:
testsuite = testsuite.replace("\\", "/")
else:
logger.warning(f"{testsuite} is not supported")
continue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With those changes it should works, but this is rather a workaround. I suggest to use in testplan only /
separator, because it works also on Windows. Best place (IMO) is to fix it in TestSuite
class, where name
is generated:
See:
twisterlib/testsuite.py#L453
and use:
unique = os.path.normpath(os.path.join(relative_ts_root, workdir, name)).replace(os.sep, '/')
But it should be tested.
You could also add some unit test for that change :)
I test manually, it works, however as we are uing os.sep this binds to the system we are running, do we have a windows CI? if not, we can not test it |
Please move changes related to the testrunner tests from #64551 to separate PR (it will be merged faster and fix tests also here) |
when load test plan it is possible the plan is built in another os so the case key would be 'samples/hello_world/samples.baseic.hello_world' but the testsuite is scaned in current os may in window and the key is like 'samples\\hello_world\\samples.baseic.hello_world' so update the uniq path with only backslash in path Signed-off-by: Hake Huang <[email protected]>
This is breaking something on Windows. When I try and run tests in an out-of-tree directory it no longer finds the test suite:
|
can you raise an issue? |
I am not sure if this is a bug nor windows specific. Twister by default creates tests id including the path name in it. The problem is that it looks for the path as relative to zephyr dir. If it is oot, then the path depends on where it starts scaning, hence with different level of -T it gets different names hence -s doesn't match any more. I found it annoying and tried to fix, but this caused issues in other places. To resolve this problem I added In your case please try modifying the last part of your command to |
btw at windows you might also need |
It's the backslashes in the path to the test. They changed the direction.
|
|
when load test plan it is possible the plan is built in another os so the case key would be
'samples/hello_world/samples.baseic.hello_world'
but the testsuite is scaned in current os may in window and the key is like
'samples\hello_world\samples.baseic.hello_world'
use ps.path.normpath, will solve this.