Skip to content
Snippets Groups Projects
Commit 5269c1c0 authored by Alyssa Ross's avatar Alyssa Ross Committed by Chris Lamb
Browse files

Fix diffing CBFS names containing spaces

The first entry in my coreboot.rom is called "cbfs master header", so
the previous behaviour of splitting on whitespace would try to extract
a non-existent file named "cbfs".

The -k argument to cbfstool print tells it to use "machine-readable"
output, which means fields are separated with tabs.  I don't think
there's any way to handle a name that actually contains a tab
character (we can't assume name is the nth last field because the
number of fields is variable), so we just have to hope that doesn't
come up.
parent 21fc4d7d
No related branches found
No related tags found
1 merge request!102Fix diffing CBFS names containing spaces
Pipeline #343019 passed
......@@ -52,7 +52,7 @@ class CbfsListing(Command):
class CbfsContainer(Archive):
@tool_required("cbfstool")
def entries(self, path):
cmd = ["cbfstool", path, "print"]
cmd = ["cbfstool", path, "print", "-k"]
output = our_check_output(cmd).decode("utf-8")
header = True
for line in output.rstrip("\n").split("\n"):
......@@ -60,7 +60,7 @@ class CbfsContainer(Archive):
if line.startswith("Name"):
header = False
continue
name = line.split()[0]
name = line.split("\t", 1)[0]
if name == "(empty)":
continue
yield name
......
......@@ -51,7 +51,7 @@ def rom1(tmpdir):
"-f",
TEST_FILE1_PATH,
"-n",
"text",
"test file",
"-t",
"raw",
),
......@@ -77,7 +77,7 @@ def rom2(tmpdir):
"-f",
TEST_FILE2_PATH,
"-n",
"text",
"test file",
"-t",
"raw",
),
......@@ -128,13 +128,13 @@ def test_listing(differences):
# and the git log of this file), perform only these basic coherence check.
assert differences[0].source1.startswith("cbfstool")
assert re.search(r"\+text\s.*\sraw\s", differences[0].unified_diff)
assert re.search(r"\+test file\s.*\sraw\s", differences[0].unified_diff)
@skip_unless_tools_exist("cbfstool")
def test_content(differences):
assert differences[1].source1 == "text"
assert differences[1].source2 == "text"
assert differences[1].source1 == "test file"
assert differences[1].source2 == "test file"
expected_diff = get_data("text_ascii_expected_diff")
assert differences[1].unified_diff == expected_diff
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment