Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Yann E. MORIN <yann.morin.1998@free.fr>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH v5 2/5] board/qemu: add post-image script for gitlab qemu testing
Date: Mon, 13 Apr 2020 09:25:23 +0200	[thread overview]
Message-ID: <20200413072523.GW29898@scaer> (raw)
In-Reply-To: <20200217205030.8157-3-romain.naour@smile.fr>

Romain, jugurtha, All,

On 2020-02-17 21:50 +0100, Romain Naour spake thusly:
> This commit add a post-image script to be used by each qemu
> board defconfig in order to generate start-qemu.sh in BINARIES_DIR.
> The start-qemu.sh script can be used by Buildroot user to start
> Qemu or by a gitlab CI.
> start-qemu.sh is not started automatically at the end of the build.
> 
> To find the correct qemu command line, we use the second post
> script argument which must contain "$(BR2_DEFCONFIG)"
> 
>   BR2_ROOTFS_POST_SCRIPT_ARGS="$(BR2_DEFCONFIG)"
> 
> The post-image script expect something like
> "/path/to/qemu_aarch64_virt_defconfig" in BR2_DEFCONFIG.
> 
> Doing a basename allow to retrieve the name of the defconfig
> file that should match on on the "tag" previously introduced in
> readme.txt files.
> 
> The script start-qemu.sh is able to modify the qemu command
> line if CI_JOB_NAME defined in the environment. This allow
> to disable the graphical output and redirect serial I/Os to
> console.

Like Thomas, I'm not too keen on this gitlab-ci knowledge leaking in
there...

I think we can abstract that in the post-build script to just prepare
the two sets of options, the default one (graphical), or the serial-only
case, and store both sets in start-qemu.sh.

Then start-qemu.sh chooses which to use based on ${1}: if it is
'serial-only' (or whatever), then ti uses the serial-only options,
otherwise it uses the graphical options.

I've already hack that: http://code.bulix.org/ip443p-1282035?raw

Of course, whis will require a bit of rewriting in the latter patch that
tries to extract the qemu command line to run it in gitlab-ci, but I've
anyway already replied to that patch (hint: it would just need to call
start-qemu.sh with the new parameter).

I understand this review is coming late, so I'll take on me to apply
those changes and respin the series a bit later today...

Regards,
Yann E. MORIN.

> Only sh4/sh4eb needs a special handling by adding
> "-serial stdio -display none" instead of "-display none".
> 
> Signed-off-by: Romain Naour <romain.naour@smile.fr>
> ---
> v5: update the script after Thomas's review [1] [2]
> 
> [1] http://lists.busybox.net/pipermail/buildroot/2020-February/273820.html
> [2] http://lists.busybox.net/pipermail/buildroot/2020-February/273822.html
> ---
>  board/qemu/post-image.sh | 50 ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 50 insertions(+)
>  create mode 100755 board/qemu/post-image.sh
> 
> diff --git a/board/qemu/post-image.sh b/board/qemu/post-image.sh
> new file mode 100755
> index 0000000000..804c5f6110
> --- /dev/null
> +++ b/board/qemu/post-image.sh
> @@ -0,0 +1,50 @@
> +#!/bin/bash
> +
> +QEMU_BOARD_DIR="$(dirname $0)"
> +DEFCONFIG_NAME="$(basename $2)"
> +README_FILES="${QEMU_BOARD_DIR}/*/readme.txt"
> +START_QEMU_SCRIPT="${BINARIES_DIR}/start-qemu.sh"
> +
> +if [[ "${DEFCONFIG_NAME}" =~ ^"qemu_*" ]]; then
> +    # Not a Qemu defconfig, can't test.
> +    exit 0
> +fi
> +
> +# Search for "# qemu_*_defconfig" tag in all readme.txt files.
> +# Qemu command line on multilines using back slash are accepted.
> +QEMU_CMD_LINE=$(sed -r ':a; /\\$/N; s/\\\n//; s/\t/ /; ta; /# '${DEFCONFIG_NAME}'$/!d; s/#.*//' ${README_FILES})
> +
> +if [ -z "$QEMU_CMD_LINE" ]; then
> +    # No Qemu cmd line found, can't test.
> +    exit 0
> +fi
> +
> +# Replace output/images path by ${IMAGE_DIR} since the script
> +# will be in the same directory as the kernel and the rootfs images.
> +QEMU_CMD_LINE=${QEMU_CMD_LINE//output\/images/\${IMAGE_DIR\}}
> +
> +# Test if we are running in gitlab
> +if [ -n "$CI_JOB_NAME" ]; then
> +    # Remove -serial stdio if present
> +    QEMU_CMD_LINE=${QEMU_CMD_LINE//-serial stdio/}
> +
> +    # Disable graphical output and redirect serial I/Os to console
> +    case ${DEFCONFIG_NAME} in
> +        # Special case for SH4
> +        qemu_sh4eb_r2d_defconfig | qemu_sh4_r2d_defconfig)
> +            QEMU_CMD_LINE="$QEMU_CMD_LINE -serial stdio -display none"
> +            ;;
> +        *)
> +            QEMU_CMD_LINE="$QEMU_CMD_LINE -nographic"
> +            ;;
> +    esac
> +fi
> +
> +cat << EOF > $START_QEMU_SCRIPT
> +#!/bin/sh
> +IMAGE_DIR="\$(dirname \$0)"
> +
> +$QEMU_CMD_LINE
> +EOF
> +
> +chmod +x $START_QEMU_SCRIPT
> -- 
> 2.24.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

  reply	other threads:[~2020-04-13  7:25 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-17 20:50 [Buildroot] [PATCH v5 0/5] gitlab Qemu runtime testing Romain Naour
2020-02-17 20:50 ` [Buildroot] [PATCH v5 1/5] board/qemu: add defconfig file name as tag after the qemu command line Romain Naour
2020-02-17 20:50 ` [Buildroot] [PATCH v5 2/5] board/qemu: add post-image script for gitlab qemu testing Romain Naour
2020-04-13  7:25   ` Yann E. MORIN [this message]
2020-02-17 20:50 ` [Buildroot] [PATCH v5 3/5] configs/qemu*: use the post-image script with "$(BR2_DEFCONFIG)" as argument Romain Naour
2020-02-17 20:50 ` [Buildroot] [PATCH v5 4/5] support/scripts/boot-qemu-image.py: boot Qemu images with Qemu-system Romain Naour
2020-04-13  7:15   ` Yann E. MORIN
2020-04-13 21:38     ` Romain Naour
2020-02-17 20:50 ` [Buildroot] [PATCH v5 5/5] gitlab.yml.in*: enable Qemu gitlab testing Romain Naour
2020-04-12 14:11 ` [Buildroot] [PATCH v5 0/5] gitlab Qemu runtime testing Thomas Petazzoni
2020-04-12 20:00   ` Romain Naour
2020-04-13 19:56 ` Yann E. MORIN
2020-04-13 20:03   ` Romain Naour

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=20200413072523.GW29898@scaer \
    --to=yann.morin.1998@free.fr \
    --cc=buildroot@busybox.net \
    /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