Skip to content

Commit 609952c

Browse files
sj-awsshuahkh
authored andcommitted
kunit: Place 'test.log' under the 'build_dir'
'kunit' writes the 'test.log' under the kernel source directory even though a 'build_dir' option is given. As users who use the option might expect the outputs to be placed under the specified directory, this commit modifies the logic to write the log file under the 'build_dir'. Signed-off-by: SeongJae Park <sjpark@amazon.de> Reviewed-by: Brendan Higgins <brendanhiggins@google.com> Tested-by: Brendan Higgins <brendanhiggins@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent e321251 commit 609952c

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

tools/testing/kunit/kunit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def main(argv, linux=None):
105105
run_parser.add_argument('--build_dir',
106106
help='As in the make command, it specifies the build '
107107
'directory.',
108-
type=str, default=None, metavar='build_dir')
108+
type=str, default='', metavar='build_dir')
109109

110110
run_parser.add_argument('--defconfig',
111111
help='Uses a default kunitconfig.',

tools/testing/kunit/kunit_kernel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ def build_um_kernel(self, jobs, build_dir):
140140
return False
141141
return True
142142

143-
def run_kernel(self, args=[], timeout=None, build_dir=None):
143+
def run_kernel(self, args=[], timeout=None, build_dir=''):
144144
args.extend(['mem=256M'])
145145
process = self._ops.linux_bin(args, timeout, build_dir)
146-
with open('test.log', 'w') as f:
146+
with open(os.path.join(build_dir, 'test.log'), 'w') as f:
147147
for line in process.stdout:
148148
f.write(line.rstrip().decode('ascii') + '\n')
149149
yield line.rstrip().decode('ascii')

tools/testing/kunit/kunit_tool_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def test_run_timeout(self):
199199
timeout = 3453
200200
kunit.main(['run', '--timeout', str(timeout)], self.linux_source_mock)
201201
assert self.linux_source_mock.build_reconfig.call_count == 1
202-
self.linux_source_mock.run_kernel.assert_called_once_with(build_dir=None, timeout=timeout)
202+
self.linux_source_mock.run_kernel.assert_called_once_with(build_dir='', timeout=timeout)
203203
self.print_mock.assert_any_call(StrContains('Testing complete.'))
204204

205205
if __name__ == '__main__':

0 commit comments

Comments
 (0)