Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/bin/dd tests/dd: add more test cases for swapping bytes



details:   https://anonhg.NetBSD.org/src/rev/3c221d971004
branches:  trunk
changeset: 366390:3c221d971004
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue May 24 21:42:37 2022 +0000

description:
tests/dd: add more test cases for swapping bytes

To demonstrate that the fix from PR 56433 works as intended.

diffstat:

 tests/bin/dd/t_dd.sh |  29 ++++++++++++++++++++---------
 1 files changed, 20 insertions(+), 9 deletions(-)

diffs (44 lines):

diff -r 95ae4141fb08 -r 3c221d971004 tests/bin/dd/t_dd.sh
--- a/tests/bin/dd/t_dd.sh      Tue May 24 20:50:17 2022 +0000
+++ b/tests/bin/dd/t_dd.sh      Tue May 24 21:42:37 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_dd.sh,v 1.2 2021/10/08 14:45:07 christos Exp $
+# $NetBSD: t_dd.sh,v 1.3 2022/05/24 21:42:37 rillig Exp $
 #
 # Copyright (c) 2007 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -129,15 +129,26 @@
 
 swab_body() {
        echo -n abcdefgh > testfile
-       atf_check -s exit:0 -e ignore -o inline:badcfehg \
-            dd if=testfile conv=swab msgfmt=quiet
-       atf_check -s exit:0 -e ignore -o inline:abcdefgh \
-            dd if=testfile conv=swab msgfmt=quiet bs=1
-       for i in 2 4 8; do
-           atf_check -s exit:0 -e ignore -o inline:badcfehg \
-                dd if=testfile conv=swab msgfmt=quiet bs=$i
-       done
+
+       test_swab() {
+               atf_check -o inline:"$1" \
+                   dd if=testfile conv=swab msgfmt=quiet $2
+       }
+
+       atf_check -o inline:badcfehg \
+           dd if=testfile conv=swab msgfmt=quiet
+
+       test_swap badcfehg # default block size
+       test_swab abcdefgh bs=1
+       test_swab badcfehg bs=2
+       test_swab bacedfhg bs=3
+       test_swab badcfehg bs=4
+       test_swab badcegfh bs=5
+       test_swab badcfehg bs=6
+       test_swab badcfegh bs=7
+       test_swab badcfehg bs=8
 }
+
 atf_init_test_cases()
 {
        atf_add_test_case length



Home | Main Index | Thread Index | Old Index