[Fuego] [PATCH 01/11] rebuild: add if_source_changed flag
Daniel Sangorrin
daniel.sangorrin at toshiba.co.jp
Wed Sep 26 02:35:36 UTC 2018
Note: there was one place where if_source_changed was not updated, it is updated now in my repository.
> -----Original Message-----
> From: fuego-bounces at lists.linuxfoundation.org
> <fuego-bounces at lists.linuxfoundation.org> On Behalf Of Daniel Sangorrin
> Sent: Tuesday, September 25, 2018 3:59 PM
> To: fuego at lists.linuxfoundation.org
> Subject: [Fuego] [PATCH 01/11] rebuild: add if_source_changed flag
>
> if_source_changed allows rebuilding only when the test source
> has changed which is the main use case. For that reason,
> we set it as the default option.
>
> FIXTHIS: consider conflicts when updating via git pull
>
> Signed-off-by: Daniel Sangorrin <daniel.sangorrin at toshiba.co.jp>
> ---
> engine/scripts/ftc | 10 +++---
> engine/scripts/functions.sh | 40
> +++++++++++++++++++---
> engine/tests/Functional.kernel_build/fuego_test.sh | 12 -------
> 3 files changed, 42 insertions(+), 20 deletions(-)
>
> diff --git a/engine/scripts/ftc b/engine/scripts/ftc
> index 7de2b70..b675dea 100755
> --- a/engine/scripts/ftc
> +++ b/engine/scripts/ftc
> @@ -96,13 +96,14 @@ where_help = \
> command_help = {
> "add-jobs": ("Adds jobs to Jenkins.",
> """Usage: ftc add-jobs -b <board>[,board2...] [-p <testplan> | -t <testcase>
> -s <testspec>]
> - [-k <kill timeout>] [--rebuild <true|false>] [--reboot <true|false>]
> + [-k <kill timeout>] [--rebuild <true|false|if_source_changed>] [--reboot
> <true|false>]
> [--precleanup <true|false>] [--postcleanup <true|false>]
> Example: ftc add-jobs -b docker -p testplan_docker
> Example: ftc add-jobs -b docker -t Benchmark.Dhrystone -k 5m --rebuild false
> board,testplan,testpec: use list-board/plans/specs to see the available ones.
> timeout: integer with a suffix from 'smhd' (seconds, minutes, hours, days).
> rebuild: if true rebuild the test source even if it was already built.
> + if_source_changed can be used to rebuild the test only when its source changes.
> reboot: if true reboot the board before the test.
> precleanup: if true clean the board's test folder before the test.
> postcleanup: if true clean the board's test folder after the test.
> @@ -241,7 +242,7 @@ You can obtain a list of run_ids for runs on the local system
> with
>
> "run-test": ("Run a test on a board.",
> """Usage: ftc run-test -b <board> -t <test> [-s <spec>] [-p <phases>]
> - [-k <kill timeout>] [--rebuild <true|false>] [--reboot <true|false>]
> + [-k <kill timeout>] [--rebuild <true|false|if_source_changed>] [--reboot
> <true|false>]
> [--precleanup <true|false>] [--postcleanup <true|false>]
> [--dynamic-vars python_dict]
> Run the indicated test on the specified board. Use the
> @@ -250,6 +251,7 @@ indicated spec, if one is provided.
> board,spec: use list-board/specs to see the available ones.
> timeout: integer with a suffix from 'smhd' (seconds, minutes, hours, days).
> rebuild: if true rebuild the test source even if it was already built.
> +if_source_changed can be used to rebuild the test only when its source changes.
> reboot: if true reboot the board before the test.
> precleanup: if true clean the board's test folder before the test.
> postcleanup: if true clean the board's test folder after the test.
> @@ -652,7 +654,7 @@ class test_class:
> 'timeout' : '30m',
> 'spec' : 'default',
> 'reboot' : 'false',
> - 'rebuild' : 'false',
> + 'rebuild' : 'if_source_changed',
> 'precleanup' : 'true',
> 'postcleanup' : 'true'
> }
> @@ -1489,7 +1491,7 @@ def do_add_jobs(conf, options):
> rebuild = options[options.index('--rebuild') + 1]
> except IndexError:
> error_out('Rebuild option not provided after --rebuild')
> - if rebuild not in ['true', 'false']:
> + if rebuild not in ['true', 'false', 'if_source_changed']:
> error_out("Invalid rebuild option '%s'" % rebuild)
> options.remove(rebuild)
> options.remove('--rebuild')
> diff --git a/engine/scripts/functions.sh b/engine/scripts/functions.sh
> index 952e9a4..05bdbc1 100755
> --- a/engine/scripts/functions.sh
> +++ b/engine/scripts/functions.sh
> @@ -94,6 +94,9 @@ function untar {
> *) echo "Unknown $tarball file format. Not unpacking."; return 1;;
> esac
> tar ${key}xf $TEST_HOME/$tarball --strip-components=1
> +
> + # record md5sum for possible source code updates
> + md5sum $TEST_HOME/$tarball > fuego_tarball_src_md5sum
> }
>
> # Unpacks/clones the test source code into the current directory.
> @@ -321,6 +324,11 @@ function build_error {
> abort_job "Build failed: $@"
> }
>
> +function prepare_build_dir {
> + find . -maxdepth 1 -mindepth 1 ! -name "fuego.build.lock" -print0 | xargs -0
> rm -rf
> + unpack || abort_job "Error while unpacking"
> +}
> +
> # process Rebuild flag, and unpack test sources if necessary.
> function pre_build {
> cd ${WORKSPACE}
> @@ -341,11 +349,35 @@ function pre_build {
>
> lock_build_dir
>
> - if [ "$Rebuild" = "false" ] && [ -e fuego_test_successfully_built ]; then
> - echo "The test is already built"
> + if [ "$Rebuild" = "true" ]; then
> + prepare_build_dir
> + elif [ "$Rebuild" = "false" ]; then
> + if [ -e fuego_test_successfully_built ]; then
> + echo "The test was already successfully built"
> + else
> + prepare_build_dir
> + fi
> + elif [ "$Rebuild" = "if_source_changed" ]; then
> + if [ -e fuego_tarball_src_md5sum ]; then
> + if md5sum -c fuego_tarball_src_md5sum; then
> + echo "No updates to the source code tarball"
> + else
> + echo "The source code tarball got updated, rebuilding"
> + prepare_build_dir
> + fi
> + elif [ -d ".git" ]; then
> + echo "Trying to update the source code with git pull"
> + if git pull | grep "Already up-to-date"; then
> + echo "No source code updates"
> + else
> + echo "The source code was updated, rebuilding"
> + rm -f fuego_test_successfully_built
> + fi
> + else
> + prepare_build_dir
> + fi
> else
> - find . -maxdepth 1 -mindepth 1 ! -name "fuego.build.lock" -print0 | xargs
> -0 rm -rf
> - unpack || abort_job "Error while unpacking"
> + abort_job "Rebuild flag $Rebuild is not recognized."
> fi
> }
>
> diff --git a/engine/tests/Functional.kernel_build/fuego_test.sh
> b/engine/tests/Functional.kernel_build/fuego_test.sh
> index 0b4ac3c..2d36055 100755
> --- a/engine/tests/Functional.kernel_build/fuego_test.sh
> +++ b/engine/tests/Functional.kernel_build/fuego_test.sh
> @@ -18,21 +18,9 @@ function test_pre_check {
> if [[ "$FUNCTIONAL_KERNEL_BUILD_TARGET" == *"uImage"* ]]; then
> is_on_sdk mkimage
> fi
> -
> - # Force the kernel to be rebuilt
> - # That's the whole point of the test - don't let Fuego skip the build.
> - export Rebuild=True
> }
>
> function test_build {
> - # make sure we have the latest source code.
> - cd "$WORKSPACE/$JOB_BUILD_DIR"
> - if [ -d ".git" ]; then
> - git pull || echo "WARNING: git pull failed"
> - else
> - echo "WARNING: no git repository, assuming you used a tarball"
> - fi
> -
> # Config
> if [ -z "$FUNCTIONAL_KERNEL_BUILD_CONFIG" ]; then
> FUNCTIONAL_KERNEL_BUILD_CONFIG="defconfig"
> --
> 2.7.4
>
> _______________________________________________
> Fuego mailing list
> Fuego at lists.linuxfoundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/fuego
More information about the Fuego
mailing list