Skip to content

Commit

Permalink
travis-ci: provide 'addr' in file2env()
Browse files Browse the repository at this point in the history
Function fetch_tftp_file() in test/py/tests/test_efi_loader.py expects that
the dictionary describing a file contains an entry 'addr' specifying the
loading address.

Add an optional parameter in function file2env() to set the 'addr' entry.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
  • Loading branch information
xypron authored and nvswarren committed Dec 6, 2019
1 parent 3eb8312 commit b587ec7
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions py/travis-ci/travis_tftp.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
import os
import binascii

def file2env(file_name):
def file2env(file_name, addr=None):
"""Create dictionary describing file
@filename: name of the file to be described
@addr: address used for loading the file as int (e.g. 0x40400000)
Return: dictionary describing the file with entries
* fn - filename
* size - file size in bytes
* crc32 - checksum using CRC-32 algorithm
* addr - loading address, optional
"""
file_full = os.environ['UBOOT_TRAVIS_BUILD_DIR'] + "/" + file_name

if not os.path.isfile(file_full):
return None

return {
ret = {
"fn": file_name,
"size": os.path.getsize(file_full),
"crc32": hex(binascii.crc32(open(file_full, 'rb').read()) & 0xffffffff)[2:],
}
if addr is not None:
ret['addr'] = addr

return ret

0 comments on commit b587ec7

Please sign in to comment.