Skip to contentSkip to conversation

tests: Add pathological iso9660 filesystem tests

PATCH In review Glenn Washburn 2 participants 5 messages Feb 16, 2023 – Feb 18, 2023

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 tests: Add pathological iso9660 filesystem tests

These are not added to grub-fs-tester because they are not generated and none of the filesystem tests are run on these isos. The test is to run the command "ls /" on the iso, and a failure is determined if the command times out, has non-zero return value or has any output.

---
Interdiff against v2:
diff --git a/tests/iso9660_test.in b/tests/iso9660_test.in index 0ec28bd066..44bc08c6df 100644
--- a/tests/iso9660_test.in
+++ b/tests/iso9660_test.in
@@ -14,12 +14,17 @@ fi
"@builddir@/grub-fs-tester" rockridge_1999 "@builddir@/grub-fs-tester" rockridge_joliet_1999

+echo "Testing for proper recognition of CE loops ... "
for fs in iso9660_ce_loop iso9660_ce_loop2; do

     tempdir=`mktemp -d "${TMPDIR:-/tmp}/${0##*/}.$(date '+%Y%m%d%H%M%S%N').${fs}.XXX"` ||
       { echo "Failed to make temporary directory"; exit 99; }
  -  gunzip <"$srcdir"/tests/${fs}.iso.gz >"${tempdir}/${fs}.iso"
  +  gunzip <"$srcdir"/tests/${fs}.iso.gz >"${tempdir}/${fs}.iso" || exit 99
     output=$(LC_ALL=C timeout -s KILL "60" \
       "@builddir@/grub-fstest" "${tempdir}/${fs}.iso" ls / ) || ret=$?
     rm -rf "$tempdir"

- test "${ret:-0}" -eq 0 -a -z "$output"
+ if [ "${ret:-0}" -ne 0 -o -n "$output" ]; then
+ echo "FAIL ($fs)"
+ exit 1
+ fi
done
+echo "PASS"

 tests/iso9660_ce_loop.iso.gz  | Bin 0 -> 897 bytes
 tests/iso9660_ce_loop2.iso.gz | Bin 0 -> 904 bytes
 tests/iso9660_test.in         |  17 ++++++++++++++++-
 3 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 tests/iso9660_ce_loop.iso.gz
 create mode 100644 tests/iso9660_ce_loop2.iso.gz
tests/iso9660_ce_loop.iso.gz new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..9c53c569b8e5c2441273d49f4c8e13e4b3303c24
GIT binary patch
tests/iso9660_ce_loop2.iso.gz new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..f59e676475cfc8376256ba65047451b5ca969e5a
GIT binary patch
tests/iso9660_test.in +16 -1
index ed0a5bf8d4..44bc08c6df 100644
@@ -12,4 +12,19 @@ fi
 "@builddir@/grub-fs-tester" rockridge_joliet
 "@builddir@/grub-fs-tester" joliet_1999
 "@builddir@/grub-fs-tester" rockridge_1999
-"@builddir@/grub-fs-tester" rockridge_joliet_1999
\ No newline at end of file
+"@builddir@/grub-fs-tester" rockridge_joliet_1999
+
+echo "Testing for proper recognition of CE loops ... "
+for fs in iso9660_ce_loop iso9660_ce_loop2; do
+  tempdir=`mktemp -d "${TMPDIR:-/tmp}/${0##*/}.$(date '+%Y%m%d%H%M%S%N').${fs}.XXX"` ||
+    { echo "Failed to make temporary directory"; exit 99; }
+  gunzip <"$srcdir"/tests/${fs}.iso.gz >"${tempdir}/${fs}.iso" || exit 99
+  output=$(LC_ALL=C timeout -s KILL "60" \
+    "@builddir@/grub-fstest" "${tempdir}/${fs}.iso" ls / ) || ret=$?
+  rm -rf "$tempdir"
+  if [ "${ret:-0}" -ne 0 -o -n "$output" ]; then
+    echo "FAIL ($fs)"
+    exit 1
+  fi
+done
+echo "PASS"
Signature · 1 line
2.34.1
Tested-by on v3 1/1
#1 lore raw

Hi,

Quoted 108 lines · Glenn Washburn

These are not added to grub-fs-tester because they are not generated and none of the filesystem tests are run on these isos. The test is to run the command "ls /" on the iso, and a failure is determined if the command times out, has non-zero return value or has any output.

