devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tests: Improve compatibility with other platforms
@ 2018-01-03  2:55 kevans-HZy0K5TPuP5AfugRpC6u6w
       [not found] ` <20180103025532.43393-1-kevans-HZy0K5TPuP5AfugRpC6u6w@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: kevans-HZy0K5TPuP5AfugRpC6u6w @ 2018-01-03  2:55 UTC (permalink / raw)
  To: David Gibson, Jon Loeliger
  Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Kyle Evans

stat -c %s's equivalent on FreeBSD is stat -f %Uz; these differ enough, allow
STATSZ in the environment to specify local replacement for a stat that outputs
size in bytes of an argument.

Signed-off-by: Kyle Evans <kevans-HZy0K5TPuP5AfugRpC6u6w@public.gmane.org>
---
 tests/run_tests.sh | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index d36dffb..13c9f1c 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -6,6 +6,11 @@ if [ -z "$CC" ]; then
     CC=gcc
 fi
 
+# stat differs between platforms
+if [ -z "$STATSZ" ]; then
+	STATSZ="stat -c %s"
+fi
+
 export QUIET_TEST=1
 STOP_ON_FAIL=0
 
@@ -114,7 +119,7 @@ run_wrap_error_test () {
 # $2: align base
 check_align () {
     shorten_echo "check_align $@:	"
-    local size=$(stat -c %s "$1")
+    local size=$($STATSZ "$1")
     local align="$2"
     (
 	if [ $(($size % $align)) -eq 0 ] ;then
@@ -714,7 +719,7 @@ fdtput_tests () {
     text=lorem.txt
 
     # Allow just enough space for $text
-    run_dtc_test -O dtb -p $(stat -c %s $text) -o $dtb $dts
+    run_dtc_test -O dtb -p $($STATSZ $text) -o $dtb $dts
 
     # run_fdtput_test <expected-result> <file> <node> <property> <flags> <value>
     run_fdtput_test "a_model" $dtb / model -ts "a_model"
@@ -733,7 +738,7 @@ fdtput_tests () {
     run_fdtput_test "$(cat $text $text)" $dtb /randomnode blob -ts "$(cat $text $text)"
 
     # Start again with a fresh dtb
-    run_dtc_test -O dtb -p $(stat -c %s $text) -o $dtb $dts
+    run_dtc_test -O dtb -p $($STATSZ $text) -o $dtb $dts
 
     # Node creation
     run_wrap_error_test $DTPUT $dtb -c /baldrick sod
@@ -761,7 +766,7 @@ fdtput_tests () {
     run_wrap_test $DTPUT $dtb -cp /chosen/son
 
     # Start again with a fresh dtb
-    run_dtc_test -O dtb -p $(stat -c %s $text) -o $dtb $dts
+    run_dtc_test -O dtb -p $($STATSZ $text) -o $dtb $dts
 
     # Node delete
     run_wrap_test $DTPUT $dtb -c /chosen/node1 /chosen/node2 /chosen/node3
-- 
2.15.1

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

* Re: [PATCH] tests: Improve compatibility with other platforms
       [not found] ` <20180103025532.43393-1-kevans-HZy0K5TPuP5AfugRpC6u6w@public.gmane.org>
@ 2018-01-03  3:14   ` David Gibson
  0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2018-01-03  3:14 UTC (permalink / raw)
  To: kevans-HZy0K5TPuP5AfugRpC6u6w
  Cc: Jon Loeliger, devicetree-compiler-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 2590 bytes --]

On Tue, Jan 02, 2018 at 08:55:32PM -0600, kevans-HZy0K5TPuP5AfugRpC6u6w@public.gmane.org wrote:
> stat -c %s's equivalent on FreeBSD is stat -f %Uz; these differ enough, allow
> STATSZ in the environment to specify local replacement for a stat that outputs
> size in bytes of an argument.
> 
> Signed-off-by: Kyle Evans <kevans-HZy0K5TPuP5AfugRpC6u6w@public.gmane.org>

Applied, thanks.

I'd also be happy with a follow up change to automatically set STATSZ
to the right thing on BSD.

> ---
>  tests/run_tests.sh | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/run_tests.sh b/tests/run_tests.sh
> index d36dffb..13c9f1c 100755
> --- a/tests/run_tests.sh
> +++ b/tests/run_tests.sh
> @@ -6,6 +6,11 @@ if [ -z "$CC" ]; then
>      CC=gcc
>  fi
>  
> +# stat differs between platforms
> +if [ -z "$STATSZ" ]; then
> +	STATSZ="stat -c %s"
> +fi
> +
>  export QUIET_TEST=1
>  STOP_ON_FAIL=0
>  
> @@ -114,7 +119,7 @@ run_wrap_error_test () {
>  # $2: align base
>  check_align () {
>      shorten_echo "check_align $@:	"
> -    local size=$(stat -c %s "$1")
> +    local size=$($STATSZ "$1")
>      local align="$2"
>      (
>  	if [ $(($size % $align)) -eq 0 ] ;then
> @@ -714,7 +719,7 @@ fdtput_tests () {
>      text=lorem.txt
>  
>      # Allow just enough space for $text
> -    run_dtc_test -O dtb -p $(stat -c %s $text) -o $dtb $dts
> +    run_dtc_test -O dtb -p $($STATSZ $text) -o $dtb $dts
>  
>      # run_fdtput_test <expected-result> <file> <node> <property> <flags> <value>
>      run_fdtput_test "a_model" $dtb / model -ts "a_model"
> @@ -733,7 +738,7 @@ fdtput_tests () {
>      run_fdtput_test "$(cat $text $text)" $dtb /randomnode blob -ts "$(cat $text $text)"
>  
>      # Start again with a fresh dtb
> -    run_dtc_test -O dtb -p $(stat -c %s $text) -o $dtb $dts
> +    run_dtc_test -O dtb -p $($STATSZ $text) -o $dtb $dts
>  
>      # Node creation
>      run_wrap_error_test $DTPUT $dtb -c /baldrick sod
> @@ -761,7 +766,7 @@ fdtput_tests () {
>      run_wrap_test $DTPUT $dtb -cp /chosen/son
>  
>      # Start again with a fresh dtb
> -    run_dtc_test -O dtb -p $(stat -c %s $text) -o $dtb $dts
> +    run_dtc_test -O dtb -p $($STATSZ $text) -o $dtb $dts
>  
>      # Node delete
>      run_wrap_test $DTPUT $dtb -c /chosen/node1 /chosen/node2 /chosen/node3

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2018-01-03  3:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-03  2:55 [PATCH] tests: Improve compatibility with other platforms kevans-HZy0K5TPuP5AfugRpC6u6w
     [not found] ` <20180103025532.43393-1-kevans-HZy0K5TPuP5AfugRpC6u6w@public.gmane.org>
2018-01-03  3:14   ` David Gibson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).