All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] travis: Add efi_loader grub2 test
Date: Fri, 18 Nov 2016 13:18:00 +0100	[thread overview]
Message-ID: <1479471480-164355-1-git-send-email-agraf@suse.de> (raw)

We have all the building blocks now to run arbitrary efi applications
in travis. The most important one out there is grub2, so let's add
a simple test to verify that grub2 still comes up.

Signed-off-by: Alexander Graf <agraf@suse.de>

---

This patch depends on the previous travis efi_loader enablement

v1 -> v2:

  - Fix syntax errors
  - Make SMBIOS check conditional (missing cmd on armv7 binary)
---
 .travis.yml                      |  8 ++++++
 test/py/tests/test_efi_loader.py | 57 +++++++++++++++++++++++++++++++++-------
 2 files changed, 55 insertions(+), 10 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 1957734..b4ae71a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -29,6 +29,9 @@ addons:
     - gcc-arm-linux-gnueabihf
     - gcc-aarch64-linux-gnu
     - iasl
+    - grub-efi-ia32-bin
+    - rpm2cpio
+    - wget
 
 install:
  # install latest device tree compiler
@@ -45,6 +48,9 @@ install:
  - virtualenv /tmp/venv
  - . /tmp/venv/bin/activate
  - pip install pytest
+ - grub-mkimage -o ~/grub_x86.efi -O i386-efi normal  echo lsefimmap lsefi lsefisystab efinet tftp minicmd
+ - mkdir ~/grub2-arm
+ - ( cd ~/grub2-arm; wget -O - http://download.opensuse.org/ports/armv7hl/distribution/leap/42.2/repo/oss/suse/armv7hl/grub2-arm-efi-2.02~beta2-87.1.armv7hl.rpm | rpm2cpio | cpio -di )
 
 env:
   global:
@@ -88,6 +94,8 @@ script:
  # "-k something" even when $TEST_PY_TEST_SPEC doesnt need a custom
  # value.
  - export UBOOT_TRAVIS_BUILD_DIR=`cd .. && pwd`/.bm-work/${TEST_PY_BD};
+   cp ~/grub_x86.efi $UBOOT_TRAVIS_BUILD_DIR/;
+   cp ~/grub2-arm/usr/lib/grub2/arm-efi/grub.efi $UBOOT_TRAVIS_BUILD_DIR/grub_arm.efi;
    if [[ "${TEST_PY_BD}" != "" ]]; then
      ./test/py/test.py --bd ${TEST_PY_BD} ${TEST_PY_ID}
        -k "${TEST_PY_TEST_SPEC:-not a_test_which_does_not_exist}"
diff --git a/test/py/tests/test_efi_loader.py b/test/py/tests/test_efi_loader.py
index 7bf0170..5d7f5db 100644
--- a/test/py/tests/test_efi_loader.py
+++ b/test/py/tests/test_efi_loader.py
@@ -104,20 +104,18 @@ def test_efi_setup_static(u_boot_console):
     global net_set_up
     net_set_up = True
 
- at pytest.mark.buildconfigspec('cmd_bootefi_hello_compile')
-def test_efi_helloworld_net(u_boot_console):
-    """Run the helloworld.efi binary via TFTP.
+def fetch_tftp_file(u_boot_console, env_conf):
+    """Grab an env described file via TFTP and return its address
 
-    The helloworld.efi file is downloaded from the TFTP server and gets
-    executed.
+    A file as described by an env config <env_conf> is downloaded from the TFTP
+    server. The address to that file is returned.
     """
-
     if not net_set_up:
         pytest.skip('Network not initialized')
 
-    f = u_boot_console.config.env.get('env__efi_loader_helloworld_file', None)
+    f = u_boot_console.config.env.get(env_conf, None)
     if not f:
-        pytest.skip('No hello world binary specified in environment')
+        pytest.skip('No %s binary specified in environment' % env_conf)
 
     addr = f.get('addr', None)
     if not addr:
@@ -133,14 +131,26 @@ def test_efi_helloworld_net(u_boot_console):
 
     expected_crc = f.get('crc32', None)
     if not expected_crc:
-        return
+        return addr
 
     if u_boot_console.config.buildconfig.get('config_cmd_crc32', 'n') != 'y':
-        return
+        return addr
 
     output = u_boot_console.run_command('crc32 %x $filesize' % addr)
     assert expected_crc in output
 
+    return addr
+
+ at pytest.mark.buildconfigspec('cmd_bootefi_hello_compile')
+def test_efi_helloworld_net(u_boot_console):
+    """Run the helloworld.efi binary via TFTP.
+
+    The helloworld.efi file is downloaded from the TFTP server and gets
+    executed.
+    """
+
+    addr = fetch_tftp_file(u_boot_console, 'env__efi_loader_helloworld_file')
+
     output = u_boot_console.run_command('bootefi %x' % addr)
     expected_text = 'Hello, world'
     assert expected_text in output
@@ -156,3 +166,30 @@ def test_efi_helloworld_builtin(u_boot_console):
     output = u_boot_console.run_command('bootefi hello')
     expected_text = 'Hello, world'
     assert expected_text in output
+
+ at pytest.mark.buildconfigspec('cmd_bootefi')
+def test_efi_grub_net(u_boot_console):
+    """Run the grub.efi binary via TFTP.
+
+    The grub.efi file is downloaded from the TFTP server and gets
+    executed.
+    """
+
+    addr = fetch_tftp_file(u_boot_console, 'env__efi_loader_grub_file')
+
+    u_boot_console.run_command('bootefi %x' % addr, wait_for_prompt=False)
+
+    # Verify that we have an SMBIOS table
+    check_smbios = u_boot_console.config.env.get('env__efi_loader_check_smbios', False)
+    if check_smbios:
+        u_boot_console.wait_for('grub>')
+        output = u_boot_console.run_command('lsefisystab', wait_for_prompt=False, wait_for_echo=False)
+        u_boot_console.wait_for('SMBIOS')
+
+    # Then exit cleanly
+    u_boot_console.wait_for('grub>')
+    output = u_boot_console.run_command('exit', wait_for_prompt=False, wait_for_echo=False)
+    u_boot_console.wait_for('r = 0')
+
+    # And give us our U-Boot prompt back
+    u_boot_console.run_command('')
-- 
1.8.5.6

             reply	other threads:[~2016-11-18 12:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-18 12:18 Alexander Graf [this message]
2016-11-21 22:21 ` [U-Boot] [PATCH v2] travis: Add efi_loader grub2 test Stephen Warren
2016-11-21 22:31   ` Tom Rini
2016-11-21 23:15     ` Alexander Graf
2016-11-30  4:27       ` Stephen Warren
2016-11-21 23:21   ` Alexander Graf
2016-11-30  4:28     ` Stephen Warren
2016-11-27 14:56 ` [U-Boot] [U-Boot,v2] " Tom Rini

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=1479471480-164355-1-git-send-email-agraf@suse.de \
    --to=agraf@suse.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.