From beeb49b16f2cb8262e5a79fa4ace117ccd9ae5ee Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thomas=20Wei=C3=9Fschuh?= Date: Thu, 15 Dec 2022 13:08:18 +0000 Subject: [PATCH] mkswap: add tests --- tests/ts/mkswap/BE-4096.img.xz | Bin 0 -> 180 bytes tests/ts/mkswap/BE-8192.img.xz | Bin 0 -> 192 bytes tests/ts/mkswap/LE-4096.img.xz | Bin 0 -> 180 bytes tests/ts/mkswap/LE-8192.img.xz | Bin 0 -> 192 bytes tests/ts/mkswap/mkswap | 53 +++++++++++++++++++++++++++++++++ 5 files changed, 53 insertions(+) create mode 100644 tests/ts/mkswap/BE-4096.img.xz create mode 100644 tests/ts/mkswap/BE-8192.img.xz create mode 100644 tests/ts/mkswap/LE-4096.img.xz create mode 100644 tests/ts/mkswap/LE-8192.img.xz create mode 100755 tests/ts/mkswap/mkswap diff --git a/tests/ts/mkswap/BE-4096.img.xz b/tests/ts/mkswap/BE-4096.img.xz new file mode 100644 index 0000000000000000000000000000000000000000..97bb3a264dd4da735ec1f1515ef0232f9aafd07c GIT binary patch literal 180 zc-jH9089Vt=Y{r~@?w}b9+nUeKA z51^VL*R=r}tY_Pl`}OgiBC%*(sr6m%e>M(Du$&fF+542TRzQWt=Y{r~@?w}b9+nUeKA z51^VL*R=r}tY_Pl`}OgiBC%*(sr6m%e>M(Du$&fF+542TRzQanN@G3zjcbda0vpp4 z^0d~4B~c0o2;c~?^qjKl;!bN`I`0E%&Kp`B5F#>;qWxwigU_miEueIe__kcQ+>*p; ub2Vh;X#fBK0002&OxD$-9qL*D0h$4TfCT`yk<&A=#Ao{g000001X)@x?p4hI literal 0 Hc-jL100001 diff --git a/tests/ts/mkswap/LE-4096.img.xz b/tests/ts/mkswap/LE-4096.img.xz new file mode 100644 index 0000000000000000000000000000000000000000..ad33ce02addf6cc25dfd333493b7d327b27053d8 GIT binary patch literal 180 zc-jH9089Vt=Y{r~@?w|_@fnUeNX z@l>CWSQ@3xtNAd19#6$?cGEgOFw%Or%!{mx%3BXwT?j6+3P6be_6+jv33DIZz?Q)3 z*j)DYZ%Q#m>bt<8ZOU^q?1+k@A~J{mV4KiC{h&rju(AR3AI~A*CLc#C`K0+)0000= if!4-<2&m`)0gnNIzybi7853Wz#Ao{g000001X)_v*iw-I literal 0 Hc-jL100001 diff --git a/tests/ts/mkswap/LE-8192.img.xz b/tests/ts/mkswap/LE-8192.img.xz new file mode 100644 index 0000000000000000000000000000000000000000..b3187fbd879e9d73520da0a0cd0e456cb133fcc2 GIT binary patch literal 192 zc-jHL06+izH+ooF000E$*0e?f03iV!0000G&sfaiKmP!JT>t=Y{r~@?w|_@fnUeNX z@l>CWSQ@3xtNAd19#6$?cGEgOFw%Or%!{mx%3BXwT?j6+3P6f8-lM$;A1TECQC_J8 z3V~Dob#9P{=uN96|8*qWgFgn~bUCW;cqCM}?n2`$J6s4#KTw?7Ujtl{cKB +# +# This file is part of util-linux. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="mkswap" + +. "$TS_TOPDIR"/functions.sh + +ts_init "$*" + +ts_check_test_command "$TS_CMD_MKSWAP" +ts_check_test_command "$TS_HELPER_SYSINFO" +ts_check_prog "xz" +ts_check_prog "cmp" + +BYTE_ORDER="$("$TS_HELPER_SYSINFO" byte-order)" +UUID=4c08e1cd-3c82-46bf-a55b-0c3270d6dfeb + +for PAGESIZE in 4096 8192; do + name="${BYTE_ORDER}-${PAGESIZE}" + outimg="$TS_OUTDIR/${name}.img" + origimg="$TS_OUTDIR/${name}.img.orig" + + ts_init_subtest $name + + rm -f "$outimg" + truncate -s $(( PAGESIZE * 10 )) "$outimg" > $TS_ERRLOG 2>&1 + + "$TS_CMD_MKSWAP" -q -L label -U "$UUID" -p "$PAGESIZE" "$outimg" \ + > "$TS_OUTPUT" 2> "$TS_ERRLOG" || ts_log "mkswap failed" + xz -dc "$TS_SELF/${name}.img.xz" > "$origimg" + + cmp "$origimg" "$outimg" > "$TS_ERRLOG" 2>&1 + + ts_finalize_subtest +done + +ts_finalize -- 2.47.3