---
Interdiff against v2:
diff --git a/tests/iso9660_test.in b/tests/iso9660_test.in index 0ec28bd066..44bc08c6df 100644
--- a/tests/iso9660_test.in
+++ b/tests/iso9660_test.in
@@ -14,12 +14,17 @@ fi
"@builddir@/grub-fs-tester" rockridge_1999 "@builddir@/grub-fs-tester" rockridge_joliet_1999

+echo "Testing for proper recognition of CE loops ... "
for fs in iso9660_ce_loop iso9660_ce_loop2; do

     tempdir=`mktemp -d "${TMPDIR:-/tmp}/${0##*/}.$(date '+%Y%m%d%H%M%S%N').${fs}.XXX"` ||
       { echo "Failed to make temporary directory"; exit 99; }
  -  gunzip <"$srcdir"/tests/${fs}.iso.gz >"${tempdir}/${fs}.iso"
  +  gunzip <"$srcdir"/tests/${fs}.iso.gz >"${tempdir}/${fs}.iso" || exit 99
     output=$(LC_ALL=C timeout -s KILL "60" \
       "@builddir@/grub-fstest" "${tempdir}/${fs}.iso" ls / ) || ret=$?
     rm -rf "$tempdir"

- test "${ret:-0}" -eq 0 -a -z "$output"
+ if [ "${ret:-0}" -ne 0 -o -n "$output" ]; then
+ echo "FAIL ($fs)"
+ exit 1
+ fi
done
+echo "PASS"

 tests/iso9660_ce_loop.iso.gz  | Bin 0 -> 897 bytes
 tests/iso9660_ce_loop2.iso.gz | Bin 0 -> 904 bytes
 tests/iso9660_test.in         |  17 ++++++++++++++++-
 3 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 tests/iso9660_ce_loop.iso.gz
 create mode 100644 tests/iso9660_ce_loop2.iso.gz
tests/iso9660_ce_loop.iso.gz new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..9c53c569b8e5c2441273d49f4c8e13e4b3303c24
GIT binary patch
tests/iso9660_ce_loop2.iso.gz new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..f59e676475cfc8376256ba65047451b5ca969e5a
GIT binary patch
tests/iso9660_test.in +6 -1
index ed0a5bf8d4..44bc08c6df 100644
@@ -12,4 +12,19 @@ fi
 "@builddir@/grub-fs-tester" rockridge_joliet
 "@builddir@/grub-fs-tester" joliet_1999
 "@builddir@/grub-fs-tester" rockridge_1999
-"@builddir@/grub-fs-tester" rockridge_joliet_1999
\ No newline at end of file
+"@builddir@/grub-fs-tester" rockridge_joliet_1999
+
+echo "Testing for proper recognition of CE loops ... "
+for fs in iso9660_ce_loop iso9660_ce_loop2; do
+  tempdir=`mktemp -d "${TMPDIR:-/tmp}/${0##*/}.$(date '+%Y%m%d%H%M%S%N').${fs}.XXX"` ||
+    { echo "Failed to make temporary directory"; exit 99; }

tests/iso9660_test.in fi · line 30

Quoted 10 lines
tests/iso9660_test.in +10 -0
+  gunzip <"$srcdir"/tests/${fs}.iso.gz >"${tempdir}/${fs}.iso" || exit 99
+  output=$(LC_ALL=C timeout -s KILL "60" \
+    "@builddir@/grub-fstest" "${tempdir}/${fs}.iso" ls / ) || ret=$?
+  rm -rf "$tempdir"
+  if [ "${ret:-0}" -ne 0 -o -n "$output" ]; then
+    echo "FAIL ($fs)"
+    exit 1
+  fi
+done
+echo "PASS"

The test passes with unchanged grub-core/fs/iso9660.c.

It fails with disabled loop breaker and with disabled processing of CE at the start of a continuation area.
The message in test-suite.log is then:

Testing for proper recognition of CE loops ...
FAIL (iso9660_ce_loop)
FAIL iso9660_test (exit status: 1)

Have a nice day :)

Thomas

#2 lore raw
Quoted 98 lines · On Thu, 16 Feb 2023 13:20:30 +0100 "Thomas Schmitt" <[email protected]> wrote:

Hi,

Quoted 94 lines · Glenn Washburn

These are not added to grub-fs-tester because they are not generated and none of the filesystem tests are run on these isos. The test is to run the command "ls /" on the iso, and a failure is determined if the command times out, has non-zero return value or has any output.

---
Interdiff against v2:
diff --git a/tests/iso9660_test.in b/tests/iso9660_test.in index 0ec28bd066..44bc08c6df 100644
--- a/tests/iso9660_test.in
+++ b/tests/iso9660_test.in
@@ -14,12 +14,17 @@ fi
"@builddir@/grub-fs-tester" rockridge_1999 "@builddir@/grub-fs-tester" rockridge_joliet_1999

+echo "Testing for proper recognition of CE loops ... "
for fs in iso9660_ce_loop iso9660_ce_loop2; do

     tempdir=`mktemp -d "${TMPDIR:-/tmp}/${0##*/}.$(date

'+%Y%m%d%H%M%S%N').${fs}.XXX"` || { echo "Failed to make temporary directory"; exit 99; }
- gunzip <"$srcdir"/tests/${fs}.iso.gz >"${tempdir}/${fs}.iso"
+ gunzip <"$srcdir"/tests/${fs}.iso.gz >"${tempdir}/${fs}.iso"

|| exit 99 output=$(LC_ALL=C timeout -s KILL "60" \
       "@builddir@/grub-fstest" "${tempdir}/${fs}.iso" ls / ) ||

ret=$? rm -rf "$tempdir"
- test "${ret:-0}" -eq 0 -a -z "$output"
+ if [ "${ret:-0}" -ne 0 -o -n "$output" ]; then
+ echo "FAIL ($fs)"
+ exit 1
+ fi
done
+echo "PASS"

 tests/iso9660_ce_loop.iso.gz  | Bin 0 -> 897 bytes
 tests/iso9660_ce_loop2.iso.gz | Bin 0 -> 904 bytes
 tests/iso9660_test.in         |  17 ++++++++++++++++-
 3 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 tests/iso9660_ce_loop.iso.gz
 create mode 100644 tests/iso9660_ce_loop2.iso.gz
(quoted diff) +0 -0

b/tests/iso9660_ce_loop.iso.gz new file mode 100644
index 0000000000000000000000000000000000000000..9c53c569b8e5c2441273d49f4c8e13e4b3303c24 GIT binary patch literal 897 zcmb2|=3ofBusfN7Rxt={M#uq3<<mExp{35L_s?rt5_&ho@gi=FE>N2(O2EDtVk zV!mF;l$o*IlVjfrJNEhM(>tw&wEQkz$h$g?Kr;{^NWwz@Be?_yzkL<P9_HYK;caP zBMZ*vjOI-%PkDY@P!aue*Zzaq4m;3TYuF0MM=}%&};V&Ru<M5?hszGIz*~OY@x6X zcYbM}Jd5?~Z?n_>ZnR$cYS&()@00TO-|oL;;k(=OmM{C=iVM<ee|KNpVUu&3zyI~i zRp+eIuf%xF7tgP@mEZA=Q1@Zn;v%0TmFwNc1#i6|FFnSBBxq3=X&U$oWoNsY<K@> z#_wqSvIkrf>qL%wO1MZ*@eTFc#D4Vlsq24hKSos?-|;s4BcIjWg#4*n%M0S}#LK*6 zd8sv(ZLaGJmh*?A=iX*Ncy8C<Ws&u7{8sJCTYqNnlH2dUEjIDHoHwcLvZJ}&mp0G; zc_w=Nw?7?zT(xV}=5vy!;+LKuy&ZR+ecj)N>Ovv@$BvV}UAExUOFfdmV~!x(?Ksxk zrK0w?3sn8izx&T{;OocR$I{=Vee?YBJpSODC#ye%Zd);Fuhnh6m|Lc2+~eEk&)ZsW z{Zcdjp)!<YqS4v=CjY4<^1D6+ke{~&Sj!r;C=0vCjRwIq#6PrZ7=PnqIv;-A>o zZ<Krd^qtb1eKE)XAIp%|KYaaQWR}%VNj87+(=qE)cfC=W^KSj6-?PVGVIZJ{i}6n z_J6@^rIx?#B>5)i{M*p+O6$Mgs?&?vT|@kyyUw*gv+V89HS3;*#TJ;_n%t4sB_li zn>4*zqn%6;>fF0)Gw}(5fA*lW2X4z6E={OX8lL&523z6?}TNWZu)yFIMDy$|$R z(3{=vx;N*}nXWxDQ!CB%S7%-cIbIr9vUpqjBd4QfC${Yl+-Wg)+hh&($iEg<A-(<T zu2=lj^TiF<hsmxxuC+WjYtx%;vwQ9H^H1$Iulr@W<KjClzs(;rcOTrj^Y>$Y|9O9; z{>Z9lzF+YF?B9bQs^+9VK7Z(e&Ca*$l^EU!?x^|p?Y})kjQVNoYdodlHa_%u03V Tj6@S-|DS2eE8$QE1||jom5H3-

literal 0
HcmV?d00001

(quoted diff) +0 -0

b/tests/iso9660_ce_loop2.iso.gz new file mode 100644
index 0000000000000000000000000000000000000000..f59e676475cfc8376256ba65047451b5ca969e5a GIT binary patch literal 904 zcmb2|=3rP?urHZ``Rxt={M#uq3<<mExp{35L_sCiA%N4Zp)eg+;;Xn>+#@LT?l zg?-)QBTE*}RZ}c{9Q>yELuJ{_9m)%n)Op{A<yr=u*kac&^#9Mlui4L@#-85_(4NK ziNtYF2^VRR(nz1p>_2y(y8f5<9>;sh?Uh^KFSyM4EiAJ7cly!4-wLcf!dIHS*s@UA zhCja~?;X4K>u<Bu{%*9^TfJ(h(f3Jt)~JOvhdyQdCQmmZp8&@wZFSBF0sfs#oxE; z=Bjg6=r)Y=Zof7+sf~F#{BN6r%eyL=Pm!o7CR;g?thx(CXrJunsYt%PtM_7M6Se zGvjwOe%S++4__GcO*ZH-(|EOMMjHR8@~P{8|9;f_VP4_v@ZWq^a})BXZrxrVb|;^I zdvnQDuVz1KtAn3ExIKSXw_$VM{>*FgyB}{_HA}l#|K+#ce>Hk9Z<)R1ZpnpS_PvRh z_DlPAH81<~V8yJpuhtYF?~W><i~B-KR0IEJ&2og<Z#7=C4Wu&nz<!EM(d@u9NZRu zuq^i2d9#?V$(MiIGZd8m+4NCz_q=+cfB)PK?Dq-pJ9kU#=IhIE54FY~PWqGj<7MV= z^TQhZMZbkjt$KZ{e(mA!v!4n4+kLQ}``!9gckV|Xox5#8@#(KKin$(K09USf$93U z_K53WPu_DY_wc*brGL_UmVGp;5uLLv?egoy4{v@Hs^?t4q*uOo+09Lx3(C@?%Vuv z62pOdz4dYJ)!p%jS7|-FuX;FflCIpdz|g*Zy{jI5aFi3>>>AfAm$vy?P2AM(q7c7Z zliiOd#<_pJSQ8i4oe>juanG9W#~CppH|ex=zq!#d44%(n}*xhnn~%Ua=oW+DoNu zI=o2E_4DFp&pV#t5Y9W&Fk+fG(08dYT5nj(+a7lcUQbrv=84Xx#?wI%$DVw(}a$i ztd?{KXvk=N&l>uJ+oYOPKCC=-q;m6d6wSpwr5l&z}A9-B$T}u63rnyC&xpUCJp~ z_x|69FDEC@Z?=D|^7ifb{rlC;(9mde2SEqqq_ZXD9eL-5xx0)|NiG^2tWDh-27Xh c^m5?%o16ExrDG<Y@bmX~KG-skfq{tu09s$LV*mgE

literal 0
HcmV?d00001

Quoted 13 lines

tests/iso9660_test.in fi · line 17

Quoted 13 lines
tests/iso9660_test.in +3 -1
index ed0a5bf8d4..44bc08c6df 100644
@@ -12,4 +12,19 @@ fi
 "@builddir@/grub-fs-tester" rockridge_joliet
 "@builddir@/grub-fs-tester" joliet_1999
 "@builddir@/grub-fs-tester" rockridge_1999
-"@builddir@/grub-fs-tester" rockridge_joliet_1999
\ No newline at end of file
+"@builddir@/grub-fs-tester" rockridge_joliet_1999
+
+echo "Testing for proper recognition of CE loops ... "

Ugh, this should be "echo -n".

Quoted 20 lines
Quoted 9 lines
tests/iso9660_test.in +2 -0
+for fs in iso9660_ce_loop iso9660_ce_loop2; do
+  tempdir=`mktemp -d "${TMPDIR:-/tmp}/${0##*/}.$(date

'+%Y%m%d%H%M%S%N').${fs}.XXX"` ||

tests/iso9660_test.in +2 -0
+    { echo "Failed to make temporary directory"; exit 99; }
+  gunzip <"$srcdir"/tests/${fs}.iso.gz >"${tempdir}/${fs}.iso" ||

exit 99

tests/iso9660_test.in +2 -0
+  output=$(LC_ALL=C timeout -s KILL "60" \
+    "@builddir@/grub-fstest" "${tempdir}/${fs}.iso" ls / ) ||

ret=$?

tests/iso9660_test.in fi · line 30

Quoted 7 lines
tests/iso9660_test.in +7 -0
+  rm -rf "$tempdir"
+  if [ "${ret:-0}" -ne 0 -o -n "$output" ]; then
+    echo "FAIL ($fs)"
+    exit 1
+  fi
+done
+echo "PASS"
Quoted 8 lines

The test passes with unchanged grub-core/fs/iso9660.c.

It fails with disabled loop breaker and with disabled processing of CE at the start of a continuation area.
The message in test-suite.log is then:

Testing for proper recognition of CE loops ...
FAIL (iso9660_ce_loop)

Thanks for testing this. I now see that I forgot to not have a newline after "...". I'll make a v4.

Glenn

#3 lore raw

Hi,

Quoted 2 lines · Glenn Washburn
Quoted 1 line
Quoted 1 line

+echo "Testing for proper recognition of CE loops ... "

Ugh, this should be "echo -n".

Quoted 3 lines · My make "check
Quoted 3 lines

Testing for proper recognition of CE loops ...
FAIL (iso9660_ce_loop)
FAIL iso9660_test (exit status: 1)

Actually this looks quite ok to me.

With
echo -n "Testing for proper recognition of CE loops ... "
and a disabled loop breaker i get in test-suite.log:

Testing for proper recognition of CE loops ... FAIL (iso9660_ce_loop) FAIL iso9660_test (exit status: 1)

which looks to me like a newline is missing.

The combination of "echo -n" and "..." seems not to occur in the GRUB code:

  $ grep -r 'echo -n .*\.\.\.' . | less

Some echo without -n have "...":

  $ grep -r 'echo .*\.\.\.' . | wc -l
  65
  $ grep -r 'echo .*\.\.\.' tests
  tests/partmap_test.in:echo "Checking MSDOS partition types..."
  tests/partmap_test.in:echo "Checking GPT partition types..."
  tests/partmap_test.in:echo "Checking SUN partition types..."
  tests/partmap_test.in:echo "Checking APPLE partition types..."
  tests/partmap_test.in:echo "Checking DVH partition types..."
  tests/partmap_test.in:echo "Checking AMIGA partition types..."
  tests/partmap_test.in:echo "Checking DragonFly BSD disklabel64..."
  $

If "..." as line end is too near to ./configure style, then how about

echo "Testing for proper recognition of CE loops:"

Have a nice day :)

Thomas

#4 lore raw
Quoted 39 lines · On Thu, 16 Feb 2023 19:36:40 +0100 "Thomas Schmitt" <[email protected]> wrote:

Hi,

Quoted 2 lines · Glenn Washburn
Quoted 1 line
Quoted 1 line

+echo "Testing for proper recognition of CE loops ... "

Ugh, this should be "echo -n".

Quoted 3 lines · My make "check
Quoted 3 lines

Testing for proper recognition of CE loops ...
FAIL (iso9660_ce_loop)
FAIL iso9660_test (exit status: 1)

Actually this looks quite ok to me.

With
echo -n "Testing for proper recognition of CE loops ... "
and a disabled loop breaker i get in test-suite.log:

Testing for proper recognition of CE loops ... FAIL
(iso9660_ce_loop) FAIL iso9660_test (exit status: 1)

which looks to me like a newline is missing.

The combination of "echo -n" and "..." seems not to occur in the GRUB
code: $ grep -r 'echo -n .*\.\.\.' . | less

Some echo without -n have "...":

  $ grep -r 'echo .*\.\.\.' . | wc -l
  65
  $ grep -r 'echo .*\.\.\.' tests
  tests/partmap_test.in:echo "Checking MSDOS partition types..."
  tests/partmap_test.in:echo "Checking GPT partition types..."
  tests/partmap_test.in:echo "Checking SUN partition types..."
  tests/partmap_test.in:echo "Checking APPLE partition types..."
  tests/partmap_test.in:echo "Checking DVH partition types..."
  tests/partmap_test.in:echo "Checking AMIGA partition types..."
  tests/partmap_test.in:echo "Checking DragonFly BSD disklabel64..."
  $
Quoted 3 lines

If "..." as line end is too near to ./configure style, then how about

echo "Testing for proper recognition of CE loops:"

I think the without the new line looks better to me, but it is more consistent with partmap_test as it is now (and less consistent with grub_cmd_cryptomount). Either way it does what it needs to do and is easy enough for a person who needs to look into it to understand. So I'll leave it as is and see if Daniel has any suggestions. Thanks for surveying the code to see what makes sense in terms of consistency.

Glenn