test: stabilize test_efi_secboot
PATCH 1/1 test: stabilize test_efi_secboot
When setting up the console via function efi_console_register() we call query_console_serial(). This functions sends an escape sequence to the terminal to query the display size. The response is another escape sequence.
console.run_command_list() is looking for a regular expression '^==>'. If the escape sequence for the screen size precedes the prompt without a line break, no match is found.
When efi_disk_register() is called before efi_console_register() this leads to a test failuere of the UEFI secure boot tests.
We can avoid the problem if the first UEFI command passed to u_boot_console.run_command_list() produces output. This patch achieves this by appending '; echo' to the first UEFI related command of the problematic tests.
--- test/py/tests/test_efi_secboot/test_authvar.py | 8 ++++---- test/py/tests/test_efi_secboot/test_signed.py | 4 ++-- test/py/tests/test_efi_secboot/test_unsigned.py | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-)
test/py/tests/test_efi_secboot/test_authvar.py +4 -4
@@ -133,7 +133,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',
@@ -174,7 +174,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',
@@ -215,7 +215,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',
@@ -249,7 +249,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',
test/py/tests/test_efi_secboot/test_signed.py +2 -2
@@ -29,7 +29,7 @@ class TestEfiSignedImage(object): # Test Case 1a, run signed image if no db/dbx output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, - 'efidebug boot add 1 HELLO1 host 0:1 /helloworld.efi.signed ""', + 'efidebug boot add 1 HELLO1 host 0:1 /helloworld.efi.signed ""; echo', 'efidebug boot next 1', 'bootefi bootmgr']) assert(re.search('Hello, world!', ''.join(output)))
@@ -81,7 +81,7 @@ class TestEfiSignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 db.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 PK.auth',
test/py/tests/test_efi_secboot/test_unsigned.py +3 -3
@@ -30,7 +30,7 @@ class TestEfiUnsignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 KEK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK; echo', 'fatload host 0:1 4000000 PK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK']) assert(not re.search('Failed to set EFI variable', ''.join(output)))
@@ -58,7 +58,7 @@ class TestEfiUnsignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 db_hello.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize db', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize db; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 PK.auth',
@@ -82,7 +82,7 @@ class TestEfiUnsignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 db_hello.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 PK.auth',
--
2.26.2
PATCH 1/1 test: stabilize test_efi_secboot
Heinrich,
Quoted 11 lines · Heinrich Schuchardt
When setting up the console via function
efi_console_register()we callquery_console_serial(). This functions sends an escape sequence to the terminal to query the display size. The response is another escape sequence.
console.run_command_list()is looking for a regular expression '^==>'. If the escape sequence for the screen size precedes the prompt without a line break, no match is found.When
efi_disk_register()is called beforeefi_console_register()this leads to a test failuere of the UEFI secure boot tests.
Why does the order of those calls affect test results?
Quoted 4 lines
We can avoid the problem if the first UEFI command passed to
u_boot_console.run_command_list()produces output. This patch achieves this by appending '; echo' to the first UEFI related command of the problematic tests.
It looks to be a workaround.
We'd better have another approach to fix the problem. Otherwise, similar issues will occur again.
Thanks,
-Takahiro Akashi
Quoted 103 lines
Signed-off-by Heinrich Schuchardt <[email protected]>--- test/py/tests/test_efi_secboot/test_authvar.py | 8 ++++---- test/py/tests/test_efi_secboot/test_signed.py | 4 ++-- test/py/tests/test_efi_secboot/test_unsigned.py | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-)test/py/tests/test_efi_secboot/test_authvar.py +4
-4@@ -133,7 +133,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',@@ -174,7 +174,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',@@ -215,7 +215,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',@@ -249,7 +249,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',test/py/tests/test_efi_secboot/test_signed.py +2
-2@@ -29,7 +29,7 @@ class TestEfiSignedImage(object): # Test Case 1a, run signed image if no db/dbx output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, - 'efidebug boot add 1 HELLO1 host 0:1 /helloworld.efi.signed ""', + 'efidebug boot add 1 HELLO1 host 0:1 /helloworld.efi.signed ""; echo', 'efidebug boot next 1', 'bootefi bootmgr']) assert(re.search('Hello, world!', ''.join(output)))@@ -81,7 +81,7 @@ class TestEfiSignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 db.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 PK.auth',test/py/tests/test_efi_secboot/test_unsigned.py +3
-4@@ -30,7 +30,7 @@ class TestEfiUnsignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 KEK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK; echo', 'fatload host 0:1 4000000 PK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK']) assert(not re.search('Failed to set EFI variable', ''.join(output)))@@ -58,7 +58,7 @@ class TestEfiUnsignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 db_hello.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize db', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize db; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 PK.auth',@@ -82,7 +82,7 @@ class TestEfiUnsignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 db_hello.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 PK.auth', --2.26.2
PATCH 1/1 test: stabilize test_efi_secboot
Quoted 8 lines · AKASHI Takahiro
Heinrich,
Quoted 5 lines · Heinrich Schuchardt
When setting up the console via function
efi_console_register()we callquery_console_serial(). This functions sends an escape sequence to the terminal to query the display size. The response is another escape sequence.
Quoted 8 lines
Quoted 6 lines
console.run_command_list()is looking for a regular expression '^==>'. If the escape sequence for the screen size precedes the prompt without a line break, no match is found.When
efi_disk_register()is called beforeefi_console_register()this leads to a test failuere of the UEFI secure boot tests.Why does the order of those calls affect test results?
Please, have a look at function query_console_serial() and at run_command_list().
As described above:
'\e7\e[r\e[999;999H\e[6n\e8==>' cannot be matched by regular expression '^==>'.
Quoted 9 lines
Quoted 5 lines
We can avoid the problem if the first UEFI command passed to
u_boot_console.run_command_list()produces output. This patch achieves this by appending '; echo' to the first UEFI related command of the problematic tests.It looks to be a workaround.
We'd better have another approach to fix the problem. Otherwise, similar issues will occur again.
I would not like to change the logic in Python to detect the U-Boot prompt for something UEFI specific. And we need a method to determine the size of a serial console.
The current approach allowed me to merge your patch series which otherwise might not have reached the v2020.07 release. Did the problem not show up in your Travis CI testing?
If you have a better solution, we can easily merge your patch.
Best regards
Heinrich
Quoted 107 lines
Thanks,
-Takahiro AkashiQuoted 103 lines
Signed-off-by Heinrich Schuchardt <[email protected]>--- test/py/tests/test_efi_secboot/test_authvar.py | 8 ++++---- test/py/tests/test_efi_secboot/test_signed.py | 4 ++-- test/py/tests/test_efi_secboot/test_unsigned.py | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-)test/py/tests/test_efi_secboot/test_authvar.py +4
-4@@ -133,7 +133,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',@@ -174,7 +174,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',@@ -215,7 +215,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',@@ -249,7 +249,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',test/py/tests/test_efi_secboot/test_signed.py +2
-2@@ -29,7 +29,7 @@ class TestEfiSignedImage(object): # Test Case 1a, run signed image if no db/dbx output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, - 'efidebug boot add 1 HELLO1 host 0:1 /helloworld.efi.signed ""', + 'efidebug boot add 1 HELLO1 host 0:1 /helloworld.efi.signed ""; echo', 'efidebug boot next 1', 'bootefi bootmgr']) assert(re.search('Hello, world!', ''.join(output)))@@ -81,7 +81,7 @@ class TestEfiSignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 db.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 PK.auth',test/py/tests/test_efi_secboot/test_unsigned.py +3
-4@@ -30,7 +30,7 @@ class TestEfiUnsignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 KEK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK; echo', 'fatload host 0:1 4000000 PK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK']) assert(not re.search('Failed to set EFI variable', ''.join(output)))@@ -58,7 +58,7 @@ class TestEfiUnsignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 db_hello.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize db', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize db; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 PK.auth',@@ -82,7 +82,7 @@ class TestEfiUnsignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 db_hello.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 PK.auth', --2.26.2
PATCH 1/1 test: stabilize test_efi_secboot
Quoted 16 lines · Heinrich Schuchardt
Quoted 15 lines · AKASHI Takahiro
Heinrich,
Quoted 11 lines · Heinrich Schuchardt
When setting up the console via function
efi_console_register()we callquery_console_serial(). This functions sends an escape sequence to the terminal to query the display size. The response is another escape sequence.
console.run_command_list()is looking for a regular expression '^==>'. If the escape sequence for the screen size precedes the prompt without a line break, no match is found.When
efi_disk_register()is called beforeefi_console_register()this leads to a test failuere of the UEFI secure boot tests.
Quoted 8 lines
Quoted 1 line
Why does the order of those calls affect test results?
Please, have a look at function
query_console_serial()and atrun_command_list().As described above:
'\e7\e[r\e[999;999H\e[6n\e8==>' cannot be matched by regular expression '^==>'.
(Probably) right, but what I don't get here is why efi_disk_register() have an impact on efi_console_register(). The former function has nothing to do with any console behaviors.
Moreover, I wonder
- why you want to move efi_console_register() after efi_disk_register().
- why python script can see such escape sequences.
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines
We can avoid the problem if the first UEFI command passed to
u_boot_console.run_command_list()produces output. This patch achieves this by appending '; echo' to the first UEFI related command of the problematic tests.It looks to be a workaround.
We'd better have another approach to fix the problem. Otherwise, similar issues will occur again.
Quoted 7 lines
I would not like to change the logic in Python to detect the U-Boot prompt for something UEFI specific. And we need a method to determine the size of a serial console.
The current approach allowed me to merge your patch series which otherwise might not have reached the v2020.07 release. Did the problem not show up in your Travis CI testing?
No. If your saying is correct, this can happen only if efi_console_register() is moved after efi_disk_register(). Right?
Quoted 1 line
If you have a better solution, we can easily merge your patch.
First, I want to understand what's happening.
-Takahiro Akashi
Quoted 112 lines
Best regards
Heinrich
Quoted 107 lines
Thanks,
-Takahiro AkashiQuoted 103 lines
Signed-off-by Heinrich Schuchardt <[email protected]>--- test/py/tests/test_efi_secboot/test_authvar.py | 8 ++++---- test/py/tests/test_efi_secboot/test_signed.py | 4 ++-- test/py/tests/test_efi_secboot/test_unsigned.py | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-)test/py/tests/test_efi_secboot/test_authvar.py +4
-4@@ -133,7 +133,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',@@ -174,7 +174,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',@@ -215,7 +215,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',@@ -249,7 +249,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',test/py/tests/test_efi_secboot/test_signed.py +2
-2@@ -29,7 +29,7 @@ class TestEfiSignedImage(object): # Test Case 1a, run signed image if no db/dbx output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, - 'efidebug boot add 1 HELLO1 host 0:1 /helloworld.efi.signed ""', + 'efidebug boot add 1 HELLO1 host 0:1 /helloworld.efi.signed ""; echo', 'efidebug boot next 1', 'bootefi bootmgr']) assert(re.search('Hello, world!', ''.join(output)))@@ -81,7 +81,7 @@ class TestEfiSignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 db.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 PK.auth',test/py/tests/test_efi_secboot/test_unsigned.py +3
-4@@ -30,7 +30,7 @@ class TestEfiUnsignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 KEK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK; echo', 'fatload host 0:1 4000000 PK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK']) assert(not re.search('Failed to set EFI variable', ''.join(output)))@@ -58,7 +58,7 @@ class TestEfiUnsignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 db_hello.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize db', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize db; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 PK.auth',@@ -82,7 +82,7 @@ class TestEfiUnsignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 db_hello.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 PK.auth', --2.26.2
PATCH 1/1 test: stabilize test_efi_secboot
Heinrich,
Quoted 22 lines · AKASHI Takahiro
Quoted 21 lines · Heinrich Schuchardt
Quoted 8 lines · AKASHI Takahiro
Heinrich,
Quoted 5 lines · Heinrich Schuchardt
When setting up the console via function
efi_console_register()we callquery_console_serial(). This functions sends an escape sequence to the terminal to query the display size. The response is another escape sequence.Quoted 8 lines
Quoted 6 lines
console.run_command_list()is looking for a regular expression '^==>'. If the escape sequence for the screen size precedes the prompt without a line break, no match is found.When
efi_disk_register()is called beforeefi_console_register()this leads to a test failuere of the UEFI secure boot tests.Why does the order of those calls affect test results?
Please, have a look at function
query_console_serial()and atrun_command_list().
Quoted 7 lines
Quoted 3 lines
As described above:
'\e7\e[r\e[999;999H\e[6n\e8==>' cannot be matched by regular expression '^==>'.(Probably) right, but what I don't get here is why
efi_disk_register()have an impact onefi_console_register(). The former function has nothing to do with any console behaviors.
You have merged your patch without replying to my comment.
Quoted 3 lines
Moreover, I wonder
- why you want to moveefi_console_register()afterefi_disk_register().
- why python script can see such escape sequences.
I don't like your fix.
With your fixes, my secure boot pytest now fails to run on sandbox locally.
Instead, I propose:
1. revert your commits
commit 16ad946f41d3 ("efi_loader: change setup sequence") commit 5827c2545849 ("test: stabilize test_efi_secboot")
2. move efi_console_register() forward *before* efi_console_register()
Then my secure boot test should work again without any modification. I believe that my solution is much better than your workaround.
-Takahiro Akashi
Quoted 140 lines
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines
We can avoid the problem if the first UEFI command passed to
u_boot_console.run_command_list()produces output. This patch achieves this by appending '; echo' to the first UEFI related command of the problematic tests.It looks to be a workaround.
We'd better have another approach to fix the problem. Otherwise, similar issues will occur again.Quoted 7 lines
I would not like to change the logic in Python to detect the U-Boot prompt for something UEFI specific. And we need a method to determine the size of a serial console.
The current approach allowed me to merge your patch series which otherwise might not have reached the v2020.07 release. Did the problem not show up in your Travis CI testing?
No. If your saying is correct, this can happen only if
efi_console_register()is moved afterefi_disk_register(). Right?Quoted 1 line
If you have a better solution, we can easily merge your patch.
First, I want to understand what's happening.
-Takahiro Akashi
Quoted 112 lines
Best regards
Heinrich
Quoted 107 lines
Thanks,
-Takahiro AkashiQuoted 103 lines
Signed-off-by Heinrich Schuchardt <[email protected]>--- test/py/tests/test_efi_secboot/test_authvar.py | 8 ++++---- test/py/tests/test_efi_secboot/test_signed.py | 4 ++-- test/py/tests/test_efi_secboot/test_unsigned.py | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-)test/py/tests/test_efi_secboot/test_authvar.py +4
-4@@ -133,7 +133,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',@@ -174,7 +174,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',@@ -215,7 +215,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',@@ -249,7 +249,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',test/py/tests/test_efi_secboot/test_signed.py +2
-2@@ -29,7 +29,7 @@ class TestEfiSignedImage(object): # Test Case 1a, run signed image if no db/dbx output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, - 'efidebug boot add 1 HELLO1 host 0:1 /helloworld.efi.signed ""', + 'efidebug boot add 1 HELLO1 host 0:1 /helloworld.efi.signed ""; echo', 'efidebug boot next 1', 'bootefi bootmgr']) assert(re.search('Hello, world!', ''.join(output)))@@ -81,7 +81,7 @@ class TestEfiSignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 db.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 PK.auth',test/py/tests/test_efi_secboot/test_unsigned.py +3
-4@@ -30,7 +30,7 @@ class TestEfiUnsignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 KEK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK; echo', 'fatload host 0:1 4000000 PK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK']) assert(not re.search('Failed to set EFI variable', ''.join(output)))@@ -58,7 +58,7 @@ class TestEfiUnsignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 db_hello.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize db', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize db; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 PK.auth',@@ -82,7 +82,7 @@ class TestEfiUnsignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 db_hello.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 PK.auth', --2.26.2
PATCH 1/1 test: stabilize test_efi_secboot
Heinrich,
Quoted 29 lines · AKASHI Takahiro
Heinrich,
Quoted 26 lines · AKASHI Takahiro
Quoted 24 lines · Heinrich Schuchardt
Quoted 8 lines · AKASHI Takahiro
Heinrich,
Quoted 5 lines · Heinrich Schuchardt
When setting up the console via function
efi_console_register()we callquery_console_serial(). This functions sends an escape sequence to the terminal to query the display size. The response is another escape sequence.Quoted 8 lines
Quoted 6 lines
console.run_command_list()is looking for a regular expression '^==>'. If the escape sequence for the screen size precedes the prompt without a line break, no match is found.When
efi_disk_register()is called beforeefi_console_register()this leads to a test failuere of the UEFI secure boot tests.Why does the order of those calls affect test results?
Please, have a look at function
query_console_serial()and atrun_command_list().As described above:
'\e7\e[r\e[999;999H\e[6n\e8==>' cannot be matched by regular expression '^==>'.
Quoted 5 lines
Quoted 3 lines
(Probably) right, but what I don't get here is why
efi_disk_register()have an impact onefi_console_register(). The former function has nothing to do with any console behaviors.You have merged your patch without replying to my comment.
Not yet
Quoted 15 lines
Quoted 3 lines
Moreover, I wonder
- why you want to moveefi_console_register()afterefi_disk_register().
- why python script can see such escape sequences.I don't like your fix.
With your fixes, my secure boot pytest now fails to run on sandbox locally.Instead, I propose:
1. revert your commits
commit16ad946f41d3("efi_loader: change setup sequence") commit5827c2545849("test: stabilizetest_efi_secboot")
2. moveefi_console_register()forward *before*efi_console_register()
Quoted 2 lines
Then my secure boot test should work again without any modification. I believe that my solution is much better than your workaround.
Any comment?
Or do you want me to post a patch?
Quoted 142 lines
-Takahiro Akashi
Quoted 140 lines
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines
We can avoid the problem if the first UEFI command passed to
u_boot_console.run_command_list()produces output. This patch achieves this by appending '; echo' to the first UEFI related command of the problematic tests.It looks to be a workaround.
We'd better have another approach to fix the problem. Otherwise, similar issues will occur again.Quoted 7 lines
I would not like to change the logic in Python to detect the U-Boot prompt for something UEFI specific. And we need a method to determine the size of a serial console.
The current approach allowed me to merge your patch series which otherwise might not have reached the v2020.07 release. Did the problem not show up in your Travis CI testing?
No. If your saying is correct, this can happen only if
efi_console_register()is moved afterefi_disk_register(). Right?Quoted 1 line
If you have a better solution, we can easily merge your patch.
First, I want to understand what's happening.
-Takahiro Akashi
Quoted 112 lines
Best regards
Heinrich
Quoted 107 lines
Thanks,
-Takahiro AkashiQuoted 103 lines
Signed-off-by Heinrich Schuchardt <[email protected]>--- test/py/tests/test_efi_secboot/test_authvar.py | 8 ++++---- test/py/tests/test_efi_secboot/test_signed.py | 4 ++-- test/py/tests/test_efi_secboot/test_unsigned.py | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-)test/py/tests/test_efi_secboot/test_authvar.py +4
-4@@ -133,7 +133,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',@@ -174,7 +174,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',@@ -215,7 +215,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',@@ -249,7 +249,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',test/py/tests/test_efi_secboot/test_signed.py +2
-2@@ -29,7 +29,7 @@ class TestEfiSignedImage(object): # Test Case 1a, run signed image if no db/dbx output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, - 'efidebug boot add 1 HELLO1 host 0:1 /helloworld.efi.signed ""', + 'efidebug boot add 1 HELLO1 host 0:1 /helloworld.efi.signed ""; echo', 'efidebug boot next 1', 'bootefi bootmgr']) assert(re.search('Hello, world!', ''.join(output)))@@ -81,7 +81,7 @@ class TestEfiSignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 db.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 PK.auth',test/py/tests/test_efi_secboot/test_unsigned.py +3
-4@@ -30,7 +30,7 @@ class TestEfiUnsignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 KEK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK; echo', 'fatload host 0:1 4000000 PK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK']) assert(not re.search('Failed to set EFI variable', ''.join(output)))@@ -58,7 +58,7 @@ class TestEfiUnsignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 db_hello.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize db', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize db; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 PK.auth',@@ -82,7 +82,7 @@ class TestEfiUnsignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 db_hello.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 PK.auth', --2.26.2
PATCH 1/1 test: stabilize test_efi_secboot
Quoted 35 lines · AKASHI Takahiro
Heinrich,
Quoted 32 lines · AKASHI Takahiro
Heinrich,
Quoted 29 lines · AKASHI Takahiro
Quoted 16 lines · Heinrich Schuchardt
Quoted 15 lines · AKASHI Takahiro
Heinrich,
Quoted 11 lines · Heinrich Schuchardt
When setting up the console via function
efi_console_register()we callquery_console_serial(). This functions sends an escape sequence to the terminal to query the display size. The response is another escape sequence.
console.run_command_list()is looking for a regular expression '^==>'. If the escape sequence for the screen size precedes the prompt without a line break, no match is found.When
efi_disk_register()is called beforeefi_console_register()this leads to a test failuere of the UEFI secure boot tests.Quoted 8 lines
Quoted 1 line
Why does the order of those calls affect test results?
Please, have a look at function
query_console_serial()and atrun_command_list().As described above:
'\e7\e[r\e[999;999H\e[6n\e8==>' cannot be matched by regular expression '^==>'.(Probably) right, but what I don't get here is why
efi_disk_register()have an impact onefi_console_register(). The former function has nothing to do with any console behaviors.
efi_console_register writes ''\e7\e[r\e[999;999H\e[6n\e8' to the console.
efi_disk_register writes to the console, e.g. "Found 2 disks\n". This output occurs before the output of the command line prompt.
Now the Python test can match the regular expression '^==>' because the prompt is the first output on the line.
Quoted 2 lines
Quoted 2 lines
You have merged your patch without replying to my comment.
Your comment was written after my pull request.
Quoted 12 lines
Not yet
Quoted 7 lines
Quoted 3 lines
Moreover, I wonder
- why you want to moveefi_console_register()afterefi_disk_register().
- why python script can see such escape sequences.I don't like your fix.
With your fixes, my secure boot pytest now fails to run on sandbox locally.
Why is it failing?
Best regards
Heinrich
Quoted 158 lines
Quoted 10 lines
Instead, I propose:
1. revert your commits
commit16ad946f41d3("efi_loader: change setup sequence") commit5827c2545849("test: stabilizetest_efi_secboot")
2. moveefi_console_register()forward *before*efi_console_register()Then my secure boot test should work again without any modification. I believe that my solution is much better than your workaround.
Any comment?
Or do you want me to post a patch?Quoted 142 lines
-Takahiro Akashi
Quoted 140 lines
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines
We can avoid the problem if the first UEFI command passed to
u_boot_console.run_command_list()produces output. This patch achieves this by appending '; echo' to the first UEFI related command of the problematic tests.It looks to be a workaround.
We'd better have another approach to fix the problem. Otherwise, similar issues will occur again.Quoted 7 lines
I would not like to change the logic in Python to detect the U-Boot prompt for something UEFI specific. And we need a method to determine the size of a serial console.
The current approach allowed me to merge your patch series which otherwise might not have reached the v2020.07 release. Did the problem not show up in your Travis CI testing?
No. If your saying is correct, this can happen only if
efi_console_register()is moved afterefi_disk_register(). Right?Quoted 1 line
If you have a better solution, we can easily merge your patch.
First, I want to understand what's happening.
-Takahiro Akashi
Quoted 112 lines
Best regards
Heinrich
Quoted 107 lines
Thanks,
-Takahiro AkashiQuoted 103 lines
Signed-off-by Heinrich Schuchardt <[email protected]>--- test/py/tests/test_efi_secboot/test_authvar.py | 8 ++++---- test/py/tests/test_efi_secboot/test_signed.py | 4 ++-- test/py/tests/test_efi_secboot/test_unsigned.py | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-)test/py/tests/test_efi_secboot/test_authvar.py +4
-4@@ -133,7 +133,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',@@ -174,7 +174,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',@@ -215,7 +215,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',@@ -249,7 +249,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',test/py/tests/test_efi_secboot/test_signed.py +2
-2@@ -29,7 +29,7 @@ class TestEfiSignedImage(object): # Test Case 1a, run signed image if no db/dbx output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, - 'efidebug boot add 1 HELLO1 host 0:1 /helloworld.efi.signed ""', + 'efidebug boot add 1 HELLO1 host 0:1 /helloworld.efi.signed ""; echo', 'efidebug boot next 1', 'bootefi bootmgr']) assert(re.search('Hello, world!', ''.join(output)))@@ -81,7 +81,7 @@ class TestEfiSignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 db.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 PK.auth',test/py/tests/test_efi_secboot/test_unsigned.py +3
-4@@ -30,7 +30,7 @@ class TestEfiUnsignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 KEK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK; echo', 'fatload host 0:1 4000000 PK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK']) assert(not re.search('Failed to set EFI variable', ''.join(output)))@@ -58,7 +58,7 @@ class TestEfiUnsignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 db_hello.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize db', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize db; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 PK.auth',@@ -82,7 +82,7 @@ class TestEfiUnsignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 db_hello.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 PK.auth', --2.26.2
PATCH 1/1 test: stabilize test_efi_secboot
Heinrich,
Quoted 33 lines · Heinrich Schuchardt
Quoted 32 lines · AKASHI Takahiro
Heinrich,
Quoted 29 lines · AKASHI Takahiro
Heinrich,
Quoted 26 lines · AKASHI Takahiro
Quoted 24 lines · Heinrich Schuchardt
Quoted 8 lines · AKASHI Takahiro
Heinrich,
Quoted 5 lines · Heinrich Schuchardt
When setting up the console via function
efi_console_register()we callquery_console_serial(). This functions sends an escape sequence to the terminal to query the display size. The response is another escape sequence.Quoted 8 lines
Quoted 6 lines
console.run_command_list()is looking for a regular expression '^==>'. If the escape sequence for the screen size precedes the prompt without a line break, no match is found.When
efi_disk_register()is called beforeefi_console_register()this leads to a test failuere of the UEFI secure boot tests.Why does the order of those calls affect test results?
Please, have a look at function
query_console_serial()and atrun_command_list().As described above:
'\e7\e[r\e[999;999H\e[6n\e8==>' cannot be matched by regular expression '^==>'.
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
(Probably) right, but what I don't get here is why
efi_disk_register()have an impact onefi_console_register(). The former function has nothing to do with any console behaviors.
efi_console_registerwrites ''\e7\e[r\e[999;999H\e[6n\e8' to the console.
efi_disk_registerwrites to the console, e.g. "Found 2 disks\n". This output occurs before the output of the command line prompt.
How on earth the output can occur *before* the command line?
After applying your patch to efi_setup.c, the sequence of initialization looks like:
efi_init_obj_list()
efi_disk_register()
efi_console_register()
But anyhow, efi_init_obj_list() will be called when the first "efi" command is executed.
Therefore, the captured output of console must be logically
1. text of command line (efi command)
2. output from efi_init_obj_list()
2.1 output from efi_disk_register()
2.2 output from efi_console_register()
Again, why can the output (2.1) lead to (1)?
As a matter of fact, the real output log from pytest clearly shows the order of output:
(I left html tags as they are.)
=== from test-log.html of pytest ===
<html>
...
U-Boot 2020.07-rc2-00021-gbd934e4844d5-dirty (May 21 2020 - 18:25:14 +0900)
Model: sandbox DRAM: 128 MiB WDT: Started with servicing (60s timeout) MMC: mmc2: 2 (SD), mmc1: 1 (SD), mmc0: 0 (SD) In: serial Out: vidconsole Err: vidconsole Model: sandbox SCSI: Net: eth0: eth at 10002000, eth5: eth at 10003000, eth3: sbe5, eth1: eth at 10004000 Hit any key to stop autoboot: 2 %08%08%08 0
=> </pre>
...
U-Boot 2020.07-rc2-00021-gbd934e4844d5-dirty (May 21 2020 - 18:25:14 +0900)
Model: sandbox DRAM: 128 MiB WDT: Started with servicing (60s timeout) MMC: mmc2: 2 (SD), mmc1: 1 (SD), mmc0: 0 (SD) In: serial Out: vidconsole Err: vidconsole Model: sandbox SCSI: Net: eth0: eth at 10002000, eth5: eth at 10003000, eth3: sbe5, eth1: eth at 10004000 Hit any key to stop autoboot: 2 %08%08%08 0
=> </pre>
...
<pre><span class="implicit">=> </span>fatload host 0:1 4000000 KEK.auth 2045 bytes read in 0 ms
=> </pre>
...
<pre><span class="implicit">=> </span>setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK Scanning disk mmc2.blk...
** Unrecognized filesystem type **
Scanning disk mmc1.blk...
** Unrecognized filesystem type **
Scanning disk mmc0.blk...
** Unrecognized filesystem type **
Scanning disk host0...
Found 5 disks
%1b7%1b[r%1b[999;999H%1b[6n%1b8=> </pre>
...
</html>
=== end of log ===
Quoted 2 lines
Now the Python test can match the regular expression '^==>' because the prompt is the first output on the line.
No. Python failed to match against "^==>."
-Takahiro Akashi
Quoted 183 lines
Quoted 2 lines
Quoted 2 lines
You have merged your patch without replying to my comment.
Your comment was written after my pull request.
Quoted 12 lines
Not yet
Quoted 7 lines
Quoted 3 lines
Moreover, I wonder
- why you want to moveefi_console_register()afterefi_disk_register().
- why python script can see such escape sequences.I don't like your fix.
With your fixes, my secure boot pytest now fails to run on sandbox locally.Why is it failing?
Best regards
Heinrich
Quoted 158 lines
Quoted 10 lines
Instead, I propose:
1. revert your commits
commit16ad946f41d3("efi_loader: change setup sequence") commit5827c2545849("test: stabilizetest_efi_secboot")
2. moveefi_console_register()forward *before*efi_console_register()Then my secure boot test should work again without any modification. I believe that my solution is much better than your workaround.
Any comment?
Or do you want me to post a patch?Quoted 142 lines
-Takahiro Akashi
Quoted 140 lines
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines
We can avoid the problem if the first UEFI command passed to
u_boot_console.run_command_list()produces output. This patch achieves this by appending '; echo' to the first UEFI related command of the problematic tests.It looks to be a workaround.
We'd better have another approach to fix the problem. Otherwise, similar issues will occur again.Quoted 7 lines
I would not like to change the logic in Python to detect the U-Boot prompt for something UEFI specific. And we need a method to determine the size of a serial console.
The current approach allowed me to merge your patch series which otherwise might not have reached the v2020.07 release. Did the problem not show up in your Travis CI testing?
No. If your saying is correct, this can happen only if
efi_console_register()is moved afterefi_disk_register(). Right?Quoted 1 line
If you have a better solution, we can easily merge your patch.
First, I want to understand what's happening.
-Takahiro Akashi
Quoted 112 lines
Best regards
Heinrich
Quoted 107 lines
Thanks,
-Takahiro AkashiQuoted 103 lines
Signed-off-by Heinrich Schuchardt <[email protected]>--- test/py/tests/test_efi_secboot/test_authvar.py | 8 ++++---- test/py/tests/test_efi_secboot/test_signed.py | 4 ++-- test/py/tests/test_efi_secboot/test_unsigned.py | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-)test/py/tests/test_efi_secboot/test_authvar.py +4
-4@@ -133,7 +133,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',@@ -174,7 +174,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',@@ -215,7 +215,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',@@ -249,7 +249,7 @@ class TestEfiAuthVar(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 PK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 db.auth',test/py/tests/test_efi_secboot/test_signed.py +2
-2@@ -29,7 +29,7 @@ class TestEfiSignedImage(object): # Test Case 1a, run signed image if no db/dbx output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, - 'efidebug boot add 1 HELLO1 host 0:1 /helloworld.efi.signed ""', + 'efidebug boot add 1 HELLO1 host 0:1 /helloworld.efi.signed ""; echo', 'efidebug boot next 1', 'bootefi bootmgr']) assert(re.search('Hello, world!', ''.join(output)))@@ -81,7 +81,7 @@ class TestEfiSignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 db.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 PK.auth',test/py/tests/test_efi_secboot/test_unsigned.py +3
-4@@ -30,7 +30,7 @@ class TestEfiUnsignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 KEK.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK; echo', 'fatload host 0:1 4000000 PK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize PK']) assert(not re.search('Failed to set EFI variable', ''.join(output)))@@ -58,7 +58,7 @@ class TestEfiUnsignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 db_hello.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize db', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize db; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 PK.auth',@@ -82,7 +82,7 @@ class TestEfiUnsignedImage(object): output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatload host 0:1 4000000 db_hello.auth', - 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx', + 'setenv -e -nv -bs -rt -at -i 4000000,$filesize dbx; echo', 'fatload host 0:1 4000000 KEK.auth', 'setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK', 'fatload host 0:1 4000000 PK.auth', --2.26.2
PATCH 1/1 test: stabilize test_efi_secboot
Quoted 126 lines · AKASHI Takahiro
Heinrich,
Quoted 33 lines · Heinrich Schuchardt
Quoted 32 lines · AKASHI Takahiro
Heinrich,
Quoted 29 lines · AKASHI Takahiro
Heinrich,
Quoted 26 lines · AKASHI Takahiro
Quoted 24 lines · Heinrich Schuchardt
Quoted 8 lines · AKASHI Takahiro
Heinrich,
Quoted 5 lines · Heinrich Schuchardt
When setting up the console via function
efi_console_register()we callquery_console_serial(). This functions sends an escape sequence to the terminal to query the display size. The response is another escape sequence.Quoted 8 lines
Quoted 6 lines
console.run_command_list()is looking for a regular expression '^==>'. If the escape sequence for the screen size precedes the prompt without a line break, no match is found.When
efi_disk_register()is called beforeefi_console_register()this leads to a test failuere of the UEFI secure boot tests.Why does the order of those calls affect test results?
Please, have a look at function
query_console_serial()and atrun_command_list().As described above:
'\e7\e[r\e[999;999H\e[6n\e8==>' cannot be matched by regular expression '^==>'.Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
(Probably) right, but what I don't get here is why
efi_disk_register()have an impact onefi_console_register(). The former function has nothing to do with any console behaviors.
efi_console_registerwrites ''\e7\e[r\e[999;999H\e[6n\e8' to the console.
efi_disk_registerwrites to the console, e.g. "Found 2 disks\n". This output occurs before the output of the command line prompt.How on earth the output can occur *before* the command line?
After applying your patch to
efi_setup.c, the sequence of initialization looks like:efi_init_obj_list() efi_disk_register() efi_console_register()But anyhow,
efi_init_obj_list()will be called when the first "efi" command is executed.
Therefore, the captured output of console must be logically
1. text of command line (efi command)
2. output fromefi_init_obj_list()
2.1 output fromefi_disk_register()
2.2 output fromefi_console_register()Again, why can the output (2.1) lead to (1)?
As a matter of fact, the real output log from pytest clearly shows the order of output:
(I left html tags as they are.)=== from test-log.html of pytest ===
<html>
...
U-Boot 2020.07-rc2-00021-gbd934e4844d5-dirty (May 21 2020 - 18:25:14 +0900)Model: sandbox DRAM: 128 MiB WDT: Started with servicing (60s timeout) MMC: mmc2: 2 (SD), mmc1: 1 (SD), mmc0: 0 (SD) In: serial Out: vidconsole Err: vidconsole Model: sandbox SCSI: Net: eth0: eth at 10002000, eth5: eth at 10003000, eth3: sbe5, eth1: eth at 10004000 Hit any key to stop autoboot: 2 %08%08%08 0=> </pre>
...
U-Boot 2020.07-rc2-00021-gbd934e4844d5-dirty (May 21 2020 - 18:25:14 +0900)
Model: sandbox DRAM: 128 MiB WDT: Started with servicing (60s timeout) MMC: mmc2: 2 (SD), mmc1: 1 (SD), mmc0: 0 (SD) In: serial Out: vidconsole Err: vidconsole Model: sandbox SCSI: Net: eth0: eth at 10002000, eth5: eth at 10003000, eth3: sbe5, eth1: eth at 10004000 Hit any key to stop autoboot: 2 %08%08%08 0=> </pre>
...
<pre><span class="implicit">=> </span>fatload host 0:1 4000000 KEK.auth 2045 bytes read in 0 ms
=> </pre>...
<pre><span class="implicit">=> </span>setenv -e -nv -bs -rt -at -i 4000000,$filesize KEK Scanning disk mmc2.blk...
** Unrecognized filesystem type **
Scanning disk mmc1.blk...
** Unrecognized filesystem type **
Scanning disk mmc0.blk...
** Unrecognized filesystem type **
Scanning disk host0...
Found 5 disks
%1b7%1b[r%1b[999;999H%1b[6n%1b8=> </pre>...
</html>
=== end of log ===
Quoted 6 lines
Quoted 2 lines
Now the Python test can match the regular expression '^==>' because the prompt is the first output on the line.
No. Python failed to match against "^==>."
-Takahiro Akashi
Hello Takahiro,
I did my best to get your patches merged. If you have a better solution that works in Gitlab CI and Travis CI, please, send a patch.
Best regards
Heinrich