From 27e1490bfcf2950f1610dd89758df8d7409194db Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Wed, 11 May 2022 21:50:11 +0200 Subject: [PATCH] examples: sd_card: fix example test not getting the expected name SD card example prints the line which looks like: Name: 00000 If only part of the line is received, the regular expression in the test still matches, and partial name is obtained. Later the example test expects to see the same name in the file read from the SD card. This check fails, because only partial name was received earlier. Fix by adding a CR to the regular expression so that the entire name is matched. --- examples/storage/sd_card/sdmmc/sd_card_example_test.py | 2 +- examples/storage/sd_card/sdspi/sd_card_example_test.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/storage/sd_card/sdmmc/sd_card_example_test.py b/examples/storage/sd_card/sdmmc/sd_card_example_test.py index d8130eed6c..7251aed5a0 100644 --- a/examples/storage/sd_card/sdmmc/sd_card_example_test.py +++ b/examples/storage/sd_card/sdmmc/sd_card_example_test.py @@ -16,7 +16,7 @@ def test_examples_sd_card_sdmmc(env, extra_data): # type: (ttfw_idf.Env.Env, No dut.expect('Filesystem mounted', timeout=60) # These lines are matched separately because of ASCII color codes in the output - name = dut.expect(re.compile(r'Name: (\w+)'), timeout=10)[0] + name = dut.expect(re.compile(r'Name: (\w+)\r'), timeout=10)[0] _type = dut.expect(re.compile(r'Type: (\S+)'), timeout=10)[0] speed = dut.expect(re.compile(r'Speed: (\S+)'), timeout=10)[0] size = dut.expect(re.compile(r'Size: (\S+)'), timeout=10)[0] diff --git a/examples/storage/sd_card/sdspi/sd_card_example_test.py b/examples/storage/sd_card/sdspi/sd_card_example_test.py index 209c6d9e16..2777599d36 100644 --- a/examples/storage/sd_card/sdspi/sd_card_example_test.py +++ b/examples/storage/sd_card/sdspi/sd_card_example_test.py @@ -16,7 +16,7 @@ def test_examples_sd_card_sdspi(env, extra_data): # type: (ttfw_idf.Env.Env, No dut.expect('Filesystem mounted', timeout=60) # These lines are matched separately because of ASCII color codes in the output - name = dut.expect(re.compile(r'Name: (\w+)'), timeout=20)[0] + name = dut.expect(re.compile(r'Name: (\w+)\r'), timeout=20)[0] _type = dut.expect(re.compile(r'Type: (\S+)'), timeout=20)[0] speed = dut.expect(re.compile(r'Speed: (\S+)'), timeout=20)[0] size = dut.expect(re.compile(r'Size: (\S+)'), timeout=20)[0]