summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/core/tests/test_runner.py
blob: 205464cfae951ffc4ce1bc0cb1abfbe7cd7ac9d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python3
#
# Copyright (C) 2016 Intel Corporation
#
# SPDX-License-Identifier: MIT
#

import unittest
import logging
import tempfile

from common import setup_sys_path, TestBase
setup_sys_path()

from oeqa.core.runner import OEStreamLogger

class TestRunner(TestBase):
    def test_stream_logger(self):
        fp = tempfile.TemporaryFile(mode='w+')

        logging.basicConfig(format='%(message)s', stream=fp)
        logger = logging.getLogger()
        logger.setLevel(logging.INFO)

        oeSL = OEStreamLogger(logger)

        lines = ['init', 'bigline_' * 65535, 'morebigline_' * 65535 * 4, 'end']
        for line in lines:
            oeSL.write(line)

        fp.seek(0)
        fp_lines = fp.readlines()
        for i, fp_line in enumerate(fp_lines):
            fp_line = fp_line.strip()
            self.assertEqual(lines[i], fp_line)

        fp.close()

if __name__ == '__main__':
    unittest.main()