From: Matthias Andree Date: Thu, 26 Jun 2025 20:28:40 +0000 (+0200) Subject: m_offset: make self-test reliable with non-GNU yes(1) X-Git-Tag: v1.47.3-rc3~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=880b431f412017f521c2d328b7e234db4568ba35;p=thirdparty%2Fe2fsprogs.git m_offset: make self-test reliable with non-GNU yes(1) m_offset has been failing sporadically on FreeBSD, and always because crc_exp(ected) was different from all other CRC values (which were mutually equal, first1, first2, last). The test scrsipt uses yes(1) to write into dd(1), but FreeBSD's "yes a" use sizes of 8192 - length-of-pattern, meaning 8190 with "a\n" (meaning a + LF). GNU yes from coreutils 9.1 instead dispatches 1024-sized writes. The peculiar thing is that dd bs=1k count=512 will dispatch 512 read attempts of 1 k each, but due to yes and dd running concurrently, dd will sometimes see a short read block, resulting in an overall shorter output file fed into crcsum, leading to a mismatched crc_exp value. Fix: Add iflag=fullblock to ensure the proper output size will be fed into crcsum, even if that means doing more than 512 reads internally. Signed-off-by: Matthias Andree Link: https://lore.kernel.org/r/20250626202919.321842-1-matthias.andree@gmx.de Signed-off-by: Theodore Ts'o --- diff --git a/tests/m_offset/script b/tests/m_offset/script index d49e555e7..8b673ecb7 100755 --- a/tests/m_offset/script +++ b/tests/m_offset/script @@ -13,7 +13,7 @@ $MKE2FS -F -b 1024 -E offset=524288 "$TMPFILE" 1024 >> "$OUT" 2>&1 # compute crc of the first and last 512 1k blocks crc_first2=`$DD if="$TMPFILE" bs=1k count=512 2>/dev/null | $CRCSUM` crc_last2=`$DD if="$TMPFILE" bs=1k count=512 skip=1536 2>/dev/null | $CRCSUM` -crc_exp=`yes a | $DD bs=1k count=512 2>/dev/null | $CRCSUM` +crc_exp=`yes a | $DD bs=1k count=512 iflag=fullblock 2>/dev/null | $CRCSUM` # a warning should be only emitted by the first mke2fs call warning=`grep -c "offset specified without an explicit file system size." \ "$OUT"`