oeqa/runtime/parselogs: improve find call

getLogList() uses remote find invocations to find the logs. Instead of
relying on shell expansion of wildcards and redundant use of -maxdepth
(pointless as the shell expansion means the find is passed the files to
return), invoke find idiomatically by telling it what directory to
search for and escape the glob so find processes it.

Also remove many pointless str() calls.

(From OE-Core rev: 03bb14cebf5879472a8da78d892ecd5c5df5c3cf)

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Ross Burton
2023-09-23 14:04:07 +01:00
committed by Richard Purdie
parent 6a660d8b44
commit c7957aeeb5

View File

@@ -229,18 +229,18 @@ class ParseLogsTest(OERuntimeTestCase):
def getLogList(self, log_locations):
logs = []
for location in log_locations:
status, _ = self.target.run('test -f ' + str(location))
status, _ = self.target.run('test -f %s' % location)
if status == 0:
logs.append(str(location))
logs.append(location)
else:
status, _ = self.target.run('test -d ' + str(location))
status, _ = self.target.run('test -d %s' % location)
if status == 0:
cmd = 'find ' + str(location) + '/*.log -maxdepth 1 -type f'
cmd = 'find %s -name \\*.log -maxdepth 1 -type f' % location
status, output = self.target.run(cmd)
if status == 0:
output = output.splitlines()
for logfile in output:
logs.append(os.path.join(location, str(logfile)))
logs.append(os.path.join(location, logfile))
return logs
# Copy the log files to be parsed locally