kunit: Place 'test.log' under the 'build_dir'
authorSeongJae Park <sjpark@amazon.de>
Fri, 20 Dec 2019 05:14:06 +0000 (05:14 +0000)
committerShuah Khan <skhan@linuxfoundation.org>
Mon, 23 Dec 2019 17:52:41 +0000 (10:52 -0700)
'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>
tools/testing/kunit/kunit.py
tools/testing/kunit/kunit_kernel.py
tools/testing/kunit/kunit_tool_test.py

index 5b22241..e4250c4 100755 (executable)
@@ -105,7 +105,7 @@ def main(argv, linux=None):
        run_parser.add_argument('--build_dir',
                                help='As in the make command, it specifies the build '
                                'directory.',
-                               type=str, default=None, metavar='build_dir')
+                               type=str, default='', metavar='build_dir')
 
        run_parser.add_argument('--defconfig',
                                help='Uses a default kunitconfig.',
index c04a12e..a10c0c7 100644 (file)
@@ -140,10 +140,10 @@ class LinuxSourceTree(object):
                        return False
                return True
 
-       def run_kernel(self, args=[], timeout=None, build_dir=None):
+       def run_kernel(self, args=[], timeout=None, build_dir=''):
                args.extend(['mem=256M'])
                process = self._ops.linux_bin(args, timeout, build_dir)
-               with open('test.log', 'w') as f:
+               with open(os.path.join(build_dir, 'test.log'), 'w') as f:
                        for line in process.stdout:
                                f.write(line.rstrip().decode('ascii') + '\n')
                                yield line.rstrip().decode('ascii')
index a2a8ea6..22f16e6 100755 (executable)
@@ -199,7 +199,7 @@ class KUnitMainTest(unittest.TestCase):
                timeout = 3453
                kunit.main(['run', '--timeout', str(timeout)], self.linux_source_mock)
                assert self.linux_source_mock.build_reconfig.call_count == 1
-               self.linux_source_mock.run_kernel.assert_called_once_with(build_dir=None, timeout=timeout)
+               self.linux_source_mock.run_kernel.assert_called_once_with(build_dir='', timeout=timeout)
                self.print_mock.assert_any_call(StrContains('Testing complete.'))
 
 if __name__ == '__main__':