diff mbox series

cpio_tests.sh: Fix failure with BusyBox cpio

Message ID 20201221110120.26165-1-radoslav.kolev@suse.com
State Accepted
Headers show
Series cpio_tests.sh: Fix failure with BusyBox cpio | expand

Commit Message

Radoslav Kolev Dec. 21, 2020, 11:01 a.m. UTC
A very limited BusyBox cpio requires the archive format to be
explicitly set to newc when creating an archive.

Signed-off-by: Radoslav Kolev <radoslav.kolev@suse.com>
---
 testcases/commands/cpio/cpio_tests.sh | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Petr Vorel Dec. 22, 2020, 5:10 p.m. UTC | #1
Hi Radoslav,

> A very limited BusyBox cpio requires the archive format to be
> explicitly set to newc when creating an archive.

Reviewed-by: Petr Vorel <pvorel@suse.cz>

...

> +ARCHIVE_FORMAT=""
ARCHIVE_FORMAT=
(quotes not needed)

> +
> +if cpio 2>&1 | grep -q '\-o\sCreate (requires -H newc)'; then
> +	ARCHIVE_FORMAT="-H newc"
> +fi
> +
>  cpio_test()
>  {
>  	ROD mkdir "dir"
> @@ -16,7 +22,7 @@ cpio_test()
>  	done

>  	ROD find dir -type f > filelist
> -	EXPECT_PASS cpio -o \> cpio.out \< filelist
> +	EXPECT_PASS cpio -o $ARCHIVE_FORMAT \> cpio.out \< filelist
>  	ROD mv "dir" "dir_orig"
>  	ROD mkdir "dir"
>  	EXPECT_PASS cpio -i \< cpio.out

Kind regards,
Petr
Petr Vorel Jan. 5, 2021, 11:12 a.m. UTC | #2
Hi Radoslav,

...
> > +
> > +if cpio 2>&1 | grep -q '\-o\sCreate (requires -H newc)'; then
Thanks for your fix, merged with these changes:

* grep for BusyBox because some older versions does not contain the
hint, but actually require it.

* move things to setup function due my following commit, which cannot be
outside API functions (setup/test function):
And check for -o (which is on BusyBox optional).

Kind regards,
Petr
Radoslav Kolev Jan. 5, 2021, 12:04 p.m. UTC | #3
Hi Petr, 

On Tue, 2021-01-05 at 12:12 +0100, Petr Vorel wrote:
> Thanks for your fix, merged with these changes:
> 
> * grep for BusyBox because some older versions does not contain the
> hint, but actually require it.
> 
> * move things to setup function due my following commit, which cannot
> be
> outside API functions (setup/test function):
> And check for -o (which is on BusyBox optional).

Thanks a lot for the review and fixes!
Feiyu Zhu Jan. 20, 2021, 7:19 a.m. UTC | #4
Hi Petr
> Hi Radoslav,
>
> ...
>>> +
>>> +if cpio 2>&1 | grep -q '\-o\sCreate (requires -H newc)'; then
> Thanks for your fix, merged with these changes:
>
> * grep for BusyBox because some older versions does not contain the
> hint, but actually require it.
>
> * move things to setup function due my following commit, which cannot be
> outside API functions (setup/test function):
> And check for -o (which is on BusyBox optional).
On my test environment, just executing cpio with no arguments will only 
output:
cpio: You must specify one of -oipt options.
Try `cpio --help' or `cpio --usage' for more information.

So the result of cpio01_sh is changed from PASS to CONF after commit 
5910bdb65c.
Is there any difference in the output from executing this command on 
your environment?

Best Regards
Feiyu Zhu
>
> Kind regards,
> Petr
>
Petr Vorel Jan. 20, 2021, 9:39 a.m. UTC | #5
Hi Zhu,

> Hi Petr
> > Hi Radoslav,

> > ...
> > > > +
> > > > +if cpio 2>&1 | grep -q '\-o\sCreate (requires -H newc)'; then
> > Thanks for your fix, merged with these changes:

> > * grep for BusyBox because some older versions does not contain the
> > hint, but actually require it.

> > * move things to setup function due my following commit, which cannot be
> > outside API functions (setup/test function):
> > And check for -o (which is on BusyBox optional).
> On my test environment, just executing cpio with no arguments will only
> output:
> cpio: You must specify one of -oipt options.
> Try `cpio --help' or `cpio --usage' for more information.
Thanks for a report and sorry for a regression. I'll fix it with --help (that is
compatible for both cpio from GNU and for busybox cpio implementation.

> So the result of cpio01_sh is changed from PASS to CONF after commit
> 5910bdb65c.
> Is there any difference in the output from executing this command on your
> environment?

> Best Regards
> Feiyu Zhu

> > Kind regards,
> > Petr
Petr Vorel Jan. 20, 2021, 11 a.m. UTC | #6
Hi Zhu,

> Hi Petr
> > Hi Radoslav,

> > ...
> > > > +
> > > > +if cpio 2>&1 | grep -q '\-o\sCreate (requires -H newc)'; then
> > Thanks for your fix, merged with these changes:

> > * grep for BusyBox because some older versions does not contain the
> > hint, but actually require it.

> > * move things to setup function due my following commit, which cannot be
> > outside API functions (setup/test function):
> > And check for -o (which is on BusyBox optional).
> On my test environment, just executing cpio with no arguments will only
> output:
> cpio: You must specify one of -oipt options.
> Try `cpio --help' or `cpio --usage' for more information.

> So the result of cpio01_sh is changed from PASS to CONF after commit
> 5910bdb65c.
> Is there any difference in the output from executing this command on your
> environment?

Fixed in c698801a8 ("cpio: Fix -o compatibility detection").

Thanks a lot for a bug report!

Kind regards,
Petr


> Best Regards
> Feiyu Zhu
diff mbox series

Patch

diff --git a/testcases/commands/cpio/cpio_tests.sh b/testcases/commands/cpio/cpio_tests.sh
index a1469d873..57b6d983c 100755
--- a/testcases/commands/cpio/cpio_tests.sh
+++ b/testcases/commands/cpio/cpio_tests.sh
@@ -8,6 +8,12 @@  TST_NEEDS_TMPDIR=1
 TST_NEEDS_CMDS="cpio"
 . tst_test.sh
 
+ARCHIVE_FORMAT=""
+
+if cpio 2>&1 | grep -q '\-o\sCreate (requires -H newc)'; then
+	ARCHIVE_FORMAT="-H newc"
+fi
+
 cpio_test()
 {
 	ROD mkdir "dir"
@@ -16,7 +22,7 @@  cpio_test()
 	done
 
 	ROD find dir -type f > filelist
-	EXPECT_PASS cpio -o \> cpio.out \< filelist
+	EXPECT_PASS cpio -o $ARCHIVE_FORMAT \> cpio.out \< filelist
 	ROD mv "dir" "dir_orig"
 	ROD mkdir "dir"
 	EXPECT_PASS cpio -i \< cpio.out