From: Liam Beguin <liambeguin@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 6/7] test/py: add generic CRC32 function
Date: Tue, 13 Mar 2018 22:03:06 -0400 [thread overview]
Message-ID: <20180314020307.23475-7-liambeguin@gmail.com> (raw)
In-Reply-To: <20180314020307.23475-1-liambeguin@gmail.com>
Add a generic function which can be used to compute the CRC32 value of
a region of RAM.
Signed-off-by: Liam Beguin <liambeguin@gmail.com>
---
test/py/u_boot_utils.py | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/test/py/u_boot_utils.py b/test/py/u_boot_utils.py
index 64584494e463..de9ee2643f51 100644
--- a/test/py/u_boot_utils.py
+++ b/test/py/u_boot_utils.py
@@ -11,6 +11,7 @@ import os.path
import pytest
import sys
import time
+import re
def md5sum_data(data):
"""Calculate the MD5 hash of some data.
@@ -310,3 +311,25 @@ def persistent_file_helper(u_boot_log, filename):
"""
return PersistentFileHelperCtxMgr(u_boot_log, filename)
+
+def crc32(u_boot_console, address, count):
+ """Helper function used to compute the CRC32 value of a section of RAM.
+
+ Args:
+ u_boot_console: A U-Boot console connection.
+ address: Address where data starts.
+ count: Amount of data to use for calculation.
+
+ Returns:
+ CRC32 value
+ """
+
+ bcfg = u_boot_console.config.buildconfig
+ has_cmd_crc32 = bcfg.get('config_cmd_crc32', 'n') == 'y'
+ assert has_cmd_crc32, 'Cannot compute crc32 without CONFIG_CMD_CRC32.'
+ output = u_boot_console.run_command('crc32 %08x %x' % (address, count))
+
+ m = re.search('==> ([0-9a-fA-F]{8})$', output)
+ assert m, 'CRC32 operation failed.'
+
+ return m.group(1)
--
2.16.1.72.g5be1f00a9a70
next prev parent reply other threads:[~2018-03-14 2:03 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-14 2:03 [U-Boot] [PATCH v3 0/7] add inital SF tests Liam Beguin
2018-03-14 2:03 ` [U-Boot] [PATCH v3 1/7] spi: spi_flash: do not fail silently on bad user input Liam Beguin
2018-03-14 2:03 ` [U-Boot] [PATCH v3 2/7] cmd: sf: fix map_physmem check Liam Beguin
2018-03-14 2:03 ` [U-Boot] [PATCH v3 3/7] test/py: README: fix typo Liam Beguin
2018-03-14 2:03 ` [U-Boot] [PATCH v3 4/7] test/py: README: add HOSTNAME to PYTHONPATH Liam Beguin
2018-03-14 2:03 ` [U-Boot] [PATCH v3 5/7] test/py: do not import pytest multiple times Liam Beguin
2018-03-14 2:03 ` Liam Beguin [this message]
2018-03-14 2:03 ` [U-Boot] [PATCH v3 7/7] test/py: add spi_flash tests Liam Beguin
2018-03-14 14:35 ` Michal Simek
2018-03-14 15:59 ` Liam Beguin
2018-03-15 6:35 ` Michal Simek
2018-03-14 16:17 ` Stephen Warren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180314020307.23475-7-liambeguin@gmail.com \
--to=liambeguin@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox