# - Implementing custom pytest markers.
import atexit
+import configparser
import errno
+import io
import os
import os.path
import pytest
-from _pytest.runner import runtestprotocol
import re
-import io
+from _pytest.runner import runtestprotocol
import sys
-import configparser
-
# Globals: The HTML log file, and the connection to the U-Boot console.
log = None
console = None
ini_str = '[root]\n' + f.read()
ini_sio = io.StringIO(ini_str)
parser = configparser.RawConfigParser()
- parser.readfp(ini_sio)
+ parser.read_file(ini_sio)
ubconfig.buildconfig.update(parser.items('root'))
ubconfig.test_py_dir = test_py_dir
"""Write data to the log stream.
Args:
- data: The data to write tot he file.
+ data: The data to write to the file.
implicit: Boolean indicating whether data actually appeared in the
stream, or was implicitly generated. A valid use-case is to
repeat a shell prompt at the start of each separate log
self.logfile.write(self, data, implicit)
if self.chained_file:
- self.chained_file.write(data)
+ # Chained file is console, convert things a little
+ self.chained_file.write((data.encode('ascii', 'replace')).decode())
def flush(self):
"""Flush the log stream, to ensure correct log interleaving.
p = subprocess.Popen(cmd, cwd=cwd,
stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
(stdout, stderr) = p.communicate()
+ if stdout is not None:
+ stdout = stdout.decode('utf-8')
+ if stderr is not None:
+ stderr = stderr.decode('utf-8')
output = ''
if stdout:
if stderr:
Nothing.
"""
- self.f = open(fn, 'wt')
+ self.f = open(fn, 'wt', encoding='utf-8')
self.last_stream = None
self.blocks = []
self.cur_evt = 1
markers =
boardspec: U-Boot: Describes the set of boards a test can/can't run on.
buildconfigspec: U-Boot: Describes Kconfig/config-header constraints.
+ notbuildconfigspec: U-Boot: Describes required disabled Kconfig options.
+ requiredtool: U-Boot: Required host tools for a test.
+ slow: U-Boot: Specific test will run slowly.
src = make_fname('u-boot.dts')
dtb = make_fname('u-boot.dtb')
with open(src, 'w') as fd:
- print(base_fdt, file=fd)
+ fd.write(base_fdt)
util.run_and_log(cons, ['dtc', src, '-O', 'dtb', '-o', dtb])
return dtb
its = make_its(params)
util.run_and_log(cons, [mkimage, '-f', its, fit])
with open(make_fname('u-boot.dts'), 'w') as fd:
- print(base_fdt, file=fd)
+ fd.write(base_fdt)
return fit
def make_kernel(filename, text):
Nothing.
"""
- os.write(self.fd, data)
+ os.write(self.fd, data.encode(errors='replace'))
def expect(self, patterns):
"""Wait for the sub-process to emit specific data.
events = self.poll.poll(poll_maxwait)
if not events:
raise Timeout()
- c = os.read(self.fd, 1024)
+ c = os.read(self.fd, 1024).decode(errors='replace')
if not c:
raise EOFError()
if self.logfile_read: