[V2] e2fsprogs: fix test f_detect_junk print error msg

Submitted by changqing.li@windriver.com on Oct. 11, 2018, 10:16 a.m. | Patch ID: 155590

Details

Message ID 1539252978-415942-1-git-send-email-changqing.li@windriver.com
State New
Headers show

Commit Message

changqing.li@windriver.com Oct. 11, 2018, 10:16 a.m.
From: Changqing Li <changqing.li@windriver.com>

1. This test need to check config.h, so install it

2. Test script have problem when the file want to grep
don't exist, change the check command to fix this problem

even we install the config.h,  but the script use relative path,
and will find the config.h decide by in which folder you run
the test scirpt. like below 2 cases, if without the fix of
check command, it will also met error msg in case (b). But, with
the fix, the problem can be fixed

a) root@qemux86-64:/usr/lib/e2fsprogs/ptest/test# ./test_one ./f_detect_junk
f_detect_junk: detect non-fs file data: ok

b) root@qemux86-64:/usr/lib/e2fsprogs/ptest# ./test/test_one ./test/f_detect_junk
grep: ../lib/config.h: No such file or directory
./test/f_detect_junk/script: line 3: [: : integer expression expected
f_detect_junk: detect non-fs file data: ok

Signed-off-by: Changqing Li <changqing.li@windriver.com>
---
 .../0001-e2fsprogs-fix-ptest-error-msg.patch       | 33 ++++++++++++++++++++++
 .../recipes-devtools/e2fsprogs/e2fsprogs_1.44.3.bb |  4 +++
 2 files changed, 37 insertions(+)
 create mode 100644 meta/recipes-devtools/e2fsprogs/e2fsprogs/0001-e2fsprogs-fix-ptest-error-msg.patch

Patch hide | download patch | download mbox

diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0001-e2fsprogs-fix-ptest-error-msg.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0001-e2fsprogs-fix-ptest-error-msg.patch
new file mode 100644
index 0000000..4187e6b
--- /dev/null
+++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0001-e2fsprogs-fix-ptest-error-msg.patch
@@ -0,0 +1,33 @@ 
+From e193316891510ec3852699d57a860c65615196ef Mon Sep 17 00:00:00 2001
+From: Changqing Li <changqing.li@windriver.com>
+Date: Thu, 11 Oct 2018 15:13:24 +0800
+Subject: [PATCH] e2fsprogs: fix ptest error msg
+
+Upstream-Status: Inappropriate [oe-specific]
+
+original command want to get count of match lines, but if
+config.h is not existed, like our case, the result of
+$(grep -c 'define HAVE_MAGIC_H' ../lib/config.h) will not be
+number, and cannot compare with 0, so fix it by check
+command executed result.
+
+Signed-off-by: Changqing Li <changqing.li@windriver.com>
+---
+ tests/f_detect_junk/script | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/tests/f_detect_junk/script b/tests/f_detect_junk/script
+index 2577842..d56ec1a 100644
+--- a/tests/f_detect_junk/script
++++ b/tests/f_detect_junk/script
+@@ -1,6 +1,6 @@
+ #!/bin/bash
+ 
+-if [ "$(grep -c 'define HAVE_MAGIC_H' ../lib/config.h)" -eq 0 ]; then
++if ! grep -q -c 'define HAVE_MAGIC_H' ../lib/config.h 2>/dev/null; then
+ 	echo "$test_name: skipped (no magic)"
+ 	exit 0
+ fi
+-- 
+2.7.4
+
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs_1.44.3.bb b/meta/recipes-devtools/e2fsprogs/e2fsprogs_1.44.3.bb
index 823d18b..fa4d837 100644
--- a/meta/recipes-devtools/e2fsprogs/e2fsprogs_1.44.3.bb
+++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs_1.44.3.bb
@@ -6,6 +6,7 @@  SRC_URI += "file://remove.ldconfig.call.patch \
             file://Revert-mke2fs-enable-the-metadata_csum-and-64bit-fea.patch \
             file://mkdir_p.patch \
             file://0001-misc-create_inode.c-set-dir-s-mode-correctly.patch \
+            file://0001-e2fsprogs-fix-ptest-error-msg.patch \
             "
 
 SRC_URI_append_class-native = " file://e2fsprogs-fix-missing-check-for-permission-denied.patch \
@@ -129,4 +130,7 @@  do_install_ptest() {
 	find "${D}${PTEST_PATH}" -type f \
 	    \( -name 'Makefile' -o -name 'Makefile.in' -o -name '*.o' -o -name '*.c' -o -name '*.h' \)\
 	    -exec  rm -f {} +
+
+        install -d ${D}${PTEST_PATH}/lib
+        install -m 0644 ${B}/lib/config.h  ${D}${PTEST_PATH}/lib/
 }

Comments

Richard Purdie Oct. 11, 2018, 10:15 p.m.
On Thu, 2018-10-11 at 18:16 +0800, changqing.li@windriver.com wrote:
> From: Changqing Li <changqing.li@windriver.com>
> 
> 1. This test need to check config.h, so install it
> 
> 2. Test script have problem when the file want to grep
> don't exist, change the check command to fix this problem
> 
> even we install the config.h,  but the script use relative path,
> and will find the config.h decide by in which folder you run
> the test scirpt. like below 2 cases, if without the fix of
> check command, it will also met error msg in case (b). But, with
> the fix, the problem can be fixed
> 
> a) root@qemux86-64:/usr/lib/e2fsprogs/ptest/test# ./test_one
> ./f_detect_junk
> f_detect_junk: detect non-fs file data: ok
> 
> b) root@qemux86-64:/usr/lib/e2fsprogs/ptest# ./test/test_one
> ./test/f_detect_junk
> grep: ../lib/config.h: No such file or directory
> ./test/f_detect_junk/script: line 3: [: : integer expression expected
> f_detect_junk: detect non-fs file data: ok
> 
> Signed-off-by: Changqing Li <changqing.li@windriver.com>

If you've fixed 1) then we don't need to carry the patch for 2)? 

Perhaps it should be sent upstream as an improvement to their code? I'm
not sure I agree with the Upstream-Status. 

Regardless, I don't want to add a patch which we don't really need
though...

Cheers,

Richard
changqing.li@windriver.com Oct. 12, 2018, 2:10 a.m.
On 10/12/2018 06:15 AM, Richard Purdie wrote:
> On Thu, 2018-10-11 at 18:16 +0800, changqing.li@windriver.com wrote:
>> From: Changqing Li <changqing.li@windriver.com>
>>
>> 1. This test need to check config.h, so install it
>>
>> 2. Test script have problem when the file want to grep
>> don't exist, change the check command to fix this problem
>>
>> even we install the config.h,  but the script use relative path,
>> and will find the config.h decide by in which folder you run
>> the test scirpt. like below 2 cases, if without the fix of
>> check command, it will also met error msg in case (b). But, with
>> the fix, the problem can be fixed
>>
>> a) root@qemux86-64:/usr/lib/e2fsprogs/ptest/test# ./test_one
>> ./f_detect_junk
>> f_detect_junk: detect non-fs file data: ok
>>
>> b) root@qemux86-64:/usr/lib/e2fsprogs/ptest# ./test/test_one
>> ./test/f_detect_junk
>> grep: ../lib/config.h: No such file or directory
>> ./test/f_detect_junk/script: line 3: [: : integer expression expected
>> f_detect_junk: detect non-fs file data: ok
>>
>> Signed-off-by: Changqing Li <changqing.li@windriver.com>
> If you've fixed 1) then we don't need to carry the patch for 2)?
I agree with you. we can first do like this, I will resend a patch.
case b) is rare and not critial.
>
> Perhaps it should be sent upstream as an improvement to their code? I'm
> not sure I agree with the Upstream-Status.
>
> Regardless, I don't want to add a patch which we don't really need
> though...
I will report the patch as improvement to upstream.  Anyway,  the check 
command
change only can see as workaround,  the correct way should  not use 
relative path
, but use like top_builddir/lib/config.h.


//Sandy

> Cheers,
>
> Richard
>
>