Skip to contentSkip to conversation

cpio_tests.sh: Fix failure with BusyBox cpio

PATCH New Radoslav Kolev 3 participants 7 messages Dec 21, 2020 – Jan 20, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpio_tests.sh: Fix failure with BusyBox cpio

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

---
 testcases/commands/cpio/cpio_tests.sh | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
testcases/commands/cpio/cpio_tests.sh +7 -1
index a1469d873..57b6d983c 100755
@@ -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
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/1 cpio_tests.sh: Fix failure with BusyBox cpio

Hi Radoslav,

Quoted 2 lines

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

...

Quoted 1 line

+ARCHIVE_FORMAT=""

ARCHIVE_FORMAT=
(quotes not needed)

Quoted 9 lines
testcases/commands/cpio/cpio_tests.sh +5 -0
+
+if cpio 2>&1 | grep -q '\-o\sCreate (requires -H newc)'; then
+	ARCHIVE_FORMAT="-H newc"
+fi
+
 cpio_test()
 {
 	ROD mkdir "dir"

testcases/commands/cpio/cpio_tests.sh cpio_test() · line 28

Quoted 8 lines
testcases/commands/cpio/cpio_tests.sh +1 -1
@@ -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

#2 lore raw

PATCH 1/1 cpio_tests.sh: Fix failure with BusyBox cpio

Hi Radoslav,

...

Quoted 2 lines

testcases/commands/cpio/cpio_tests.sh TST_NEEDS_TMPDIR=1 · line 13

Quoted 2 lines
testcases/commands/cpio/cpio_tests.sh +2 -0
+
+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

#3 lore raw

PATCH 1/1 cpio_tests.sh: Fix failure with BusyBox cpio

Hi Petr,

Quoted 9 lines · Petr Vorel

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!

#4 lore raw

PATCH 1/1 cpio_tests.sh: Fix failure with BusyBox cpio

In reply to Petr Vorel

Hi Petr

Quoted 7 lines

Hi Radoslav,

...

Quoted 2 lines

testcases/commands/cpio/cpio_tests.sh TST_NEEDS_TMPDIR=1 · line 13

Quoted 2 lines
testcases/commands/cpio/cpio_tests.sh +2 -0
+
+if cpio 2>&1 | grep -q '\-o\sCreate (requires -H newc)'; then

Thanks for your fix, merged with these changes:

Quoted 6 lines

* 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

Quoted 4 lines

Kind regards,
Petr

#5 lore raw

PATCH 1/1 cpio_tests.sh: Fix failure with BusyBox cpio

Hi Zhu,

Quoted 11 lines

Hi Petr

Quoted 9 lines

Hi Radoslav,

...

Quoted 2 lines

testcases/commands/cpio/cpio_tests.sh TST_NEEDS_TMPDIR=1 · line 13

Quoted 2 lines
testcases/commands/cpio/cpio_tests.sh +2 -0
+
+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.

Quoted 7 lines
Quoted 3 lines

* 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.

Quoted 10 lines

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

Quoted 2 lines

Kind regards,
Petr

#6 lore raw

PATCH 1/1 cpio_tests.sh: Fix failure with BusyBox cpio

In reply to Zhu Feiyu

Hi Zhu,

Quoted 19 lines

Hi Petr

Quoted 7 lines

Hi Radoslav,

...

Quoted 2 lines

testcases/commands/cpio/cpio_tests.sh TST_NEEDS_TMPDIR=1 · line 13

Quoted 2 lines
testcases/commands/cpio/cpio_tests.sh +2 -0
+
+if cpio 2>&1 | grep -q '\-o\sCreate (requires -H newc)'; then

Thanks for your fix, merged with these changes:

Quoted 6 lines

* 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.

Quoted 4 lines

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

Quoted 2 lines

Best Regards
Feiyu Zhu