All of lore.kernel.org
 help / color / mirror / Atom feed
* [Fuego] [PATCH v2] Add a core function: assert_has_program().
@ 2018-10-18  5:53 Wang Mingyu
  2018-10-19  5:22 ` Tim.Bird
  0 siblings, 1 reply; 2+ messages in thread
From: Wang Mingyu @ 2018-10-18  5:53 UTC (permalink / raw)
  To: fuego

This function is used to combine the code that check whether a program or file exists, from 2 lines into a single function call.
Called like so:
assert_has_program expect

Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
---
 engine/scripts/functions.sh | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/engine/scripts/functions.sh b/engine/scripts/functions.sh
index ff7b272..dffacbd 100644
--- a/engine/scripts/functions.sh
+++ b/engine/scripts/functions.sh
@@ -961,3 +961,13 @@ function is_on_sdk {
     export $2=$LOCATION
     rm -f $tmpfile
 }
+
+# check for a program or file on the target, and send message if the program or file is missing
+# $1 has the program that is required on the target board
+# this has the side effect of defining PROGRAM_$1 (uppercased)
+# with the value as the directory where $1 is found on the board.
+function assert_has_program {
+   progVar=PROGRAM_${1//[-,.]/_}
+   is_on_target_path $1 ${progVar}
+   assert_define ${progVar} "Missing '$1' program on target board"
+}
-- 
1.8.3.1




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Fuego] [PATCH v2] Add a core function: assert_has_program().
  2018-10-18  5:53 [Fuego] [PATCH v2] Add a core function: assert_has_program() Wang Mingyu
@ 2018-10-19  5:22 ` Tim.Bird
  0 siblings, 0 replies; 2+ messages in thread
From: Tim.Bird @ 2018-10-19  5:22 UTC (permalink / raw)
  To: wangmy, fuego



> -----Original Message-----
> From: Wang Mingyu
> 
> This function is used to combine the code that check whether a program or
> file exists, from 2 lines into a single function call.
> Called like so:
> assert_has_program expect
> 
> Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
> ---
>  engine/scripts/functions.sh | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/engine/scripts/functions.sh b/engine/scripts/functions.sh
> index ff7b272..dffacbd 100644
> --- a/engine/scripts/functions.sh
> +++ b/engine/scripts/functions.sh
> @@ -961,3 +961,13 @@ function is_on_sdk {
>      export $2=$LOCATION
>      rm -f $tmpfile
>  }
> +
> +# check for a program or file on the target, and send message if the
> program or file is missing
> +# $1 has the program that is required on the target board
> +# this has the side effect of defining PROGRAM_$1 (uppercased)
> +# with the value as the directory where $1 is found on the board.
> +function assert_has_program {
In my example, I mistakenly omitted the part where $1 is converted to uppercase,
which can  be done with the bash string substitution: $(var^^).

I have added the following:
upName=${1^^}

and changed the following to:
> +   progVar=PROGRAM_${1//[-,.]/_}
progVar=PROGRAM_${upName//[-,.]/_}

> +   is_on_target_path $1 ${progVar}
> +   assert_define ${progVar} "Missing '$1' program on target board"
> +}
> --
> 1.8.3.1


I tested this, and it worked great!

Applied and amended as I describe above.

Thanks,
 -- Tim


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-10-19  5:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-18  5:53 [Fuego] [PATCH v2] Add a core function: assert_has_program() Wang Mingyu
2018-10-19  5:22 ` Tim.Bird

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.