From cfe5e3905201349e9cf3f95d52ff4bd100bde37d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 21:10:49 +0200 Subject: Adding upstream version 2.39.3. Signed-off-by: Daniel Baumann --- tests/ts/bitops/swapbytes | 29 +++ tests/ts/blkdiscard/offsets | 101 ++++++++ tests/ts/blkid/cache | 48 ++++ tests/ts/blkid/dm-err | 52 ++++ tests/ts/blkid/images-fs/adaptec-raid.img.xz | Bin 0 -> 672 bytes tests/ts/blkid/images-fs/apfs.img.xz | Bin 0 -> 2728 bytes tests/ts/blkid/images-fs/bcache-B.img.xz | Bin 0 -> 180 bytes tests/ts/blkid/images-fs/bcache-C.img.xz | Bin 0 -> 9976 bytes tests/ts/blkid/images-fs/bcache-journal.img.xz | Bin 0 -> 2320 bytes tests/ts/blkid/images-fs/bcachefs-2.img.xz | Bin 0 -> 1000 bytes tests/ts/blkid/images-fs/bcachefs.img.xz | Bin 0 -> 1808 bytes tests/ts/blkid/images-fs/befs.img.xz | Bin 0 -> 28584 bytes tests/ts/blkid/images-fs/bfs.img.xz | Bin 0 -> 492 bytes tests/ts/blkid/images-fs/bluestore.img.xz | Bin 0 -> 412 bytes tests/ts/blkid/images-fs/btrfs.img.xz | Bin 0 -> 21696 bytes tests/ts/blkid/images-fs/cramfs-big.img.xz | Bin 0 -> 480 bytes tests/ts/blkid/images-fs/cramfs.img.xz | Bin 0 -> 144 bytes tests/ts/blkid/images-fs/cs_fvault2.img.xz | Bin 0 -> 200 bytes tests/ts/blkid/images-fs/ddf-raid.img.xz | Bin 0 -> 8140 bytes tests/ts/blkid/images-fs/drbd-v08.img.xz | Bin 0 -> 448 bytes tests/ts/blkid/images-fs/drbd-v09.img.xz | Bin 0 -> 460 bytes .../images-fs/drbdmanage-control-volume.img.xz | Bin 0 -> 2520 bytes tests/ts/blkid/images-fs/erofs.img.xz | Bin 0 -> 200 bytes tests/ts/blkid/images-fs/exfat.img.xz | Bin 0 -> 4620 bytes tests/ts/blkid/images-fs/ext2.img.xz | Bin 0 -> 384 bytes tests/ts/blkid/images-fs/ext3.img.xz | Bin 0 -> 1612 bytes tests/ts/blkid/images-fs/ext4.img.xz | Bin 0 -> 3140 bytes tests/ts/blkid/images-fs/f2fs.img.xz | Bin 0 -> 22432 bytes tests/ts/blkid/images-fs/fat.img.xz | Bin 0 -> 488 bytes tests/ts/blkid/images-fs/fat16_noheads.img.xz | Bin 0 -> 16300 bytes .../ts/blkid/images-fs/fat32_cp850_O_tilde.img.xz | Bin 0 -> 5400 bytes tests/ts/blkid/images-fs/fat32_label_64MB.img.xz | Bin 0 -> 10428 bytes .../ts/blkid/images-fs/fat32_mkdosfs_label1.img.xz | Bin 0 -> 5400 bytes .../fat32_mkdosfs_label1_dosfslabel_NO_NAME.img.xz | Bin 0 -> 5404 bytes .../fat32_mkdosfs_label1_dosfslabel_empty.img.xz | Bin 0 -> 5396 bytes .../fat32_mkdosfs_label1_dosfslabel_label2.img.xz | Bin 0 -> 5400 bytes .../fat32_mkdosfs_label1_mlabel_NO_NAME.img.xz | Bin 0 -> 5412 bytes .../fat32_mkdosfs_label1_mlabel_erase.img.xz | Bin 0 -> 5412 bytes .../images-fs/fat32_mkdosfs_label1_xp_erase.img.xz | Bin 0 -> 5400 bytes .../fat32_mkdosfs_label1_xp_label2.img.xz | Bin 0 -> 5404 bytes tests/ts/blkid/images-fs/fat32_mkdosfs_none.img.xz | Bin 0 -> 5376 bytes .../fat32_mkdosfs_none_dosfslabel_NO_NAME.img.xz | Bin 0 -> 5384 bytes .../fat32_mkdosfs_none_dosfslabel_label1.img.xz | Bin 0 -> 5380 bytes ...mkdosfs_none_dosfslabel_label1_xp_label2.img.xz | Bin 0 -> 5404 bytes .../images-fs/fat32_mkdosfs_none_xp_label1.img.xz | Bin 0 -> 5400 bytes ...mkdosfs_none_xp_label1_dosfslabel_label2.img.xz | Bin 0 -> 5396 bytes tests/ts/blkid/images-fs/fat32_xp_label1.img.xz | Bin 0 -> 5936 bytes tests/ts/blkid/images-fs/fat32_xp_none.img.xz | Bin 0 -> 5908 bytes .../fat32_xp_none_dosfslabel_label1.img.xz | Bin 0 -> 5908 bytes .../images-fs/fat32_xp_none_mlabel_label1.img.xz | Bin 0 -> 5660 bytes tests/ts/blkid/images-fs/gfs2.img.xz | Bin 0 -> 5092 bytes tests/ts/blkid/images-fs/hfs.img.xz | Bin 0 -> 1876 bytes tests/ts/blkid/images-fs/hfsplus.img.xz | Bin 0 -> 1940 bytes tests/ts/blkid/images-fs/hpfs.img.xz | Bin 0 -> 2172 bytes tests/ts/blkid/images-fs/hpt37x-raid.img.xz | Bin 0 -> 400 bytes tests/ts/blkid/images-fs/hpt45x-raid.img.xz | Bin 0 -> 424 bytes .../iso-different-iso-joliet-label.img.xz | Bin 0 -> 712 bytes tests/ts/blkid/images-fs/iso-joliet.img.xz | Bin 0 -> 21884 bytes .../iso-multi-0-174-348-genisoimage.img.xz | Bin 0 -> 656 bytes tests/ts/blkid/images-fs/iso-rr-joliet.img.xz | Bin 0 -> 22144 bytes .../blkid/images-fs/iso-unicode-long-label.img.xz | Bin 0 -> 616 bytes tests/ts/blkid/images-fs/iso.img.xz | Bin 0 -> 21656 bytes tests/ts/blkid/images-fs/isw-raid.img.xz | Bin 0 -> 528 bytes tests/ts/blkid/images-fs/jbd.img.xz | Bin 0 -> 688 bytes tests/ts/blkid/images-fs/jfs.img.xz | Bin 0 -> 4768 bytes tests/ts/blkid/images-fs/jmicron-raid.img.xz | Bin 0 -> 480 bytes tests/ts/blkid/images-fs/lsi-raid.img.xz | Bin 0 -> 436 bytes tests/ts/blkid/images-fs/luks1.img.xz | Bin 0 -> 300 bytes tests/ts/blkid/images-fs/luks2.img.xz | Bin 0 -> 276 bytes tests/ts/blkid/images-fs/lvm2.img.xz | Bin 0 -> 512 bytes tests/ts/blkid/images-fs/mdraid-1.img.xz | Bin 0 -> 1764 bytes tests/ts/blkid/images-fs/mdraid.img.xz | Bin 0 -> 1752 bytes tests/ts/blkid/images-fs/minix-BE.img.xz | Bin 0 -> 220 bytes tests/ts/blkid/images-fs/minix-LE.img.xz | Bin 0 -> 224 bytes tests/ts/blkid/images-fs/mpool.img.xz | Bin 0 -> 544 bytes tests/ts/blkid/images-fs/netware.img.xz | Bin 0 -> 244 bytes tests/ts/blkid/images-fs/nilfs2.img.xz | Bin 0 -> 25072 bytes tests/ts/blkid/images-fs/ntfs.img.xz | Bin 0 -> 89576 bytes tests/ts/blkid/images-fs/nvidia-raid.img.xz | Bin 0 -> 572 bytes tests/ts/blkid/images-fs/ocfs2.img.xz | Bin 0 -> 18644 bytes tests/ts/blkid/images-fs/promise-raid.img.xz | Bin 0 -> 740 bytes tests/ts/blkid/images-fs/reiser3.img.xz | Bin 0 -> 936 bytes tests/ts/blkid/images-fs/reiser4.img.xz | Bin 0 -> 904 bytes tests/ts/blkid/images-fs/romfs.img.xz | Bin 0 -> 384 bytes tests/ts/blkid/images-fs/silicon-raid.img.xz | Bin 0 -> 588 bytes tests/ts/blkid/images-fs/small-fat32.img.xz | Bin 0 -> 576 bytes tests/ts/blkid/images-fs/squashfs3.img.xz | Bin 0 -> 368 bytes tests/ts/blkid/images-fs/squashfs4.img.xz | Bin 0 -> 380 bytes tests/ts/blkid/images-fs/swap0.img.xz | Bin 0 -> 496 bytes tests/ts/blkid/images-fs/swap1-big.img.xz | Bin 0 -> 328 bytes tests/ts/blkid/images-fs/swap1.img.xz | Bin 0 -> 524 bytes tests/ts/blkid/images-fs/tuxonice.img.xz | Bin 0 -> 37032 bytes tests/ts/blkid/images-fs/ubi.img.xz | Bin 0 -> 380 bytes tests/ts/blkid/images-fs/ubifs.img.xz | Bin 0 -> 1128 bytes tests/ts/blkid/images-fs/udf-bdr-2.60-nero.img.xz | Bin 0 -> 1956 bytes .../images-fs/udf-cd-mkudfiso-20100208.img.xz | Bin 0 -> 756 bytes tests/ts/blkid/images-fs/udf-cd-nero-6.img.xz | Bin 0 -> 2168 bytes .../images-fs/udf-hdd-macosx-2.60-4096.img.xz | Bin 0 -> 2604 bytes .../blkid/images-fs/udf-hdd-mkudffs-1.0.0-1.img.xz | Bin 0 -> 2728 bytes .../blkid/images-fs/udf-hdd-mkudffs-1.0.0-2.img.xz | Bin 0 -> 2772 bytes .../blkid/images-fs/udf-hdd-mkudffs-1.3-1.img.xz | Bin 0 -> 2364 bytes .../blkid/images-fs/udf-hdd-mkudffs-1.3-2.img.xz | Bin 0 -> 2380 bytes .../blkid/images-fs/udf-hdd-mkudffs-1.3-3.img.xz | Bin 0 -> 2376 bytes .../blkid/images-fs/udf-hdd-mkudffs-1.3-4.img.xz | Bin 0 -> 2380 bytes .../blkid/images-fs/udf-hdd-mkudffs-1.3-5.img.xz | Bin 0 -> 2396 bytes .../blkid/images-fs/udf-hdd-mkudffs-1.3-6.img.xz | Bin 0 -> 2360 bytes .../blkid/images-fs/udf-hdd-mkudffs-1.3-7.img.xz | Bin 0 -> 2720 bytes .../blkid/images-fs/udf-hdd-mkudffs-1.3-8.img.xz | Bin 0 -> 2328 bytes .../ts/blkid/images-fs/udf-hdd-mkudffs-2.2.img.xz | Bin 0 -> 2396 bytes .../blkid/images-fs/udf-hdd-udfclient-0.7.5.img.xz | Bin 0 -> 2292 bytes .../blkid/images-fs/udf-hdd-udfclient-0.7.7.img.xz | Bin 0 -> 2296 bytes tests/ts/blkid/images-fs/udf-hdd-win7.img.xz | Bin 0 -> 2624 bytes .../images-fs/udf-multi-0-320-640-mkudffs.img.xz | Bin 0 -> 1720 bytes .../udf-multi-0-417-834-genisoimage.img.xz | Bin 0 -> 3176 bytes tests/ts/blkid/images-fs/udf.img.xz | Bin 0 -> 1884 bytes tests/ts/blkid/images-fs/ufs.img.xz | Bin 0 -> 1296 bytes tests/ts/blkid/images-fs/vdo.img.xz | Bin 0 -> 140 bytes tests/ts/blkid/images-fs/via-raid.img.xz | Bin 0 -> 528 bytes tests/ts/blkid/images-fs/vmfs.img.xz | Bin 0 -> 512 bytes tests/ts/blkid/images-fs/vmfs_volume.img.xz | Bin 0 -> 680 bytes tests/ts/blkid/images-fs/xfs-log.img.xz | Bin 0 -> 1720 bytes tests/ts/blkid/images-fs/xfs-v5.img.xz | Bin 0 -> 4040 bytes tests/ts/blkid/images-fs/xfs.img.xz | Bin 0 -> 2892 bytes tests/ts/blkid/images-fs/zfs.img.xz | Bin 0 -> 19904 bytes tests/ts/blkid/images-fs/zonefs.img.xz | Bin 0 -> 784 bytes tests/ts/blkid/images-pt/atari-primary.img.xz | Bin 0 -> 932 bytes tests/ts/blkid/images-pt/atari-xgm.img.xz | Bin 0 -> 956 bytes tests/ts/blkid/images-pt/bsd.img.xz | Bin 0 -> 840 bytes tests/ts/blkid/images-pt/dos+bsd.img.xz | Bin 0 -> 2620 bytes tests/ts/blkid/images-pt/gpt.img.xz | Bin 0 -> 2140 bytes tests/ts/blkid/images-pt/sgi.img.xz | Bin 0 -> 1724 bytes tests/ts/blkid/images-pt/sun.img.xz | Bin 0 -> 1748 bytes tests/ts/blkid/low-probe | 66 +++++ tests/ts/blkid/lowprobe-pt | 44 ++++ tests/ts/blkid/md-raid0-whole | 99 +++++++ tests/ts/blkid/md-raid1-part | 99 +++++++ tests/ts/blkid/md-raid1-whole | 103 ++++++++ tests/ts/blkid/offset | 58 +++++ tests/ts/blkid/topology | 54 ++++ tests/ts/build-sys/config | 83 ++++++ tests/ts/cal/bigyear | 83 ++++++ tests/ts/cal/color | 95 +++++++ tests/ts/cal/colorw | 80 ++++++ tests/ts/cal/column | 49 ++++ tests/ts/cal/jan1753 | 45 ++++ tests/ts/cal/month | 72 ++++++ tests/ts/cal/sep1752 | 86 +++++++ tests/ts/cal/vertical | 72 ++++++ tests/ts/cal/weekarg | 99 +++++++ tests/ts/cal/weeknum | 57 ++++ tests/ts/cal/year | 54 ++++ tests/ts/chfn/gecos | 38 +++ tests/ts/col/io | 86 +++++++ tests/ts/col/multibyte | 40 +++ tests/ts/col/multibyte.data | 1 + tests/ts/col/newlines | 46 ++++ tests/ts/col/options | 43 ++++ tests/ts/colcrt/crash1 | Bin 0 -> 314 bytes tests/ts/colcrt/crash2 | Bin 0 -> 776 bytes tests/ts/colcrt/functional | 51 ++++ tests/ts/colcrt/hang1 | 1 + tests/ts/colcrt/nasty-input | Bin 0 -> 545 bytes tests/ts/colcrt/regressions | 38 +++ tests/ts/colcrt/underlines | 23 ++ tests/ts/colrm/rm2-2 | 28 ++ tests/ts/column/columnate | 52 ++++ tests/ts/column/files/fivecols | 10 + tests/ts/column/files/mountinfo | 41 +++ tests/ts/column/files/onecolumn | 9 + tests/ts/column/files/table | 6 + tests/ts/column/files/table-empty-lines | 6 + tests/ts/column/files/table-sep | 6 + tests/ts/column/files/table-sep-space | 6 + tests/ts/column/invalid-multibyte | 30 +++ tests/ts/column/multi-file | 34 +++ tests/ts/column/table | 148 +++++++++++ tests/ts/cramfs/cramfs-big.img | Bin 0 -> 4096 bytes tests/ts/cramfs/cramfs-little.img | Bin 0 -> 4096 bytes tests/ts/cramfs/doubles | 62 +++++ tests/ts/cramfs/fsck-bad-header | 102 ++++++++ tests/ts/cramfs/fsck-endianness | 58 +++++ tests/ts/cramfs/mkfs | 125 +++++++++ tests/ts/cramfs/mkfs-endianness | 63 +++++ tests/ts/cramfs/mkfs-endianness_testdata_a | 8 + tests/ts/cramfs/mkfs-endianness_testdata_b | 217 ++++++++++++++++ tests/ts/dmesg/colors | 29 +++ tests/ts/dmesg/console-levels | 36 +++ tests/ts/dmesg/decode | 28 ++ tests/ts/dmesg/delta | 28 ++ tests/ts/dmesg/facilities | 30 +++ tests/ts/dmesg/indentation | 40 +++ tests/ts/dmesg/input | 105 ++++++++ tests/ts/dmesg/limit | 29 +++ tests/ts/dmesg/newlines | 5 + tests/ts/eject/umount | 127 +++++++++ tests/ts/fadvise/drop | 67 +++++ tests/ts/fdisk/align-512-4K | 79 ++++++ tests/ts/fdisk/align-512-4K-63 | 80 ++++++ tests/ts/fdisk/align-512-4K-md | 104 ++++++++ tests/ts/fdisk/align-512-512 | 73 ++++++ tests/ts/fdisk/align-512-512-topology | 79 ++++++ tests/ts/fdisk/bsd | 141 ++++++++++ tests/ts/fdisk/gpt | 107 ++++++++ tests/ts/fdisk/gpt-resize | 63 +++++ tests/ts/fdisk/id | 56 ++++ tests/ts/fdisk/mbr-dos-mode | 145 +++++++++++ tests/ts/fdisk/mbr-nondos-mode | 190 ++++++++++++++ tests/ts/fdisk/mbr-sort | 83 ++++++ tests/ts/fdisk/oddinput | 53 ++++ tests/ts/fdisk/sunlabel | 104 ++++++++ tests/ts/fincore/count | 230 +++++++++++++++++ tests/ts/findmnt/files/mountinfo | 32 +++ tests/ts/findmnt/files/mountinfo-messy | 29 +++ tests/ts/findmnt/files/mountinfo-nonroot | 31 +++ tests/ts/findmnt/filter | 79 ++++++ tests/ts/findmnt/outputs | 49 ++++ tests/ts/findmnt/target | 35 +++ tests/ts/fsck/ismounted | 49 ++++ tests/ts/fuzzers/test_blkid_fuzz | 29 +++ .../fuzzers/test_blkid_fuzz_files/oss-fuzz-53142 | Bin 0 -> 1025 bytes .../fuzzers/test_blkid_fuzz_files/oss-fuzz-53149 | Bin 0 -> 35663 bytes .../fuzzers/test_blkid_fuzz_files/oss-fuzz-53160 | Bin 0 -> 1024 bytes .../fuzzers/test_blkid_fuzz_files/oss-fuzz-55282 | Bin 0 -> 131072 bytes .../fuzzers/test_blkid_fuzz_files/oss-fuzz-55291 | Bin 0 -> 131305 bytes .../fuzzers/test_blkid_fuzz_files/oss-fuzz-55318 | Bin 0 -> 134034 bytes .../fuzzers/test_blkid_fuzz_files/oss-fuzz-62691 | Bin 0 -> 16863 bytes tests/ts/fuzzers/test_fdisk_script_fuzz | 29 +++ .../crash-8ae1c667bed4b4b864f62e78cded81d5083177eb | 1 + .../crash-d216dfd17039a189c3858d78fbcf588695439b3b | 1 + .../test_fdisk_script_fuzz_files/github-1015-1 | Bin 0 -> 12 bytes .../test_fdisk_script_fuzz_files/github-1015-2 | 2 + .../test_fdisk_script_fuzz_files/oss-fuzz-24589 | 2 + .../test_fdisk_script_fuzz_files/oss-fuzz-24861 | 1 + ...parse_line_valcommas-use-of-uninitialized-value | 1 + tests/ts/fuzzers/test_last_fuzz | 29 +++ tests/ts/fuzzers/test_last_fuzz_files/github-1097 | Bin 0 -> 384 bytes tests/ts/fuzzers/test_mount_fuzz | 29 +++ .../fuzzers/test_mount_fuzz_files/oss-fuzz-23722 | Bin 0 -> 4 bytes tests/ts/getopt/basic | 49 ++++ tests/ts/getopt/options | 231 +++++++++++++++++ tests/ts/hardlink/options | 107 ++++++++ tests/ts/hardlink/testdir1.tar.xz | Bin 0 -> 26468 bytes tests/ts/hexdump/files/ascii.in | Bin 0 -> 640 bytes tests/ts/hexdump/format-strings | 69 +++++ tests/ts/hexdump/highlighting | 267 +++++++++++++++++++ tests/ts/hwclock/show | 38 +++ tests/ts/hwclock/systohc | 103 ++++++++ tests/ts/ipcs/functions.sh | 114 ++++++++ tests/ts/ipcs/headers | 60 +++++ tests/ts/ipcs/limits | 54 ++++ tests/ts/ipcs/limits2 | 37 +++ tests/ts/ipcs/mk-rm-msg | 44 ++++ tests/ts/ipcs/mk-rm-sem | 44 ++++ tests/ts/ipcs/mk-rm-shm | 44 ++++ tests/ts/isosize/print-size | 37 +++ tests/ts/isosize/sample.iso.gz | Bin 0 -> 632 bytes tests/ts/kill/all_processes | 66 +++++ tests/ts/kill/kill_functions.sh | 29 +++ tests/ts/kill/name_to_number | 75 ++++++ tests/ts/kill/options | 68 +++++ tests/ts/kill/print_pid | 63 +++++ tests/ts/kill/queue | 58 +++++ tests/ts/lib/procfs | 57 ++++ tests/ts/lib/procfs-data/proc/1/cmdline | Bin 0 -> 7 bytes tests/ts/lib/procfs-data/proc/1/comm | 1 + tests/ts/lib/procfs-data/proc/1/stat | 1 + tests/ts/lib/procfs-data/proc/2/cmdline | Bin 0 -> 10 bytes tests/ts/lib/procfs-data/proc/2/comm | 2 + tests/ts/lib/procfs-data/proc/2/stat | 2 + tests/ts/lib/procfs-data/proc/3/cmdline | Bin 0 -> 11 bytes tests/ts/lib/procfs-data/proc/3/comm | 1 + tests/ts/lib/procfs-data/proc/3/stat | 1 + tests/ts/lib/timeutils | 24 ++ tests/ts/libfdisk/gpt | 65 +++++ tests/ts/libfdisk/mkpart | 66 +++++ tests/ts/libfdisk/mkpart-full | 225 ++++++++++++++++ tests/ts/libmount/context | 169 ++++++++++++ tests/ts/libmount/context-py | 152 +++++++++++ tests/ts/libmount/context-utab | 129 ++++++++++ tests/ts/libmount/context-utab-py | 134 ++++++++++ tests/ts/libmount/debug | 30 +++ tests/ts/libmount/files/fstab | 14 + tests/ts/libmount/files/fstab.broken | 14 + tests/ts/libmount/files/fstab.comment | 22 ++ tests/ts/libmount/files/kernel_cmdline | 1 + tests/ts/libmount/files/mountinfo | 33 +++ tests/ts/libmount/files/mountinfo_mv | 32 +++ tests/ts/libmount/files/mountinfo_nosrc | 7 + tests/ts/libmount/files/mountinfo_re | 32 +++ tests/ts/libmount/files/mountinfo_u | 31 +++ tests/ts/libmount/files/mtab | 12 + tests/ts/libmount/files/swaps | 4 + tests/ts/libmount/lock | 41 +++ tests/ts/libmount/loop | 152 +++++++++++ tests/ts/libmount/loop-overlay | 65 +++++ tests/ts/libmount/optstr | 160 ++++++++++++ tests/ts/libmount/tabdiff | 31 +++ tests/ts/libmount/tabfiles | 85 ++++++ tests/ts/libmount/tabfiles-py | 75 ++++++ tests/ts/libmount/tabfiles-tags | 86 +++++++ tests/ts/libmount/tabfiles-tags-py | 90 +++++++ tests/ts/libmount/update | 69 +++++ tests/ts/libmount/update-py | 32 +++ tests/ts/libmount/utils | 84 ++++++ tests/ts/libsmartcols/files/col-hidden | 3 + tests/ts/libsmartcols/files/col-id | 3 + tests/ts/libsmartcols/files/col-name | 3 + tests/ts/libsmartcols/files/col-noextremes | 3 + tests/ts/libsmartcols/files/col-number | 3 + tests/ts/libsmartcols/files/col-parent | 3 + tests/ts/libsmartcols/files/col-strict | 3 + tests/ts/libsmartcols/files/col-string | 3 + tests/ts/libsmartcols/files/col-tree | 3 + tests/ts/libsmartcols/files/col-trunc | 3 + tests/ts/libsmartcols/files/col-wrap | 3 + tests/ts/libsmartcols/files/col-wrapnl | 3 + tests/ts/libsmartcols/files/data-id | 10 + tests/ts/libsmartcols/files/data-number | 10 + tests/ts/libsmartcols/files/data-number-tiny | 10 + tests/ts/libsmartcols/files/data-parent | 10 + tests/ts/libsmartcols/files/data-string | 10 + tests/ts/libsmartcols/files/data-string-empty | 10 + tests/ts/libsmartcols/files/data-string-extreme | 10 + tests/ts/libsmartcols/files/data-string-long | 10 + tests/ts/libsmartcols/files/data-string-nl | 10 + tests/ts/libsmartcols/fromfile | 286 +++++++++++++++++++++ tests/ts/libsmartcols/title | 28 ++ tests/ts/logger/errors | 116 +++++++++ tests/ts/logger/formats | 85 ++++++ tests/ts/logger/journald | 35 +++ tests/ts/logger/options | 82 ++++++ tests/ts/login/islocal | 29 +++ tests/ts/login/islocal.data | 10 + tests/ts/login/logindefs | 26 ++ tests/ts/login/logindefs.data | 16 ++ tests/ts/look/separator | 41 +++ tests/ts/look/words | 3 + tests/ts/losetup/losetup | 86 +++++++ tests/ts/losetup/losetup-blkdev | 81 ++++++ tests/ts/losetup/losetup-loop | 247 ++++++++++++++++++ tests/ts/losetup/losetup_functions.sh | 7 + tests/ts/lsblk/README | 19 ++ tests/ts/lsblk/dumps/simple-lvm.tar.xz | Bin 0 -> 14216 bytes tests/ts/lsblk/dumps/simple-nvme.tar.xz | Bin 0 -> 10292 bytes tests/ts/lsblk/lsblk | 56 ++++ tests/ts/lsblk/mk-input.sh | 124 +++++++++ tests/ts/lscpu/dumps/armv7.tar.gz | Bin 0 -> 3163 bytes .../dumps/loongarch-loongson_3a5000_hv.tar.gz | Bin 0 -> 7954 bytes tests/ts/lscpu/dumps/ppc-qemu.tar.gz | Bin 0 -> 2014 bytes tests/ts/lscpu/dumps/ppc64-POWER7-64cpu.tar.gz | Bin 0 -> 56867 bytes tests/ts/lscpu/dumps/ppc64-POWER7.tar.gz | Bin 0 -> 14350 bytes tests/ts/lscpu/dumps/rv64-linux.tar.gz | Bin 0 -> 4215 bytes tests/ts/lscpu/dumps/s390-kvm.tar.gz | Bin 0 -> 2275 bytes tests/ts/lscpu/dumps/s390-lpar-drawer.tar.gz | Bin 0 -> 18131 bytes tests/ts/lscpu/dumps/s390-lpar.tar.gz | Bin 0 -> 6611 bytes tests/ts/lscpu/dumps/s390-nested-virt.tar.gz | Bin 0 -> 7199 bytes tests/ts/lscpu/dumps/s390-zvm.tar.gz | Bin 0 -> 2582 bytes tests/ts/lscpu/dumps/sparc64.tar.gz | Bin 0 -> 2756 bytes tests/ts/lscpu/dumps/vbox-win.tar.gz | Bin 0 -> 15769 bytes tests/ts/lscpu/dumps/vmware_fpe.tar.gz | Bin 0 -> 59743 bytes tests/ts/lscpu/dumps/x86_64-64cpu-linux6.2.tar.gz | Bin 0 -> 39020 bytes tests/ts/lscpu/dumps/x86_64-64cpu.tar.gz | Bin 0 -> 153140 bytes tests/ts/lscpu/dumps/x86_64-dell_e4310.tar.gz | Bin 0 -> 12933 bytes tests/ts/lscpu/dumps/x86_64-epyc_7451.tar.gz | Bin 0 -> 361027 bytes tests/ts/lscpu/lscpu | 61 +++++ tests/ts/lscpu/mk-input.sh | 48 ++++ tests/ts/lsfd/column-ainodeclass | 52 ++++ tests/ts/lsfd/column-kthread | 41 +++ tests/ts/lsfd/column-name | 74 ++++++ tests/ts/lsfd/column-type | 60 +++++ tests/ts/lsfd/lsfd-functions.bash | 85 ++++++ tests/ts/lsfd/mkfds-directory | 109 ++++++++ tests/ts/lsfd/mkfds-mapped-packet-socket | 65 +++++ tests/ts/lsfd/mkfds-netlink-groups | 59 +++++ tests/ts/lsfd/mkfds-netlink-protocol | 58 +++++ tests/ts/lsfd/mkfds-netns | 72 ++++++ tests/ts/lsfd/mkfds-pidfd | 51 ++++ tests/ts/lsfd/mkfds-ping | 142 ++++++++++ tests/ts/lsfd/mkfds-pipe-no-fork | 124 +++++++++ tests/ts/lsfd/mkfds-raw | 49 ++++ tests/ts/lsfd/mkfds-raw6 | 50 ++++ tests/ts/lsfd/mkfds-ro-block-device | 80 ++++++ tests/ts/lsfd/mkfds-ro-regular-file | 78 ++++++ tests/ts/lsfd/mkfds-rw-character-device | 50 ++++ tests/ts/lsfd/mkfds-socketpair | 48 ++++ tests/ts/lsfd/mkfds-symlink | 45 ++++ tests/ts/lsfd/mkfds-tcp | 50 ++++ tests/ts/lsfd/mkfds-tcp6 | 51 ++++ tests/ts/lsfd/mkfds-udp | 138 ++++++++++ tests/ts/lsfd/mkfds-udp6 | 139 ++++++++++ tests/ts/lsfd/mkfds-unix-dgram | 68 +++++ tests/ts/lsfd/mkfds-unix-in-netns | 109 ++++++++ tests/ts/lsfd/mkfds-unix-stream | 98 +++++++ tests/ts/lsfd/option-filter-broken-exp | 36 +++ tests/ts/lsfd/option-inet | 98 +++++++ tests/ts/lsfd/option-pid | 80 ++++++ tests/ts/lsfd/option-summary | 62 +++++ tests/ts/lsmem/dumps/s390-zvm-6g.tar.bz2 | Bin 0 -> 2459 bytes tests/ts/lsmem/dumps/x86_64-16g.tar.bz2 | Bin 0 -> 8660 bytes tests/ts/lsmem/lsmem | 60 +++++ tests/ts/lsmem/mk-input.sh | 22 ++ tests/ts/lsns/ioctl_ns | 118 +++++++++ tests/ts/lsns/netnsid | 97 +++++++ tests/ts/lsns/nsfs | 95 +++++++ tests/ts/md5/data | 7 + tests/ts/md5/md5 | 31 +++ tests/ts/minix/broken-root | Bin 0 -> 5120 bytes tests/ts/minix/debian.bug.773892 | Bin 0 -> 16384 bytes tests/ts/minix/fsck | 59 +++++ tests/ts/minix/fsck-images | 90 +++++++ tests/ts/minix/mkfs | 57 ++++ tests/ts/misc/fallocate | 39 +++ tests/ts/misc/flock | 124 +++++++++ tests/ts/misc/ionice | 30 +++ tests/ts/misc/line | 65 +++++ tests/ts/misc/mbsencode | 85 ++++++ tests/ts/misc/mcookie | 28 ++ tests/ts/misc/mountpoint | 36 +++ tests/ts/misc/pipesz | 80 ++++++ tests/ts/misc/rev | 34 +++ tests/ts/misc/setarch | 109 ++++++++ tests/ts/misc/setsid | 25 ++ tests/ts/misc/strtosize | 62 +++++ tests/ts/misc/swaplabel | 69 +++++ tests/ts/misc/waitpid | 59 +++++ tests/ts/misc/whereis | 50 ++++ 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 | 65 +++++ tests/ts/more/regexp | 27 ++ tests/ts/more/squeeze | 26 ++ tests/ts/mount/complex | 106 ++++++++ tests/ts/mount/devname | 57 ++++ tests/ts/mount/dm-verity | 72 ++++++ tests/ts/mount/fallback | 86 +++++++ tests/ts/mount/fslists | 90 +++++++ tests/ts/mount/fstab-all | 156 +++++++++++ tests/ts/mount/fstab-bind | 35 +++ tests/ts/mount/fstab-broken | 81 ++++++ tests/ts/mount/fstab-btrfs | 144 +++++++++++ tests/ts/mount/fstab-devname | 58 +++++ tests/ts/mount/fstab-devname2label | 52 ++++ tests/ts/mount/fstab-devname2uuid | 50 ++++ tests/ts/mount/fstab-label | 63 +++++ tests/ts/mount/fstab-label2devname | 60 +++++ tests/ts/mount/fstab-label2uuid | 63 +++++ tests/ts/mount/fstab-loop | 56 ++++ tests/ts/mount/fstab-none | 38 +++ tests/ts/mount/fstab-symlink | 71 +++++ tests/ts/mount/fstab-uuid | 64 +++++ tests/ts/mount/fstab-uuid2devname | 59 +++++ tests/ts/mount/fstab-uuid2label | 61 +++++ tests/ts/mount/label | 56 ++++ tests/ts/mount/move | 95 +++++++ tests/ts/mount/regfile | 41 +++ tests/ts/mount/remount | 59 +++++ tests/ts/mount/set_ugid_mode | 64 +++++ tests/ts/mount/shared-subtree | 87 +++++++ tests/ts/mount/special | 61 +++++ tests/ts/mount/subdir | 66 +++++ tests/ts/mount/umount-alltargets | 120 +++++++++ tests/ts/mount/umount-recursive | 100 +++++++ tests/ts/mount/uuid | 53 ++++ tests/ts/namei/logic | 35 +++ tests/ts/partx/partx | 186 ++++++++++++++ tests/ts/partx/partx-image | 43 ++++ tests/ts/paths/built-in | 32 +++ tests/ts/rename/basic | 75 ++++++ tests/ts/rename/exit_codes | 42 +++ tests/ts/rename/overwrite | 31 +++ tests/ts/rename/subdir | 95 +++++++ tests/ts/rename/symlink | 57 ++++ tests/ts/schedutils/chrt | 110 ++++++++ tests/ts/schedutils/chrt-non-root | 61 +++++ tests/ts/schedutils/cpuset | 59 +++++ tests/ts/script/buffering-race | 27 ++ tests/ts/script/options | 66 +++++ tests/ts/script/race | 48 ++++ tests/ts/script/replay | 98 +++++++ tests/ts/sfdisk/dos | 276 ++++++++++++++++++++ tests/ts/sfdisk/dump | 87 +++++++ tests/ts/sfdisk/files/dump-gaps | 7 + tests/ts/sfdisk/files/dump-old | 7 + tests/ts/sfdisk/gpt | 206 +++++++++++++++ tests/ts/sfdisk/movedata | 75 ++++++ tests/ts/sfdisk/resize | 154 +++++++++++ tests/ts/sfdisk/script | 157 +++++++++++ tests/ts/sfdisk/wipe | 104 ++++++++ tests/ts/sha1/data | 7 + tests/ts/sha1/sha1 | 31 +++ tests/ts/swapon/devname | 50 ++++ tests/ts/swapon/fixpgsz | 49 ++++ tests/ts/swapon/fixsig | 53 ++++ tests/ts/swapon/label | 52 ++++ tests/ts/swapon/uuid | 50 ++++ tests/ts/ul/basic | 42 +++ tests/ts/ul/basic.input | 95 +++++++ tests/ts/ul/filter.input | 9 + tests/ts/ul/ul | 29 +++ tests/ts/utmp/last | 93 +++++++ tests/ts/utmp/last-ipv6 | 66 +++++ tests/ts/utmp/subsec | 3 + tests/ts/utmp/txt-a | 19 ++ tests/ts/utmp/txt-a-old | 19 ++ tests/ts/utmp/txt-b | 10 + tests/ts/utmp/txt-b-old | 10 + tests/ts/utmp/txt-ipv6 | 2 + tests/ts/utmp/txt-ipv6-old | 2 + tests/ts/utmp/utmp_functions.sh | 18 ++ tests/ts/utmp/utmpdump-circle | 48 ++++ tests/ts/utmp/utmpdump-subsecond | 32 +++ tests/ts/utmp/utmpdump-tobin | 32 +++ tests/ts/utmp/utmpdump-tobin-ipv6 | 32 +++ tests/ts/utmp/utmpdump-totxt | 28 ++ tests/ts/utmp/utmpdump-totxt-ipv6 | 28 ++ tests/ts/utmp/wtmp-a.BE | Bin 0 -> 7296 bytes tests/ts/utmp/wtmp-a.LE | Bin 0 -> 7296 bytes tests/ts/utmp/wtmp-b.BE | Bin 0 -> 3840 bytes tests/ts/utmp/wtmp-b.LE | Bin 0 -> 3840 bytes tests/ts/utmp/wtmp-ipv6.BE | Bin 0 -> 768 bytes tests/ts/utmp/wtmp-ipv6.LE | Bin 0 -> 768 bytes tests/ts/uuid/namespace | 29 +++ tests/ts/uuid/oids | 33 +++ tests/ts/uuid/uuid_parser | 26 ++ tests/ts/uuid/uuidd | 59 +++++ tests/ts/uuid/uuidgen | 45 ++++ tests/ts/uuid/uuidparse | 61 +++++ tests/ts/wipefs/wipefs | 33 +++ 530 files changed, 20672 insertions(+) create mode 100755 tests/ts/bitops/swapbytes create mode 100755 tests/ts/blkdiscard/offsets create mode 100755 tests/ts/blkid/cache create mode 100755 tests/ts/blkid/dm-err create mode 100644 tests/ts/blkid/images-fs/adaptec-raid.img.xz create mode 100644 tests/ts/blkid/images-fs/apfs.img.xz create mode 100644 tests/ts/blkid/images-fs/bcache-B.img.xz create mode 100644 tests/ts/blkid/images-fs/bcache-C.img.xz create mode 100644 tests/ts/blkid/images-fs/bcache-journal.img.xz create mode 100644 tests/ts/blkid/images-fs/bcachefs-2.img.xz create mode 100644 tests/ts/blkid/images-fs/bcachefs.img.xz create mode 100644 tests/ts/blkid/images-fs/befs.img.xz create mode 100644 tests/ts/blkid/images-fs/bfs.img.xz create mode 100644 tests/ts/blkid/images-fs/bluestore.img.xz create mode 100644 tests/ts/blkid/images-fs/btrfs.img.xz create mode 100644 tests/ts/blkid/images-fs/cramfs-big.img.xz create mode 100644 tests/ts/blkid/images-fs/cramfs.img.xz create mode 100644 tests/ts/blkid/images-fs/cs_fvault2.img.xz create mode 100644 tests/ts/blkid/images-fs/ddf-raid.img.xz create mode 100644 tests/ts/blkid/images-fs/drbd-v08.img.xz create mode 100644 tests/ts/blkid/images-fs/drbd-v09.img.xz create mode 100644 tests/ts/blkid/images-fs/drbdmanage-control-volume.img.xz create mode 100644 tests/ts/blkid/images-fs/erofs.img.xz create mode 100644 tests/ts/blkid/images-fs/exfat.img.xz create mode 100644 tests/ts/blkid/images-fs/ext2.img.xz create mode 100644 tests/ts/blkid/images-fs/ext3.img.xz create mode 100644 tests/ts/blkid/images-fs/ext4.img.xz create mode 100644 tests/ts/blkid/images-fs/f2fs.img.xz create mode 100644 tests/ts/blkid/images-fs/fat.img.xz create mode 100644 tests/ts/blkid/images-fs/fat16_noheads.img.xz create mode 100644 tests/ts/blkid/images-fs/fat32_cp850_O_tilde.img.xz create mode 100644 tests/ts/blkid/images-fs/fat32_label_64MB.img.xz create mode 100644 tests/ts/blkid/images-fs/fat32_mkdosfs_label1.img.xz create mode 100644 tests/ts/blkid/images-fs/fat32_mkdosfs_label1_dosfslabel_NO_NAME.img.xz create mode 100644 tests/ts/blkid/images-fs/fat32_mkdosfs_label1_dosfslabel_empty.img.xz create mode 100644 tests/ts/blkid/images-fs/fat32_mkdosfs_label1_dosfslabel_label2.img.xz create mode 100644 tests/ts/blkid/images-fs/fat32_mkdosfs_label1_mlabel_NO_NAME.img.xz create mode 100644 tests/ts/blkid/images-fs/fat32_mkdosfs_label1_mlabel_erase.img.xz create mode 100644 tests/ts/blkid/images-fs/fat32_mkdosfs_label1_xp_erase.img.xz create mode 100644 tests/ts/blkid/images-fs/fat32_mkdosfs_label1_xp_label2.img.xz create mode 100644 tests/ts/blkid/images-fs/fat32_mkdosfs_none.img.xz create mode 100644 tests/ts/blkid/images-fs/fat32_mkdosfs_none_dosfslabel_NO_NAME.img.xz create mode 100644 tests/ts/blkid/images-fs/fat32_mkdosfs_none_dosfslabel_label1.img.xz create mode 100644 tests/ts/blkid/images-fs/fat32_mkdosfs_none_dosfslabel_label1_xp_label2.img.xz create mode 100644 tests/ts/blkid/images-fs/fat32_mkdosfs_none_xp_label1.img.xz create mode 100644 tests/ts/blkid/images-fs/fat32_mkdosfs_none_xp_label1_dosfslabel_label2.img.xz create mode 100644 tests/ts/blkid/images-fs/fat32_xp_label1.img.xz create mode 100644 tests/ts/blkid/images-fs/fat32_xp_none.img.xz create mode 100644 tests/ts/blkid/images-fs/fat32_xp_none_dosfslabel_label1.img.xz create mode 100644 tests/ts/blkid/images-fs/fat32_xp_none_mlabel_label1.img.xz create mode 100644 tests/ts/blkid/images-fs/gfs2.img.xz create mode 100644 tests/ts/blkid/images-fs/hfs.img.xz create mode 100644 tests/ts/blkid/images-fs/hfsplus.img.xz create mode 100644 tests/ts/blkid/images-fs/hpfs.img.xz create mode 100644 tests/ts/blkid/images-fs/hpt37x-raid.img.xz create mode 100644 tests/ts/blkid/images-fs/hpt45x-raid.img.xz create mode 100644 tests/ts/blkid/images-fs/iso-different-iso-joliet-label.img.xz create mode 100644 tests/ts/blkid/images-fs/iso-joliet.img.xz create mode 100644 tests/ts/blkid/images-fs/iso-multi-0-174-348-genisoimage.img.xz create mode 100644 tests/ts/blkid/images-fs/iso-rr-joliet.img.xz create mode 100644 tests/ts/blkid/images-fs/iso-unicode-long-label.img.xz create mode 100644 tests/ts/blkid/images-fs/iso.img.xz create mode 100644 tests/ts/blkid/images-fs/isw-raid.img.xz create mode 100644 tests/ts/blkid/images-fs/jbd.img.xz create mode 100644 tests/ts/blkid/images-fs/jfs.img.xz create mode 100644 tests/ts/blkid/images-fs/jmicron-raid.img.xz create mode 100644 tests/ts/blkid/images-fs/lsi-raid.img.xz create mode 100644 tests/ts/blkid/images-fs/luks1.img.xz create mode 100644 tests/ts/blkid/images-fs/luks2.img.xz create mode 100644 tests/ts/blkid/images-fs/lvm2.img.xz create mode 100644 tests/ts/blkid/images-fs/mdraid-1.img.xz create mode 100644 tests/ts/blkid/images-fs/mdraid.img.xz create mode 100644 tests/ts/blkid/images-fs/minix-BE.img.xz create mode 100644 tests/ts/blkid/images-fs/minix-LE.img.xz create mode 100644 tests/ts/blkid/images-fs/mpool.img.xz create mode 100644 tests/ts/blkid/images-fs/netware.img.xz create mode 100644 tests/ts/blkid/images-fs/nilfs2.img.xz create mode 100644 tests/ts/blkid/images-fs/ntfs.img.xz create mode 100644 tests/ts/blkid/images-fs/nvidia-raid.img.xz create mode 100644 tests/ts/blkid/images-fs/ocfs2.img.xz create mode 100644 tests/ts/blkid/images-fs/promise-raid.img.xz create mode 100644 tests/ts/blkid/images-fs/reiser3.img.xz create mode 100644 tests/ts/blkid/images-fs/reiser4.img.xz create mode 100644 tests/ts/blkid/images-fs/romfs.img.xz create mode 100644 tests/ts/blkid/images-fs/silicon-raid.img.xz create mode 100644 tests/ts/blkid/images-fs/small-fat32.img.xz create mode 100755 tests/ts/blkid/images-fs/squashfs3.img.xz create mode 100644 tests/ts/blkid/images-fs/squashfs4.img.xz create mode 100644 tests/ts/blkid/images-fs/swap0.img.xz create mode 100644 tests/ts/blkid/images-fs/swap1-big.img.xz create mode 100644 tests/ts/blkid/images-fs/swap1.img.xz create mode 100644 tests/ts/blkid/images-fs/tuxonice.img.xz create mode 100644 tests/ts/blkid/images-fs/ubi.img.xz create mode 100644 tests/ts/blkid/images-fs/ubifs.img.xz create mode 100644 tests/ts/blkid/images-fs/udf-bdr-2.60-nero.img.xz create mode 100644 tests/ts/blkid/images-fs/udf-cd-mkudfiso-20100208.img.xz create mode 100644 tests/ts/blkid/images-fs/udf-cd-nero-6.img.xz create mode 100644 tests/ts/blkid/images-fs/udf-hdd-macosx-2.60-4096.img.xz create mode 100644 tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.0.0-1.img.xz create mode 100644 tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.0.0-2.img.xz create mode 100644 tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-1.img.xz create mode 100644 tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-2.img.xz create mode 100644 tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-3.img.xz create mode 100644 tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-4.img.xz create mode 100644 tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-5.img.xz create mode 100644 tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-6.img.xz create mode 100644 tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-7.img.xz create mode 100644 tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-8.img.xz create mode 100644 tests/ts/blkid/images-fs/udf-hdd-mkudffs-2.2.img.xz create mode 100644 tests/ts/blkid/images-fs/udf-hdd-udfclient-0.7.5.img.xz create mode 100644 tests/ts/blkid/images-fs/udf-hdd-udfclient-0.7.7.img.xz create mode 100644 tests/ts/blkid/images-fs/udf-hdd-win7.img.xz create mode 100644 tests/ts/blkid/images-fs/udf-multi-0-320-640-mkudffs.img.xz create mode 100644 tests/ts/blkid/images-fs/udf-multi-0-417-834-genisoimage.img.xz create mode 100644 tests/ts/blkid/images-fs/udf.img.xz create mode 100644 tests/ts/blkid/images-fs/ufs.img.xz create mode 100644 tests/ts/blkid/images-fs/vdo.img.xz create mode 100644 tests/ts/blkid/images-fs/via-raid.img.xz create mode 100644 tests/ts/blkid/images-fs/vmfs.img.xz create mode 100644 tests/ts/blkid/images-fs/vmfs_volume.img.xz create mode 100644 tests/ts/blkid/images-fs/xfs-log.img.xz create mode 100644 tests/ts/blkid/images-fs/xfs-v5.img.xz create mode 100644 tests/ts/blkid/images-fs/xfs.img.xz create mode 100644 tests/ts/blkid/images-fs/zfs.img.xz create mode 100644 tests/ts/blkid/images-fs/zonefs.img.xz create mode 100644 tests/ts/blkid/images-pt/atari-primary.img.xz create mode 100644 tests/ts/blkid/images-pt/atari-xgm.img.xz create mode 100644 tests/ts/blkid/images-pt/bsd.img.xz create mode 100644 tests/ts/blkid/images-pt/dos+bsd.img.xz create mode 100644 tests/ts/blkid/images-pt/gpt.img.xz create mode 100644 tests/ts/blkid/images-pt/sgi.img.xz create mode 100644 tests/ts/blkid/images-pt/sun.img.xz create mode 100755 tests/ts/blkid/low-probe create mode 100755 tests/ts/blkid/lowprobe-pt create mode 100755 tests/ts/blkid/md-raid0-whole create mode 100755 tests/ts/blkid/md-raid1-part create mode 100755 tests/ts/blkid/md-raid1-whole create mode 100755 tests/ts/blkid/offset create mode 100755 tests/ts/blkid/topology create mode 100755 tests/ts/build-sys/config create mode 100755 tests/ts/cal/bigyear create mode 100755 tests/ts/cal/color create mode 100755 tests/ts/cal/colorw create mode 100755 tests/ts/cal/column create mode 100755 tests/ts/cal/jan1753 create mode 100755 tests/ts/cal/month create mode 100755 tests/ts/cal/sep1752 create mode 100755 tests/ts/cal/vertical create mode 100755 tests/ts/cal/weekarg create mode 100755 tests/ts/cal/weeknum create mode 100755 tests/ts/cal/year create mode 100755 tests/ts/chfn/gecos create mode 100755 tests/ts/col/io create mode 100755 tests/ts/col/multibyte create mode 100644 tests/ts/col/multibyte.data create mode 100755 tests/ts/col/newlines create mode 100755 tests/ts/col/options create mode 100644 tests/ts/colcrt/crash1 create mode 100644 tests/ts/colcrt/crash2 create mode 100755 tests/ts/colcrt/functional create mode 100644 tests/ts/colcrt/hang1 create mode 100644 tests/ts/colcrt/nasty-input create mode 100755 tests/ts/colcrt/regressions create mode 100644 tests/ts/colcrt/underlines create mode 100755 tests/ts/colrm/rm2-2 create mode 100755 tests/ts/column/columnate create mode 100644 tests/ts/column/files/fivecols create mode 100644 tests/ts/column/files/mountinfo create mode 100644 tests/ts/column/files/onecolumn create mode 100644 tests/ts/column/files/table create mode 100644 tests/ts/column/files/table-empty-lines create mode 100644 tests/ts/column/files/table-sep create mode 100644 tests/ts/column/files/table-sep-space create mode 100755 tests/ts/column/invalid-multibyte create mode 100755 tests/ts/column/multi-file create mode 100755 tests/ts/column/table create mode 100644 tests/ts/cramfs/cramfs-big.img create mode 100644 tests/ts/cramfs/cramfs-little.img create mode 100755 tests/ts/cramfs/doubles create mode 100755 tests/ts/cramfs/fsck-bad-header create mode 100755 tests/ts/cramfs/fsck-endianness create mode 100755 tests/ts/cramfs/mkfs create mode 100755 tests/ts/cramfs/mkfs-endianness create mode 100644 tests/ts/cramfs/mkfs-endianness_testdata_a create mode 100644 tests/ts/cramfs/mkfs-endianness_testdata_b create mode 100755 tests/ts/dmesg/colors create mode 100755 tests/ts/dmesg/console-levels create mode 100755 tests/ts/dmesg/decode create mode 100755 tests/ts/dmesg/delta create mode 100755 tests/ts/dmesg/facilities create mode 100755 tests/ts/dmesg/indentation create mode 100644 tests/ts/dmesg/input create mode 100755 tests/ts/dmesg/limit create mode 100644 tests/ts/dmesg/newlines create mode 100755 tests/ts/eject/umount create mode 100755 tests/ts/fadvise/drop create mode 100755 tests/ts/fdisk/align-512-4K create mode 100755 tests/ts/fdisk/align-512-4K-63 create mode 100755 tests/ts/fdisk/align-512-4K-md create mode 100755 tests/ts/fdisk/align-512-512 create mode 100755 tests/ts/fdisk/align-512-512-topology create mode 100755 tests/ts/fdisk/bsd create mode 100755 tests/ts/fdisk/gpt create mode 100755 tests/ts/fdisk/gpt-resize create mode 100755 tests/ts/fdisk/id create mode 100755 tests/ts/fdisk/mbr-dos-mode create mode 100755 tests/ts/fdisk/mbr-nondos-mode create mode 100755 tests/ts/fdisk/mbr-sort create mode 100755 tests/ts/fdisk/oddinput create mode 100755 tests/ts/fdisk/sunlabel create mode 100755 tests/ts/fincore/count create mode 100644 tests/ts/findmnt/files/mountinfo create mode 100644 tests/ts/findmnt/files/mountinfo-messy create mode 100644 tests/ts/findmnt/files/mountinfo-nonroot create mode 100755 tests/ts/findmnt/filter create mode 100755 tests/ts/findmnt/outputs create mode 100755 tests/ts/findmnt/target create mode 100755 tests/ts/fsck/ismounted create mode 100755 tests/ts/fuzzers/test_blkid_fuzz create mode 100644 tests/ts/fuzzers/test_blkid_fuzz_files/oss-fuzz-53142 create mode 100644 tests/ts/fuzzers/test_blkid_fuzz_files/oss-fuzz-53149 create mode 100644 tests/ts/fuzzers/test_blkid_fuzz_files/oss-fuzz-53160 create mode 100644 tests/ts/fuzzers/test_blkid_fuzz_files/oss-fuzz-55282 create mode 100644 tests/ts/fuzzers/test_blkid_fuzz_files/oss-fuzz-55291 create mode 100644 tests/ts/fuzzers/test_blkid_fuzz_files/oss-fuzz-55318 create mode 100644 tests/ts/fuzzers/test_blkid_fuzz_files/oss-fuzz-62691 create mode 100755 tests/ts/fuzzers/test_fdisk_script_fuzz create mode 100644 tests/ts/fuzzers/test_fdisk_script_fuzz_files/crash-8ae1c667bed4b4b864f62e78cded81d5083177eb create mode 100644 tests/ts/fuzzers/test_fdisk_script_fuzz_files/crash-d216dfd17039a189c3858d78fbcf588695439b3b create mode 100644 tests/ts/fuzzers/test_fdisk_script_fuzz_files/github-1015-1 create mode 100644 tests/ts/fuzzers/test_fdisk_script_fuzz_files/github-1015-2 create mode 100644 tests/ts/fuzzers/test_fdisk_script_fuzz_files/oss-fuzz-24589 create mode 100644 tests/ts/fuzzers/test_fdisk_script_fuzz_files/oss-fuzz-24861 create mode 100644 tests/ts/fuzzers/test_fdisk_script_fuzz_files/parse_line_valcommas-use-of-uninitialized-value create mode 100755 tests/ts/fuzzers/test_last_fuzz create mode 100644 tests/ts/fuzzers/test_last_fuzz_files/github-1097 create mode 100755 tests/ts/fuzzers/test_mount_fuzz create mode 100644 tests/ts/fuzzers/test_mount_fuzz_files/oss-fuzz-23722 create mode 100755 tests/ts/getopt/basic create mode 100755 tests/ts/getopt/options create mode 100755 tests/ts/hardlink/options create mode 100644 tests/ts/hardlink/testdir1.tar.xz create mode 100644 tests/ts/hexdump/files/ascii.in create mode 100755 tests/ts/hexdump/format-strings create mode 100755 tests/ts/hexdump/highlighting create mode 100755 tests/ts/hwclock/show create mode 100755 tests/ts/hwclock/systohc create mode 100644 tests/ts/ipcs/functions.sh create mode 100755 tests/ts/ipcs/headers create mode 100755 tests/ts/ipcs/limits create mode 100755 tests/ts/ipcs/limits2 create mode 100755 tests/ts/ipcs/mk-rm-msg create mode 100755 tests/ts/ipcs/mk-rm-sem create mode 100755 tests/ts/ipcs/mk-rm-shm create mode 100755 tests/ts/isosize/print-size create mode 100644 tests/ts/isosize/sample.iso.gz create mode 100755 tests/ts/kill/all_processes create mode 100644 tests/ts/kill/kill_functions.sh create mode 100755 tests/ts/kill/name_to_number create mode 100755 tests/ts/kill/options create mode 100755 tests/ts/kill/print_pid create mode 100755 tests/ts/kill/queue create mode 100755 tests/ts/lib/procfs create mode 100644 tests/ts/lib/procfs-data/proc/1/cmdline create mode 100644 tests/ts/lib/procfs-data/proc/1/comm create mode 100644 tests/ts/lib/procfs-data/proc/1/stat create mode 100644 tests/ts/lib/procfs-data/proc/2/cmdline create mode 100644 tests/ts/lib/procfs-data/proc/2/comm create mode 100644 tests/ts/lib/procfs-data/proc/2/stat create mode 100644 tests/ts/lib/procfs-data/proc/3/cmdline create mode 100644 tests/ts/lib/procfs-data/proc/3/comm create mode 100644 tests/ts/lib/procfs-data/proc/3/stat create mode 100755 tests/ts/lib/timeutils create mode 100755 tests/ts/libfdisk/gpt create mode 100755 tests/ts/libfdisk/mkpart create mode 100755 tests/ts/libfdisk/mkpart-full create mode 100755 tests/ts/libmount/context create mode 100755 tests/ts/libmount/context-py create mode 100755 tests/ts/libmount/context-utab create mode 100755 tests/ts/libmount/context-utab-py create mode 100755 tests/ts/libmount/debug create mode 100644 tests/ts/libmount/files/fstab create mode 100644 tests/ts/libmount/files/fstab.broken create mode 100644 tests/ts/libmount/files/fstab.comment create mode 100644 tests/ts/libmount/files/kernel_cmdline create mode 100644 tests/ts/libmount/files/mountinfo create mode 100644 tests/ts/libmount/files/mountinfo_mv create mode 100644 tests/ts/libmount/files/mountinfo_nosrc create mode 100644 tests/ts/libmount/files/mountinfo_re create mode 100644 tests/ts/libmount/files/mountinfo_u create mode 100644 tests/ts/libmount/files/mtab create mode 100644 tests/ts/libmount/files/swaps create mode 100755 tests/ts/libmount/lock create mode 100755 tests/ts/libmount/loop create mode 100755 tests/ts/libmount/loop-overlay create mode 100755 tests/ts/libmount/optstr create mode 100755 tests/ts/libmount/tabdiff create mode 100755 tests/ts/libmount/tabfiles create mode 100755 tests/ts/libmount/tabfiles-py create mode 100755 tests/ts/libmount/tabfiles-tags create mode 100755 tests/ts/libmount/tabfiles-tags-py create mode 100755 tests/ts/libmount/update create mode 100755 tests/ts/libmount/update-py create mode 100755 tests/ts/libmount/utils create mode 100644 tests/ts/libsmartcols/files/col-hidden create mode 100644 tests/ts/libsmartcols/files/col-id create mode 100644 tests/ts/libsmartcols/files/col-name create mode 100644 tests/ts/libsmartcols/files/col-noextremes create mode 100644 tests/ts/libsmartcols/files/col-number create mode 100644 tests/ts/libsmartcols/files/col-parent create mode 100644 tests/ts/libsmartcols/files/col-strict create mode 100644 tests/ts/libsmartcols/files/col-string create mode 100644 tests/ts/libsmartcols/files/col-tree create mode 100644 tests/ts/libsmartcols/files/col-trunc create mode 100644 tests/ts/libsmartcols/files/col-wrap create mode 100644 tests/ts/libsmartcols/files/col-wrapnl create mode 100644 tests/ts/libsmartcols/files/data-id create mode 100644 tests/ts/libsmartcols/files/data-number create mode 100644 tests/ts/libsmartcols/files/data-number-tiny create mode 100644 tests/ts/libsmartcols/files/data-parent create mode 100644 tests/ts/libsmartcols/files/data-string create mode 100644 tests/ts/libsmartcols/files/data-string-empty create mode 100644 tests/ts/libsmartcols/files/data-string-extreme create mode 100644 tests/ts/libsmartcols/files/data-string-long create mode 100644 tests/ts/libsmartcols/files/data-string-nl create mode 100755 tests/ts/libsmartcols/fromfile create mode 100755 tests/ts/libsmartcols/title create mode 100755 tests/ts/logger/errors create mode 100755 tests/ts/logger/formats create mode 100755 tests/ts/logger/journald create mode 100755 tests/ts/logger/options create mode 100755 tests/ts/login/islocal create mode 100644 tests/ts/login/islocal.data create mode 100755 tests/ts/login/logindefs create mode 100644 tests/ts/login/logindefs.data create mode 100755 tests/ts/look/separator create mode 100644 tests/ts/look/words create mode 100755 tests/ts/losetup/losetup create mode 100755 tests/ts/losetup/losetup-blkdev create mode 100755 tests/ts/losetup/losetup-loop create mode 100644 tests/ts/losetup/losetup_functions.sh create mode 100644 tests/ts/lsblk/README create mode 100644 tests/ts/lsblk/dumps/simple-lvm.tar.xz create mode 100644 tests/ts/lsblk/dumps/simple-nvme.tar.xz create mode 100755 tests/ts/lsblk/lsblk create mode 100755 tests/ts/lsblk/mk-input.sh create mode 100644 tests/ts/lscpu/dumps/armv7.tar.gz create mode 100644 tests/ts/lscpu/dumps/loongarch-loongson_3a5000_hv.tar.gz create mode 100644 tests/ts/lscpu/dumps/ppc-qemu.tar.gz create mode 100644 tests/ts/lscpu/dumps/ppc64-POWER7-64cpu.tar.gz create mode 100644 tests/ts/lscpu/dumps/ppc64-POWER7.tar.gz create mode 100644 tests/ts/lscpu/dumps/rv64-linux.tar.gz create mode 100644 tests/ts/lscpu/dumps/s390-kvm.tar.gz create mode 100644 tests/ts/lscpu/dumps/s390-lpar-drawer.tar.gz create mode 100644 tests/ts/lscpu/dumps/s390-lpar.tar.gz create mode 100644 tests/ts/lscpu/dumps/s390-nested-virt.tar.gz create mode 100644 tests/ts/lscpu/dumps/s390-zvm.tar.gz create mode 100644 tests/ts/lscpu/dumps/sparc64.tar.gz create mode 100644 tests/ts/lscpu/dumps/vbox-win.tar.gz create mode 100644 tests/ts/lscpu/dumps/vmware_fpe.tar.gz create mode 100644 tests/ts/lscpu/dumps/x86_64-64cpu-linux6.2.tar.gz create mode 100644 tests/ts/lscpu/dumps/x86_64-64cpu.tar.gz create mode 100644 tests/ts/lscpu/dumps/x86_64-dell_e4310.tar.gz create mode 100644 tests/ts/lscpu/dumps/x86_64-epyc_7451.tar.gz create mode 100755 tests/ts/lscpu/lscpu create mode 100755 tests/ts/lscpu/mk-input.sh create mode 100755 tests/ts/lsfd/column-ainodeclass create mode 100755 tests/ts/lsfd/column-kthread create mode 100755 tests/ts/lsfd/column-name create mode 100755 tests/ts/lsfd/column-type create mode 100644 tests/ts/lsfd/lsfd-functions.bash create mode 100755 tests/ts/lsfd/mkfds-directory create mode 100755 tests/ts/lsfd/mkfds-mapped-packet-socket create mode 100755 tests/ts/lsfd/mkfds-netlink-groups create mode 100755 tests/ts/lsfd/mkfds-netlink-protocol create mode 100755 tests/ts/lsfd/mkfds-netns create mode 100755 tests/ts/lsfd/mkfds-pidfd create mode 100755 tests/ts/lsfd/mkfds-ping create mode 100755 tests/ts/lsfd/mkfds-pipe-no-fork create mode 100755 tests/ts/lsfd/mkfds-raw create mode 100755 tests/ts/lsfd/mkfds-raw6 create mode 100755 tests/ts/lsfd/mkfds-ro-block-device create mode 100755 tests/ts/lsfd/mkfds-ro-regular-file create mode 100755 tests/ts/lsfd/mkfds-rw-character-device create mode 100755 tests/ts/lsfd/mkfds-socketpair create mode 100755 tests/ts/lsfd/mkfds-symlink create mode 100755 tests/ts/lsfd/mkfds-tcp create mode 100755 tests/ts/lsfd/mkfds-tcp6 create mode 100755 tests/ts/lsfd/mkfds-udp create mode 100755 tests/ts/lsfd/mkfds-udp6 create mode 100755 tests/ts/lsfd/mkfds-unix-dgram create mode 100755 tests/ts/lsfd/mkfds-unix-in-netns create mode 100755 tests/ts/lsfd/mkfds-unix-stream create mode 100755 tests/ts/lsfd/option-filter-broken-exp create mode 100755 tests/ts/lsfd/option-inet create mode 100755 tests/ts/lsfd/option-pid create mode 100755 tests/ts/lsfd/option-summary create mode 100644 tests/ts/lsmem/dumps/s390-zvm-6g.tar.bz2 create mode 100644 tests/ts/lsmem/dumps/x86_64-16g.tar.bz2 create mode 100755 tests/ts/lsmem/lsmem create mode 100755 tests/ts/lsmem/mk-input.sh create mode 100755 tests/ts/lsns/ioctl_ns create mode 100755 tests/ts/lsns/netnsid create mode 100755 tests/ts/lsns/nsfs create mode 100644 tests/ts/md5/data create mode 100755 tests/ts/md5/md5 create mode 100644 tests/ts/minix/broken-root create mode 100644 tests/ts/minix/debian.bug.773892 create mode 100755 tests/ts/minix/fsck create mode 100755 tests/ts/minix/fsck-images create mode 100755 tests/ts/minix/mkfs create mode 100755 tests/ts/misc/fallocate create mode 100755 tests/ts/misc/flock create mode 100755 tests/ts/misc/ionice create mode 100755 tests/ts/misc/line create mode 100755 tests/ts/misc/mbsencode create mode 100755 tests/ts/misc/mcookie create mode 100755 tests/ts/misc/mountpoint create mode 100755 tests/ts/misc/pipesz create mode 100755 tests/ts/misc/rev create mode 100755 tests/ts/misc/setarch create mode 100755 tests/ts/misc/setsid create mode 100755 tests/ts/misc/strtosize create mode 100755 tests/ts/misc/swaplabel create mode 100755 tests/ts/misc/waitpid create mode 100755 tests/ts/misc/whereis 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 create mode 100755 tests/ts/more/regexp create mode 100755 tests/ts/more/squeeze create mode 100755 tests/ts/mount/complex create mode 100755 tests/ts/mount/devname create mode 100755 tests/ts/mount/dm-verity create mode 100755 tests/ts/mount/fallback create mode 100755 tests/ts/mount/fslists create mode 100755 tests/ts/mount/fstab-all create mode 100755 tests/ts/mount/fstab-bind create mode 100755 tests/ts/mount/fstab-broken create mode 100755 tests/ts/mount/fstab-btrfs create mode 100755 tests/ts/mount/fstab-devname create mode 100755 tests/ts/mount/fstab-devname2label create mode 100755 tests/ts/mount/fstab-devname2uuid create mode 100755 tests/ts/mount/fstab-label create mode 100755 tests/ts/mount/fstab-label2devname create mode 100755 tests/ts/mount/fstab-label2uuid create mode 100755 tests/ts/mount/fstab-loop create mode 100755 tests/ts/mount/fstab-none create mode 100755 tests/ts/mount/fstab-symlink create mode 100755 tests/ts/mount/fstab-uuid create mode 100755 tests/ts/mount/fstab-uuid2devname create mode 100755 tests/ts/mount/fstab-uuid2label create mode 100755 tests/ts/mount/label create mode 100755 tests/ts/mount/move create mode 100755 tests/ts/mount/regfile create mode 100755 tests/ts/mount/remount create mode 100755 tests/ts/mount/set_ugid_mode create mode 100755 tests/ts/mount/shared-subtree create mode 100755 tests/ts/mount/special create mode 100755 tests/ts/mount/subdir create mode 100755 tests/ts/mount/umount-alltargets create mode 100755 tests/ts/mount/umount-recursive create mode 100755 tests/ts/mount/uuid create mode 100755 tests/ts/namei/logic create mode 100755 tests/ts/partx/partx create mode 100755 tests/ts/partx/partx-image create mode 100755 tests/ts/paths/built-in create mode 100755 tests/ts/rename/basic create mode 100755 tests/ts/rename/exit_codes create mode 100755 tests/ts/rename/overwrite create mode 100755 tests/ts/rename/subdir create mode 100755 tests/ts/rename/symlink create mode 100755 tests/ts/schedutils/chrt create mode 100755 tests/ts/schedutils/chrt-non-root create mode 100755 tests/ts/schedutils/cpuset create mode 100755 tests/ts/script/buffering-race create mode 100755 tests/ts/script/options create mode 100755 tests/ts/script/race create mode 100755 tests/ts/script/replay create mode 100755 tests/ts/sfdisk/dos create mode 100755 tests/ts/sfdisk/dump create mode 100644 tests/ts/sfdisk/files/dump-gaps create mode 100644 tests/ts/sfdisk/files/dump-old create mode 100755 tests/ts/sfdisk/gpt create mode 100755 tests/ts/sfdisk/movedata create mode 100755 tests/ts/sfdisk/resize create mode 100755 tests/ts/sfdisk/script create mode 100755 tests/ts/sfdisk/wipe create mode 100644 tests/ts/sha1/data create mode 100755 tests/ts/sha1/sha1 create mode 100755 tests/ts/swapon/devname create mode 100755 tests/ts/swapon/fixpgsz create mode 100755 tests/ts/swapon/fixsig create mode 100755 tests/ts/swapon/label create mode 100755 tests/ts/swapon/uuid create mode 100755 tests/ts/ul/basic create mode 100644 tests/ts/ul/basic.input create mode 100644 tests/ts/ul/filter.input create mode 100755 tests/ts/ul/ul create mode 100755 tests/ts/utmp/last create mode 100755 tests/ts/utmp/last-ipv6 create mode 100644 tests/ts/utmp/subsec create mode 100644 tests/ts/utmp/txt-a create mode 100644 tests/ts/utmp/txt-a-old create mode 100644 tests/ts/utmp/txt-b create mode 100644 tests/ts/utmp/txt-b-old create mode 100644 tests/ts/utmp/txt-ipv6 create mode 100644 tests/ts/utmp/txt-ipv6-old create mode 100644 tests/ts/utmp/utmp_functions.sh create mode 100755 tests/ts/utmp/utmpdump-circle create mode 100755 tests/ts/utmp/utmpdump-subsecond create mode 100755 tests/ts/utmp/utmpdump-tobin create mode 100755 tests/ts/utmp/utmpdump-tobin-ipv6 create mode 100755 tests/ts/utmp/utmpdump-totxt create mode 100755 tests/ts/utmp/utmpdump-totxt-ipv6 create mode 100644 tests/ts/utmp/wtmp-a.BE create mode 100644 tests/ts/utmp/wtmp-a.LE create mode 100644 tests/ts/utmp/wtmp-b.BE create mode 100644 tests/ts/utmp/wtmp-b.LE create mode 100644 tests/ts/utmp/wtmp-ipv6.BE create mode 100644 tests/ts/utmp/wtmp-ipv6.LE create mode 100755 tests/ts/uuid/namespace create mode 100755 tests/ts/uuid/oids create mode 100755 tests/ts/uuid/uuid_parser create mode 100755 tests/ts/uuid/uuidd create mode 100755 tests/ts/uuid/uuidgen create mode 100755 tests/ts/uuid/uuidparse create mode 100755 tests/ts/wipefs/wipefs (limited to 'tests/ts') diff --git a/tests/ts/bitops/swapbytes b/tests/ts/bitops/swapbytes new file mode 100755 index 0000000..1272617 --- /dev/null +++ b/tests/ts/bitops/swapbytes @@ -0,0 +1,29 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="swap bytes" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_BYTESWAP" + +$TS_HELPER_BYTESWAP >> $TS_OUTPUT + +ts_finalize + diff --git a/tests/ts/blkdiscard/offsets b/tests/ts/blkdiscard/offsets new file mode 100755 index 0000000..21bb78a --- /dev/null +++ b/tests/ts/blkdiscard/offsets @@ -0,0 +1,101 @@ +#!/bin/bash + +# +# Copyright (C) 2014 Federico Simoncelli +# +# 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="offsets" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_BLKDISCARD" + +ts_skip_nonroot +ts_check_losetup + +ORIGPWD=$(pwd) +IMAGE_NAME="${TS_TESTNAME}-loop.img" +IMAGE_PATH="$TS_OUTDIR/$IMAGE_NAME" + +truncate -s 10M $IMAGE_PATH + +ts_log "create loop device from image" +DEVICE=$($TS_CMD_LOSETUP --show -f $IMAGE_PATH) +ts_register_loop_device "$DEVICE" + +function run_tscmd { + local ret + "$@" >> $TS_OUTPUT 2>> $TS_ERRLOG + ret=$? + echo "ret: $ret" >> "$TS_OUTPUT" + return $ret +} + +ts_log "testing offsets with full block size" +run_tscmd $TS_CMD_BLKDISCARD -v $DEVICE +if [ "$?" != "0" ]; then + # Skip the rest? For example loop backing files on NFS seem unsupported. + grep -q "BLKDISCARD ioctl failed: Operation not supported" "$TS_ERRLOG" \ + && ts_skip "BLKDISCARD not supported" +fi +run_tscmd $TS_CMD_BLKDISCARD -v -o 1 $DEVICE +run_tscmd $TS_CMD_BLKDISCARD -v -o 511 $DEVICE +run_tscmd $TS_CMD_BLKDISCARD -v -o 512 $DEVICE +run_tscmd $TS_CMD_BLKDISCARD -v -o 1024 $DEVICE + +ts_log "testing offsets with specific length" +run_tscmd $TS_CMD_BLKDISCARD -v -l 5242880 $DEVICE +run_tscmd $TS_CMD_BLKDISCARD -v -l 5242881 $DEVICE +run_tscmd $TS_CMD_BLKDISCARD -v -l 5243391 $DEVICE +run_tscmd $TS_CMD_BLKDISCARD -v -o 1 -l 5242880 $DEVICE +run_tscmd $TS_CMD_BLKDISCARD -v -o 511 -l 5242880 $DEVICE +run_tscmd $TS_CMD_BLKDISCARD -v -o 512 -l 5242880 $DEVICE +run_tscmd $TS_CMD_BLKDISCARD -v -o 1024 -l 5242880 $DEVICE + +ts_log "testing aligned steps full device" +run_tscmd $TS_CMD_BLKDISCARD -v -p 5242880 $DEVICE +run_tscmd $TS_CMD_BLKDISCARD -v -p 1310720 $DEVICE + +ts_log "testing aligned steps with offsets and length" +run_tscmd $TS_CMD_BLKDISCARD -v -p 512 -l 1024 $DEVICE +run_tscmd $TS_CMD_BLKDISCARD -v -p 512 -o 1 -l 1024 $DEVICE +run_tscmd $TS_CMD_BLKDISCARD -v -p 512 -o 1 -l 1536 $DEVICE +run_tscmd $TS_CMD_BLKDISCARD -v -p 512 -o 511 -l 1536 $DEVICE +run_tscmd $TS_CMD_BLKDISCARD -v -p 512 -o 512 -l 1536 $DEVICE +run_tscmd $TS_CMD_BLKDISCARD -v -p 512 -o 1024 -l 1024 $DEVICE + +ts_log "testing misaligned steps full device" +run_tscmd $TS_CMD_BLKDISCARD -v -p 1 $DEVICE +run_tscmd $TS_CMD_BLKDISCARD -v -p 256 $DEVICE +run_tscmd $TS_CMD_BLKDISCARD -v -p 511 $DEVICE +run_tscmd $TS_CMD_BLKDISCARD -v -p 513 $DEVICE +run_tscmd $TS_CMD_BLKDISCARD -v -p 768 $DEVICE + +ts_log "testing misaligned steps with offsets and length" +run_tscmd $TS_CMD_BLKDISCARD -v -p 511 -l 1024 $DEVICE +run_tscmd $TS_CMD_BLKDISCARD -v -p 511 -o 1 -l 1536 $DEVICE +run_tscmd $TS_CMD_BLKDISCARD -v -p 511 -o 511 -l 1536 $DEVICE +run_tscmd $TS_CMD_BLKDISCARD -v -p 511 -l 10240 $DEVICE +run_tscmd $TS_CMD_BLKDISCARD -v -p 511 -o 1 -l 10240 $DEVICE +run_tscmd $TS_CMD_BLKDISCARD -v -p 511 -o 511 -l 10240 $DEVICE + +sed -i "s#$DEVICE:\s##" $TS_OUTPUT $TS_ERRLOG + +ts_log "detach loop device from image" + +ts_cd "$ORIGPWD" + +ts_finalize diff --git a/tests/ts/blkid/cache b/tests/ts/blkid/cache new file mode 100755 index 0000000..7c35805 --- /dev/null +++ b/tests/ts/blkid/cache @@ -0,0 +1,48 @@ +#!/bin/bash + +# +# Copyright (C) 2009 Karel Zak +# +# 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="caching" + +. "$TS_TOPDIR"/functions.sh + +ts_init "$*" + +ts_skip_nonroot +ts_check_test_command "$TS_CMD_BLKID" +ts_check_test_command "$TS_CMD_MKSWAP" +ts_check_losetup + +ts_device_init + +"$TS_CMD_MKSWAP" -q -p 4096 -e little \ + -U 11111111-1111-1111-1111-111111111111 \ + "$TS_LODEV" \ + >> "$TS_OUTPUT" 2>> "$TS_ERRLOG" + +blkid "$TS_LODEV" \ + | sed -e "s|$TS_LODEV|DEVICE|" \ + >> "$TS_OUTPUT" 2>> "$TS_ERRLOG" + +cat "$BLKID_FILE" \ + | sed -e 's/DEVNO="[^"]*"/DEVNO=""/' \ + -e 's/TIME="[^"]*"/TIME=""/' \ + -e "s|$TS_LODEV|DEVICE|" \ + >> "$TS_OUTPUT" + +ts_finalize diff --git a/tests/ts/blkid/dm-err b/tests/ts/blkid/dm-err new file mode 100755 index 0000000..a23b2e0 --- /dev/null +++ b/tests/ts/blkid/dm-err @@ -0,0 +1,52 @@ +#!/bin/bash + +# +# Copyright (C) 2016 Karel Zak +# +# 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="DM error" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_BLKID" + +ts_skip_nonroot +ts_check_prog "dmsetup" + +DEVNAME="blkid-dm-err" +DEVICE="/dev/mapper/${DEVNAME}" + +ts_log "Initialize device" +echo "0 262144 error" | dmsetup create $DEVNAME + +# Some tests are run in LXD containers on Travis CI where `mknod` doesn't always work +# https://docs.travis-ci.com/user/multi-cpu-architectures/#security-and-lxd-container +# https://linuxcontainers.org/lxd/docs/master/syscall-interception +if [ "$TRAVIS" == "true" ] && [ ! -b "$DEVICE" ]; then + ts_skip "$DEVICE wasn't created" +fi + +ts_log "Probe device" +$TS_CMD_BLKID -p -o udev $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "Return code: $?" >> $TS_OUTPUT + +udevadm settle +ts_log "Deinitialize device" + +dmsetup remove $DEVNAME + +ts_finalize diff --git a/tests/ts/blkid/images-fs/adaptec-raid.img.xz b/tests/ts/blkid/images-fs/adaptec-raid.img.xz new file mode 100644 index 0000000..20387cd Binary files /dev/null and b/tests/ts/blkid/images-fs/adaptec-raid.img.xz differ diff --git a/tests/ts/blkid/images-fs/apfs.img.xz b/tests/ts/blkid/images-fs/apfs.img.xz new file mode 100644 index 0000000..4145c01 Binary files /dev/null and b/tests/ts/blkid/images-fs/apfs.img.xz differ diff --git a/tests/ts/blkid/images-fs/bcache-B.img.xz b/tests/ts/blkid/images-fs/bcache-B.img.xz new file mode 100644 index 0000000..ed187f1 Binary files /dev/null and b/tests/ts/blkid/images-fs/bcache-B.img.xz differ diff --git a/tests/ts/blkid/images-fs/bcache-C.img.xz b/tests/ts/blkid/images-fs/bcache-C.img.xz new file mode 100644 index 0000000..af90cbf Binary files /dev/null and b/tests/ts/blkid/images-fs/bcache-C.img.xz differ diff --git a/tests/ts/blkid/images-fs/bcache-journal.img.xz b/tests/ts/blkid/images-fs/bcache-journal.img.xz new file mode 100644 index 0000000..5d2201b Binary files /dev/null and b/tests/ts/blkid/images-fs/bcache-journal.img.xz differ diff --git a/tests/ts/blkid/images-fs/bcachefs-2.img.xz b/tests/ts/blkid/images-fs/bcachefs-2.img.xz new file mode 100644 index 0000000..267df3f Binary files /dev/null and b/tests/ts/blkid/images-fs/bcachefs-2.img.xz differ diff --git a/tests/ts/blkid/images-fs/bcachefs.img.xz b/tests/ts/blkid/images-fs/bcachefs.img.xz new file mode 100644 index 0000000..6ef0e50 Binary files /dev/null and b/tests/ts/blkid/images-fs/bcachefs.img.xz differ diff --git a/tests/ts/blkid/images-fs/befs.img.xz b/tests/ts/blkid/images-fs/befs.img.xz new file mode 100644 index 0000000..188a6e8 Binary files /dev/null and b/tests/ts/blkid/images-fs/befs.img.xz differ diff --git a/tests/ts/blkid/images-fs/bfs.img.xz b/tests/ts/blkid/images-fs/bfs.img.xz new file mode 100644 index 0000000..98f024a Binary files /dev/null and b/tests/ts/blkid/images-fs/bfs.img.xz differ diff --git a/tests/ts/blkid/images-fs/bluestore.img.xz b/tests/ts/blkid/images-fs/bluestore.img.xz new file mode 100644 index 0000000..4fd8cbd Binary files /dev/null and b/tests/ts/blkid/images-fs/bluestore.img.xz differ diff --git a/tests/ts/blkid/images-fs/btrfs.img.xz b/tests/ts/blkid/images-fs/btrfs.img.xz new file mode 100644 index 0000000..418833d Binary files /dev/null and b/tests/ts/blkid/images-fs/btrfs.img.xz differ diff --git a/tests/ts/blkid/images-fs/cramfs-big.img.xz b/tests/ts/blkid/images-fs/cramfs-big.img.xz new file mode 100644 index 0000000..3d5dbe8 Binary files /dev/null and b/tests/ts/blkid/images-fs/cramfs-big.img.xz differ diff --git a/tests/ts/blkid/images-fs/cramfs.img.xz b/tests/ts/blkid/images-fs/cramfs.img.xz new file mode 100644 index 0000000..5943867 Binary files /dev/null and b/tests/ts/blkid/images-fs/cramfs.img.xz differ diff --git a/tests/ts/blkid/images-fs/cs_fvault2.img.xz b/tests/ts/blkid/images-fs/cs_fvault2.img.xz new file mode 100644 index 0000000..a1dec14 Binary files /dev/null and b/tests/ts/blkid/images-fs/cs_fvault2.img.xz differ diff --git a/tests/ts/blkid/images-fs/ddf-raid.img.xz b/tests/ts/blkid/images-fs/ddf-raid.img.xz new file mode 100644 index 0000000..b5b64fe Binary files /dev/null and b/tests/ts/blkid/images-fs/ddf-raid.img.xz differ diff --git a/tests/ts/blkid/images-fs/drbd-v08.img.xz b/tests/ts/blkid/images-fs/drbd-v08.img.xz new file mode 100644 index 0000000..2c8db6b Binary files /dev/null and b/tests/ts/blkid/images-fs/drbd-v08.img.xz differ diff --git a/tests/ts/blkid/images-fs/drbd-v09.img.xz b/tests/ts/blkid/images-fs/drbd-v09.img.xz new file mode 100644 index 0000000..798042d Binary files /dev/null and b/tests/ts/blkid/images-fs/drbd-v09.img.xz differ diff --git a/tests/ts/blkid/images-fs/drbdmanage-control-volume.img.xz b/tests/ts/blkid/images-fs/drbdmanage-control-volume.img.xz new file mode 100644 index 0000000..d31bfc1 Binary files /dev/null and b/tests/ts/blkid/images-fs/drbdmanage-control-volume.img.xz differ diff --git a/tests/ts/blkid/images-fs/erofs.img.xz b/tests/ts/blkid/images-fs/erofs.img.xz new file mode 100644 index 0000000..4087344 Binary files /dev/null and b/tests/ts/blkid/images-fs/erofs.img.xz differ diff --git a/tests/ts/blkid/images-fs/exfat.img.xz b/tests/ts/blkid/images-fs/exfat.img.xz new file mode 100644 index 0000000..43cc09a Binary files /dev/null and b/tests/ts/blkid/images-fs/exfat.img.xz differ diff --git a/tests/ts/blkid/images-fs/ext2.img.xz b/tests/ts/blkid/images-fs/ext2.img.xz new file mode 100644 index 0000000..3b5489f Binary files /dev/null and b/tests/ts/blkid/images-fs/ext2.img.xz differ diff --git a/tests/ts/blkid/images-fs/ext3.img.xz b/tests/ts/blkid/images-fs/ext3.img.xz new file mode 100644 index 0000000..7d170e2 Binary files /dev/null and b/tests/ts/blkid/images-fs/ext3.img.xz differ diff --git a/tests/ts/blkid/images-fs/ext4.img.xz b/tests/ts/blkid/images-fs/ext4.img.xz new file mode 100644 index 0000000..7dbfd70 Binary files /dev/null and b/tests/ts/blkid/images-fs/ext4.img.xz differ diff --git a/tests/ts/blkid/images-fs/f2fs.img.xz b/tests/ts/blkid/images-fs/f2fs.img.xz new file mode 100644 index 0000000..ed6b95e Binary files /dev/null and b/tests/ts/blkid/images-fs/f2fs.img.xz differ diff --git a/tests/ts/blkid/images-fs/fat.img.xz b/tests/ts/blkid/images-fs/fat.img.xz new file mode 100644 index 0000000..4e0997a Binary files /dev/null and b/tests/ts/blkid/images-fs/fat.img.xz differ diff --git a/tests/ts/blkid/images-fs/fat16_noheads.img.xz b/tests/ts/blkid/images-fs/fat16_noheads.img.xz new file mode 100644 index 0000000..a0ee296 Binary files /dev/null and b/tests/ts/blkid/images-fs/fat16_noheads.img.xz differ diff --git a/tests/ts/blkid/images-fs/fat32_cp850_O_tilde.img.xz b/tests/ts/blkid/images-fs/fat32_cp850_O_tilde.img.xz new file mode 100644 index 0000000..06eb2c9 Binary files /dev/null and b/tests/ts/blkid/images-fs/fat32_cp850_O_tilde.img.xz differ diff --git a/tests/ts/blkid/images-fs/fat32_label_64MB.img.xz b/tests/ts/blkid/images-fs/fat32_label_64MB.img.xz new file mode 100644 index 0000000..f0976bc Binary files /dev/null and b/tests/ts/blkid/images-fs/fat32_label_64MB.img.xz differ diff --git a/tests/ts/blkid/images-fs/fat32_mkdosfs_label1.img.xz b/tests/ts/blkid/images-fs/fat32_mkdosfs_label1.img.xz new file mode 100644 index 0000000..4df4b1d Binary files /dev/null and b/tests/ts/blkid/images-fs/fat32_mkdosfs_label1.img.xz differ diff --git a/tests/ts/blkid/images-fs/fat32_mkdosfs_label1_dosfslabel_NO_NAME.img.xz b/tests/ts/blkid/images-fs/fat32_mkdosfs_label1_dosfslabel_NO_NAME.img.xz new file mode 100644 index 0000000..932ab11 Binary files /dev/null and b/tests/ts/blkid/images-fs/fat32_mkdosfs_label1_dosfslabel_NO_NAME.img.xz differ diff --git a/tests/ts/blkid/images-fs/fat32_mkdosfs_label1_dosfslabel_empty.img.xz b/tests/ts/blkid/images-fs/fat32_mkdosfs_label1_dosfslabel_empty.img.xz new file mode 100644 index 0000000..3027031 Binary files /dev/null and b/tests/ts/blkid/images-fs/fat32_mkdosfs_label1_dosfslabel_empty.img.xz differ diff --git a/tests/ts/blkid/images-fs/fat32_mkdosfs_label1_dosfslabel_label2.img.xz b/tests/ts/blkid/images-fs/fat32_mkdosfs_label1_dosfslabel_label2.img.xz new file mode 100644 index 0000000..1551e11 Binary files /dev/null and b/tests/ts/blkid/images-fs/fat32_mkdosfs_label1_dosfslabel_label2.img.xz differ diff --git a/tests/ts/blkid/images-fs/fat32_mkdosfs_label1_mlabel_NO_NAME.img.xz b/tests/ts/blkid/images-fs/fat32_mkdosfs_label1_mlabel_NO_NAME.img.xz new file mode 100644 index 0000000..264c440 Binary files /dev/null and b/tests/ts/blkid/images-fs/fat32_mkdosfs_label1_mlabel_NO_NAME.img.xz differ diff --git a/tests/ts/blkid/images-fs/fat32_mkdosfs_label1_mlabel_erase.img.xz b/tests/ts/blkid/images-fs/fat32_mkdosfs_label1_mlabel_erase.img.xz new file mode 100644 index 0000000..f0a9571 Binary files /dev/null and b/tests/ts/blkid/images-fs/fat32_mkdosfs_label1_mlabel_erase.img.xz differ diff --git a/tests/ts/blkid/images-fs/fat32_mkdosfs_label1_xp_erase.img.xz b/tests/ts/blkid/images-fs/fat32_mkdosfs_label1_xp_erase.img.xz new file mode 100644 index 0000000..cc4280e Binary files /dev/null and b/tests/ts/blkid/images-fs/fat32_mkdosfs_label1_xp_erase.img.xz differ diff --git a/tests/ts/blkid/images-fs/fat32_mkdosfs_label1_xp_label2.img.xz b/tests/ts/blkid/images-fs/fat32_mkdosfs_label1_xp_label2.img.xz new file mode 100644 index 0000000..66d4838 Binary files /dev/null and b/tests/ts/blkid/images-fs/fat32_mkdosfs_label1_xp_label2.img.xz differ diff --git a/tests/ts/blkid/images-fs/fat32_mkdosfs_none.img.xz b/tests/ts/blkid/images-fs/fat32_mkdosfs_none.img.xz new file mode 100644 index 0000000..0d084f3 Binary files /dev/null and b/tests/ts/blkid/images-fs/fat32_mkdosfs_none.img.xz differ diff --git a/tests/ts/blkid/images-fs/fat32_mkdosfs_none_dosfslabel_NO_NAME.img.xz b/tests/ts/blkid/images-fs/fat32_mkdosfs_none_dosfslabel_NO_NAME.img.xz new file mode 100644 index 0000000..a238a01 Binary files /dev/null and b/tests/ts/blkid/images-fs/fat32_mkdosfs_none_dosfslabel_NO_NAME.img.xz differ diff --git a/tests/ts/blkid/images-fs/fat32_mkdosfs_none_dosfslabel_label1.img.xz b/tests/ts/blkid/images-fs/fat32_mkdosfs_none_dosfslabel_label1.img.xz new file mode 100644 index 0000000..1486031 Binary files /dev/null and b/tests/ts/blkid/images-fs/fat32_mkdosfs_none_dosfslabel_label1.img.xz differ diff --git a/tests/ts/blkid/images-fs/fat32_mkdosfs_none_dosfslabel_label1_xp_label2.img.xz b/tests/ts/blkid/images-fs/fat32_mkdosfs_none_dosfslabel_label1_xp_label2.img.xz new file mode 100644 index 0000000..5401e1f Binary files /dev/null and b/tests/ts/blkid/images-fs/fat32_mkdosfs_none_dosfslabel_label1_xp_label2.img.xz differ diff --git a/tests/ts/blkid/images-fs/fat32_mkdosfs_none_xp_label1.img.xz b/tests/ts/blkid/images-fs/fat32_mkdosfs_none_xp_label1.img.xz new file mode 100644 index 0000000..acf01cc Binary files /dev/null and b/tests/ts/blkid/images-fs/fat32_mkdosfs_none_xp_label1.img.xz differ diff --git a/tests/ts/blkid/images-fs/fat32_mkdosfs_none_xp_label1_dosfslabel_label2.img.xz b/tests/ts/blkid/images-fs/fat32_mkdosfs_none_xp_label1_dosfslabel_label2.img.xz new file mode 100644 index 0000000..bff0971 Binary files /dev/null and b/tests/ts/blkid/images-fs/fat32_mkdosfs_none_xp_label1_dosfslabel_label2.img.xz differ diff --git a/tests/ts/blkid/images-fs/fat32_xp_label1.img.xz b/tests/ts/blkid/images-fs/fat32_xp_label1.img.xz new file mode 100644 index 0000000..97d71e9 Binary files /dev/null and b/tests/ts/blkid/images-fs/fat32_xp_label1.img.xz differ diff --git a/tests/ts/blkid/images-fs/fat32_xp_none.img.xz b/tests/ts/blkid/images-fs/fat32_xp_none.img.xz new file mode 100644 index 0000000..a8c819e Binary files /dev/null and b/tests/ts/blkid/images-fs/fat32_xp_none.img.xz differ diff --git a/tests/ts/blkid/images-fs/fat32_xp_none_dosfslabel_label1.img.xz b/tests/ts/blkid/images-fs/fat32_xp_none_dosfslabel_label1.img.xz new file mode 100644 index 0000000..0ebe6be Binary files /dev/null and b/tests/ts/blkid/images-fs/fat32_xp_none_dosfslabel_label1.img.xz differ diff --git a/tests/ts/blkid/images-fs/fat32_xp_none_mlabel_label1.img.xz b/tests/ts/blkid/images-fs/fat32_xp_none_mlabel_label1.img.xz new file mode 100644 index 0000000..5a7a774 Binary files /dev/null and b/tests/ts/blkid/images-fs/fat32_xp_none_mlabel_label1.img.xz differ diff --git a/tests/ts/blkid/images-fs/gfs2.img.xz b/tests/ts/blkid/images-fs/gfs2.img.xz new file mode 100644 index 0000000..22d4d6b Binary files /dev/null and b/tests/ts/blkid/images-fs/gfs2.img.xz differ diff --git a/tests/ts/blkid/images-fs/hfs.img.xz b/tests/ts/blkid/images-fs/hfs.img.xz new file mode 100644 index 0000000..cfa3252 Binary files /dev/null and b/tests/ts/blkid/images-fs/hfs.img.xz differ diff --git a/tests/ts/blkid/images-fs/hfsplus.img.xz b/tests/ts/blkid/images-fs/hfsplus.img.xz new file mode 100644 index 0000000..1c37a70 Binary files /dev/null and b/tests/ts/blkid/images-fs/hfsplus.img.xz differ diff --git a/tests/ts/blkid/images-fs/hpfs.img.xz b/tests/ts/blkid/images-fs/hpfs.img.xz new file mode 100644 index 0000000..4e22a8e Binary files /dev/null and b/tests/ts/blkid/images-fs/hpfs.img.xz differ diff --git a/tests/ts/blkid/images-fs/hpt37x-raid.img.xz b/tests/ts/blkid/images-fs/hpt37x-raid.img.xz new file mode 100644 index 0000000..1b53059 Binary files /dev/null and b/tests/ts/blkid/images-fs/hpt37x-raid.img.xz differ diff --git a/tests/ts/blkid/images-fs/hpt45x-raid.img.xz b/tests/ts/blkid/images-fs/hpt45x-raid.img.xz new file mode 100644 index 0000000..7dfe68a Binary files /dev/null and b/tests/ts/blkid/images-fs/hpt45x-raid.img.xz differ diff --git a/tests/ts/blkid/images-fs/iso-different-iso-joliet-label.img.xz b/tests/ts/blkid/images-fs/iso-different-iso-joliet-label.img.xz new file mode 100644 index 0000000..73c5f2b Binary files /dev/null and b/tests/ts/blkid/images-fs/iso-different-iso-joliet-label.img.xz differ diff --git a/tests/ts/blkid/images-fs/iso-joliet.img.xz b/tests/ts/blkid/images-fs/iso-joliet.img.xz new file mode 100644 index 0000000..16b8961 Binary files /dev/null and b/tests/ts/blkid/images-fs/iso-joliet.img.xz differ diff --git a/tests/ts/blkid/images-fs/iso-multi-0-174-348-genisoimage.img.xz b/tests/ts/blkid/images-fs/iso-multi-0-174-348-genisoimage.img.xz new file mode 100644 index 0000000..ec15d8c Binary files /dev/null and b/tests/ts/blkid/images-fs/iso-multi-0-174-348-genisoimage.img.xz differ diff --git a/tests/ts/blkid/images-fs/iso-rr-joliet.img.xz b/tests/ts/blkid/images-fs/iso-rr-joliet.img.xz new file mode 100644 index 0000000..1d6ad2c Binary files /dev/null and b/tests/ts/blkid/images-fs/iso-rr-joliet.img.xz differ diff --git a/tests/ts/blkid/images-fs/iso-unicode-long-label.img.xz b/tests/ts/blkid/images-fs/iso-unicode-long-label.img.xz new file mode 100644 index 0000000..488be1a Binary files /dev/null and b/tests/ts/blkid/images-fs/iso-unicode-long-label.img.xz differ diff --git a/tests/ts/blkid/images-fs/iso.img.xz b/tests/ts/blkid/images-fs/iso.img.xz new file mode 100644 index 0000000..f1146f3 Binary files /dev/null and b/tests/ts/blkid/images-fs/iso.img.xz differ diff --git a/tests/ts/blkid/images-fs/isw-raid.img.xz b/tests/ts/blkid/images-fs/isw-raid.img.xz new file mode 100644 index 0000000..8e5529a Binary files /dev/null and b/tests/ts/blkid/images-fs/isw-raid.img.xz differ diff --git a/tests/ts/blkid/images-fs/jbd.img.xz b/tests/ts/blkid/images-fs/jbd.img.xz new file mode 100644 index 0000000..7c5a089 Binary files /dev/null and b/tests/ts/blkid/images-fs/jbd.img.xz differ diff --git a/tests/ts/blkid/images-fs/jfs.img.xz b/tests/ts/blkid/images-fs/jfs.img.xz new file mode 100644 index 0000000..4780f6d Binary files /dev/null and b/tests/ts/blkid/images-fs/jfs.img.xz differ diff --git a/tests/ts/blkid/images-fs/jmicron-raid.img.xz b/tests/ts/blkid/images-fs/jmicron-raid.img.xz new file mode 100644 index 0000000..cde0811 Binary files /dev/null and b/tests/ts/blkid/images-fs/jmicron-raid.img.xz differ diff --git a/tests/ts/blkid/images-fs/lsi-raid.img.xz b/tests/ts/blkid/images-fs/lsi-raid.img.xz new file mode 100644 index 0000000..d6ae15a Binary files /dev/null and b/tests/ts/blkid/images-fs/lsi-raid.img.xz differ diff --git a/tests/ts/blkid/images-fs/luks1.img.xz b/tests/ts/blkid/images-fs/luks1.img.xz new file mode 100644 index 0000000..c0f5902 Binary files /dev/null and b/tests/ts/blkid/images-fs/luks1.img.xz differ diff --git a/tests/ts/blkid/images-fs/luks2.img.xz b/tests/ts/blkid/images-fs/luks2.img.xz new file mode 100644 index 0000000..997fb04 Binary files /dev/null and b/tests/ts/blkid/images-fs/luks2.img.xz differ diff --git a/tests/ts/blkid/images-fs/lvm2.img.xz b/tests/ts/blkid/images-fs/lvm2.img.xz new file mode 100644 index 0000000..4c3c183 Binary files /dev/null and b/tests/ts/blkid/images-fs/lvm2.img.xz differ diff --git a/tests/ts/blkid/images-fs/mdraid-1.img.xz b/tests/ts/blkid/images-fs/mdraid-1.img.xz new file mode 100644 index 0000000..c17ad3b Binary files /dev/null and b/tests/ts/blkid/images-fs/mdraid-1.img.xz differ diff --git a/tests/ts/blkid/images-fs/mdraid.img.xz b/tests/ts/blkid/images-fs/mdraid.img.xz new file mode 100644 index 0000000..e8ff4f5 Binary files /dev/null and b/tests/ts/blkid/images-fs/mdraid.img.xz differ diff --git a/tests/ts/blkid/images-fs/minix-BE.img.xz b/tests/ts/blkid/images-fs/minix-BE.img.xz new file mode 100644 index 0000000..c349a4f Binary files /dev/null and b/tests/ts/blkid/images-fs/minix-BE.img.xz differ diff --git a/tests/ts/blkid/images-fs/minix-LE.img.xz b/tests/ts/blkid/images-fs/minix-LE.img.xz new file mode 100644 index 0000000..da646a8 Binary files /dev/null and b/tests/ts/blkid/images-fs/minix-LE.img.xz differ diff --git a/tests/ts/blkid/images-fs/mpool.img.xz b/tests/ts/blkid/images-fs/mpool.img.xz new file mode 100644 index 0000000..4bfefde Binary files /dev/null and b/tests/ts/blkid/images-fs/mpool.img.xz differ diff --git a/tests/ts/blkid/images-fs/netware.img.xz b/tests/ts/blkid/images-fs/netware.img.xz new file mode 100644 index 0000000..fe5b103 Binary files /dev/null and b/tests/ts/blkid/images-fs/netware.img.xz differ diff --git a/tests/ts/blkid/images-fs/nilfs2.img.xz b/tests/ts/blkid/images-fs/nilfs2.img.xz new file mode 100644 index 0000000..38de645 Binary files /dev/null and b/tests/ts/blkid/images-fs/nilfs2.img.xz differ diff --git a/tests/ts/blkid/images-fs/ntfs.img.xz b/tests/ts/blkid/images-fs/ntfs.img.xz new file mode 100644 index 0000000..2b414c4 Binary files /dev/null and b/tests/ts/blkid/images-fs/ntfs.img.xz differ diff --git a/tests/ts/blkid/images-fs/nvidia-raid.img.xz b/tests/ts/blkid/images-fs/nvidia-raid.img.xz new file mode 100644 index 0000000..775f810 Binary files /dev/null and b/tests/ts/blkid/images-fs/nvidia-raid.img.xz differ diff --git a/tests/ts/blkid/images-fs/ocfs2.img.xz b/tests/ts/blkid/images-fs/ocfs2.img.xz new file mode 100644 index 0000000..12ed926 Binary files /dev/null and b/tests/ts/blkid/images-fs/ocfs2.img.xz differ diff --git a/tests/ts/blkid/images-fs/promise-raid.img.xz b/tests/ts/blkid/images-fs/promise-raid.img.xz new file mode 100644 index 0000000..77f135f Binary files /dev/null and b/tests/ts/blkid/images-fs/promise-raid.img.xz differ diff --git a/tests/ts/blkid/images-fs/reiser3.img.xz b/tests/ts/blkid/images-fs/reiser3.img.xz new file mode 100644 index 0000000..8bc595f Binary files /dev/null and b/tests/ts/blkid/images-fs/reiser3.img.xz differ diff --git a/tests/ts/blkid/images-fs/reiser4.img.xz b/tests/ts/blkid/images-fs/reiser4.img.xz new file mode 100644 index 0000000..e97f960 Binary files /dev/null and b/tests/ts/blkid/images-fs/reiser4.img.xz differ diff --git a/tests/ts/blkid/images-fs/romfs.img.xz b/tests/ts/blkid/images-fs/romfs.img.xz new file mode 100644 index 0000000..680eeed Binary files /dev/null and b/tests/ts/blkid/images-fs/romfs.img.xz differ diff --git a/tests/ts/blkid/images-fs/silicon-raid.img.xz b/tests/ts/blkid/images-fs/silicon-raid.img.xz new file mode 100644 index 0000000..28d6a42 Binary files /dev/null and b/tests/ts/blkid/images-fs/silicon-raid.img.xz differ diff --git a/tests/ts/blkid/images-fs/small-fat32.img.xz b/tests/ts/blkid/images-fs/small-fat32.img.xz new file mode 100644 index 0000000..7a04f42 Binary files /dev/null and b/tests/ts/blkid/images-fs/small-fat32.img.xz differ diff --git a/tests/ts/blkid/images-fs/squashfs3.img.xz b/tests/ts/blkid/images-fs/squashfs3.img.xz new file mode 100755 index 0000000..8b2e15d Binary files /dev/null and b/tests/ts/blkid/images-fs/squashfs3.img.xz differ diff --git a/tests/ts/blkid/images-fs/squashfs4.img.xz b/tests/ts/blkid/images-fs/squashfs4.img.xz new file mode 100644 index 0000000..81f0785 Binary files /dev/null and b/tests/ts/blkid/images-fs/squashfs4.img.xz differ diff --git a/tests/ts/blkid/images-fs/swap0.img.xz b/tests/ts/blkid/images-fs/swap0.img.xz new file mode 100644 index 0000000..3cfea73 Binary files /dev/null and b/tests/ts/blkid/images-fs/swap0.img.xz differ diff --git a/tests/ts/blkid/images-fs/swap1-big.img.xz b/tests/ts/blkid/images-fs/swap1-big.img.xz new file mode 100644 index 0000000..7d256fc Binary files /dev/null and b/tests/ts/blkid/images-fs/swap1-big.img.xz differ diff --git a/tests/ts/blkid/images-fs/swap1.img.xz b/tests/ts/blkid/images-fs/swap1.img.xz new file mode 100644 index 0000000..6e6f539 Binary files /dev/null and b/tests/ts/blkid/images-fs/swap1.img.xz differ diff --git a/tests/ts/blkid/images-fs/tuxonice.img.xz b/tests/ts/blkid/images-fs/tuxonice.img.xz new file mode 100644 index 0000000..472cf9c Binary files /dev/null and b/tests/ts/blkid/images-fs/tuxonice.img.xz differ diff --git a/tests/ts/blkid/images-fs/ubi.img.xz b/tests/ts/blkid/images-fs/ubi.img.xz new file mode 100644 index 0000000..1a073f2 Binary files /dev/null and b/tests/ts/blkid/images-fs/ubi.img.xz differ diff --git a/tests/ts/blkid/images-fs/ubifs.img.xz b/tests/ts/blkid/images-fs/ubifs.img.xz new file mode 100644 index 0000000..2004f5b Binary files /dev/null and b/tests/ts/blkid/images-fs/ubifs.img.xz differ diff --git a/tests/ts/blkid/images-fs/udf-bdr-2.60-nero.img.xz b/tests/ts/blkid/images-fs/udf-bdr-2.60-nero.img.xz new file mode 100644 index 0000000..9fb9a4f Binary files /dev/null and b/tests/ts/blkid/images-fs/udf-bdr-2.60-nero.img.xz differ diff --git a/tests/ts/blkid/images-fs/udf-cd-mkudfiso-20100208.img.xz b/tests/ts/blkid/images-fs/udf-cd-mkudfiso-20100208.img.xz new file mode 100644 index 0000000..1da9a28 Binary files /dev/null and b/tests/ts/blkid/images-fs/udf-cd-mkudfiso-20100208.img.xz differ diff --git a/tests/ts/blkid/images-fs/udf-cd-nero-6.img.xz b/tests/ts/blkid/images-fs/udf-cd-nero-6.img.xz new file mode 100644 index 0000000..673fa62 Binary files /dev/null and b/tests/ts/blkid/images-fs/udf-cd-nero-6.img.xz differ diff --git a/tests/ts/blkid/images-fs/udf-hdd-macosx-2.60-4096.img.xz b/tests/ts/blkid/images-fs/udf-hdd-macosx-2.60-4096.img.xz new file mode 100644 index 0000000..68412ad Binary files /dev/null and b/tests/ts/blkid/images-fs/udf-hdd-macosx-2.60-4096.img.xz differ diff --git a/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.0.0-1.img.xz b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.0.0-1.img.xz new file mode 100644 index 0000000..39db4be Binary files /dev/null and b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.0.0-1.img.xz differ diff --git a/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.0.0-2.img.xz b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.0.0-2.img.xz new file mode 100644 index 0000000..4cba447 Binary files /dev/null and b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.0.0-2.img.xz differ diff --git a/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-1.img.xz b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-1.img.xz new file mode 100644 index 0000000..7df36db Binary files /dev/null and b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-1.img.xz differ diff --git a/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-2.img.xz b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-2.img.xz new file mode 100644 index 0000000..bc0facc Binary files /dev/null and b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-2.img.xz differ diff --git a/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-3.img.xz b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-3.img.xz new file mode 100644 index 0000000..d774e0a Binary files /dev/null and b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-3.img.xz differ diff --git a/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-4.img.xz b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-4.img.xz new file mode 100644 index 0000000..047e39a Binary files /dev/null and b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-4.img.xz differ diff --git a/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-5.img.xz b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-5.img.xz new file mode 100644 index 0000000..291d7eb Binary files /dev/null and b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-5.img.xz differ diff --git a/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-6.img.xz b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-6.img.xz new file mode 100644 index 0000000..393ab9e Binary files /dev/null and b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-6.img.xz differ diff --git a/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-7.img.xz b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-7.img.xz new file mode 100644 index 0000000..5940009 Binary files /dev/null and b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-7.img.xz differ diff --git a/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-8.img.xz b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-8.img.xz new file mode 100644 index 0000000..b91180c Binary files /dev/null and b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-8.img.xz differ diff --git a/tests/ts/blkid/images-fs/udf-hdd-mkudffs-2.2.img.xz b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-2.2.img.xz new file mode 100644 index 0000000..bc00729 Binary files /dev/null and b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-2.2.img.xz differ diff --git a/tests/ts/blkid/images-fs/udf-hdd-udfclient-0.7.5.img.xz b/tests/ts/blkid/images-fs/udf-hdd-udfclient-0.7.5.img.xz new file mode 100644 index 0000000..baddc84 Binary files /dev/null and b/tests/ts/blkid/images-fs/udf-hdd-udfclient-0.7.5.img.xz differ diff --git a/tests/ts/blkid/images-fs/udf-hdd-udfclient-0.7.7.img.xz b/tests/ts/blkid/images-fs/udf-hdd-udfclient-0.7.7.img.xz new file mode 100644 index 0000000..dfb8cdb Binary files /dev/null and b/tests/ts/blkid/images-fs/udf-hdd-udfclient-0.7.7.img.xz differ diff --git a/tests/ts/blkid/images-fs/udf-hdd-win7.img.xz b/tests/ts/blkid/images-fs/udf-hdd-win7.img.xz new file mode 100644 index 0000000..ee86115 Binary files /dev/null and b/tests/ts/blkid/images-fs/udf-hdd-win7.img.xz differ diff --git a/tests/ts/blkid/images-fs/udf-multi-0-320-640-mkudffs.img.xz b/tests/ts/blkid/images-fs/udf-multi-0-320-640-mkudffs.img.xz new file mode 100644 index 0000000..cac6318 Binary files /dev/null and b/tests/ts/blkid/images-fs/udf-multi-0-320-640-mkudffs.img.xz differ diff --git a/tests/ts/blkid/images-fs/udf-multi-0-417-834-genisoimage.img.xz b/tests/ts/blkid/images-fs/udf-multi-0-417-834-genisoimage.img.xz new file mode 100644 index 0000000..c1c6fc7 Binary files /dev/null and b/tests/ts/blkid/images-fs/udf-multi-0-417-834-genisoimage.img.xz differ diff --git a/tests/ts/blkid/images-fs/udf.img.xz b/tests/ts/blkid/images-fs/udf.img.xz new file mode 100644 index 0000000..fdf0edf Binary files /dev/null and b/tests/ts/blkid/images-fs/udf.img.xz differ diff --git a/tests/ts/blkid/images-fs/ufs.img.xz b/tests/ts/blkid/images-fs/ufs.img.xz new file mode 100644 index 0000000..58f8b20 Binary files /dev/null and b/tests/ts/blkid/images-fs/ufs.img.xz differ diff --git a/tests/ts/blkid/images-fs/vdo.img.xz b/tests/ts/blkid/images-fs/vdo.img.xz new file mode 100644 index 0000000..08c7ecb Binary files /dev/null and b/tests/ts/blkid/images-fs/vdo.img.xz differ diff --git a/tests/ts/blkid/images-fs/via-raid.img.xz b/tests/ts/blkid/images-fs/via-raid.img.xz new file mode 100644 index 0000000..c5f6fb7 Binary files /dev/null and b/tests/ts/blkid/images-fs/via-raid.img.xz differ diff --git a/tests/ts/blkid/images-fs/vmfs.img.xz b/tests/ts/blkid/images-fs/vmfs.img.xz new file mode 100644 index 0000000..ce4544e Binary files /dev/null and b/tests/ts/blkid/images-fs/vmfs.img.xz differ diff --git a/tests/ts/blkid/images-fs/vmfs_volume.img.xz b/tests/ts/blkid/images-fs/vmfs_volume.img.xz new file mode 100644 index 0000000..93f11b4 Binary files /dev/null and b/tests/ts/blkid/images-fs/vmfs_volume.img.xz differ diff --git a/tests/ts/blkid/images-fs/xfs-log.img.xz b/tests/ts/blkid/images-fs/xfs-log.img.xz new file mode 100644 index 0000000..35ff33b Binary files /dev/null and b/tests/ts/blkid/images-fs/xfs-log.img.xz differ diff --git a/tests/ts/blkid/images-fs/xfs-v5.img.xz b/tests/ts/blkid/images-fs/xfs-v5.img.xz new file mode 100644 index 0000000..e2399e3 Binary files /dev/null and b/tests/ts/blkid/images-fs/xfs-v5.img.xz differ diff --git a/tests/ts/blkid/images-fs/xfs.img.xz b/tests/ts/blkid/images-fs/xfs.img.xz new file mode 100644 index 0000000..5576c66 Binary files /dev/null and b/tests/ts/blkid/images-fs/xfs.img.xz differ diff --git a/tests/ts/blkid/images-fs/zfs.img.xz b/tests/ts/blkid/images-fs/zfs.img.xz new file mode 100644 index 0000000..f85e536 Binary files /dev/null and b/tests/ts/blkid/images-fs/zfs.img.xz differ diff --git a/tests/ts/blkid/images-fs/zonefs.img.xz b/tests/ts/blkid/images-fs/zonefs.img.xz new file mode 100644 index 0000000..c936a80 Binary files /dev/null and b/tests/ts/blkid/images-fs/zonefs.img.xz differ diff --git a/tests/ts/blkid/images-pt/atari-primary.img.xz b/tests/ts/blkid/images-pt/atari-primary.img.xz new file mode 100644 index 0000000..6f915fa Binary files /dev/null and b/tests/ts/blkid/images-pt/atari-primary.img.xz differ diff --git a/tests/ts/blkid/images-pt/atari-xgm.img.xz b/tests/ts/blkid/images-pt/atari-xgm.img.xz new file mode 100644 index 0000000..a98c02d Binary files /dev/null and b/tests/ts/blkid/images-pt/atari-xgm.img.xz differ diff --git a/tests/ts/blkid/images-pt/bsd.img.xz b/tests/ts/blkid/images-pt/bsd.img.xz new file mode 100644 index 0000000..bfdb50b Binary files /dev/null and b/tests/ts/blkid/images-pt/bsd.img.xz differ diff --git a/tests/ts/blkid/images-pt/dos+bsd.img.xz b/tests/ts/blkid/images-pt/dos+bsd.img.xz new file mode 100644 index 0000000..f87dd74 Binary files /dev/null and b/tests/ts/blkid/images-pt/dos+bsd.img.xz differ diff --git a/tests/ts/blkid/images-pt/gpt.img.xz b/tests/ts/blkid/images-pt/gpt.img.xz new file mode 100644 index 0000000..9a085b4 Binary files /dev/null and b/tests/ts/blkid/images-pt/gpt.img.xz differ diff --git a/tests/ts/blkid/images-pt/sgi.img.xz b/tests/ts/blkid/images-pt/sgi.img.xz new file mode 100644 index 0000000..d5fed80 Binary files /dev/null and b/tests/ts/blkid/images-pt/sgi.img.xz differ diff --git a/tests/ts/blkid/images-pt/sun.img.xz b/tests/ts/blkid/images-pt/sun.img.xz new file mode 100644 index 0000000..a00594a Binary files /dev/null and b/tests/ts/blkid/images-pt/sun.img.xz differ diff --git a/tests/ts/blkid/low-probe b/tests/ts/blkid/low-probe new file mode 100755 index 0000000..27a074b --- /dev/null +++ b/tests/ts/blkid/low-probe @@ -0,0 +1,66 @@ +#!/bin/bash + +# +# Copyright (C) 2009 Karel Zak +# +# 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="superblocks probing" + +. "$TS_TOPDIR"/functions.sh + +ts_init "$*" + +ts_check_test_command "$TS_CMD_BLKID" +ts_check_prog "xz" + +mkdir -p $TS_OUTDIR/images-fs + +for img in $(ls $TS_SELF/images-fs/*.img.xz | sort); do + name=$(basename $img .img.xz) + outimg=$TS_OUTDIR/images-fs/${name}.img + + xz -dc $img > $outimg + + # + # multi session images, the image name contains "-multi-" and all + # -- are interpreted as offset to the sessions. The offset is + # calculated in 2048 sectors. For example: iso-multi-0-174-348-genisoimage.img + # + if [[ $name =~ (.*multi.*) ]]; then + sessions=$(echo "$name" \ + | awk 'BEGIN { RS="-" } /^[[:digit:]]+$/ { print $0 }') + name=$(echo "$name" \ + | awk 'BEGIN { RS="-"; ORS="-" } !/^[[:digit:]]+$/ { print $1 }' \ + | sed 's/-$//g') + for off in $sessions; do + ts_init_subtest $name-$off + $TS_CMD_BLKID -p -o udev $outimg \ + --hint session_offset=$(( $off * 2048 )) \ + 2> $TS_ERRLOG | sort > $TS_OUTPUT + ts_finalize_subtest + done + # + # Standard filesystem images + # + else + ts_init_subtest $name + $TS_CMD_BLKID -p -o udev $outimg 2> $TS_ERRLOG | sort > $TS_OUTPUT + ts_finalize_subtest + fi +done + +ts_finalize + diff --git a/tests/ts/blkid/lowprobe-pt b/tests/ts/blkid/lowprobe-pt new file mode 100755 index 0000000..8e55ccc --- /dev/null +++ b/tests/ts/blkid/lowprobe-pt @@ -0,0 +1,44 @@ +#!/bin/bash + +# +# Copyright (C) 2009 Karel Zak +# +# 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="partitions probing" + +. "$TS_TOPDIR"/functions.sh + +ts_init "$*" + +ts_check_test_command "$TS_HELPER_PARTITIONS" +ts_check_prog "xz" + +mkdir -p $TS_OUTDIR/images-pt + +for img in $(ls $TS_SELF/images-pt/*.img.xz | sort); do + name=$(basename $img .img.xz) + outimg=$TS_OUTDIR/images-pt/${name}.img + + ts_init_subtest $name + + xz -dc $img > $outimg + + $TS_HELPER_PARTITIONS $outimg &> $TS_OUTPUT + ts_finalize_subtest +done + +ts_finalize + diff --git a/tests/ts/blkid/md-raid0-whole b/tests/ts/blkid/md-raid0-whole new file mode 100755 index 0000000..0c957ab --- /dev/null +++ b/tests/ts/blkid/md-raid0-whole @@ -0,0 +1,99 @@ +#!/bin/bash + +# +# Copyright (C) 2010 Karel Zak +# +# 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="MD raid0 (whole-disks)" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FDISK" +ts_check_test_command "$TS_CMD_BLKID" + +ts_skip_nonroot +ts_check_losetup +ts_check_prog "mdadm" + +# rhbz#182625: It can't create new raid0 with metadata 0.90 from mdadm-4.1 +TS_KNOWN_FAIL="yes" + +ts_log "Initialize devices" +IMGNAME="${TS_OUTDIR}/${TS_TESTNAME}" + +ts_device_init 50 ${IMGNAME}1.img +DEVICE1=$TS_LODEV + +ts_device_init 50 ${IMGNAME}2.img +DEVICE2=$TS_LODEV + +MD_DEVNAME=md8 +MD_DEVICE=/dev/${MD_DEVNAME} + +ts_lock "md" +mdadm -q -S ${MD_DEVICE} &> /dev/null + +ts_log "Create RAID device" +mdadm -q --create ${MD_DEVICE} --metadata=0.90 --chunk=64 --level=0 \ + --raid-devices=2 ${DEVICE1} ${DEVICE2} >> $TS_OUTPUT 2>> $TS_ERRLOG + +# create dos partition table +$TS_CMD_FDISK --noauto-pt ${MD_DEVICE} &>/dev/null <> $TS_OUTPUT 2>> $TS_ERRLOG <> $TS_ERRLOG | sort >> $TS_OUTPUT + +ts_log "Probe second RAID member" +$TS_CMD_BLKID -p -o udev $DEVICE1 2>> $TS_ERRLOG | sort >> $TS_OUTPUT + +ts_log "Stop RAID device" +mdadm -q -S ${MD_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG + +udevadm settle +ts_unlock "md" + +ts_log "Deinitialize devices" + +ts_fdisk_clean $MD_DEVICE + +# remove generated UUIDs +sed -i -e 's/ID_FS_UUID.*//g' $TS_OUTPUT + +ts_finalize diff --git a/tests/ts/blkid/md-raid1-part b/tests/ts/blkid/md-raid1-part new file mode 100755 index 0000000..b0ef822 --- /dev/null +++ b/tests/ts/blkid/md-raid1-part @@ -0,0 +1,99 @@ +#!/bin/bash + +# +# Copyright (C) 2010 Karel Zak +# +# 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="MD raid1 (last partition)" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FDISK" +ts_check_test_command "$TS_CMD_BLKID" + +ts_skip_nonroot +ts_check_prog "mdadm" + +# rhbz#182625: It can't create new raid0 with metadata 0.90 from mdadm-4.1 +TS_KNOWN_FAIL="yes" + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=51 sector_size=512 + +ts_log "Create partitions" +$TS_CMD_FDISK --noauto-pt ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG < /dev/null < /dev/null +mdadm -q --create ${MD_DEVICE} --metadata=0.90 --chunk=64 --level=1 \ + --raid-devices=2 ${TS_DEVICE}1 ${TS_DEVICE}2 >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle + +ts_log "Probe whole-disk" +$TS_CMD_BLKID -p -o udev ${TS_DEVICE} 2>> $TS_ERRLOG | sort >> $TS_OUTPUT + +ts_log "Probe first RAID member" +$TS_CMD_BLKID -p -o udev ${TS_DEVICE}1 2>> $TS_ERRLOG | sort >> $TS_OUTPUT + +ts_log "Probe second RAID member" +$TS_CMD_BLKID -p -o udev ${TS_DEVICE}2 2>> $TS_ERRLOG | sort >> $TS_OUTPUT + +mdadm -q -S ${MD_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG + +udevadm settle +ts_unlock "md" + +ts_fdisk_clean $TS_DEVICE +# substitute UUIDs and major/minor number before comparison +sed -i \ + -e 's/^\(ID_FS_UUID\)=.*/\1=__ts_uuid__/' \ + -e 's/^\(ID_FS_UUID_ENC\)=.*/\1=__ts_uuid_enc__/' \ + -e 's/^\(ID_PART_ENTRY_DISK\)=.*/\1=__ts_majorminor__/' \ + $TS_OUTPUT + +ts_finalize diff --git a/tests/ts/blkid/md-raid1-whole b/tests/ts/blkid/md-raid1-whole new file mode 100755 index 0000000..1199fab --- /dev/null +++ b/tests/ts/blkid/md-raid1-whole @@ -0,0 +1,103 @@ +#!/bin/bash + +# +# Copyright (C) 2010 Karel Zak +# +# 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="MD raid1 (whole-disks)" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FDISK" +ts_check_test_command "$TS_CMD_BLKID" + +ts_skip_nonroot +ts_check_losetup +ts_check_prog "mdadm" + +# rhbz#182625: It can't create new raid0 with metadata 0.90 from mdadm-4.1 +TS_KNOWN_FAIL="yes" + +ts_log "Initialize devices" +IMGNAME="${TS_OUTDIR}/${TS_TESTNAME}" + +ts_device_init 50 ${IMGNAME}1.img +DEVICE1=$TS_LODEV + +ts_device_init 50 ${IMGNAME}2.img +DEVICE2=$TS_LODEV + +MD_DEVNAME=md8 +MD_DEVICE=/dev/${MD_DEVNAME} + +ts_lock "md" + +mdadm -q -S ${MD_DEVICE} &> /dev/null +udevadm settle + +ts_log "Create RAID device" +mdadm -q --create ${MD_DEVICE} --metadata=0.90 --chunk=64 --level=1 \ + --raid-devices=2 ${DEVICE1} ${DEVICE2} >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle + +# create dos partition table +$TS_CMD_FDISK --noauto-pt ${MD_DEVICE} &>/dev/null <> $TS_OUTPUT 2>> $TS_ERRLOG <> $TS_ERRLOG | sort >> $TS_OUTPUT + +ts_log "Probe second RAID member" +$TS_CMD_BLKID -p -o udev $DEVICE1 2>> $TS_ERRLOG | sort >> $TS_OUTPUT + +ts_log "Stop RAID device" +mdadm -q -S ${MD_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG + +udevadm settle +ts_unlock "md" + +ts_log "Deinitialize devices" + +ts_fdisk_clean +# seems that raid1 minimum I/O size has been changed in kernels >4.4.x and >4.8 +sed -i 's@^\(I/O size (minimum/optimal): \)[1-9][0-9]*@\1@' $TS_OUTPUT +# remove generated UUIDs +sed -i -e 's/ID_FS_UUID.*//g' $TS_OUTPUT + +ts_finalize diff --git a/tests/ts/blkid/offset b/tests/ts/blkid/offset new file mode 100755 index 0000000..1b81ecf --- /dev/null +++ b/tests/ts/blkid/offset @@ -0,0 +1,58 @@ +#!/bin/bash + +# 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="offset" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_SFDISK" +ts_check_test_command "$TS_CMD_BLKID" +ts_check_test_command "$TS_CMD_PARTX" + +ts_check_prog "mkfs.ext2" +ts_skip_nonroot + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=50 sector_size=512 + +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG < /dev/null +udevadm settle +ts_device_has "TYPE" "ext2" ${TS_DEVICE}2 || + ts_die "Cannot find ext2 on ${TS_DEVICE}2" + +DEVNAME=$(basename $TS_DEVICE) +offset=$(( $(cat /sys/block/${DEVNAME}/${DEVNAME}2/start) * 512)) +size=$(( $(cat /sys/block/${DEVNAME}/${DEVNAME}2/size) * 512)) + +$TS_CMD_PARTX --delete ${TS_DEVICE} &> /dev/null + +$TS_CMD_BLKID -p -o udev --offset=${offset} --size=${size} $TS_DEVICE \ + >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_finalize diff --git a/tests/ts/blkid/topology b/tests/ts/blkid/topology new file mode 100755 index 0000000..fcf0724 --- /dev/null +++ b/tests/ts/blkid/topology @@ -0,0 +1,54 @@ +#!/bin/bash + +# +# Copyright (C) 2022 Thomas Weißschuh +# +# 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="topology probing" + +. "$TS_TOPDIR"/functions.sh + +ts_init "$*" + +ts_skip_nonroot +ts_check_losetup +ts_check_test_command "$TS_CMD_BLKID" +ts_check_test_command "$TS_CMD_SFDISK" + +ts_device_init + + +ts_init_subtest disk +echo -e 'label: dos\n- - - -' | "$TS_CMD_SFDISK" -q "$TS_LODEV" + +"$TS_CMD_BLKID" -i -o udev "$TS_LODEV" \ + 2> "$TS_ERRLOG" \ + | sed -E -e 's/^ID_FS_DISKSEQ=[[:digit:]]+$/ID_FS_DISKSEQ=S/' \ + | sort > "$TS_OUTPUT" + +ts_finalize_subtest + + +ts_init_subtest partition + +"$TS_CMD_BLKID" -i -o udev "$TS_LODEV"p1 \ + 2> "$TS_ERRLOG" \ + | sed -E -e 's/^ID_FS_DISKSEQ=[[:digit:]]+$/ID_FS_DISKSEQ=S/' \ + | sort > "$TS_OUTPUT" + +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/build-sys/config b/tests/ts/build-sys/config new file mode 100755 index 0000000..2d12913 --- /dev/null +++ b/tests/ts/build-sys/config @@ -0,0 +1,83 @@ +#!/bin/bash + +# Copyright (C) 2011 Karel Zak + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="config" + +# Don't execute this test by default, --force required +TS_OPTIONAL="yes" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_prog "readelf" +ts_check_prog "file" + +config_gen_dir="$top_srcdir/tools" +. $config_gen_dir/config-gen-functions.sh + +[ -n "$CFLAGS" ] && export CFLAGS="$CFLAGS" + +ts_cd $top_builddir && make -j clean &> /dev/null + +wanted=$(ts_option_argument "conf" "$*") + +function make_conf { + local conf="$1" + + ts_init_subtest $(basename $conf | sed 's/\.conf//') + + opts=$(ul_get_configuration $conf | sed 's/--enable-asan//') + + olddir=$(pwd) + ts_cd $top_builddir + + ./configure $opts &> /dev/null + make -j &> /dev/null + + bins=$(find . -type f \( -perm -u=x -o -perm -g=x -o -perm -o=x \) | sort) + for b in $bins; do + libs=$(readelf --dynamic $b 2> /dev/null | \ + awk '/NEEDED/ { print $5 }' | \ + sed 's:\[::g; s:\..*::g; s:^libc$::g; s:ld\-.*::g' | \ + sort -u | tr '\n' ' ') + + if [ -n "$libs" ]; then + echo "$(basename $b): $libs" >> $TS_OUTPUT + else + fres=$(file $b) + case $fres in + *statically*) + echo "$(basename $b): STATIC" >> $TS_OUTPUT + ;; + *) # ignore scripts, ...etc. + ;; + esac + fi + done + + # clean the tree, but exclude tests/{diff,output} dirs + # + [ -d tests/diff ] && mv tests/diff tests/diff.save + [ -d tests/output ] && mv tests/output tests/output.save + + make -j clean &> /dev/null + + [ -d tests/diff.save ] && mv tests/diff.save tests/diff + [ -d tests/output.save ] && mv tests/output.save tests/output + + ts_cd $olddir + ts_finalize_subtest +} + + +if [ -n "$wanted" ]; then + make_conf $wanted +else + for x in $config_gen_dir/config-gen.d/*.conf; do + make_conf "$x" + done +fi + +ts_finalize diff --git a/tests/ts/cal/bigyear b/tests/ts/cal/bigyear new file mode 100755 index 0000000..25c54f5 --- /dev/null +++ b/tests/ts/cal/bigyear @@ -0,0 +1,83 @@ +#!/bin/bash + +# 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="Year 2147483646" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_CAL" + +export TERM=linux + +USETERM=$( ts_has_option "useterm" "$*" ) +MYMONTH="12 2147483646" +MYYEAR="2147483646" + + +CAL_TEST_TIME=1516562739 # 21st January 2018 +export CAL_TEST_TIME + +function call_cal { + local testname=$(echo "$2" | sed 's/-//g') + + if [ "$3" == "$MYYEAR" ]; then + testname="${testname}-year" + else + testname="${testname}-month" + fi + + ts_init_subtest "$testname" + ts_log "$1" + shift + if [ "$USETERM" == "yes" ]; then + $TS_HELPER_CAL "$@" + fi + $TS_HELPER_CAL "$@" >> $TS_OUTPUT + ts_finalize_subtest +} + +call_cal "Gregorian - Monday-based month" -1m $MYMONTH +call_cal "Gregorian - Sunday-based month" -1s $MYMONTH +call_cal "Julian - Monday-based month" -1mj $MYMONTH +call_cal "Julian - Sunday-based month" -1sj $MYMONTH + +call_cal "Gregorian - Monday-based 3 months" -3m $MYMONTH +call_cal "Gregorian - Sunday-based 3 months" -3s $MYMONTH +call_cal "Julian - Monday-based 3 months" -3mj $MYMONTH +call_cal "Julian - Sunday-based 3 months" -3sj $MYMONTH + +call_cal "Gregorian - Monday-based year" -1m $MYYEAR +call_cal "Gregorian - Sunday-based year" -1s $MYYEAR +call_cal "Julian - Monday-based year" -1mj $MYYEAR +call_cal "Julian - Sunday-based year" -1sj $MYYEAR + + +call_cal "Gregorian - Monday-based month with weeks" -1mw $MYMONTH +call_cal "Gregorian - Sunday-based month with weeks" -1sw $MYMONTH +call_cal "Julian - Monday-based month with weeks" -1mjw $MYMONTH +call_cal "Julian - Sunday-based month with weeks" -1sjw $MYMONTH + +call_cal "Gregorian - Monday-based 3 months with weeks" -3mw $MYMONTH +call_cal "Gregorian - Sunday-based 3 months with weeks" -3sw $MYMONTH +call_cal "Julian - Monday-based 3 months with weeks" -3mjw $MYMONTH +call_cal "Julian - Sunday-based 3 months with weeks" -3sjw $MYMONTH + +call_cal "Gregorian - Monday-based year with weeks" -1mw $MYYEAR +call_cal "Gregorian - Sunday-based year with weeks" -1sw $MYYEAR +call_cal "Julian - Monday-based year with weeks" -1mjw $MYYEAR +call_cal "Julian - Sunday-based year with weeks" -1sjw $MYYEAR + +ts_finalize diff --git a/tests/ts/cal/color b/tests/ts/cal/color new file mode 100755 index 0000000..90840ea --- /dev/null +++ b/tests/ts/cal/color @@ -0,0 +1,95 @@ +#!/bin/bash + +# +# 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="color" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_CAL" +ts_inhibit_custom_colorscheme + +has_ncurses=$( ts_has_ncurses_support ) +if [ "$has_ncurses" != "yes" ]; then + ts_skip "without-ncurses" +fi + +# --color output depends on terminal type +export TERM=linux + +USETERM=$( ts_has_option "useterm" "$*" ) + +[ "$USETERM" == "yes" ] && TS_VERBOSE="yes" + +ts_init_subtest "first-day" +if [ "$USETERM" == "yes" ]; then + $TS_CMD_CAL --color=always 1 1 1 +fi +$TS_CMD_CAL --color=always 1 1 1 >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "reformation-corner-cases-1" +if [ "$USETERM" == "yes" ]; then + $TS_CMD_CAL --color=always 2 9 1752 +fi +$TS_CMD_CAL --color=always 2 9 1752 >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "reformation-corner-cases-2" +if [ "$USETERM" == "yes" ]; then + $TS_CMD_CAL --color=always 3 9 1752 +fi +$TS_CMD_CAL --color=always 3 9 1752 >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "reformation-corner-cases-3" +if [ "$USETERM" == "yes" ]; then + $TS_CMD_CAL --color=always 13 9 1752 +fi +$TS_CMD_CAL --color=always 13 9 1752 >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "reformation-corner-cases-4" +if [ "$USETERM" == "yes" ]; then + $TS_CMD_CAL --color=always 14 9 1752 +fi +$TS_CMD_CAL --color=always 14 9 1752 >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "last-day" +if [ "$USETERM" == "yes" ]; then + $TS_CMD_CAL --color=always 31 12 9999 +fi +$TS_CMD_CAL --color=always -3 31 12 9999 >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "vertical" +if [ "$USETERM" == "yes" ]; then + $TS_CMD_CAL --color=always 15 2 2023 +fi +$TS_CMD_CAL --color=always --vertical 15 2 2023 >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "vertical-week" +if [ "$USETERM" == "yes" ]; then + $TS_CMD_CAL --color=always 15 2 2023 +fi +$TS_CMD_CAL --color=always --vertical --week=15 15 2 2023 >> $TS_OUTPUT +ts_finalize_subtest + + +ts_finalize diff --git a/tests/ts/cal/colorw b/tests/ts/cal/colorw new file mode 100755 index 0000000..96e6e0a --- /dev/null +++ b/tests/ts/cal/colorw @@ -0,0 +1,80 @@ +#!/bin/bash + +# +# 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="color with week numbers" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_CAL" +ts_inhibit_custom_colorscheme + +has_ncurses=$( ts_has_ncurses_support ) +if [ "$has_ncurses" != "yes" ]; then + ts_skip "without-ncurses" +fi + +# --color output depends on terminal type +export TERM=linux + +USETERM=$( ts_has_option "useterm" "$*" ) + +[ "$USETERM" == "yes" ] && TS_VERBOSE="yes" + +ts_init_subtest "first-day-week-numbers" +if [ "$USETERM" == "yes" ]; then + $TS_CMD_CAL -w --color=always 1 1 1 +fi +$TS_CMD_CAL -w --color=always 1 1 1 >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "reformation-corner-cases-1-week-numbers" +if [ "$USETERM" == "yes" ]; then + $TS_CMD_CAL -w --color=always 2 9 1752 +fi +$TS_CMD_CAL -w --color=always 2 9 1752 >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "reformation-corner-cases-2-week-numbers" +if [ "$USETERM" == "yes" ]; then + $TS_CMD_CAL -w --color=always 3 9 1752 +fi +$TS_CMD_CAL -w --color=always 3 9 1752 >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "reformation-corner-cases-3-week-numbers" +if [ "$USETERM" == "yes" ]; then + $TS_CMD_CAL -w --color=always 13 9 1752 +fi +$TS_CMD_CAL -w --color=always 13 9 1752 >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "reformation-corner-cases-4-week-numbers" +if [ "$USETERM" == "yes" ]; then + $TS_CMD_CAL -w --color=always 14 9 1752 +fi +$TS_CMD_CAL -w --color=always 14 9 1752 >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "last-day-week-numbers" +if [ "$USETERM" == "yes" ]; then + $TS_CMD_CAL -w --color=always 31 12 9999 +fi +$TS_CMD_CAL -w --color=always -3 31 12 9999 >> $TS_OUTPUT +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/cal/column b/tests/ts/cal/column new file mode 100755 index 0000000..ce336ca --- /dev/null +++ b/tests/ts/cal/column @@ -0,0 +1,49 @@ +#!/bin/bash + +# +# Copyright (C) 2007-2018 Karel Zak +# Copyright (C) 2023 Thomas Weißschuh +# +# 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="year" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_CAL" + +export TERM=linux + +USETERM=$( ts_has_option "useterm" "$*" ) +MYTIME="29 11 2006" + +function call_cal { + + ts_init_subtest "$(echo "$1" | cut -d ' ' -f 1)" + ts_log "$1" + shift + if [ "$USETERM" == "yes" ]; then + $TS_CMD_CAL "$@" + fi + $TS_CMD_CAL "$@" >> $TS_OUTPUT + ts_finalize_subtest +} + +call_cal "6 columns" --year --columns 6 $MYTIME +call_cal "5 columns" --year --columns 5 $MYTIME +call_cal "auto columns" --year --columns auto $MYTIME + +ts_finalize + diff --git a/tests/ts/cal/jan1753 b/tests/ts/cal/jan1753 new file mode 100755 index 0000000..5366e68 --- /dev/null +++ b/tests/ts/cal/jan1753 @@ -0,0 +1,45 @@ +#!/bin/bash + +# 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="January 1753" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_CAL" + +export TERM=linux + +USETERM=$( ts_has_option "useterm" "$*" ) +MYMONTH="1 1753" + +function call_cal { + local testname=$(echo "$2" | sed 's/-//g') + + ts_init_subtest "$testname" + ts_log "$1" + shift + if [ "$USETERM" == "yes" ]; then + $TS_CMD_CAL "$@" + fi + $TS_CMD_CAL "$@" >> $TS_OUTPUT + + ts_finalize_subtest +} + +call_cal "Monday-based 1753 week numbers" -m3w $MYMONTH +call_cal "Sunday-based 1753 week numbers" -3w $MYMONTH + +ts_finalize diff --git a/tests/ts/cal/month b/tests/ts/cal/month new file mode 100755 index 0000000..96ab113 --- /dev/null +++ b/tests/ts/cal/month @@ -0,0 +1,72 @@ +#!/bin/bash + +# +# Copyright (C) 2007-2018 Karel Zak +# +# 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="month" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_CAL" + +export TERM=linux + +USETERM=$( ts_has_option "useterm" "$*" ) +MYTIME="27 09 2006" + +CAL_TEST_TIME=1516562739 # 21st January 2018 +export CAL_TEST_TIME + +function call_cal { + local testname=$(echo "$2" | sed 's/-//g; s/ //g') + + ts_init_subtest "$testname" + ts_log "$1" + shift + if [ "$USETERM" == "yes" ]; then + $TS_HELPER_CAL "$@" + fi + $TS_HELPER_CAL "$@" >> $TS_OUTPUT + + ts_finalize_subtest +} + +call_cal "Gregorian - Monday-based week" -1m $MYTIME +call_cal "Gregorian - Sunday-based week" -1s $MYTIME +call_cal "Julian - Monday-based week" -1mj $MYTIME +call_cal "Julian - Sunday-based week" -1sj $MYTIME +call_cal "Gregorian - Monday-based week with week numbers" -1mw $MYTIME +call_cal "Gregorian - Sunday-based week with week numbers" -1sw $MYTIME +call_cal "Julian - Monday-based week with week numbers" -1mjw $MYTIME +call_cal "Julian - Sunday-based week with week numbers" -1sjw $MYTIME +call_cal "Gregorian - Monday-based week" -3m $MYTIME +call_cal "Gregorian - Sunday-based week" -3s $MYTIME +call_cal "Julian - Monday-based week" -3mj $MYTIMET +call_cal "Julian - Sunday-based week" -3sj $MYTIME +call_cal "Gregorian - Monday-based week with week numbers" -3mw $MYTIME +call_cal "Gregorian - Sunday-based week with week numbers" -3sw $MYTIME +call_cal "Julian - Monday-based week with week numbers" -3mjw $MYTIME +call_cal "Julian - Sunday-based week with week numbers" -3sjw $MYTIME + +call_cal "Normal span" "-Sn 3" $MYTIME +call_cal "Large span" "-Sn 21" $MYTIME +call_cal "Very Large span" "-Sn 51" $MYTIME +call_cal "Extreme span" "-Sn 201" $MYTIME + +ts_finalize + diff --git a/tests/ts/cal/sep1752 b/tests/ts/cal/sep1752 new file mode 100755 index 0000000..0fe1ffd --- /dev/null +++ b/tests/ts/cal/sep1752 @@ -0,0 +1,86 @@ +#!/bin/bash + +# 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="September 1752" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_CAL" + +export TERM=linux + +USETERM=$( ts_has_option "useterm" "$*" ) +MYMONTH="09 1752" +MYYEAR="1752" + +CAL_TEST_TIME=1516562739 # 21st January 2018 +export CAL_TEST_TIME + +function call_cal_simple { + ts_log "$1" + shift + if [ "$USETERM" == "yes" ]; then + $TS_HELPER_CAL "$@" + fi + $TS_HELPER_CAL "$@" >> $TS_OUTPUT +} + +function call_cal { + local testname=$(echo "$2" | sed 's/-//g') + + if [ "$3" == "$MYYEAR" ]; then + testname="${testname}-year" + else + testname="${testname}-month" + fi + + ts_init_subtest "$testname" + call_cal_simple "$@" + ts_finalize_subtest +} + + +call_cal "Gregorian - Monday-based month with week numbers" -1mw $MYMONTH +call_cal "Gregorian - Sunday-based month with week numbers" -1sw $MYMONTH +call_cal "Julian - Monday-based month with week numbers" -1mjw $MYMONTH +call_cal "Julian - Sunday-based month with week numbers" -1sjw $MYMONTH +call_cal "Gregorian - Monday-based three months with week numbers" -3mw $MYMONTH +call_cal "Gregorian - Sunday-based three months with week numbers" -3sw $MYMONTH +call_cal "Julian - Monday-based three months with week numbers" -3mjw $MYMONTH +call_cal "Julian - Sunday-based three months with week numbers" -3sjw $MYMONTH +call_cal "Gregorian - Monday-based year with week numbers" -1mw $MYYEAR +call_cal "Gregorian - Sunday-based year with week numbers" -1sw $MYYEAR +call_cal "Julian - Monday-based year with week numbers" -1mjw $MYYEAR +call_cal "Julian - Sunday-based year with week numbers" -1sjw $MYYEAR + +ts_init_subtest "week-iso" +call_cal_simple "Gregorian - address by week number" --week=40 --iso $MYYEAR +ts_finalize_subtest + +call_cal "Gregorian - Monday-based month" -1m $MYMONTH +call_cal "Gregorian - Sunday-based month" -1s $MYMONTH +call_cal "Julian - Monday-based month" -1mj $MYMONTH +call_cal "Julian - Sunday-based month" -1sj $MYMONTH +call_cal "Gregorian - Monday-based three months" -3m $MYMONTH +call_cal "Gregorian - Sunday-based three months" -3s $MYMONTH +call_cal "Julian - Monday-based three months" -3mj $MYMONTH +call_cal "Julian - Sunday-based three months" -3sj $MYMONTH +call_cal "Gregorian - Monday-based year" -1m $MYYEAR +call_cal "Gregorian - Sunday-based year" -1s $MYYEAR +call_cal "Julian - Monday-based year" -1mj $MYYEAR +call_cal "Julian - Sunday-based year" -1sj $MYYEAR + +ts_finalize diff --git a/tests/ts/cal/vertical b/tests/ts/cal/vertical new file mode 100755 index 0000000..fe0b904 --- /dev/null +++ b/tests/ts/cal/vertical @@ -0,0 +1,72 @@ +#!/bin/bash + +# +# Copyright (C) 2007-2018 Karel Zak +# +# 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="vertical" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_CAL" + +export TERM=linux + +USETERM=$( ts_has_option "useterm" "$*" ) +MYTIME="27 09 2006" + +CAL_TEST_TIME=1516562739 # 21st January 2018 +export CAL_TEST_TIME + +function call_cal { + local testname=$(echo "$2" | sed 's/-//g; s/ //g') + + ts_init_subtest "$testname" + ts_log "$1" + shift + if [ "$USETERM" == "yes" ]; then + $TS_HELPER_CAL "$@" + fi + $TS_HELPER_CAL "$@" >> $TS_OUTPUT + + ts_finalize_subtest +} + +call_cal "Gregorian - Monday-based week" -1mv $MYTIME +call_cal "Gregorian - Sunday-based week" -1sv $MYTIME +call_cal "Julian - Monday-based week" -1mjv $MYTIME +call_cal "Julian - Sunday-based week" -1sjv $MYTIME +call_cal "Gregorian - Monday-based week with week numbers" -1mwv $MYTIME +call_cal "Gregorian - Sunday-based week with week numbers" -1swv $MYTIME +call_cal "Julian - Monday-based week with week numbers" -1mjwv $MYTIME +call_cal "Julian - Sunday-based week with week numbers" -1sjwv $MYTIME +call_cal "Gregorian - Monday-based week" -3mv $MYTIME +call_cal "Gregorian - Sunday-based week" -3sv $MYTIME +call_cal "Julian - Monday-based week" -3mjv $MYTIMET +call_cal "Julian - Sunday-based week" -3sjv $MYTIME +call_cal "Gregorian - Monday-based week with week numbers" -3mwv $MYTIME +call_cal "Gregorian - Sunday-based week with week numbers" -3swv $MYTIME +call_cal "Julian - Monday-based week with week numbers" -3mjwv $MYTIME +call_cal "Julian - Sunday-based week with week numbers" -3sjwv $MYTIME + +call_cal "Normal span" "-vSn 3" $MYTIME +call_cal "Large span" "-vSn 21" $MYTIME +call_cal "Very Large span" "-vSn 51" $MYTIME +call_cal "Extreme span" "-vSn 201" $MYTIME + +ts_finalize + diff --git a/tests/ts/cal/weekarg b/tests/ts/cal/weekarg new file mode 100755 index 0000000..477cbd5 --- /dev/null +++ b/tests/ts/cal/weekarg @@ -0,0 +1,99 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="week number given as argument" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_CAL" +ts_inhibit_custom_colorscheme + +has_ncurses=$( ts_has_ncurses_support ) +if [ "$has_ncurses" != "yes" ]; then + ts_skip "without-ncurses" +fi + +export TERM=linux + +USETERM=$( ts_has_option "useterm" "$*" ) + +function call_cal_simple { + ts_log "$1" + shift + if [ "$USETERM" == "yes" ]; then + $TS_CMD_CAL "$@" + fi + $TS_CMD_CAL "$@" >> $TS_OUTPUT +} + +function call_cal { + local testname=$(echo "${2}" | sed 's/-//g') + testname="${testname}-$(echo "${3}" | sed 's/=//g;s/-//g')" + + ts_init_subtest "$testname" + call_cal_simple "$@" + ts_finalize_subtest +} + +function call_cal_color { + local testname=$(echo "${2}" | sed 's/-//g') + testname="${testname}-$(echo "${3}" | sed 's/=//g;s/-//g')-color" + + ts_init_subtest "$testname" + call_cal_simple "$@" --color=always + ts_finalize_subtest +} + +MYTIME="7 10 2013" +PWEEK="week 40" +WEEK="--week=40" +call_cal "Gregorian - Monday-based, $PWEEK, 3 month" -3m $WEEK $MYTIME +call_cal "Gregorian - Sunday-based, $PWEEK, 3 month" -3s $WEEK $MYTIME +call_cal "Julian - Monday-based, $PWEEK, 3 month" -3mj $WEEK $MYTIME +call_cal "Julian - Sunday-based, $PWEEK, 3 month" -3sj $WEEK $MYTIME +call_cal "Gregorian - Monday-based, $PWEEK, 1 month" -m $WEEK $MYTIME +call_cal "Gregorian - Sunday-based, $PWEEK, 1 month" -s $WEEK $MYTIME +call_cal "Julian - Monday-based, $PWEEK, 1 month" -mj $WEEK $MYTIME +call_cal "Julian - Sunday-based, $PWEEK, 1 month" -sj $WEEK $MYTIME + +call_cal_color "Gregorian - Monday-based, $PWEEK, 3 month" -3m $WEEK $MYTIME +call_cal_color "Julian - Monday-based, $PWEEK, 3 month" -3mj $WEEK $MYTIME + +# tricky year, starts with a bit of 53 yet ends during 52 +MYTIME="2010" +PWEEK="week 53" +WEEK="--week=53" +call_cal "Gregorian - Monday-based, $PWEEK, 1 month" -1m $WEEK $MYTIME +call_cal "Julian - Monday-based, $PWEEK, 1 month" -1mj $WEEK $MYTIME +call_cal_color "Gregorian - Monday-based, $PWEEK, 3 month" -3m $WEEK $MYTIME +call_cal_color "Gregorian - Monday-based, $PWEEK, 1 month" -1m $WEEK $MYTIME +call_cal_color "Julian - Monday-based, $PWEEK, 1 month" -1mj $WEEK $MYTIME + +MYTIME="31 12 2000" +PWEEK="week 54" +WEEK="--week=54" +call_cal_color "Gregorian - Sunday-based, $PWEEK, 3 month" -3s $WEEK $MYTIME + +MYTIME="31 12 2000" +PWEEK="week 52" +WEEK="--week=52" +call_cal_color "Gregorian - Monday-based, $PWEEK, 3 month" -3m $WEEK $MYTIME + +ts_finalize + diff --git a/tests/ts/cal/weeknum b/tests/ts/cal/weeknum new file mode 100755 index 0000000..444c50b --- /dev/null +++ b/tests/ts/cal/weeknum @@ -0,0 +1,57 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="week number corner cases" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_CAL" + +export TERM=linux + +USETERM=$( ts_has_option "useterm" "$*" ) + +[ "$USETERM" == "yes" ] && TS_VERBOSE="yes" + +function call_cal { + local testname=$(echo "$2" | sed 's/-//g') + + ts_init_subtest "$testname" + ts_log "$1" + shift + for x in 2001 2002 2003 2009 2010 2011 2012 ; do + if [ "$USETERM" == "yes" ]; then + $TS_CMD_CAL "$@" 1 $x + fi + $TS_CMD_CAL "$@" 1 $x >> $TS_OUTPUT + done + ts_finalize_subtest +} + +call_cal "Gregorian - Monday-based week with week numbers" -ymw +call_cal "Gregorian - Sunday-based week with week numbers" -ysw +call_cal "Julian - Monday-based week with week numbers" -ymjw +call_cal "Julian - Sunday-based week with week numbers" -ysjw +call_cal "Gregorian - Monday-based week with week number" -3mw +call_cal "Gregorian - Sunday-based week with week numbers - 3 month" -3sw +call_cal "Julian - Monday-based week with week numbers - 3 month" -3mjw +call_cal "Julian - Sunday-based week with week numbers - 3 month" -3sjw + +ts_finalize + diff --git a/tests/ts/cal/year b/tests/ts/cal/year new file mode 100755 index 0000000..6bd958a --- /dev/null +++ b/tests/ts/cal/year @@ -0,0 +1,54 @@ +#!/bin/bash + +# +# Copyright (C) 2007-2018 Karel Zak +# +# 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="year" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_CAL" + +export TERM=linux + +USETERM=$( ts_has_option "useterm" "$*" ) +MYTIME="29 11 2006" + +function call_cal { + local testname=$(echo "$2" | sed 's/-//g') + + ts_init_subtest "$testname" + ts_log "$1" + shift + if [ "$USETERM" == "yes" ]; then + $TS_CMD_CAL "$@" + fi + $TS_CMD_CAL "$@" >> $TS_OUTPUT + ts_finalize_subtest +} + +call_cal "Gregorian - Monday-based week" -ym $MYTIME +call_cal "Gregorian - Sunday-based week" -ys $MYTIME +call_cal "Julian - Monday-based week" -ymj $MYTIME +call_cal "Julian - Sunday-based week" -ysj $MYTIME +call_cal "Gregorian - Monday-based week with week numbers" -ymw $MYTIME +call_cal "Gregorian - Sunday-based week with week numbers" -ysw $MYTIME +call_cal "Julian - Monday-based week with week numbers" -ymjw $MYTIME +call_cal "Julian - Sunday-based week with week numbers" -ysjw $MYTIME + +ts_finalize + diff --git a/tests/ts/chfn/gecos b/tests/ts/chfn/gecos new file mode 100755 index 0000000..f7a0bdb --- /dev/null +++ b/tests/ts/chfn/gecos @@ -0,0 +1,38 @@ +#!/bin/bash + +# +# Copyright (C) 2019 Radka Skvarilova +# +# 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="gecos" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +export LIBUSER_CONF=/dev/null + +ts_skip_nonroot +ts_check_test_command "$TS_CMD_CHFN" +ts_check_prog "useradd" +ts_check_prog "userdel" + +ts_log "Initialize user" +useradd -u 9899 --shell /bin/bash testuser_chfn_test +grep testuser /etc/passwd >> $TS_OUTPUT +$TS_CMD_CHFN -f test_gecos testuser_chfn_test >>$TS_OUTPUT +grep testuser /etc/passwd >> $TS_OUTPUT +userdel --remove testuser_chfn_test &> /dev/null +ts_finalize diff --git a/tests/ts/col/io b/tests/ts/col/io new file mode 100755 index 0000000..9766683 --- /dev/null +++ b/tests/ts/col/io @@ -0,0 +1,86 @@ +#!/bin/bash + +# +# Copyright (C) 2020 Sami Kerola +# +# 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="io effects" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_COL" + +ts_init_subtest "trailing-spaces" +printf "1 \t\n2\n" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>&1 +ts_finalize_subtest + +ts_init_subtest "tab-backspace" +printf "1\t\x082\n" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>&1 +ts_finalize_subtest + +ts_init_subtest "various-spaces" +printf "1 \t\f2\n" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>&1 +ts_finalize_subtest + +ts_init_subtest "cr" +printf "1\r2\n" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>&1 +ts_finalize_subtest + +ts_init_subtest "vt1" +printf "1\n23\v\n4\n5\n" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>&1 +ts_finalize_subtest + +ts_init_subtest "vt2" +printf "a\v\vb\v\vc" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>&1 +ts_finalize_subtest + +ts_init_subtest "reverse-lf" +printf "1\n2\e\x073\n" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>&1 +ts_finalize_subtest + +ts_init_subtest "so-si" +printf "\x0e\x0f" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>&1 +ts_finalize_subtest + +ts_init_subtest "esc-tab" +printf "\e\t\b1\n" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>&1 +ts_finalize_subtest + +ts_init_subtest "esc-backspace" +printf "1\e\b2\n" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>&1 +ts_finalize_subtest + +ts_init_subtest "cs-normal" +printf "> $TS_OUTPUT 2>&1 +ts_finalize_subtest + +ts_init_subtest "cs-alternate" +printf "1\t\x0E2\n" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>&1 +ts_finalize_subtest + +ts_init_subtest "allocate-here" +printf "1\t\v2\t\n3" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>&1 +ts_finalize_subtest + +ts_init_subtest "half-line" +printf "\e\t\b1\n" | ts_run $TS_CMD_COL --fine >> $TS_OUTPUT 2>&1 +ts_finalize_subtest + +ts_init_subtest "flushing" +seq 1 199 | ts_run $TS_CMD_COL --lines 8 >> $TS_OUTPUT 2>&1 +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/col/multibyte b/tests/ts/col/multibyte new file mode 100755 index 0000000..fa14a0a --- /dev/null +++ b/tests/ts/col/multibyte @@ -0,0 +1,40 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="multibyte input" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_COL" +ts_check_test_command "$TS_HELPER_STRERROR" + +ts_init_subtest "valid" +cat $TS_SELF/multibyte.data | + LC_ALL=C ts_run $TS_CMD_COL 2>&1 | + sed -e "s@$($TS_HELPER_STRERROR EILSEQ)@EILSEQ@" > $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "invalid" +printf '%s\n' $'abc\200\200jkl' | + LC_ALL=C ts_run $TS_CMD_COL 2>&1 | + sed -e "s@$($TS_HELPER_STRERROR EILSEQ)@EILSEQ@" > $TS_OUTPUT +ts_finalize_subtest + + +ts_finalize diff --git a/tests/ts/col/multibyte.data b/tests/ts/col/multibyte.data new file mode 100644 index 0000000..b203afd --- /dev/null +++ b/tests/ts/col/multibyte.data @@ -0,0 +1 @@ +Dateiname der Versandhülle diff --git a/tests/ts/col/newlines b/tests/ts/col/newlines new file mode 100755 index 0000000..8a6d904 --- /dev/null +++ b/tests/ts/col/newlines @@ -0,0 +1,46 @@ +#!/bin/bash + +# +# Copyright (C) 2020 Sami Kerola +# +# 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="newline handling" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_COL" + +ts_init_subtest "zero-length-file" +printf "" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "one-line-no-nl" +printf "1" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "one-line-with-nl" +printf "1\n" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "second-line-no-nl" +printf "1\n2" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "second-line-with-nl" +printf "1\n2\n" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/col/options b/tests/ts/col/options new file mode 100755 index 0000000..6df11ae --- /dev/null +++ b/tests/ts/col/options @@ -0,0 +1,43 @@ +#!/bin/bash + +# +# Copyright (C) 2020 Sami Kerola +# +# 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="options" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_COL" + +ts_init_subtest "no-backspaces" +printf "FIXME" | ts_run $TS_CMD_COL --no-backspaces >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "pass" +printf "a\x11b" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>> $TS_ERRLOG +printf "a\x11b" | ts_run $TS_CMD_COL --pass >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "tabs" +printf " 1\n" | ts_run $TS_CMD_COL --tabs >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "spaces" +printf "\t1\n" | ts_run $TS_CMD_COL --spaces >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/colcrt/crash1 b/tests/ts/colcrt/crash1 new file mode 100644 index 0000000..6681181 Binary files /dev/null and b/tests/ts/colcrt/crash1 differ diff --git a/tests/ts/colcrt/crash2 b/tests/ts/colcrt/crash2 new file mode 100644 index 0000000..0843cb6 Binary files /dev/null and b/tests/ts/colcrt/crash2 differ diff --git a/tests/ts/colcrt/functional b/tests/ts/colcrt/functional new file mode 100755 index 0000000..26014b8 --- /dev/null +++ b/tests/ts/colcrt/functional @@ -0,0 +1,51 @@ +#!/bin/bash + +# +# 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="functional" + +export LC_CTYPE='C' + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" +ts_check_wcsspn + +ts_check_test_command "$TS_CMD_COLCRT" + +ts_init_subtest 'no-options' +$TS_CMD_COLCRT < $TS_SELF/nasty-input >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_COLCRT < $TS_SELF/underlines >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "return value: $?" >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest 'no-underlining' +$TS_CMD_COLCRT --no-underlining < $TS_SELF/nasty-input >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_COLCRT --no-underlining < $TS_SELF/underlines >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "return value: $?" >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest 'half-lines' +$TS_CMD_COLCRT --half-lines < $TS_SELF/nasty-input >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_COLCRT --half-lines < $TS_SELF/underlines >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "return value: $?" >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest 'short-options' +$TS_CMD_COLCRT - -2 $TS_SELF/nasty-input >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_COLCRT - -2 $TS_SELF/underlines >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "return value: $?" >> $TS_OUTPUT +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/colcrt/hang1 b/tests/ts/colcrt/hang1 new file mode 100644 index 0000000..d26259e --- /dev/null +++ b/tests/ts/colcrt/hang1 @@ -0,0 +1 @@ +789:;<=>=>?IABUVNXYZ[_`abcdefgg !"#$%&'()*+,-./01234)*:,-./0123456789:;[=>?1234)*:,-./0123456789:;[=>?4456789:;<=>?IABUVN`abcdefg !" $%&'()*+,-./0123z{|ü~e \ No newline at end of file diff --git a/tests/ts/colcrt/nasty-input b/tests/ts/colcrt/nasty-input new file mode 100644 index 0000000..5e541bc Binary files /dev/null and b/tests/ts/colcrt/nasty-input differ diff --git a/tests/ts/colcrt/regressions b/tests/ts/colcrt/regressions new file mode 100755 index 0000000..7bbba65 --- /dev/null +++ b/tests/ts/colcrt/regressions @@ -0,0 +1,38 @@ +#!/bin/bash + +# +# 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="regressions" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" +ts_check_wcsspn + +ts_check_test_command "$TS_CMD_COLCRT" +ts_check_prog "timeout" +ts_check_prog "env" + +check_input_file() { + ts_init_subtest ${1##*/} + timeout 2 env LC_ALL=C.UTF-8 $TS_CMD_COLCRT < $1 >> $TS_OUTPUT 2>> $TS_ERRLOG + echo "return value: $?" >> $TS_OUTPUT + ts_finalize_subtest +} + +check_input_file "$TS_SELF/crash1" +check_input_file "$TS_SELF/crash2" +check_input_file "$TS_SELF/hang1" + +ts_finalize diff --git a/tests/ts/colcrt/underlines b/tests/ts/colcrt/underlines new file mode 100644 index 0000000..940c7a8 --- /dev/null +++ b/tests/ts/colcrt/underlines @@ -0,0 +1,23 @@ + 200 ___ + 201 abc + 202 _abc + 203 a_bc + 204 ab_c + 205 abc_ + 206 __abc + 207 a__bc + 208 ab__c + 209 abc__ + 210 _a_bc + 211 _ab_c + 212 a_b_c + 213 a__bc + 214 a_bc_ + 215 abc__ + 216 _abc_ + 217 _a_b_c + 218 _a__bc + 219 a__bc_ + 220 _abc__ + 221 ___abc + 222 abc___ diff --git a/tests/ts/colrm/rm2-2 b/tests/ts/colrm/rm2-2 new file mode 100755 index 0000000..ed6e962 --- /dev/null +++ b/tests/ts/colrm/rm2-2 @@ -0,0 +1,28 @@ +#!/bin/bash + +# +# Copyright (C) 2011 Sami Kerola +# +# 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="basic check" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_COLRM" + +printf "a b\nc\td\nef\b\tg\n" | $TS_CMD_COLRM 2 2 >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_finalize diff --git a/tests/ts/column/columnate b/tests/ts/column/columnate new file mode 100755 index 0000000..9bd53a7 --- /dev/null +++ b/tests/ts/column/columnate @@ -0,0 +1,52 @@ +#!/bin/bash + +# +# Copyright (C) 2011 Sami Kerola +# +# 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="columnate" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_COLUMN" +ts_cd "$TS_OUTDIR" + + +ts_init_subtest "fill-cols-80" +$TS_CMD_COLUMN -c 80 $TS_SELF/files/onecolumn >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "fill-cols-50" +$TS_CMD_COLUMN -c 50 $TS_SELF/files/onecolumn >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "fill-cols-250" +$TS_CMD_COLUMN -c 250 $TS_SELF/files/onecolumn >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "fill-rows-80" +$TS_CMD_COLUMN --fillrows -c 80 $TS_SELF/files/onecolumn >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "fill-rows-50" +$TS_CMD_COLUMN --fillrows -c 50 $TS_SELF/files/onecolumn >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "fill-rows-250" +$TS_CMD_COLUMN --fillrows -c 250 $TS_SELF/files/onecolumn >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/column/files/fivecols b/tests/ts/column/files/fivecols new file mode 100644 index 0000000..d3ea4a8 --- /dev/null +++ b/tests/ts/column/files/fivecols @@ -0,0 +1,10 @@ +0 1 2 3 4 5 +0 1 2 3 4 5 +0 1 2 3 4 5 +0 1 2 3 4 5 +0 1 2 3 4 5 +0 1 2 3 4 5 +0 1 2 3 4 5 +0 1 2 3 4 5 +0 1 2 3 4 5 +0 1 2 3 4 5 diff --git a/tests/ts/column/files/mountinfo b/tests/ts/column/files/mountinfo new file mode 100644 index 0000000..b751e16 --- /dev/null +++ b/tests/ts/column/files/mountinfo @@ -0,0 +1,41 @@ +17 62 0:17 / /sys rw,nosuid,nodev,noexec,relatime shared:6 - sysfs sysfs rw +18 62 0:4 / /proc rw,nosuid,nodev,noexec,relatime shared:5 - proc proc rw +19 62 0:6 / /dev rw,nosuid shared:2 - devtmpfs devtmpfs rw,size=8175740k,nr_inodes=2043935,mode=755 +20 17 0:18 / /sys/kernel/security rw,nosuid,nodev,noexec,relatime shared:7 - securityfs securityfs rw +21 19 0:19 / /dev/shm rw,nosuid,nodev shared:3 - tmpfs tmpfs rw +22 19 0:20 / /dev/pts rw,nosuid,noexec,relatime shared:4 - devpts devpts rw,gid=5,mode=620,ptmxmode=000 +23 62 0:21 / /run rw,nosuid,nodev shared:23 - tmpfs tmpfs rw,mode=755 +24 17 0:22 / /sys/fs/cgroup ro,nosuid,nodev,noexec shared:8 - tmpfs tmpfs ro,mode=755 +25 24 0:23 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime shared:9 - cgroup cgroup rw,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd +26 17 0:24 / /sys/fs/pstore rw,nosuid,nodev,noexec,relatime shared:20 - pstore pstore rw +27 17 0:25 / /sys/firmware/efi/efivars rw,nosuid,nodev,noexec,relatime shared:21 - efivarfs efivarfs rw +28 24 0:26 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime shared:10 - cgroup cgroup rw,blkio +29 24 0:27 / /sys/fs/cgroup/cpu,cpuacct rw,nosuid,nodev,noexec,relatime shared:11 - cgroup cgroup rw,cpu,cpuacct +30 24 0:28 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime shared:12 - cgroup cgroup rw,devices +31 24 0:29 / /sys/fs/cgroup/hugetlb rw,nosuid,nodev,noexec,relatime shared:13 - cgroup cgroup rw,hugetlb +32 24 0:30 / /sys/fs/cgroup/pids rw,nosuid,nodev,noexec,relatime shared:14 - cgroup cgroup rw,pids +33 24 0:31 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime shared:15 - cgroup cgroup rw,memory +34 24 0:32 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime shared:16 - cgroup cgroup rw,cpuset +35 24 0:33 / /sys/fs/cgroup/perf_event rw,nosuid,nodev,noexec,relatime shared:17 - cgroup cgroup rw,perf_event +36 24 0:34 / /sys/fs/cgroup/net_cls,net_prio rw,nosuid,nodev,noexec,relatime shared:18 - cgroup cgroup rw,net_cls,net_prio +37 24 0:35 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime shared:19 - cgroup cgroup rw,freezer +60 17 0:36 / /sys/kernel/config rw,relatime shared:22 - configfs configfs rw +62 0 8:4 / / rw,relatime shared:1 - ext4 /dev/sda4 rw,data=ordered +38 18 0:37 / /proc/sys/fs/binfmt_misc rw,relatime shared:24 - autofs systemd-1 rw,fd=37,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=12781 +39 17 0:7 / /sys/kernel/debug rw,relatime shared:25 - debugfs debugfs rw +40 19 0:38 / /dev/hugepages rw,relatime shared:26 - hugetlbfs hugetlbfs rw +41 19 0:16 / /dev/mqueue rw,relatime shared:27 - mqueue mqueue rw +42 38 0:39 / /proc/sys/fs/binfmt_misc rw,relatime shared:28 - binfmt_misc binfmt_misc rw +75 18 0:40 / /proc/fs/nfsd rw,relatime shared:29 - nfsd nfsd rw +77 62 0:41 / /tmp rw,nosuid,nodev shared:30 - tmpfs tmpfs rw +80 62 8:3 / /home rw,relatime shared:31 - ext4 /dev/sda3 rw,data=ordered +81 62 8:2 / /boot rw,relatime shared:32 - ext4 /dev/sda2 rw,data=ordered +84 80 8:5 / /home/games rw,relatime shared:33 - ext4 /dev/sda5 rw,data=ordered +86 81 8:1 / /boot/efi rw,relatime shared:34 - vfat /dev/sda1 rw,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=winnt,errors=remount-ro +88 80 8:17 / /home/archive rw,relatime shared:35 - ext4 /dev/sdb1 rw,data=ordered +90 62 0:43 / /var/lib/nfs/rpc_pipefs rw,relatime shared:36 - rpc_pipefs sunrpc rw +223 17 0:47 / /sys/fs/fuse/connections rw,relatime shared:163 - fusectl fusectl rw +217 23 0:46 / /run/user/1000 rw,nosuid,nodev,relatime shared:158 - tmpfs tmpfs rw,size=1637324k,mode=700,uid=1000,gid=1000 +203 217 0:45 / /run/user/1000/gvfs rw,nosuid,nodev,relatime shared:153 - fuse.gvfsd-fuse gvfsd-fuse rw,user_id=1000,group_id=1000 +171 23 0:44 / /run/user/0 rw,nosuid,nodev,relatime shared:114 - tmpfs tmpfs rw,size=1637324k,mode=700 +177 62 0:48 / /mnt/sounds rw,relatime shared:119 - cifs //sr.net.home/sounds rw,vers=1.0,cache=strict,username=kzak,domain=SRGROUP,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.111.1,unix,posixpaths,serverino,mapposix,acl,rsize=1048576,wsize=65536,echo_interval=60,actimeo=1 diff --git a/tests/ts/column/files/onecolumn b/tests/ts/column/files/onecolumn new file mode 100644 index 0000000..69ec82f --- /dev/null +++ b/tests/ts/column/files/onecolumn @@ -0,0 +1,9 @@ +AAAAAAAAAAAAAAAAAAAA +BBBBBBBBBBBBBBBBBBBBB +CCCCCCCCCCCCCCCC +DDDDDDDDDDDDDDDDD +EEEEEEEEEEEEE +FFFFFFFFFFFFFFFFFFF +XXXXXXX +YYYYYYYYYYY +ZZZZZZZZZZZ diff --git a/tests/ts/column/files/table b/tests/ts/column/files/table new file mode 100644 index 0000000..e051631 --- /dev/null +++ b/tests/ts/column/files/table @@ -0,0 +1,6 @@ +AAA BBBB C DDDD +A BBB CCCC DDD +AA BB CCC DD +AAAA B CC D +AA BB CC DD +AAAAA BBB CCC DDDD diff --git a/tests/ts/column/files/table-empty-lines b/tests/ts/column/files/table-empty-lines new file mode 100644 index 0000000..9429b4d --- /dev/null +++ b/tests/ts/column/files/table-empty-lines @@ -0,0 +1,6 @@ + +A B CCC +AA BBB AA +AAA BB C + +AAAA BBBB CCCC diff --git a/tests/ts/column/files/table-sep b/tests/ts/column/files/table-sep new file mode 100644 index 0000000..d4c2bf3 --- /dev/null +++ b/tests/ts/column/files/table-sep @@ -0,0 +1,6 @@ +AAA,BBBB,C,DDDD +,BBB,CCCC,DDD +AA,BB,,DD +AAAA,B,CC,D +AA,,CC,DD +AAAAA,BBB,CCC,DDDD diff --git a/tests/ts/column/files/table-sep-space b/tests/ts/column/files/table-sep-space new file mode 100644 index 0000000..25d9b5a --- /dev/null +++ b/tests/ts/column/files/table-sep-space @@ -0,0 +1,6 @@ +AAA BBBB C DDDD + BBB CCCC DDD +AA BB DD +AAAA B CC D +AA CC DD +AAAAA BBB CCC DDDD diff --git a/tests/ts/column/invalid-multibyte b/tests/ts/column/invalid-multibyte new file mode 100755 index 0000000..32cc3f3 --- /dev/null +++ b/tests/ts/column/invalid-multibyte @@ -0,0 +1,30 @@ +#!/bin/bash + +# +# Copyright (C) 2014 Sami Kerola +# +# 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="invalid multibyte" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_COLUMN" + +ts_cd "$TS_OUTDIR" + +printf "\x94\x7e\n" | LC_ALL=C.UTF-8 $TS_CMD_COLUMN >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_finalize diff --git a/tests/ts/column/multi-file b/tests/ts/column/multi-file new file mode 100755 index 0000000..28c3689 --- /dev/null +++ b/tests/ts/column/multi-file @@ -0,0 +1,34 @@ +#!/bin/bash + +# +# Copyright (C) 2011 Sami Kerola +# 2011 Karel Zak +# +# 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="multiple files" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_COLUMN" + +ts_cd "$TS_OUTDIR" + +$TS_CMD_COLUMN -x -c 50 $TS_SELF/files/fivecols \ + $TS_SELF/files/fivecols \ + $TS_SELF/files/fivecols >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_finalize + diff --git a/tests/ts/column/table b/tests/ts/column/table new file mode 100755 index 0000000..8b22d83 --- /dev/null +++ b/tests/ts/column/table @@ -0,0 +1,148 @@ +#!/bin/bash + +# +# Copyright (C) 2011 Sami Kerola +# +# 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="table" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" +ts_check_wcsspn + +ts_check_test_command "$TS_CMD_COLUMN" +ts_cd "$TS_OUTDIR" + +ts_init_subtest "default" +$TS_CMD_COLUMN --table $TS_SELF/files/table >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "output-separator" +$TS_CMD_COLUMN --output-separator '|' --table $TS_SELF/files/table >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "input-separator" +$TS_CMD_COLUMN --separator ',' --table $TS_SELF/files/table-sep >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "input-separator-space" +$TS_CMD_COLUMN --separator "$(echo -e '\t')" --table $TS_SELF/files/table-sep-space >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "empty-lines" +$TS_CMD_COLUMN --table --table-empty-lines $TS_SELF/files/table-empty-lines >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "noempty-lines" +$TS_CMD_COLUMN --table $TS_SELF/files/table-empty-lines >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "long" +$TS_CMD_COLUMN --table $TS_SELF/files/mountinfo >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "hide" +$TS_CMD_COLUMN --table $TS_SELF/files/mountinfo \ + --table-hide 1,2,3,4,7,8 >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "headers" +$TS_CMD_COLUMN --table $TS_SELF/files/mountinfo \ + --table-columns ID,PARENT,MAJMIN,ROOT,TARGET,VFS-OPTS,PROP,SEP,TYPE,SOURCE,FS-OPTS \ + --table-hide SEP,ID,PARENT,ROOT \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "truncate" +$TS_CMD_COLUMN --table $TS_SELF/files/mountinfo \ + --table-columns ID,PARENT,MAJMIN,ROOT,TARGET,VFS-OPTS,PROP,SEP,TYPE,SOURCE,FS-OPTS \ + --table-hide SEP,ID,PARENT,ROOT \ + --table-truncate VFS-OPTS,FS-OPTS \ + --output-width 80 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "right" +$TS_CMD_COLUMN --table $TS_SELF/files/mountinfo \ + --table-columns ID,PARENT,MAJMIN,ROOT,TARGET,VFS-OPTS,PROP,SEP,TYPE,SOURCE,FS-OPTS \ + --table-hide SEP,ID,PARENT,ROOT,VFS-OPTS,FS-OPTS,PROP \ + --table-right SOURCE,TYPE \ + --output-width 80 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "wrap" +$TS_CMD_COLUMN --table $TS_SELF/files/mountinfo \ + --table-columns ID,PARENT,MAJMIN,ROOT,TARGET,VFS-OPTS,PROP,SEP,TYPE,SOURCE,FS-OPTS \ + --table-hide=SEP,ID,PARENT,ROOT,VFS-OPTS,PROP \ + --table-wrap FS-OPTS \ + --output-width 110 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "order" +$TS_CMD_COLUMN --table $TS_SELF/files/mountinfo \ + --table-columns ID,PARENT,MAJMIN,ROOT,TARGET,VFS-OPTS,PROP,SEP,TYPE,SOURCE,FS-OPTS \ + --table-hide=SEP,ID,PARENT,ROOT,PROP,FS-OPTS,MAJMIN \ + --table-order TARGET,SOURCE,TYPE,VFS-OPTS \ + --output-width 110 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "tree" +$TS_CMD_COLUMN --table $TS_SELF/files/mountinfo \ + --table-columns ID,PARENT,MAJMIN,ROOT,TARGET,VFS-OPTS,PROP,SEP,TYPE,SOURCE,FS-OPTS \ + --table-hide=SEP,ID,PARENT,ROOT,PROP,FS-OPTS,MAJMIN \ + --table-order TARGET,SOURCE,TYPE,VFS-OPTS \ + --tree TARGET \ + --tree-id ID \ + --tree-parent PARENT \ + --output-width 110 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "empty-column" +printf ':a:b\n' | $TS_CMD_COLUMN --table --separator ':' --output-separator ':' >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "empty-column-at-eol" +printf '|' | $TS_CMD_COLUMN --separator '|' --output-separator '|' --table >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "empty-column-at-eol2" +printf '||' | $TS_CMD_COLUMN --separator '|' --output-separator '|' --table >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "neg-1" +echo "A B C D" | $TS_CMD_COLUMN --output-separator '|' --table --table-maxout \ + --table-right -1 --output-width=80 >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "neg-2" +echo "A B C D" | $TS_CMD_COLUMN --output-separator '|' --table --table-maxout \ + --table-right -2 --output-width=80 >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "neg-1-2" +echo "A B C D" | $TS_CMD_COLUMN --output-separator '|' --table --table-maxout \ + --table-right -1,-2 --output-width=80 >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "range" +echo "A B C D" | $TS_CMD_COLUMN --output-separator '|' --table --table-maxout \ + --table-right 2-3 --output-width=80 >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/cramfs/cramfs-big.img b/tests/ts/cramfs/cramfs-big.img new file mode 100644 index 0000000..2ea516e Binary files /dev/null and b/tests/ts/cramfs/cramfs-big.img differ diff --git a/tests/ts/cramfs/cramfs-little.img b/tests/ts/cramfs/cramfs-little.img new file mode 100644 index 0000000..a1dfab5 Binary files /dev/null and b/tests/ts/cramfs/cramfs-little.img differ diff --git a/tests/ts/cramfs/doubles b/tests/ts/cramfs/doubles new file mode 100755 index 0000000..d81daf1 --- /dev/null +++ b/tests/ts/cramfs/doubles @@ -0,0 +1,62 @@ +#!/bin/bash + +# +# Copyright (C) 2011 Karel Zak +# +# 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="mkfs doubles" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MKCRAMFS" +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" + +ts_skip_nonroot +ts_check_losetup + +ORIGPWD=$(pwd) +IMAGE_NAME="${TS_TESTNAME}.img" +IMAGE_PATH="$TS_OUTDIR/$IMAGE_NAME" +IMAGE_SRC="$TS_OUTDIR/${TS_TESTNAME}-data" + +ts_log "create mountpoint dir" +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + +rm -rf "$IMAGE_SRC" +mkdir -m 755 -p $IMAGE_SRC + +umask 133 + +echo hello > $IMAGE_SRC/a +echo hello > $IMAGE_SRC/b + +# sudo may use whatever group +chgrp -R 0 "$IMAGE_SRC" + +ts_log "create cramfs image" +$TS_CMD_MKCRAMFS $IMAGE_SRC $IMAGE_PATH >> $TS_OUTPUT 2>> $TS_ERRLOG +[ -s "$IMAGE_PATH" ] || ts_die "Cannot create $IMAGE_PATH" + +ts_mount "cramfs" -r $IMAGE_PATH $TS_MOUNTPOINT + +# check it +ts_is_mounted $TS_MOUNTPOINT || ts_die "Cannot find $TS_MOUNTPOINT in /proc/mounts" + +ts_log "umount the image" +$TS_CMD_UMOUNT $TS_MOUNTPOINT +ts_finalize + diff --git a/tests/ts/cramfs/fsck-bad-header b/tests/ts/cramfs/fsck-bad-header new file mode 100755 index 0000000..d834b24 --- /dev/null +++ b/tests/ts/cramfs/fsck-bad-header @@ -0,0 +1,102 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="fsck bad header" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MKCRAMFS" +ts_check_test_command "$TS_CMD_FSCKCRAMFS" +ts_check_prog "dd" + +function num2binary() +{ + local num=$1 + local endian=$2 + + test "$num" -ge 0 -a "$num" -le 4294967295 || return 1 + test "$endian" = "be" -o "$endian" = "le" || return 1 + + # how to do that easier? + if test "$endian" = "be"; then + echo -en "$(printf "%08x" "$1" | sed 's/\(..\)/\\x\1/g')" + else + echo -en "$(printf "%08x" "$1" | sed 's/^\(..\)\(..\)\(..\)\(..\)$/\\x\4\\x\3\\x\2\\x\1/')" + fi +} + +function fsck_loop_sizes() +{ + local endian=$1 # be, le + local seek=$2 # 4 for nopad, 516 for pad + shift 2 # the rest are sizes to loop over + + for size in "$@"; do + ts_log_both "## size: $size" + cp -a "$IMAGE_FILE" "$IMAGE_FILE.tmp" + num2binary "$size" $endian | + dd of="$IMAGE_FILE.tmp" bs=1 seek="$seek" count=4 conv=notrunc &> /dev/null + $TS_CMD_FSCKCRAMFS "$IMAGE_FILE.tmp" >> $TS_OUTPUT 2>> $TS_ERRLOG + ts_log "ret: $? +" + done + rm -f "$IMAGE_FILE" +} + + +IMAGE_SOURCE="$TS_OUTDIR/${TS_TESTNAME}-data" +IMAGE_FILE="$TS_OUTDIR/${TS_TESTNAME}-cramfs.img" + +mkdir -p "${IMAGE_SOURCE}/subdir" &> /dev/null + +ts_init_subtest "nopad-4K-be" +$TS_CMD_MKCRAMFS -N big -b 4096 $IMAGE_SOURCE $IMAGE_FILE &> /dev/null +fsck_loop_sizes be 4 0 75 76 4095 4096 4097 4294967295 +rm -f "$IMAGE_FILE" +ts_finalize_subtest + +ts_init_subtest "nopad-4K-le" +$TS_CMD_MKCRAMFS -N little -b 4096 $IMAGE_SOURCE $IMAGE_FILE &> /dev/null +fsck_loop_sizes le 4 0 75 76 4095 4096 4097 4294967295 +ts_finalize_subtest + +ts_init_subtest "pad-4K-be" +$TS_CMD_MKCRAMFS -p -N big -b 4096 $IMAGE_SOURCE $IMAGE_FILE &> /dev/null +fsck_loop_sizes be 516 76 587 588 4095 4096 4097 4294967295 +ts_finalize_subtest + +ts_init_subtest "pad-4K-le" +$TS_CMD_MKCRAMFS -p -N little -b 4096 $IMAGE_SOURCE $IMAGE_FILE &> /dev/null +fsck_loop_sizes le 516 76 587 588 4095 4096 4097 4294967295 +ts_finalize_subtest + +ts_init_subtest "pad-64K-be" +$TS_CMD_MKCRAMFS -p -N big -b 65536 $IMAGE_SOURCE $IMAGE_FILE &> /dev/null +fsck_loop_sizes be 516 76 587 588 65535 65536 65537 4294967295 +ts_finalize_subtest + +ts_init_subtest "pad-64K-le" +$TS_CMD_MKCRAMFS -p -N little -b 65536 $IMAGE_SOURCE $IMAGE_FILE &> /dev/null +fsck_loop_sizes le 516 76 587 588 65535 65536 65537 4294967295 +ts_finalize_subtest + +rm -rf "$IMAGE_SOURCE" "$IMAGE_FILE.tmp" + +ts_finalize + diff --git a/tests/ts/cramfs/fsck-endianness b/tests/ts/cramfs/fsck-endianness new file mode 100755 index 0000000..53af53e --- /dev/null +++ b/tests/ts/cramfs/fsck-endianness @@ -0,0 +1,58 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="fsck endianness" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MKCRAMFS" +ts_check_test_command "$TS_CMD_FSCKCRAMFS" +ts_check_test_command "$TS_HELPER_MD5" + +ts_skip_nonroot + +IMAGE_LITTLE="$TS_SELF/cramfs-little.img" #Known good little endian image +IMAGE_BIG="$TS_SELF/cramfs-big.img" #Known good big endian image + +IMAGE_CREATED="$TS_OUTDIR/${TS_TESTNAME}-cramfs.img" #Image created during the test and compared against the known images. +IMAGE_DATA="$TS_OUTDIR/${TS_TESTNAME}-data" + +test_image() { + local FROM_ENDIANNESS="$1"; shift + local TO_ENDIANNESS="$1"; shift + local FROM_IMAGE="$1"; shift + + rm -rf "$IMAGE_DATA" + ts_log "extract from $FROM_ENDIANNESS endian" + $TS_CMD_FSCKCRAMFS -v -b 4096 --extract=$IMAGE_DATA $FROM_IMAGE | head -n1 | cut -d" " -f4 >> $TS_OUTPUT 2>> $TS_ERRLOG + + ts_log "create $TO_ENDIANNESS endian" + $TS_CMD_MKCRAMFS -N "$TO_ENDIANNESS" -b 4096 "$IMAGE_DATA" \ + "$IMAGE_CREATED" >> $TS_OUTPUT 2>> $TS_ERRLOG + + "$TS_HELPER_MD5" < "$IMAGE_CREATED" >> $TS_OUTPUT + + rm "$IMAGE_CREATED" +} + +test_image "little" "big" "$IMAGE_LITTLE" +test_image "big" "little" "$IMAGE_BIG" + +ts_finalize + diff --git a/tests/ts/cramfs/mkfs b/tests/ts/cramfs/mkfs new file mode 100755 index 0000000..1e415d8 --- /dev/null +++ b/tests/ts/cramfs/mkfs @@ -0,0 +1,125 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="mkfs checksums" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MKCRAMFS" +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" +ts_check_test_command "$TS_CMD_BLKID" +ts_check_test_command "$TS_HELPER_MD5" +ts_check_test_command "$TS_HELPER_SYSINFO" + +ts_skip_nonroot +ts_check_losetup + +ORIGPWD=$(pwd) +IMAGE_NAME="${TS_TESTNAME}-loop.img" +IMAGE_PATH="$TS_OUTDIR/$IMAGE_NAME" +IMAGE_SRC="$TS_OUTDIR/${TS_TESTNAME}-data" +LABEL="testCramfs" + +BYTE_ORDER=$($TS_HELPER_SYSINFO byte-order) +PAGE_SIZE=$($TS_HELPER_SYSINFO pagesize) +case "${BYTE_ORDER}:${PAGE_SIZE}" in + LE:4096) + MD5_EXP="a6667acb1cb0685d9eb5b9cd3724766c" ;; + LE:16384 | LE:65536) + MD5_EXP="b60133682603b0118592b55f1dba017c" ;; + BE:4096) + MD5_EXP="eaf05031dc8ec97c91ba5c773635cc89" ;; + BE:8192 | BE:65536) + MD5_EXP="5859f87b185b1187fca3b2b00c809c03" ;; + *) + echo "warning ${TS_NS}: unknown checksum for ${BYTE_ORDER}:${PAGE_SIZE}" + MD5_EXP="unknown" ;; +esac + +ts_log "create mountpoint dir" + +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + +ts_log "generate data" +rm -rf "$IMAGE_SRC" +mkdir -m 755 -p $IMAGE_SRC + +umask 133 + +for d in `seq 0 110`; do + DIRNAME="$IMAGE_SRC/$(printf "dir-%03d" $d)" + mkdir -m 755 $DIRNAME + for f in `seq 0 10`; do + FILENAME="$DIRNAME/$(printf "data.%03d" $f)" + printf "data in %03d-%03d" $d $f >> $FILENAME + done +done + +chgrp -R 0 "$IMAGE_SRC" + +ts_cd "$IMAGE_SRC" + +ts_log "list checksums from original data" +find . -type f -exec md5sum {} \; | sort >> $TS_OUTPUT +echo >> $TS_OUTPUT + +ts_log "create cramfs image" +$TS_CMD_MKCRAMFS -n $LABEL $IMAGE_SRC $IMAGE_PATH >> $TS_OUTPUT 2>> $TS_ERRLOG +[ -s "$IMAGE_PATH" ] || ts_die "Cannot create $IMAGE_PATH" + +ts_cd "$TS_OUTDIR" + +ts_log "count MD5 from the image" +MD5_OUT=$("$TS_HELPER_MD5" < "$IMAGE_NAME") >> $TS_OUTPUT 2>> $TS_ERRLOG +if [ "$MD5_EXP" != "$MD5_OUT" -a "$MD5_EXP" != "unknown" ]; then + ts_log "is $MD5_OUT, should be $MD5_EXP" +fi +echo >> $TS_OUTPUT + +ts_log "create loop device from image" +DEVICE=$($TS_CMD_LOSETUP --show -f $IMAGE_PATH) +ts_register_loop_device "$DEVICE" + +ts_log "check the image" +ts_device_has "TYPE" "cramfs" $DEVICE +[ "$?" == "0" ] || ts_die "Cannot find cramfs on $DEVICE" + +ts_log "mount the image" +ts_mount "cramfs" -r -L $LABEL $TS_MOUNTPOINT + +# check it +ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts" + +ts_cd "$TS_MOUNTPOINT" + +ts_log "list the image" +export TZ='GMT-1' +ls -laR --time-style=long-iso . | sed 's:\. : :g' >> $TS_OUTPUT +echo >> $TS_OUTPUT + +ts_log "list checksums from new data" +find . -type f -exec md5sum {} \; | sort >> $TS_OUTPUT +echo >> $TS_OUTPUT + +ts_cd "$ORIGPWD" + +ts_log "umount the image" +ts_finalize + diff --git a/tests/ts/cramfs/mkfs-endianness b/tests/ts/cramfs/mkfs-endianness new file mode 100755 index 0000000..d10e1e1 --- /dev/null +++ b/tests/ts/cramfs/mkfs-endianness @@ -0,0 +1,63 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="mkfs endianness" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MKCRAMFS" +ts_check_test_command "$TS_CMD_HEXDUMP" + +ts_skip_nonroot + +IMAGE_DATA="$TS_OUTDIR/${TS_TESTNAME}-data" +IMAGE_CREATED="$TS_OUTDIR/${TS_TESTNAME}-cramfs.img" #Image created during the test and compared against the known images. + +umask 133 + +test_image() { + local TO_ENDIANNESS="$1"; shift + ts_log "create $TO_ENDIANNESS endian" + + $TS_CMD_MKCRAMFS -N "$TO_ENDIANNESS" -b 4096 "$IMAGE_DATA" \ + "$IMAGE_CREATED" >> $TS_OUTPUT 2>> $TS_ERRLOG + + $TS_CMD_HEXDUMP -C $IMAGE_CREATED >> $TS_OUTPUT + + rm "$IMAGE_CREATED" +} + +#generate test data, must be owner root +rm -rf "$IMAGE_DATA" +mkdir -m 755 $IMAGE_DATA +mkdir -m 755 $IMAGE_DATA/dirA +mkdir -m 755 $IMAGE_DATA/dirA/dirB + +cp $TS_SELF/mkfs-endianness_testdata_a $IMAGE_DATA/dirA/dirB/a +cp $TS_SELF/mkfs-endianness_testdata_b $IMAGE_DATA/dirA/dirB/b + +# sudo may use whatever group +chgrp -R 0 $IMAGE_DATA + +#perform tests for both endians +test_image "little" +test_image "big" + +ts_finalize + diff --git a/tests/ts/cramfs/mkfs-endianness_testdata_a b/tests/ts/cramfs/mkfs-endianness_testdata_a new file mode 100644 index 0000000..d6c57b7 --- /dev/null +++ b/tests/ts/cramfs/mkfs-endianness_testdata_a @@ -0,0 +1,8 @@ +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs \ No newline at end of file diff --git a/tests/ts/cramfs/mkfs-endianness_testdata_b b/tests/ts/cramfs/mkfs-endianness_testdata_b new file mode 100644 index 0000000..30f9faf --- /dev/null +++ b/tests/ts/cramfs/mkfs-endianness_testdata_b @@ -0,0 +1,217 @@ +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 1234567890 Endianness check 1234567890 Endianness check +Testing cramfs 123456789 \ No newline at end of file diff --git a/tests/ts/dmesg/colors b/tests/ts/dmesg/colors new file mode 100755 index 0000000..8028c48 --- /dev/null +++ b/tests/ts/dmesg/colors @@ -0,0 +1,29 @@ +#!/bin/bash + +# 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="colors" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_DMESG" +ts_inhibit_custom_colorscheme + +export TZ="GMT" +export DMESG_TEST_BOOTIME="1234567890.123456" + +$TS_HELPER_DMESG --color=always -F $TS_SELF/input -x >> $TS_OUTPUT 2>/dev/null + +ts_finalize diff --git a/tests/ts/dmesg/console-levels b/tests/ts/dmesg/console-levels new file mode 100755 index 0000000..fc39cf0 --- /dev/null +++ b/tests/ts/dmesg/console-levels @@ -0,0 +1,36 @@ +#!/bin/bash + +# 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="levels" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_DMESG" + +export TZ="GMT" +export DMESG_TEST_BOOTIME="1234567890.123456" + +for I in {-1..8}; do + $TS_HELPER_DMESG -F $TS_SELF/input -l $I >> $TS_OUTPUT 2>/dev/null +done + +$TS_HELPER_DMESG -F $TS_SELF/input -l err+ >> $TS_OUTPUT 2>/dev/null +$TS_HELPER_DMESG -F $TS_SELF/input -l emerg+ >> $TS_OUTPUT 2>/dev/null +$TS_HELPER_DMESG -F $TS_SELF/input -l +err >> $TS_OUTPUT 2>/dev/null +$TS_HELPER_DMESG -F $TS_SELF/input -l +debug >> $TS_OUTPUT 2>/dev/null +$TS_HELPER_DMESG -F $TS_SELF/input -l + 2>> $TS_OUTPUT >/dev/null + +ts_finalize diff --git a/tests/ts/dmesg/decode b/tests/ts/dmesg/decode new file mode 100755 index 0000000..673f2bb --- /dev/null +++ b/tests/ts/dmesg/decode @@ -0,0 +1,28 @@ +#!/bin/bash + +# 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="decode" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_DMESG" + +export TZ="GMT" +export DMESG_TEST_BOOTIME="1234567890.123456" + +$TS_HELPER_DMESG -x -F $TS_SELF/input >> $TS_OUTPUT 2>/dev/null + +ts_finalize diff --git a/tests/ts/dmesg/delta b/tests/ts/dmesg/delta new file mode 100755 index 0000000..83d8629 --- /dev/null +++ b/tests/ts/dmesg/delta @@ -0,0 +1,28 @@ +#!/bin/bash + +# 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="delta" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_DMESG" + +export TZ="GMT" +export DMESG_TEST_BOOTIME="1234567890.123456" + +$TS_HELPER_DMESG -d -F $TS_SELF/input >> $TS_OUTPUT 2>/dev/null + +ts_finalize diff --git a/tests/ts/dmesg/facilities b/tests/ts/dmesg/facilities new file mode 100755 index 0000000..13dd6c6 --- /dev/null +++ b/tests/ts/dmesg/facilities @@ -0,0 +1,30 @@ +#!/bin/bash + +# 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="facilities" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_DMESG" + +export TZ="GMT" +export DMESG_TEST_BOOTIME="1234567890.123456" + +for I in {-1..12}; do + $TS_HELPER_DMESG -F $TS_SELF/input -f $I >> $TS_OUTPUT 2>/dev/null +done + +ts_finalize diff --git a/tests/ts/dmesg/indentation b/tests/ts/dmesg/indentation new file mode 100755 index 0000000..a4f8e1c --- /dev/null +++ b/tests/ts/dmesg/indentation @@ -0,0 +1,40 @@ +#!/bin/bash + +# 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="indentation" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_DMESG" + +export TZ="GMT" +export DMESG_TEST_BOOTIME="1234567890.123456" + +$TS_HELPER_DMESG -F $TS_SELF/newlines >> $TS_OUTPUT 2>> $TS_ERRLOG + +$TS_HELPER_DMESG -F $TS_SELF/newlines -x >> $TS_OUTPUT 2>> $TS_ERRLOG + +$TS_HELPER_DMESG --time-format=delta --file $TS_SELF/newlines >> $TS_OUTPUT 2>> $TS_ERRLOG + +$TS_HELPER_DMESG --time-format=notime --file $TS_SELF/newlines >> $TS_OUTPUT 2>> $TS_ERRLOG + +$TS_HELPER_DMESG --time-format=reltime --file $TS_SELF/newlines >> $TS_OUTPUT 2>> $TS_ERRLOG + +$TS_HELPER_DMESG --time-format=ctime --file $TS_SELF/newlines >> $TS_OUTPUT 2>> $TS_ERRLOG + +$TS_HELPER_DMESG --time-format=iso --file $TS_SELF/newlines >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_finalize diff --git a/tests/ts/dmesg/input b/tests/ts/dmesg/input new file mode 100644 index 0000000..98307df --- /dev/null +++ b/tests/ts/dmesg/input @@ -0,0 +1,105 @@ +<0>[ 0.000000] example[0] +<1>[ 1.000000] example[1] +<2>[ 8.000000] example[2] +<3>[ 27.000000] example[3] +<4>[ 64.000000] example[4] +<5>[ 125.000000] example[5] +<6>[ 216.000000] example[6] +<7>[ 343.000000] example[7] +<8>[ 512.000000] example[8] +<9>[ 729.000000] example[9] +<10>[ 1000.000000] example[10] +<11>[ 1331.000000] example[11] +<12>[ 1728.000000] example[12] +<13>[ 2197.000000] example[13] +<14>[ 2744.000000] example[14] +<15>[ 3375.000000] example[15] +<16>[ 4096.000000] example[16] +<17>[ 4913.000000] example[17] +<18>[ 5832.000000] example[18] +<19>[ 6859.000000] example[19] +<20>[ 8000.000000] example[20] +<21>[ 9261.000000] example[21] +<22>[10648.000000] example[22] +<23>[12167.000000] example[23] +<24>[13824.000000] example[24] +<25>[15625.000000] example[25] +<26>[17576.000000] example[26] +<27>[19683.000000] example[27] +<28>[21952.000000] example[28] +<29>[24389.000000] example[29] +<30>[27000.000000] example[30] +<31>[29791.000000] example[31] +<32>[32768.000000] example[32] +<33>[35937.000000] example[33] +<34>[39304.000000] example[34] +<35>[42875.000000] example[35] +<36>[46656.000000] example[36] +<37>[50653.000000] example[37] +<38>[54872.000000] example[38] +<39>[59319.000000] example[39] +<40>[64000.000000] example[40] +<41>[68921.000000] example[41] +<42>[74088.000000] example[42] +<43>[79507.000000] example[43] +<44>[85184.000000] example[44] +<45>[91125.000000] example[45] +<46>[97336.000000] example[46] +<47>[103823.000000] example[47] +<48>[110592.000000] example[48] +<49>[117649.000000] example[49] +<50>[125000.000000] example[50] +<51>[132651.000000] example[51] +<52>[140608.000000] example[52] +<53>[148877.000000] example[53] +<54>[157464.000000] example[54] +<55>[166375.000000] example[55] +<56>[175616.000000] example[56] +<57>[185193.000000] example[57] +<58>[195112.000000] example[58] +<59>[205379.000000] example[59] +<60>[216000.000000] example[60] +<61>[226981.000000] example[61] +<62>[238328.000000] example[62] +<63>[250047.000000] example[63] +<64>[262144.000000] example[64] +<65>[274625.000000] example[65] +<66>[287496.000000] example[66] +<67>[300763.000000] example[67] +<68>[314432.000000] example[68] +<69>[328509.000000] example[69] +<70>[343000.000000] example[70] +<71>[357911.000000] example[71] +<72>[373248.000000] example[72] +<73>[389017.000000] example[73] +<74>[405224.000000] example[74] +<75>[421875.000000] example[75] +<76>[438976.000000] example[76] +<77>[456533.000000] example[77] +<78>[474552.000000] example[78] +<79>[493039.000000] example[79] +<80>[512000.000000] example[80] +<81>[531441.000000] example[81] +<82>[551368.000000] example[82] +<83>[571787.000000] example[83] +<84>[592704.000000] example[84] +<85>[614125.000000] example[85] +<86>[636056.000000] example[86] +<87>[658503.000000] example[87] +<88>[681472.000000] example[88] +<89>[704969.000000] example[89] +<90>[729000.000000] example[90] +<91>[753571.000000] example[91] +<92>[778688.000000] example[92] +<93>[804357.000000] example[93] +<94>[830584.000000] example[94] +<95>[857375.000000] example[95] +<96>[884736.000000] example[96] +<97>[912673.000000] example[97] +<98>[941192.000000] example[98] +<99>[970299.000000] example[99] +<100>[1000000.000000] example[100] +<101>[1030301.000000] example[101] +<102>[1061208.000000] example[102] +<103>[1092727.000000] example[103] +<104>[1124864.000000] example[104] diff --git a/tests/ts/dmesg/limit b/tests/ts/dmesg/limit new file mode 100755 index 0000000..f3f9643 --- /dev/null +++ b/tests/ts/dmesg/limit @@ -0,0 +1,29 @@ +#!/bin/bash + +# 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="limit" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_DMESG" + +export TZ="GMT" +export DMESG_TEST_BOOTIME="1234567890.123456" + +$TS_HELPER_DMESG --since @1234567890.124 --until @1234567991 -F $TS_SELF/input \ + >> $TS_OUTPUT 2> $TS_ERRLOG + +ts_finalize diff --git a/tests/ts/dmesg/newlines b/tests/ts/dmesg/newlines new file mode 100644 index 0000000..6b298c6 --- /dev/null +++ b/tests/ts/dmesg/newlines @@ -0,0 +1,5 @@ +<10>[ 1.000000] new +line +<20>[ 2.000000] two +new +lines diff --git a/tests/ts/eject/umount b/tests/ts/eject/umount new file mode 100755 index 0000000..838ee9c --- /dev/null +++ b/tests/ts/eject/umount @@ -0,0 +1,127 @@ +#!/bin/bash + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="umount" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_skip_nonroot + +ts_check_test_command "$TS_CMD_FDISK" +ts_check_test_command "$TS_CMD_EJECT" +ts_check_test_command "$TS_CMD_KILL" +ts_check_test_command "$TS_CMD_MOUNT" + +ts_check_prog "mkfs.ext2" + +# scsi_debug could not eject for kernel >=3.19 and <4.4 +if x=$(echo "3.19" && uname -r && echo "4.4") \ + && test "$x" = "$(echo "$x" | sort --version-sort)" +then + ts_skip "3.19 <= $(uname -sr) < 4.4" +fi + +# +# Note that eject --force is required because scsi_debug is +# not removable device. +# + +# set global variable TS_DEVICE +function init_device { + ts_scsi_debug_init dev_size_mb=100 +} + +function init_partitions { + local dev=$1 + + ts_log "Create partitions" + $TS_CMD_FDISK --noauto-pt $dev >> /dev/null 2>&1 <& /dev/null +} + +{ + create_file + "$TS_CMD_FINCORE" "$FILE" + echo + + create_file + echo "whole file" + "$TS_CMD_FADVISE" "$FILE" + echo status: $? + "$TS_CMD_FINCORE" "$FILE" + echo + + create_file + echo "offset: 8192" + "$TS_CMD_FADVISE" -o 8192 "$FILE" + echo status: $? + "$TS_CMD_FINCORE" "$FILE" + echo + + create_file + echo "length: 16384" + "$TS_CMD_FADVISE" -l 16384 "$FILE" + echo status: $? + "$TS_CMD_FINCORE" "$FILE" + echo + + create_file + echo "offset: 8192, length: 16384 fd: 42" + "$TS_CMD_FADVISE" -o 8192 -l 16384 --fd 42 42<"$FILE" + echo status: $? + "$TS_CMD_FINCORE" "$FILE" + echo + + rm "$FILE" +} >> "$TS_OUTPUT" 2>> "$TS_ERRLOG" + +ts_finalize diff --git a/tests/ts/fdisk/align-512-4K b/tests/ts/fdisk/align-512-4K new file mode 100755 index 0000000..d44c6df --- /dev/null +++ b/tests/ts/fdisk/align-512-4K @@ -0,0 +1,79 @@ +#!/bin/bash + +# +# 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. +# + + +# +# Test alignment for 512/512 disk *with* topology -- aligned to optimal +# I/O size (32KiB) +# + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="align 512/4K" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FDISK" + +ts_skip_nonroot + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=50 sector_size=512 physblk_exp=3 +DEVNAME=$(basename $TS_DEVICE) + +ts_log "Create partitions" +$TS_CMD_FDISK --noauto-pt ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_fdisk_clean $TS_DEVICE + +ts_finalize diff --git a/tests/ts/fdisk/align-512-4K-63 b/tests/ts/fdisk/align-512-4K-63 new file mode 100755 index 0000000..3d66899 --- /dev/null +++ b/tests/ts/fdisk/align-512-4K-63 @@ -0,0 +1,80 @@ +#!/bin/bash + +# +# 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. +# + + +# +# Test alignment for 512/512 disk *with* topology -- aligned to optimal +# I/O size (32KiB) +# + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="align 512/4K +alignment_offset" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FDISK" + +ts_skip_nonroot + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=50 sector_size=512 physblk_exp=3 lowest_aligned=7 +DEVNAME=$(basename $TS_DEVICE) + +ts_log "Create partitions" +$TS_CMD_FDISK --noauto-pt ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <> $TS_OUTPUT 2>> $TS_ERRLOG + + +ts_fdisk_clean $TS_DEVICE + +ts_finalize diff --git a/tests/ts/fdisk/align-512-4K-md b/tests/ts/fdisk/align-512-4K-md new file mode 100755 index 0000000..1e0dd3c --- /dev/null +++ b/tests/ts/fdisk/align-512-4K-md @@ -0,0 +1,104 @@ +#!/bin/bash + +# +# 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. +# + + +# +# Test alignment for 512/512 disk *with* topology -- aligned to optimal +# I/O size (32KiB) +# + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="align 512/4K +MD" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FDISK" + +ts_skip_nonroot +ts_check_prog "mdadm" + +# rhbz#182625: It can't create new raid0 with metadata 0.90 from mdadm-4.1 +TS_KNOWN_FAIL="yes" + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=50 sector_size=512 physblk_exp=3 +DEVNAME=$(basename $TS_DEVICE) + +ts_log "Create partitions" +$TS_CMD_FDISK --noauto-pt ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_lock "md" + +MD_DEVNAME=md8 +MD_DEVICE=/dev/${MD_DEVNAME} + +mdadm -q -S ${MD_DEVICE} &> /dev/null +udevadm settle + +mdadm -q --create ${MD_DEVICE} --metadata=0.90 --chunk=64 \ + --level=0 --raid-devices=2 ${TS_DEVICE}1 ${TS_DEVICE}2 >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle + +ts_log "Create partitions (MD)" +$TS_CMD_FDISK ${MD_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <> $TS_OUTPUT 2>> $TS_ERRLOG + +mdadm -q -S ${MD_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG + +udevadm settle +ts_unlock "md" + +ts_fdisk_clean $TS_DEVICE +ts_fdisk_clean $MD_DEVICE + +ts_finalize diff --git a/tests/ts/fdisk/align-512-512 b/tests/ts/fdisk/align-512-512 new file mode 100755 index 0000000..e61110f --- /dev/null +++ b/tests/ts/fdisk/align-512-512 @@ -0,0 +1,73 @@ +#!/bin/bash + +# +# 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. +# + +# +# Test default 1MiB (2048 sectors) alignment for 512/512 disk *without* +# topology. +# + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="align 512/512" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FDISK" + +ts_skip_nonroot +ts_check_losetup + +ts_device_init 50 +DEVICE=$TS_LODEV + +ts_log "Create partitions" +$TS_CMD_FDISK --noauto-pt ${DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <> $TS_OUTPUT 2>> $TS_ERRLOG <> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_fdisk_clean $TS_DEVICE + +ts_finalize diff --git a/tests/ts/fdisk/bsd b/tests/ts/fdisk/bsd new file mode 100755 index 0000000..8477f92 --- /dev/null +++ b/tests/ts/fdisk/bsd @@ -0,0 +1,141 @@ +#!/bin/bash +# +# This file is part of util-linux. +# +# Copyright (C) 2013 Karel Zak +# +# 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="nested BSD" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FDISK" +ts_check_test_command "$TS_CMD_HEXDUMP" +ts_check_test_command "$TS_HELPER_SYSINFO" + +FDISK_CMD_CREATE_DOSLABEL="o\n" # create dos label +FDISK_CMD_SETID="x\ni\n0x1\nr\n" # set non-random ID +FDISK_CMD_WRITE_CLOSE="w\nq\n" # write to image +FDISK_CMD_CREATE_PRIMARY1="n\np\n1\n\n+1M\n" # 1st primary partition of size 1MiB +FDISK_CMD_CREATE_PRIMARY2="n\np\n2\n\n\n" # 2nd primary partition for whole of the disk +FDISK_CMD_CHANGE_PART2TYPE="t\n2\na5\n" # change partition type FreeBSD + +FDISK_CMD_BSD_CREATE="b\ny\n" # create nested BSD PT +FDISK_CMD_BSD_LIST="b\np\nr\nq\n" # list nested BSD PT and quit +FDISK_CMD_BSD_CREATE_PART="b\nn\na\n\n+1M\n" # add BSD partition 'a', size 1MiB +FDISK_CMD_BSD_PARTTYPE="b\nt\na\n7\n" # set partition 'a' to type 4.2BSD +FDISK_CMD_BSD_LIST_TYPES="b\nl\nq\n" # list supported PT types and quit + +#set -x + +# BSD disklabel depends on endianness +BYTE_ORDER=$($TS_HELPER_SYSINFO byte-order) + +# and also on arch-specific offset (see include/pt-bsd.h) +ARCH=$(uname -m) +case $ARCH in + # see include/pt-bsd.h + *alpha* | *ppc* | *ia64* | *hppa* | *parisc* ) + BSD_LABELSECTOR=0 + BSD_LABELOFFSET=64 + ;; + *) + BSD_LABELSECTOR=1 + BSD_LABELOFFSET=0 + ;; +esac + +# and contains extra options for alpha +BSD_EXTRA="" +case $ARCH in + *alpha*) + BSD_EXTRA="_alpha" + ;; +esac + +echo "BSD_LABELSECTOR=$BSD_LABELSECTOR" >> $TS_OUTPUT +echo "BSD_LABELOFFSET=$BSD_LABELOFFSET" >> $TS_OUTPUT +echo "BSD_EXTRA=$BSD_EXTRA" >> $TS_OUTPUT +echo "BYTE_ORDER=$BYTE_ORDER" >> $TS_OUTPUT +echo >> $TS_OUTPUT + +TS_EXPECTED+="_${BSD_LABELSECTOR}_${BSD_LABELOFFSET}${BSD_EXTRA}.${BYTE_ORDER}" + +function print_layout { + echo -ne "\n---layout----------\n" >> $TS_OUTPUT + $TS_CMD_FDISK -x ${TEST_IMAGE_NAME} >> $TS_OUTPUT + echo -ne "-------------------\n\n" >> $TS_OUTPUT +} + +function print_bsd_layout { + echo -ne "\n---layout----------\n" >> $TS_OUTPUT + echo -e "${FDISK_CMD_BSD_LIST}" | \ + $TS_CMD_FDISK ${TEST_IMAGE_NAME} >> $TS_OUTPUT + echo -ne "-------------------\n\n" >> $TS_OUTPUT +} + +ts_log "Initialize empty image" +TEST_IMAGE_NAME=$(ts_image_init 10) +$TS_CMD_HEXDUMP -C ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_log "Create new DOS partition table" +echo -e "${FDISK_CMD_CREATE_DOSLABEL}${FDISK_CMD_SETID}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK --noauto-pt ${TEST_IMAGE_NAME} &> /dev/null +$TS_CMD_HEXDUMP -C ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout + +ts_log "Create 1st primary partition" +echo -e "${FDISK_CMD_CREATE_PRIMARY1}${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null +$TS_CMD_HEXDUMP -C ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout + +ts_log "Create 2nd primary partition" +echo -e "${FDISK_CMD_CREATE_PRIMARY2}${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null +$TS_CMD_HEXDUMP -C ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_log "Set 2nd partition type" +echo -e "${FDISK_CMD_CHANGE_PART2TYPE}${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null +$TS_CMD_HEXDUMP -C ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout + +ts_log "Create default BSD" +echo -e "${FDISK_CMD_BSD_CREATE}${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null +$TS_CMD_HEXDUMP -C ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_bsd_layout + +echo -e "${FDISK_CMD_BSD_CREATE_PART}${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null + +echo -e "${FDISK_CMD_BSD_PARTTYPE}${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null +$TS_CMD_HEXDUMP -C ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_bsd_layout + +echo -e "${FDISK_CMD_BSD_LIST_TYPES}" | \ + $TS_CMD_FDISK ${TEST_IMAGE_NAME} | \ + sed 's/Reading .*//g; s/Welcome to fdisk .*//' >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize diff --git a/tests/ts/fdisk/gpt b/tests/ts/fdisk/gpt new file mode 100755 index 0000000..d1c76da --- /dev/null +++ b/tests/ts/fdisk/gpt @@ -0,0 +1,107 @@ +#!/bin/bash +# +# This file is part of util-linux. +# +# Copyright (C) 2013 Karel Zak +# +# 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="GPT" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FDISK" + +FDISK_CMD_CREATE_GPTLABEL="g\n" # create GPT label +FDISK_CMD_WRITE_CLOSE="w\nq\n" # write to image + +FDISK_CMD_CHANGE_TYPE_BY_NUM="t\n1\n1\n" # set 1st partition to EFI System + # set 5th partition to Linux swap +FDISK_CMD_CHANGE_TYPE_BY_UUID="t\n5\n0657FD6D-A4AB-43C4-84E5-0933C84B4F4F\n" + +FDISK_CMD_DELETE_PART="d\n2\n" # delete 2nd partition +FDISK_CMD_CREATE_PART="n\n2\n\n\n" # create 2nd partition + +function print_layout { + echo -ne "\n---layout----------\n" >> $TS_OUTPUT + $TS_CMD_FDISK -l ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG + echo -ne "-------------------\n\n" >> $TS_OUTPUT + + ts_fdisk_clean ${TEST_IMAGE_NAME} +} + + +ts_init_subtest "empty-pt" +ts_log "Initialize empty image" +TEST_IMAGE_NAME=$(ts_image_init 10) + +ts_log "Create new GPT partition table" +echo -e "${FDISK_CMD_CREATE_GPTLABEL}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK --noauto-pt ${TEST_IMAGE_NAME} &> /dev/null + +print_layout +ts_finalize_subtest + +ts_init_subtest "create-partitions" +for i in {1..8}; do + echo -e "n\n${i}\n\n+1M\n${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null +done +ts_finalize_subtest + +ts_init_subtest "change-type-by-number" +echo -e "${FDISK_CMD_CHANGE_TYPE_BY_NUM}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null + +print_layout +ts_finalize_subtest + +ts_init_subtest "change-type-by-uuid" +echo -e "${FDISK_CMD_CHANGE_TYPE_BY_UUID}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null + +print_layout +ts_finalize_subtest + +ts_init_subtest "delete-partition" +echo -e "${FDISK_CMD_DELETE_PART}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null + +print_layout +ts_finalize_subtest + +ts_init_subtest "create-again-partition" +echo -e "${FDISK_CMD_CREATE_PART}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null + +print_layout +ts_finalize_subtest + +ts_init_subtest "corrupt-primary-table" +dd if=/dev/zero of=${TEST_IMAGE_NAME} bs=512 count=1 seek=1 conv=notrunc &> /dev/null +echo -e "w\n" | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null + +print_layout +ts_finalize_subtest + +ts_init_subtest "corrupt-backup-table" +dd if=/dev/zero of=${TEST_IMAGE_NAME} bs=512 count=1 \ + seek=$(( 1024 * 1024 * 10 / 512 - 1)) conv=notrunc &> /dev/null +echo -e "w\n" | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null + +print_layout +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/fdisk/gpt-resize b/tests/ts/fdisk/gpt-resize new file mode 100755 index 0000000..198f38e --- /dev/null +++ b/tests/ts/fdisk/gpt-resize @@ -0,0 +1,63 @@ +#!/bin/bash + +# +# 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. +# + +# +# Test GPT Alternative-LBA and backup header update after device resize. +# + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="gpt-resize" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_skip_nonroot + +ts_check_test_command "$TS_CMD_FDISK" +ts_check_test_command "$TS_CMD_SFDISK" +ts_check_prog "dd" + +ts_check_losetup + +ts_device_init 10 +DEVICE=$TS_LODEV + +# create GPT with one partition +echo ",," | $TS_CMD_SFDISK --no-reread --no-tell-kernel --label gpt $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle + +# enlarge the image +IMAGE=$($TS_CMD_LOSETUP --output BACK-FILE --noheadings $DEVICE) +dd if=/dev/zero of=${IMAGE} bs=1MiB count=10 conv=notrunc oflag=append &> /dev/null +udevadm settle + +# update device size +$TS_CMD_LOSETUP --set-capacity $DEVICE +udevadm settle + +ts_log_both "----- fixing after resize: -----" + +# create another GPT partition on new free space (all default) +echo -e 'n\n\n\n\nw\n' | $TS_CMD_FDISK $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle + + +ts_log "----- list result: -----" + +$TS_CMD_FDISK --list $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_fdisk_clean $DEVICE +ts_finalize diff --git a/tests/ts/fdisk/id b/tests/ts/fdisk/id new file mode 100755 index 0000000..57fbc60 --- /dev/null +++ b/tests/ts/fdisk/id @@ -0,0 +1,56 @@ +#!/bin/bash + +# +# 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="MBR - id" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FDISK" + +FDISK_CMD_ID1="x\ni\n0x1\nr\nw\n" +FDISK_CMD_ID2="x\ni\n0x2\nr\nw\n" + +# Sparc uses SUN disk labels by default and thus has a different output +ARCH=$(uname -m) +case $ARCH in + *sparc* ) + ARCH_EXT=".sparc" + ;; + *) + ARCH_EXT="" + ;; +esac + +TS_EXPECTED+="${ARCH_EXT}" + +ts_log "Initialize empty image" +TEST_IMAGE_NAME=$(ts_image_init 10) + +ts_init_subtest "create-mbr-with-id-0x1" +TS_EXPECTED+="${ARCH_EXT}" +echo -e "${FDISK_CMD_ID1}" | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null +$TS_CMD_FDISK -l ${TEST_IMAGE_NAME} | grep identifier >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "create-mbr-with-id-0x2" +TS_EXPECTED+="${ARCH_EXT}" +echo -e "${FDISK_CMD_ID2}" | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null +$TS_CMD_FDISK -l ${TEST_IMAGE_NAME} | grep identifier >> $TS_OUTPUT +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/fdisk/mbr-dos-mode b/tests/ts/fdisk/mbr-dos-mode new file mode 100755 index 0000000..57d69fe --- /dev/null +++ b/tests/ts/fdisk/mbr-dos-mode @@ -0,0 +1,145 @@ +#!/bin/bash + +# +# 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="MBR - dos mode" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FDISK" +ts_check_test_command "$TS_HELPER_MD5" + +FDISK_CMD_INIT="x\ni\n0x1\nr\n" +FDISK_CMD_WRITE_CLOSE="w\nq\n" +FDISK_CMD_CREATE_DOSLABEL="o\n" #create dos label +FDISK_CMD_CREATE_PRIMARY="n\np\n1\n\n+1M\n" # create primary partition 1 of size 1MB +FDISK_CMD_CHANGE_PARTTYPE="t\nbf\n" # change partition type to "bf - solaris", this requires that there is only one partition to change +FDISK_CMD_SET_ACTIVE="a\n1\n" # set first partition active +FDISK_CMD_CREATE_EXTENDED="n\ne\n2\n\n+10\n" # create extended partition 2 of size 11 cylinders +FDISK_CMD_CREATE_LOGICAL="n\nl\n\n+1\n" # create next logical partition of size 2 cyl +FDISK_CMD_DELETE_LOGICALS="d\n6\nd\n5\nd\n6\n" # delete middle, head, tail, last partitions +FDISK_CMD_DELETE_PRIMARY="d\n1\n" # delete first primary +FDISK_CMD_DELETE_EXTENDED="d\n2\n" # delete second primary + +FDISK_OPTIONS="-C 1024 -c=dos -u=cylinders" + +function print_layout { + echo -ne "\n---layout----------\n" >> $TS_OUTPUT + $TS_CMD_FDISK ${FDISK_OPTIONS} -x ${TEST_IMAGE_NAME} >> $TS_OUTPUT + echo -ne "-------------------\n\n" >> $TS_OUTPUT + + ts_fdisk_clean ${TEST_IMAGE_NAME} +} + +# +# Note that fdisk will enlarge the disk image (to 57MB) because the logical +# partitions are out of the original range (10MB). +# +ts_init_subtest "empty-pt" +TEST_IMAGE_NAME=$(ts_image_init 10) +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +echo -e "${FDISK_CMD_CREATE_DOSLABEL}${FDISK_CMD_INIT}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK --noauto-pt ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout +ts_finalize_subtest + +ts_init_subtest "create-primary-partition" +echo -e "${FDISK_CMD_CREATE_PRIMARY}${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout +ts_finalize_subtest + +ts_init_subtest "set-partition-type" +echo -e "${FDISK_CMD_CHANGE_PARTTYPE}${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout +ts_finalize_subtest + +ts_init_subtest "set-primary-par-active" +echo -e "${FDISK_CMD_SET_ACTIVE}${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout +ts_finalize_subtest + +ts_init_subtest "re-create-primary-par" +echo -e "d\n${FDISK_CMD_CREATE_PRIMARY}${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout +ts_finalize_subtest + +ts_init_subtest "create-extended-par" +echo -e "${FDISK_CMD_CREATE_EXTENDED}${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout +ts_finalize_subtest + +ts_init_subtest "create-logical-par" +echo -e "${FDISK_CMD_CREATE_LOGICAL}${FDISK_CMD_CREATE_LOGICAL}${FDISK_CMD_CREATE_LOGICAL}${FDISK_CMD_CREATE_LOGICAL}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout +ts_finalize_subtest + +ts_init_subtest "delete-logical-par" +echo -e "${FDISK_CMD_DELETE_LOGICALS}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout +ts_finalize_subtest + +ts_init_subtest "create-another-log-par" +echo -e "${FDISK_CMD_CREATE_LOGICAL}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout +ts_finalize_subtest + +ts_init_subtest "delete-primary-par" +echo -e "${FDISK_CMD_DELETE_PRIMARY}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout +ts_finalize_subtest + +ts_init_subtest "delete-extended-par" +echo -e "${FDISK_CMD_DELETE_EXTENDED}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/fdisk/mbr-nondos-mode b/tests/ts/fdisk/mbr-nondos-mode new file mode 100755 index 0000000..4db2064 --- /dev/null +++ b/tests/ts/fdisk/mbr-nondos-mode @@ -0,0 +1,190 @@ +#!/bin/bash + +# +# 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="MBR - non-dos mode" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FDISK" +ts_check_test_command "$TS_HELPER_MD5" + +# cmd to changes system id to 0x1 +FDISK_CMD_INIT="x\ni\n0x1\nr\n" +FDISK_CMD_WRITE_CLOSE="w\nq\n" +FDISK_CMD_CREATE_DOSLABEL="o\n" #create dos label +FDISK_CMD_CREATE_1PRIMARY="n\np\n\n\n+3M\n" # create primary partition of size 3MiB +FDISK_CMD_CREATE_2PRIMARY="n\np\n\n\n+2M\n" # create primary partition of size 2MiB +FDISK_CMD_SET_ACTIVE="a\n1\n" # set first partition active +FDISK_CMD_CREATE_EXTENDED="n\ne\n\n\n\n" # create extended partition +FDISK_CMD_CREATE_LOGICAL="n\nl\n\n+2M\n" # create next logical partition of size 10 sectors +FDISK_CMD_DELETE_LOGICALS="d\n6\nd\n5\nd\n6\n" # delete middle, head, tail, last partitions +FDISK_CMD_DELETE_1PRIMARY="d\n1\n" # delete first primary +FDISK_CMD_DELETE_2PRIMARY="d\n2\n" # delete first primary +FDISK_CMD_DELETE_EXTENDED="d\n3\n" # delete second primary + +# ignore architectures where MBR is not a default +ARCH=$(uname -m) +case $ARCH in + *sparc* ) + ts_skip "unsupported" + ;; + *) + ;; +esac + +function print_layout { + echo -ne "\n---layout----------\n" >> $TS_OUTPUT + $TS_CMD_FDISK -x ${TEST_IMAGE_NAME} >> $TS_OUTPUT + echo -ne "-------------------\n\n" >> $TS_OUTPUT + + ts_fdisk_clean ${TEST_IMAGE_NAME} +} + +#set -x + +ts_init_subtest "empty-pt" +ts_log "Initialize empty image" +TEST_IMAGE_NAME=$(ts_image_init 20) # 20 MiB +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +# need to run init twice, to change system ID after new label, otherwise system +# ID will be random and will screw up md5's +ts_log "Create new DOS partition table" +echo -e "${FDISK_CMD_CREATE_DOSLABEL}${FDISK_CMD_INIT}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK --noauto-pt ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG +print_layout +ts_finalize_subtest + + +ts_init_subtest "1st-primary" +ts_log "Create 1st primary partition" +echo -e "${FDISK_CMD_CREATE_1PRIMARY}${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG +print_layout +ts_finalize_subtest + + +ts_init_subtest "1st-active" +ts_log "Set primary partition active" +echo -e "${FDISK_CMD_SET_ACTIVE}${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG +print_layout +ts_finalize_subtest + + +ts_init_subtest "1st-primary-recreate" +ts_log "Re-create 1st primary partition" +echo -e "d\n${FDISK_CMD_CREATE_1PRIMARY}${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG +print_layout +ts_finalize_subtest + + +ts_init_subtest "2nd-primary" +ts_log "Create 2nd primary partition" +echo -e "${FDISK_CMD_CREATE_2PRIMARY}${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG +print_layout +ts_finalize_subtest + + +ts_init_subtest "extended" +ts_log "Create extended partition" +echo -e "${FDISK_CMD_CREATE_EXTENDED}${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG +print_layout +ts_finalize_subtest + + +ts_init_subtest "logical" +ts_log "Create logical partitions" +echo -e "${FDISK_CMD_CREATE_LOGICAL}${FDISK_CMD_CREATE_LOGICAL}${FDISK_CMD_CREATE_LOGICAL}${FDISK_CMD_CREATE_LOGICAL}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG +print_layout +ts_finalize_subtest + + +ts_init_subtest "logical-delete" +ts_log "Delete logical partitions" +echo -e "${FDISK_CMD_DELETE_LOGICALS}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG +print_layout +ts_finalize_subtest + + +ts_init_subtest "logical-recreate" +ts_log "Create another logical partition" +echo -e "${FDISK_CMD_CREATE_LOGICAL}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG +print_layout +ts_finalize_subtest + + +ts_init_subtest "1st-primary-delete" +ts_log "Delete primary partition" +echo -e "${FDISK_CMD_DELETE_1PRIMARY}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG +print_layout +ts_finalize_subtest + + +ts_init_subtest "1nd-primary-delete" +ts_log "Delete primary partition" +echo -e "${FDISK_CMD_DELETE_2PRIMARY}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG +print_layout +ts_finalize_subtest + + +ts_init_subtest "extended-delete" +ts_log "Delete extended partition" +echo -e "${FDISK_CMD_DELETE_EXTENDED}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK -c=dos -u=cylinders ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG +print_layout +ts_finalize_subtest + + +ts_init_subtest "first-sector-at-end" +ts_log "Create new DOS partition table (again)" +echo -e "${FDISK_CMD_INIT}${FDISK_CMD_CREATE_DOSLABEL}${FDISK_CMD_INIT}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null +ts_log "Create 1st primary at the end of device" +echo -e "n\np\n1\n20000\n\n${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null +print_layout + +ts_log "Create 2nd primary at the begin of device" +echo -e "n\np\n2\n\n\n${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${TEST_IMAGE_NAME} >> $TS_OUTPUT +print_layout +ts_finalize_subtest + + +ts_finalize diff --git a/tests/ts/fdisk/mbr-sort b/tests/ts/fdisk/mbr-sort new file mode 100755 index 0000000..6d0ec9e --- /dev/null +++ b/tests/ts/fdisk/mbr-sort @@ -0,0 +1,83 @@ +#!/bin/bash + +# +# 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="MBR - sort" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FDISK" + +# cmd to changes system id to 0x1 +FDISK_CMD_WRITE_CLOSE="w\nq\n" +FDISK_CMD_CREATE_DOSLABEL="o\n" #create dos label + +FDISK_CMD_CREATE_1PRIMARY="n\np\n1\n4096\n6143\n" +FDISK_CMD_CREATE_2PRIMARY="n\np\n2\n2048\n4095\n" +FDISK_CMD_CREATE_3PRIMARY="n\np\n3\n6144\n8191\n" +FDISK_CMD_CREATE_EXTENDED="n\ne\n\n\n" + +FDISK_CMD_CREATE_1LOGICAL="n\n14336\n16383\n" +FDISK_CMD_CREATE_2LOGICAL="n\n22528\n24575\n" +FDISK_CMD_CREATE_3LOGICAL="n\n18432\n20479\n" +FDISK_CMD_CREATE_4LOGICAL="n\n10240\n12287\n" + +FDISK_CMD_EXPERT_SORT="x\nf\nr\n" + +function print_layout { + echo -ne "\n---layout----------\n" >> $TS_OUTPUT + $TS_CMD_FDISK -x ${TEST_IMAGE_NAME} >> $TS_OUTPUT + echo -ne "-------------------\n\n" >> $TS_OUTPUT + + ts_fdisk_clean ${TEST_IMAGE_NAME} +} + +#set -x + +ts_init_subtest "empty-pt" +TEST_IMAGE_NAME=$(ts_image_init 20) # 20 MiB + +echo -e "${FDISK_CMD_CREATE_DOSLABEL}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK --noauto-pt ${TEST_IMAGE_NAME} &> /dev/null + +print_layout +ts_finalize_subtest + +ts_init_subtest "create-primary-partitions" +echo -e "${FDISK_CMD_CREATE_1PRIMARY}${FDISK_CMD_CREATE_2PRIMARY}${FDISK_CMD_CREATE_3PRIMARY}${FDISK_CMD_CREATE_EXTENDED}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null + +print_layout +ts_finalize_subtest + + +ts_init_subtest "create-logical-partitions" +echo -e "${FDISK_CMD_CREATE_1LOGICAL}${FDISK_CMD_CREATE_2LOGICAL}${FDISK_CMD_CREATE_3LOGICAL}${FDISK_CMD_CREATE_4LOGICAL}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null + +print_layout +ts_finalize_subtest + + +ts_init_subtest "fix-order" +echo -e "${FDISK_CMD_EXPERT_SORT}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null + +print_layout +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/fdisk/oddinput b/tests/ts/fdisk/oddinput new file mode 100755 index 0000000..9b55d75 --- /dev/null +++ b/tests/ts/fdisk/oddinput @@ -0,0 +1,53 @@ +#!/bin/bash + +# +# 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="invalid input tests" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FDISK" +ts_check_test_command "$TS_HELPER_MD5" + +#set -x + +ts_log "---Initialize empty image" +TEST_IMAGE_NAME=$(ts_image_init 10) +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +# +# Note that since 2.23 the DOS-mode has effect only if there is a MBR on the device. +# + +ts_log "---Empty image listing" # this should report empty partition table +# TEST_IMAGE_NAME has absolute path, and is by definition different on each computer, we need to sed it away +$TS_CMD_FDISK -c=dos -u=cylinders -x ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +sed -i -e "s/${TEST_IMAGE_NAME//\//\\/}/testimage/" $TS_OUTPUT $TS_ERRLOG + +# +# Errors +# +ts_logerr "---Nonexistent file" +$TS_CMD_FDISK -c=dos -u=cylinders -x _a_file_that_does_not_exist_ >> $TS_OUTPUT 2>> $TS_ERRLOG +sed -i -e "s@$($TS_HELPER_STRERROR ENOENT)@ENOENT@" $TS_OUTPUT $TS_ERRLOG + +ts_logerr "---Too small file" +echo "This file is too small" >> oddinput.toosmall +$TS_CMD_FDISK -c=dos -u=cylinders -x oddinput.toosmall >> $TS_OUTPUT 2>> $TS_ERRLOG +sed -i -e "s@$($TS_HELPER_STRERROR EINVAL)@EINVAL@" $TS_OUTPUT $TS_ERRLOG +rm oddinput.toosmall +ts_finalize diff --git a/tests/ts/fdisk/sunlabel b/tests/ts/fdisk/sunlabel new file mode 100755 index 0000000..ead0aac --- /dev/null +++ b/tests/ts/fdisk/sunlabel @@ -0,0 +1,104 @@ +#!/bin/bash + +# +# 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="sunlabel tests" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FDISK" +ts_check_test_command "$TS_HELPER_MD5" + +FDISK_CMD_INIT="s\n" # create new sunlabel +FDISK_CMD_WRITE_CLOSE="w\nq\n" +FDISK_CMD_DELETEALL="d\n1\nd\n2\nd\n3\nd\n4\nd\n5\nd\n6\nd\n7\nd\n8\n" # delete all partitions + +FDISK_CMD_CREATE_PRIMARY="n\n\n\n128\n" # create first partition +FDISK_CMD_TOGGLE_READONLY="a\n1\n" # sets first partition as read-only +FDISK_CMD_TOGGLE_MOUNTABLE="c\n1\n" # sets first partition as mountable +FDISK_CMD_CHANGE_SYSID="t\n4\n" # changes sysid to 4 (SunOS usr) +FDISK_CMD_CREATE_SECONDARY="n\n2\n128\n\n" # create secondary partition to the end of disk + +FDISK_OPTIONS="-H 1 -S 63 -u=cylinders" + +function print_layout { + $TS_CMD_FDISK ${FDISK_OPTIONS} -x ${TEST_IMAGE_NAME} >> $TS_OUTPUT + ts_fdisk_clean ${TEST_IMAGE_NAME} +} + +#set -x + +ts_init_subtest "empty-sun-pt" +TEST_IMAGE_NAME=$(ts_image_init 10) +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +echo -e "${FDISK_CMD_INIT}${FDISK_CMD_DELETEALL}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK --noauto-pt ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout +ts_finalize_subtest + + +ts_init_subtest "create-first-partition" +echo -e "${FDISK_CMD_CREATE_PRIMARY}${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout +ts_finalize_subtest + +ts_init_subtest "set-partition-sysid" +echo -e "${FDISK_CMD_CHANGE_SYSID}${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout +ts_finalize_subtest + +ts_init_subtest "set-first-par-readonly" +echo -e "${FDISK_CMD_TOGGLE_READONLY}${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout +ts_finalize_subtest + +ts_init_subtest "set-first-par-mountable" +echo -e "${FDISK_CMD_TOGGLE_MOUNTABLE}${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout +ts_finalize_subtest + +ts_init_subtest "create-second-partition" +echo -e "${FDISK_CMD_CREATE_SECONDARY}${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout +ts_finalize_subtest + +ts_init_subtest "delete-all-partitions" +echo -e "${FDISK_CMD_DELETEALL}${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +ts_finalize diff --git a/tests/ts/fincore/count b/tests/ts/fincore/count new file mode 100755 index 0000000..ba5f6cd --- /dev/null +++ b/tests/ts/fincore/count @@ -0,0 +1,230 @@ +#!/bin/bash + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="count file contents in core" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FINDMNT" +ts_check_test_command "$TS_HELPER_SYSINFO" + +FS="$("$TS_CMD_FINDMNT" -nr -o FSTYPE -T "$PWD")" +if [[ "$FS" = "tmpfs" ]]; then + ts_skip "fincore does not work on tmpfs" +fi + +function footer +{ + echo "return value: $1" +} + +function make_input_name +{ + header=$1 + prefix=i_ + echo ${prefix}$(sed -e "s/[^-+a-zA-Z0-9_]/_/g"<<<"$header") +} + +function _dd +{ + local msg + local ret=0 + + msg=$(dd "$@" 2>&1) + ret=$? + if [ $ret != 0 ]; then + echo "failed: dd $@" >&2 + echo "$msg" >&2 + fi + return $ret +} + +function check_dd_fs_feat +{ + local testf="$TS_OUTDIR/ddtest" + rm -f "$testf" + touch "$testf" + + # NFS seems to fail for direct AND append + _dd if=/dev/zero of="$testf" bs=1k count=2 oflag=direct,append &>/dev/null \ + || ts_skip "unsupported: dd oflag=direct,append" + + # TODO: Should we check for sparse file support? + + rm -f "$testf" +} + +function run_dd_test +{ + header=$1 + bs=$2 + flags=$3 + + input=$(make_input_name "$header") + INPUT="${INPUT} ${input}" + rm -f "$input" + + if [ "$bs" = 0 ]; then + touch $input + else + _dd if=/dev/zero of=$input count=1 bs=$bs $flags || return + fi + + $TS_CMD_FINCORE --output $OUT_COLUMNS --bytes --noheadings $input + + footer "$?" +} + +function run_dd_dd_test +{ + header=$1 + flags0=$2 + flags1=$3 + + bs=$PAGE_SIZE + + input=$(make_input_name "$header") + INPUT="${INPUT} ${input}" + rm -f "$input" + + _dd if=/dev/zero of=$input count=1 bs=$bs $flags0 || return + _dd if=/dev/zero of=$input count=1 bs=$bs $flags1 || return + + $TS_CMD_FINCORE --output $OUT_COLUMNS --bytes --noheadings $input + + footer "$?" +} + + +PAGE_SIZE=$($TS_HELPER_SYSINFO pagesize) +WINDOW_SIZE=$(( 32 * 1024 * PAGE_SIZE )) + +# we use PAGE_SIZE dependent output for a few systems +if test -f "$TS_EXPECTED.$PAGE_SIZE"; then + TS_EXPECTED+=".$PAGE_SIZE" + TS_EXPECTED_ERR+=".$PAGE_SIZE" + OUT_COLUMNS="PAGES,SIZE,FILE" +else + TS_EXPECTED+=".nosize" + OUT_COLUMNS="PAGES,FILE" +fi + + +ts_check_test_command "$TS_CMD_FINCORE" +ts_cd "$TS_OUTDIR" + +check_dd_fs_feat + +INPUT= +input= + +{ + input=no_such_file + INPUT="${INPUT} ${input}" + + ts_log_both "[ NO EXCITING FILE ]" + $TS_CMD_FINCORE --output $OUT_COLUMNS --bytes --noheadings $input + footer "$?" +} >> $TS_OUTPUT 2>> $TS_ERRLOG + +{ + run_dd_test "EMPTY FILE" 0 +} >> $TS_OUTPUT 2>> $TS_ERRLOG + +{ + run_dd_test "PAGESIZE -1 (incore)" $(( PAGE_SIZE - 1 )) +} >> $TS_OUTPUT 2>> $TS_ERRLOG + +{ + run_dd_test "JUST PAGESIZE(incore)" $(( PAGE_SIZE )) +} >> $TS_OUTPUT 2>> $TS_ERRLOG + +{ + run_dd_test "JUST PAGESIZE(directio)" $(( PAGE_SIZE )) "oflag=direct" +} >> $TS_OUTPUT 2>> $TS_ERRLOG + +{ + run_dd_test "TWO PAGES(incore)" $(( 2 * PAGE_SIZE )) +} >> $TS_OUTPUT 2>> $TS_ERRLOG + +{ + run_dd_test "TWO PAGES(directio)" $(( 2 * PAGE_SIZE )) "oflag=direct" +} >> $TS_OUTPUT 2>> $TS_ERRLOG + +{ + run_dd_dd_test "TWO PAGES(mixed directio/incore)" \ + oflag=direct \ + "oflag=append seek=1" +} >> $TS_OUTPUT 2>> $TS_ERRLOG + +{ + run_dd_dd_test "TWO PAGES(mixed incore/directio)" \ + "" \ + "oflag=direct,append seek=1" +} >> $TS_OUTPUT 2>> $TS_ERRLOG + +{ + hole_count=$(( WINDOW_SIZE / PAGE_SIZE - 2 )) + run_dd_dd_test "WINDOW SIZE(incore-sparse-incore)" \ + "" \ + "oflag=append seek=$hole_count" +} >> $TS_OUTPUT 2>> $TS_ERRLOG + +{ + hole_count=$(( WINDOW_SIZE / PAGE_SIZE - 2 )) + run_dd_dd_test "WINDOW SIZE(directio-sparse-directio)" \ + "oflag=direct" \ + "oflag=append,direct seek=$hole_count" +} >> $TS_OUTPUT 2>> $TS_ERRLOG + +{ + hole_count=$(( WINDOW_SIZE / PAGE_SIZE - 2 )) + run_dd_dd_test "WINDOW SIZE(incore-sparse-directio)" \ + "" \ + "oflag=append,direct seek=$hole_count" +} >> $TS_OUTPUT 2>> $TS_ERRLOG + +{ + hole_count=$(( WINDOW_SIZE / PAGE_SIZE - 2 )) + run_dd_dd_test "WINDOW SIZE(directio-sparse-incore)" \ + "oflag=direct" \ + "oflag=append seek=$hole_count" +} >> $TS_OUTPUT 2>> $TS_ERRLOG + +{ + hole_count=$(( WINDOW_SIZE / PAGE_SIZE - 1 )) + run_dd_dd_test "WINDOW SIZE + 1 page(incore-sparse-incore)" \ + "" \ + "oflag=append seek=$hole_count" +} >> $TS_OUTPUT 2>> $TS_ERRLOG + +{ + hole_count=$(( WINDOW_SIZE / PAGE_SIZE - 1 )) + run_dd_dd_test "WINDOW SIZE + 1 page(directio-sparse-directio)" \ + "oflag=direct" \ + "oflag=append,direct seek=$hole_count" +} >> $TS_OUTPUT 2>> $TS_ERRLOG + +{ + hole_count=$(( WINDOW_SIZE / PAGE_SIZE - 1 )) + run_dd_dd_test "WINDOW SIZE + 1 page(incore-sparse-directio)" \ + "" \ + "oflag=append,direct seek=$hole_count" +} >> $TS_OUTPUT 2>> $TS_ERRLOG + +{ + hole_count=$(( WINDOW_SIZE / PAGE_SIZE - 1 )) + run_dd_dd_test "WINDOW SIZE + 1 page(directio-sparse-incore)" \ + "oflag=direct" \ + "oflag=append seek=$hole_count" +} >> $TS_OUTPUT 2>> $TS_ERRLOG + +{ + ts_log_both "[ MULTIPLE FILES ]" + $TS_CMD_FINCORE --output $OUT_COLUMNS --bytes $INPUT + footer "$?" +} >> $TS_OUTPUT 2>> $TS_ERRLOG + +rm -f $INPUT +ts_finalize diff --git a/tests/ts/findmnt/files/mountinfo b/tests/ts/findmnt/files/mountinfo new file mode 100644 index 0000000..ff1e664 --- /dev/null +++ b/tests/ts/findmnt/files/mountinfo @@ -0,0 +1,32 @@ +15 20 0:3 / /proc rw,relatime - proc /proc rw +16 20 0:15 / /sys rw,relatime - sysfs /sys rw +17 20 0:5 / /dev rw,relatime - devtmpfs udev rw,size=1983516k,nr_inodes=495879,mode=755 +18 17 0:10 / /dev/pts rw,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000 +19 17 0:16 / /dev/shm rw,relatime - tmpfs tmpfs rw +20 1 8:4 / / rw,noatime - ext3 /dev/sda4 rw,errors=continue,user_xattr,acl,barrier=0,data=ordered +21 16 0:17 / /sys/fs/cgroup rw,nosuid,nodev,noexec,relatime - tmpfs tmpfs rw,mode=755 +22 21 0:18 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd +23 21 0:19 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpuset +24 21 0:20 / /sys/fs/cgroup/ns rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,ns +25 21 0:21 / /sys/fs/cgroup/cpu rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpu +26 21 0:22 / /sys/fs/cgroup/cpuacct rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpuacct +27 21 0:23 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,memory +28 21 0:24 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,devices +29 21 0:25 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,freezer +30 21 0:26 / /sys/fs/cgroup/net_cls rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,net_cls +31 21 0:27 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,blkio +32 16 0:28 / /sys/kernel/security rw,relatime - autofs systemd-1 rw,fd=22,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +33 17 0:29 / /dev/hugepages rw,relatime - autofs systemd-1 rw,fd=23,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +34 16 0:30 / /sys/kernel/debug rw,relatime - autofs systemd-1 rw,fd=24,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +35 15 0:31 / /proc/sys/fs/binfmt_misc rw,relatime - autofs systemd-1 rw,fd=25,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +36 17 0:32 / /dev/mqueue rw,relatime - autofs systemd-1 rw,fd=26,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +37 15 0:14 / /proc/bus/usb rw,relatime - usbfs /proc/bus/usb rw +38 33 0:33 / /dev/hugepages rw,relatime - hugetlbfs hugetlbfs rw +39 36 0:12 / /dev/mqueue rw,relatime - mqueue mqueue rw +40 20 8:6 / /boot rw,noatime - ext3 /dev/sda6 rw,errors=continue,barrier=0,data=ordered +41 20 253:0 / /home/kzak rw,noatime - ext4 /dev/mapper/kzak-home rw,barrier=1,data=ordered +42 35 0:34 / /proc/sys/fs/binfmt_misc rw,relatime - binfmt_misc none rw +43 16 0:35 / /sys/fs/fuse/connections rw,relatime - fusectl fusectl rw +44 41 0:36 / /home/kzak/.gvfs rw,nosuid,nodev,relatime - fuse.gvfs-fuse-daemon gvfs-fuse-daemon rw,user_id=500,group_id=500 +45 20 0:37 / /var/lib/nfs/rpc_pipefs rw,relatime - rpc_pipefs sunrpc rw +47 20 0:38 / /mnt/sounds rw,relatime - cifs //foo.home/bar/ rw,unc=\\foo.home\bar,username=kzak,domain=SRGROUP,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.111.1,posixpaths,serverino,acl,rsize=16384,wsize=57344 diff --git a/tests/ts/findmnt/files/mountinfo-messy b/tests/ts/findmnt/files/mountinfo-messy new file mode 100644 index 0000000..6e2ac9d --- /dev/null +++ b/tests/ts/findmnt/files/mountinfo-messy @@ -0,0 +1,29 @@ +220 189 8:3 /arch / rw,relatime shared:50 - ext4 /dev/sda3 rw +221 220 0:17 / /sys ro,nosuid,nodev,noexec,relatime shared:51 - sysfs sysfs rw +222 220 0:52 / /dev rw,nosuid shared:52 - tmpfs tmpfs rw,mode=755 +223 222 0:53 / /dev/shm rw,nosuid,nodev shared:53 - tmpfs tmpfs rw +224 222 0:56 / /dev/pts rw,nosuid,noexec,relatime shared:56 - devpts devpts rw,gid=5,mode=620,ptmxmode=666 +225 222 0:21 /5 /dev/console rw,nosuid,noexec,relatime shared:57 master:4 - devpts devpts rw,gid=5,mode=620,ptmxmode=000 +226 220 0:54 / /run rw,nosuid,nodev shared:54 - tmpfs tmpfs rw,mode=755 +227 226 0:18 /systemd/nspawn/propagate/arch /run/systemd/nspawn/incoming ro,relatime master:11 - tmpfs run rw,mode=755 +228 220 0:55 / /tmp rw shared:55 - tmpfs tmpfs rw +231 220 0:58 / /proc rw,nosuid,nodev,noexec,relatime shared:58 - proc proc rw +232 231 0:58 /sys /proc/sys ro,nosuid,nodev,noexec,relatime shared:58 - proc proc rw +233 231 0:58 /sysrq-trigger /proc/sysrq-trigger ro,nosuid,nodev,noexec,relatime shared:58 - proc proc rw +93 221 0:59 / /sys/fs/cgroup ro,nosuid,nodev,noexec shared:59 - tmpfs tmpfs ro,mode=755 +94 93 0:29 / /sys/fs/cgroup/perf_event ro,nosuid,nodev,noexec,relatime shared:60 - cgroup cgroup rw,perf_event +95 93 0:31 / /sys/fs/cgroup/net_cls ro,nosuid,nodev,noexec,relatime shared:61 - cgroup cgroup rw,net_cls +96 93 0:30 / /sys/fs/cgroup/blkio ro,nosuid,nodev,noexec,relatime shared:62 - cgroup cgroup rw,blkio +98 93 0:33 / /sys/fs/cgroup/memory ro,nosuid,nodev,noexec,relatime shared:63 - cgroup cgroup rw,memory +99 93 0:32 / /sys/fs/cgroup/pids ro,nosuid,nodev,noexec,relatime shared:64 - cgroup cgroup rw,pids +100 93 0:27 / /sys/fs/cgroup/cpuset ro,nosuid,nodev,noexec,relatime shared:65 - cgroup cgroup rw,cpuset +101 93 0:25 / /sys/fs/cgroup/freezer ro,nosuid,nodev,noexec,relatime shared:66 - cgroup cgroup rw,freezer +102 93 0:28 / /sys/fs/cgroup/cpu,cpuacct ro,nosuid,nodev,noexec,relatime shared:67 - cgroup cgroup rw,cpu,cpuacct +103 93 0:26 / /sys/fs/cgroup/devices ro,nosuid,nodev,noexec,relatime shared:68 - cgroup cgroup rw,devices +104 93 0:23 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime shared:69 - cgroup cgroup rw,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd +105 232 0:54 /proc-sys-kernel-random-boot-id//deleted /proc/sys/kernel/random/boot_id ro,nosuid,nodev shared:54 - tmpfs tmpfs rw,mode=755 +106 231 0:54 /proc-sys-kernel-random-boot-id//deleted /proc/sys/kernel/random/boot_id rw,nosuid,nodev shared:54 - tmpfs tmpfs rw,mode=755 +107 231 0:54 /kmsg//deleted /proc/kmsg rw,nosuid,nodev shared:54 - tmpfs tmpfs rw,mode=755 +97 222 0:57 / /dev/mqueue rw,relatime shared:70 - mqueue mqueue rw +108 222 0:60 / /dev/hugepages rw,relatime shared:71 - hugetlbfs hugetlbfs rw +109 226 0:61 / /run/user/0 rw,nosuid,nodev,relatime shared:72 - tmpfs tmpfs rw,size=1634120k,mode=700 diff --git a/tests/ts/findmnt/files/mountinfo-nonroot b/tests/ts/findmnt/files/mountinfo-nonroot new file mode 100644 index 0000000..87b421d --- /dev/null +++ b/tests/ts/findmnt/files/mountinfo-nonroot @@ -0,0 +1,31 @@ +15 20 0:3 / /proc rw,relatime - proc /proc rw +16 20 0:15 / /sys rw,relatime - sysfs /sys rw +17 20 0:5 / /dev rw,relatime - devtmpfs udev rw,size=1983516k,nr_inodes=495879,mode=755 +18 17 0:10 / /dev/pts rw,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000 +19 17 0:16 / /dev/shm rw,relatime - tmpfs tmpfs rw +21 16 0:17 / /sys/fs/cgroup rw,nosuid,nodev,noexec,relatime - tmpfs tmpfs rw,mode=755 +22 21 0:18 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd +23 21 0:19 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpuset +24 21 0:20 / /sys/fs/cgroup/ns rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,ns +25 21 0:21 / /sys/fs/cgroup/cpu rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpu +26 21 0:22 / /sys/fs/cgroup/cpuacct rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpuacct +27 21 0:23 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,memory +28 21 0:24 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,devices +29 21 0:25 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,freezer +30 21 0:26 / /sys/fs/cgroup/net_cls rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,net_cls +31 21 0:27 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,blkio +32 16 0:28 / /sys/kernel/security rw,relatime - autofs systemd-1 rw,fd=22,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +33 17 0:29 / /dev/hugepages rw,relatime - autofs systemd-1 rw,fd=23,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +34 16 0:30 / /sys/kernel/debug rw,relatime - autofs systemd-1 rw,fd=24,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +35 15 0:31 / /proc/sys/fs/binfmt_misc rw,relatime - autofs systemd-1 rw,fd=25,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +36 17 0:32 / /dev/mqueue rw,relatime - autofs systemd-1 rw,fd=26,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +37 15 0:14 / /proc/bus/usb rw,relatime - usbfs /proc/bus/usb rw +38 33 0:33 / /dev/hugepages rw,relatime - hugetlbfs hugetlbfs rw +39 36 0:12 / /dev/mqueue rw,relatime - mqueue mqueue rw +40 20 8:6 / /boot rw,noatime - ext3 /dev/sda6 rw,errors=continue,barrier=0,data=ordered +41 20 253:0 / /home/kzak rw,noatime - ext4 /dev/mapper/kzak-home rw,barrier=1,data=ordered +42 35 0:34 / /proc/sys/fs/binfmt_misc rw,relatime - binfmt_misc none rw +43 16 0:35 / /sys/fs/fuse/connections rw,relatime - fusectl fusectl rw +44 41 0:36 / /home/kzak/.gvfs rw,nosuid,nodev,relatime - fuse.gvfs-fuse-daemon gvfs-fuse-daemon rw,user_id=500,group_id=500 +45 20 0:37 / /var/lib/nfs/rpc_pipefs rw,relatime - rpc_pipefs sunrpc rw +47 20 0:38 / /mnt/sounds rw,relatime - cifs //foo.home/bar/ rw,unc=\\foo.home\bar,username=kzak,domain=SRGROUP,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.111.1,posixpaths,serverino,acl,rsize=16384,wsize=57344 diff --git a/tests/ts/findmnt/filter b/tests/ts/findmnt/filter new file mode 100755 index 0000000..8b24292 --- /dev/null +++ b/tests/ts/findmnt/filter @@ -0,0 +1,79 @@ +#!/bin/bash + +# 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="filter" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FINDMNT" + +ts_init_subtest "types" +$TS_CMD_FINDMNT --types ext3 --kernel --tab-file "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +echo rc=$? >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "types-multi" +$TS_CMD_FINDMNT --types ext3,ext4, --kernel --tab-file "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +echo rc=$? >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "types-neg" +$TS_CMD_FINDMNT --types noext3,ext4, --kernel --tab-file "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +echo rc=$? >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "options" +$TS_CMD_FINDMNT --options relatime --kernel --tab-file "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +echo rc=$? >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "options-name" +$TS_CMD_FINDMNT --options fd --kernel --tab-file "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +echo rc=$? >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "options-nameval" +$TS_CMD_FINDMNT --options "fd=22" --kernel --tab-file "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +echo rc=$? >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "options-nameval-neg" +$TS_CMD_FINDMNT --options "nofd=22" --kernel --tab-file "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +echo rc=$? >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "options-nameval-multi" +$TS_CMD_FINDMNT --options "gid=5,mode=620,ptmxmode=000" --kernel --tab-file "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +echo rc=$? >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "options-neg" +$TS_CMD_FINDMNT --options norelatime --kernel --tab-file "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +echo rc=$? >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "options-no" +$TS_CMD_FINDMNT --options +noatime --kernel --tab-file "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +echo rc=$? >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "options-no-multi" +$TS_CMD_FINDMNT --options +nosuid,+nodev,blkio --kernel --tab-file "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +echo rc=$? >> $TS_OUTPUT +ts_finalize_subtest + + +ts_finalize diff --git a/tests/ts/findmnt/outputs b/tests/ts/findmnt/outputs new file mode 100755 index 0000000..83c9134 --- /dev/null +++ b/tests/ts/findmnt/outputs @@ -0,0 +1,49 @@ +#!/bin/bash + +# 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="outputs" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FINDMNT" + + +ts_init_subtest "default" +$TS_CMD_FINDMNT --tab-file "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +echo rc=$? >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "kernel" +$TS_CMD_FINDMNT --kernel --tab-file "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +echo rc=$? >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "force-tree" +$TS_CMD_FINDMNT --tree --kernel --tab-file "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +echo rc=$? >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "submounts" +$TS_CMD_FINDMNT /sys --submounts --kernel --tab-file "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +echo rc=$? >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "messy-mountinfo" +$TS_CMD_FINDMNT --tab-file "$TS_SELF/files/mountinfo-messy" &> $TS_OUTPUT +echo rc=$? >> $TS_OUTPUT +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/findmnt/target b/tests/ts/findmnt/target new file mode 100755 index 0000000..6b4136d --- /dev/null +++ b/tests/ts/findmnt/target @@ -0,0 +1,35 @@ +#!/bin/bash + +# 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="target" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FINDMNT" + + +ts_init_subtest "root" +$TS_CMD_FINDMNT --target "/" --kernel --tab-file "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +echo rc=$? >> $TS_OUTPUT +ts_finalize_subtest + + +ts_init_subtest "non-root" +$TS_CMD_FINDMNT --target "/" --kernel --tab-file "$TS_SELF/files/mountinfo-nonroot" &> $TS_OUTPUT +echo rc=$? >> $TS_OUTPUT +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/fsck/ismounted b/tests/ts/fsck/ismounted new file mode 100755 index 0000000..477ac4b --- /dev/null +++ b/tests/ts/fsck/ismounted @@ -0,0 +1,49 @@ +#!/bin/bash +# +# Copyright (C) 2009 Karel Zak +# +# 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="is mounted" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" +ts_check_test_command "$TS_HELPER_ISMOUNTED" + +ts_skip_nonroot +ts_check_losetup +ts_check_prog "mkfs.ext2" + +> $TS_OUTPUT + +ts_device_init +DEVICE=$TS_LODEV + +mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE" + +ts_device_has "TYPE" "ext2" $DEVICE || ts_die "Cannot find ext2 on $DEVICE" + +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + +$TS_CMD_MOUNT $DEVICE $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG + +# test by ismounted.c +$TS_HELPER_ISMOUNTED $DEVICE | awk '{print $1}' >> $TS_OUTPUT 2>> $TS_ERRLOG + +$TS_CMD_UMOUNT $DEVICE || ts_die "Cannot umount $DEVICE" + +ts_finalize diff --git a/tests/ts/fuzzers/test_blkid_fuzz b/tests/ts/fuzzers/test_blkid_fuzz new file mode 100755 index 0000000..7ce89bc --- /dev/null +++ b/tests/ts/fuzzers/test_blkid_fuzz @@ -0,0 +1,29 @@ +#!/bin/bash + +# 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="test_blkid_fuzz" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_BLKID_FUZZ" + +ASAN_RT_PATH="$(ts_get_asan_rt_path "$TS_HELPER_BLKID_FUZZ")" +[ -n "$ASAN_RT_PATH" ] && export LD_PRELOAD="$ASAN_RT_PATH:$LD_PRELOAD" + +mkdir -p ${TS_OUTPUT}_workdir ${TS_SCRIPT}_files +ts_run $TS_HELPER_BLKID_FUZZ ${TS_OUTPUT}_workdir ${TS_SCRIPT}_files -max_total_time=10 >$TS_OUTPUT 2>$TS_ERRLOG + +ts_finalize diff --git a/tests/ts/fuzzers/test_blkid_fuzz_files/oss-fuzz-53142 b/tests/ts/fuzzers/test_blkid_fuzz_files/oss-fuzz-53142 new file mode 100644 index 0000000..b671bcd Binary files /dev/null and b/tests/ts/fuzzers/test_blkid_fuzz_files/oss-fuzz-53142 differ diff --git a/tests/ts/fuzzers/test_blkid_fuzz_files/oss-fuzz-53149 b/tests/ts/fuzzers/test_blkid_fuzz_files/oss-fuzz-53149 new file mode 100644 index 0000000..f1c6c3c Binary files /dev/null and b/tests/ts/fuzzers/test_blkid_fuzz_files/oss-fuzz-53149 differ diff --git a/tests/ts/fuzzers/test_blkid_fuzz_files/oss-fuzz-53160 b/tests/ts/fuzzers/test_blkid_fuzz_files/oss-fuzz-53160 new file mode 100644 index 0000000..b3586ec Binary files /dev/null and b/tests/ts/fuzzers/test_blkid_fuzz_files/oss-fuzz-53160 differ diff --git a/tests/ts/fuzzers/test_blkid_fuzz_files/oss-fuzz-55282 b/tests/ts/fuzzers/test_blkid_fuzz_files/oss-fuzz-55282 new file mode 100644 index 0000000..b4bb8d7 Binary files /dev/null and b/tests/ts/fuzzers/test_blkid_fuzz_files/oss-fuzz-55282 differ diff --git a/tests/ts/fuzzers/test_blkid_fuzz_files/oss-fuzz-55291 b/tests/ts/fuzzers/test_blkid_fuzz_files/oss-fuzz-55291 new file mode 100644 index 0000000..79e2fd0 Binary files /dev/null and b/tests/ts/fuzzers/test_blkid_fuzz_files/oss-fuzz-55291 differ diff --git a/tests/ts/fuzzers/test_blkid_fuzz_files/oss-fuzz-55318 b/tests/ts/fuzzers/test_blkid_fuzz_files/oss-fuzz-55318 new file mode 100644 index 0000000..36b07a9 Binary files /dev/null and b/tests/ts/fuzzers/test_blkid_fuzz_files/oss-fuzz-55318 differ diff --git a/tests/ts/fuzzers/test_blkid_fuzz_files/oss-fuzz-62691 b/tests/ts/fuzzers/test_blkid_fuzz_files/oss-fuzz-62691 new file mode 100644 index 0000000..9d10ae3 Binary files /dev/null and b/tests/ts/fuzzers/test_blkid_fuzz_files/oss-fuzz-62691 differ diff --git a/tests/ts/fuzzers/test_fdisk_script_fuzz b/tests/ts/fuzzers/test_fdisk_script_fuzz new file mode 100755 index 0000000..44f2d6a --- /dev/null +++ b/tests/ts/fuzzers/test_fdisk_script_fuzz @@ -0,0 +1,29 @@ +#!/bin/bash + +# 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="test_fdisk_script_fuzz" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_LIBFDISK_SCRIPT_FUZZ" + +ASAN_RT_PATH="$(ts_get_asan_rt_path "$TS_HELPER_LIBFDISK_SCRIPT_FUZZ")" +[ -n "$ASAN_RT_PATH" ] && export LD_PRELOAD="$ASAN_RT_PATH:$LD_PRELOAD" + +mkdir -p ${TS_OUTPUT}_workdir +ts_run $TS_HELPER_LIBFDISK_SCRIPT_FUZZ ${TS_OUTPUT}_workdir ${TS_SCRIPT}_files -max_total_time=10 >$TS_OUTPUT 2>$TS_ERRLOG + +ts_finalize diff --git a/tests/ts/fuzzers/test_fdisk_script_fuzz_files/crash-8ae1c667bed4b4b864f62e78cded81d5083177eb b/tests/ts/fuzzers/test_fdisk_script_fuzz_files/crash-8ae1c667bed4b4b864f62e78cded81d5083177eb new file mode 100644 index 0000000..66aafba --- /dev/null +++ b/tests/ts/fuzzers/test_fdisk_script_fuzz_files/crash-8ae1c667bed4b4b864f62e78cded81d5083177eb @@ -0,0 +1 @@ +Id=tÎ] \ No newline at end of file diff --git a/tests/ts/fuzzers/test_fdisk_script_fuzz_files/crash-d216dfd17039a189c3858d78fbcf588695439b3b b/tests/ts/fuzzers/test_fdisk_script_fuzz_files/crash-d216dfd17039a189c3858d78fbcf588695439b3b new file mode 100644 index 0000000..5805924 --- /dev/null +++ b/tests/ts/fuzzers/test_fdisk_script_fuzz_files/crash-d216dfd17039a189c3858d78fbcf588695439b3b @@ -0,0 +1 @@ +0z \ No newline at end of file diff --git a/tests/ts/fuzzers/test_fdisk_script_fuzz_files/github-1015-1 b/tests/ts/fuzzers/test_fdisk_script_fuzz_files/github-1015-1 new file mode 100644 index 0000000..1827bdf Binary files /dev/null and b/tests/ts/fuzzers/test_fdisk_script_fuzz_files/github-1015-1 differ diff --git a/tests/ts/fuzzers/test_fdisk_script_fuzz_files/github-1015-2 b/tests/ts/fuzzers/test_fdisk_script_fuzz_files/github-1015-2 new file mode 100644 index 0000000..961ac8a --- /dev/null +++ b/tests/ts/fuzzers/test_fdisk_script_fuzz_files/github-1015-2 @@ -0,0 +1,2 @@ +:=0M +, diff --git a/tests/ts/fuzzers/test_fdisk_script_fuzz_files/oss-fuzz-24589 b/tests/ts/fuzzers/test_fdisk_script_fuzz_files/oss-fuzz-24589 new file mode 100644 index 0000000..96d8c6c --- /dev/null +++ b/tests/ts/fuzzers/test_fdisk_script_fuzz_files/oss-fuzz-24589 @@ -0,0 +1,2 @@ +device:ÿ +- \ No newline at end of file diff --git a/tests/ts/fuzzers/test_fdisk_script_fuzz_files/oss-fuzz-24861 b/tests/ts/fuzzers/test_fdisk_script_fuzz_files/oss-fuzz-24861 new file mode 100644 index 0000000..be8baa6 --- /dev/null +++ b/tests/ts/fuzzers/test_fdisk_script_fuzz_files/oss-fuzz-24861 @@ -0,0 +1 @@ +name=;name=ÿ \ No newline at end of file diff --git a/tests/ts/fuzzers/test_fdisk_script_fuzz_files/parse_line_valcommas-use-of-uninitialized-value b/tests/ts/fuzzers/test_fdisk_script_fuzz_files/parse_line_valcommas-use-of-uninitialized-value new file mode 100644 index 0000000..cf4c8e4 --- /dev/null +++ b/tests/ts/fuzzers/test_fdisk_script_fuzz_files/parse_line_valcommas-use-of-uninitialized-value @@ -0,0 +1 @@ +,- \ No newline at end of file diff --git a/tests/ts/fuzzers/test_last_fuzz b/tests/ts/fuzzers/test_last_fuzz new file mode 100755 index 0000000..c121aba --- /dev/null +++ b/tests/ts/fuzzers/test_last_fuzz @@ -0,0 +1,29 @@ +#!/bin/bash + +# 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="test_last_fuzz" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_LAST_FUZZ" + +ASAN_RT_PATH="$(ts_get_asan_rt_path "$TS_HELPER_LAST_FUZZ")" +[ -n "$ASAN_RT_PATH" ] && export LD_PRELOAD="$ASAN_RT_PATH:$LD_PRELOAD" + +mkdir -p ${TS_OUTPUT}_workdir +ts_run $TS_HELPER_LAST_FUZZ ${TS_OUTPUT}_workdir ${TS_SCRIPT}_files -max_total_time=10 >$TS_OUTPUT 2>$TS_ERRLOG + +ts_finalize diff --git a/tests/ts/fuzzers/test_last_fuzz_files/github-1097 b/tests/ts/fuzzers/test_last_fuzz_files/github-1097 new file mode 100644 index 0000000..fbd7dbf Binary files /dev/null and b/tests/ts/fuzzers/test_last_fuzz_files/github-1097 differ diff --git a/tests/ts/fuzzers/test_mount_fuzz b/tests/ts/fuzzers/test_mount_fuzz new file mode 100755 index 0000000..3fcf599 --- /dev/null +++ b/tests/ts/fuzzers/test_mount_fuzz @@ -0,0 +1,29 @@ +#!/bin/bash + +# 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="test_mount_fuzz" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_LIBMOUNT_FUZZ" + +ASAN_RT_PATH="$(ts_get_asan_rt_path "$TS_HELPER_LIBMOUNT_FUZZ")" +[ -n "$ASAN_RT_PATH" ] && export LD_PRELOAD="$ASAN_RT_PATH:$LD_PRELOAD" + +mkdir -p ${TS_OUTPUT}_workdir +ts_run $TS_HELPER_LIBMOUNT_FUZZ ${TS_OUTPUT}_workdir ${TS_SCRIPT}_files -max_total_time=10 >$TS_OUTPUT 2>$TS_ERRLOG + +ts_finalize diff --git a/tests/ts/fuzzers/test_mount_fuzz_files/oss-fuzz-23722 b/tests/ts/fuzzers/test_mount_fuzz_files/oss-fuzz-23722 new file mode 100644 index 0000000..f66c9cf Binary files /dev/null and b/tests/ts/fuzzers/test_mount_fuzz_files/oss-fuzz-23722 differ diff --git a/tests/ts/getopt/basic b/tests/ts/getopt/basic new file mode 100755 index 0000000..f73695f --- /dev/null +++ b/tests/ts/getopt/basic @@ -0,0 +1,49 @@ +#!/bin/bash + +# 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. + +# This test script is modified version of 'getopt-example.bash' example +# file in misc/ directory. + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="basic" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_GETOPT" + +TEMP=$($TS_CMD_GETOPT -o ab:c:: --long a-long,b-long:,c-long:: -n 'example.bash' -- -a -b 1 -c2 --a-long --b-long 3 --c-long foo bar) + +if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi + +eval set -- "$TEMP" + +while true ; do + case "$1" in + -a|--a-long) echo "Option a"; shift ;; + -b|--b-long) echo "Option b, argument \`$2'"; shift 2 ;; + -c|--c-long) + case "$2" in + "") echo "Option c, no argument"; shift 2 ;; + *) echo "Option c, argument \`$2'"; shift 2 ;; + esac ;; + --) shift ; break ;; + *) echo "Internal error!"; break;; + esac +done >> $TS_OUTPUT 2>> $TS_ERRLOG + +echo "Remaining arguments:" >> $TS_OUTPUT 2>> $TS_ERRLOG +for arg do echo '--> '"\`$arg'" >> $TS_OUTPUT 2>> $TS_ERRLOG; done + +ts_finalize diff --git a/tests/ts/getopt/options b/tests/ts/getopt/options new file mode 100755 index 0000000..b245b32 --- /dev/null +++ b/tests/ts/getopt/options @@ -0,0 +1,231 @@ +#!/bin/bash + +# 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="options" + +. "$TS_TOPDIR"/functions.sh + +ts_init "$*" +ts_check_test_command "$TS_CMD_GETOPT" + +export LANG=C + +function gnu_getopt_clean() { + sed --in-place \ + -e "s/: \(.*\) -- \(.\)$/: \1 -- '\2'/" \ + -e "s/ ['\`]\(--[a-zA-Z0-9]\{1,\}\)'/ '\1'/g" \ + -e "s/unrecognized option: \(.\)$/invalid option -- '\1'/" \ + -e "s/option requires an argument: \(.\)$/option requires an argument -- '\1'/" \ + -e "s/unrecognized option: \([^'-].\{1,\}\)$/unrecognized option '--\1'/" \ + $TS_OUTPUT $TS_ERRLOG +} + +ts_init_subtest alternative_option_clash +$TS_CMD_GETOPT -a -o abcde -l abcde -- -a -ab -abc -ac >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +gnu_getopt_clean +ts_finalize_subtest + +ts_init_subtest alternative_option_long +$TS_CMD_GETOPT --alternative -o a -l one,two:,three::,four:: -- -a -one -two=MANDATORY -three=OPTIONAL >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +gnu_getopt_clean +ts_finalize_subtest + +ts_init_subtest alternative_option_short +$TS_CMD_GETOPT -a -o a -l one,two:,three::,four:: -- -a -one -two=MANDATORY -three=OPTIONAL >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +gnu_getopt_clean +ts_finalize_subtest + +ts_init_subtest invalid_getopt_option +$TS_CMD_GETOPT -b >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +sed -i '1,1s/.*\///' $TS_OUTPUT $TS_ERRLOG +gnu_getopt_clean +ts_finalize_subtest + +ts_init_subtest invocation_model_one +$TS_CMD_GETOPT abc:d::e::f::g: ARG0 -b ARG1 -d -eOPTIONAL1 -f NOT_OPTIONAL ARG2 -a -c -ISREQUIRED ARG3 -g "BECOMES THREE ARGUMENTS" >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +gnu_getopt_clean +ts_finalize_subtest + +ts_init_subtest invocation_model_three_as_one +$TS_CMD_GETOPT -o abc:d::e::f::g: -- ARG0 -b ARG1 -d -eOPTIONAL1 -f NOT_OPTIONAL ARG2 -a -c -ISREQUIRED ARG3 -g "BECOMES THREE ARGUMENTS" >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +gnu_getopt_clean +ts_finalize_subtest + +ts_init_subtest invocation_model_two_as_one +$TS_CMD_GETOPT -- abc:d::e::f::g: ARG0 -b ARG1 -d -eOPTIONAL1 -f NOT_OPTIONAL ARG2 -a -c -ISREQUIRED ARG3 -g "BECOMES THREE ARGUMENTS" >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +gnu_getopt_clean +ts_finalize_subtest + +ts_init_subtest invocation_without_parameters +$TS_CMD_GETOPT >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +gnu_getopt_clean +ts_finalize_subtest + +ts_init_subtest long_option_ambiguous_1 +$TS_CMD_GETOPT -o a -l long1,long2 -- --long >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +sed -i -e '1,1s/.*\///' -e "1s/ambiguous$/ambiguous; possibilities: '--long1' '--long2'/" $TS_OUTPUT $TS_ERRLOG +sed -i -e "1s/is ambiguous: long$/'--long' is ambiguous; possibilities: '--long1' '--long2'/" $TS_OUTPUT $TS_ERRLOG +gnu_getopt_clean +ts_finalize_subtest + +ts_init_subtest longopts +$TS_CMD_GETOPT -o a -l long1,secondlong:,thirdlong::,abbreviation: -- --long1 EXTRA1 --thirdlong=ARGUMENT --secondlong=ARG --abbr ABBRARG -a >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +gnu_getopt_clean +ts_finalize_subtest + +ts_init_subtest name_option_long +$TS_CMD_GETOPT -n THIS_PROGRAM -o a -l long -- -b --long --whatever -a >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +gnu_getopt_clean +ts_finalize_subtest + +ts_init_subtest name_option_short +$TS_CMD_GETOPT --name THIS_PROGRAM -o a -l long -- -b --long --whatever -a >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +gnu_getopt_clean +ts_finalize_subtest + +ts_init_subtest quiet_option_long +$TS_CMD_GETOPT --quiet -o a,b: -l long1,long2 -- -c --unknown --long -b >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +gnu_getopt_clean +ts_finalize_subtest + +ts_init_subtest quiet_option_short +$TS_CMD_GETOPT -q -o a,b: -l long1,long2 -- -c --unknown --long -b >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +gnu_getopt_clean +ts_finalize_subtest + +ts_init_subtest quiet_output_option_long +$TS_CMD_GETOPT --quiet-output -o a,b: -l long1,long2 -- -c --unknown --long -b >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +sed -i -e '1,4s/.*\///' -e "3s/ambiguous$/ambiguous; possibilities: '--long1' '--long2'/" $TS_OUTPUT $TS_ERRLOG +sed -i -e "3s/is ambiguous: long$/'--long' is ambiguous; possibilities: '--long1' '--long2'/" $TS_OUTPUT $TS_ERRLOG +gnu_getopt_clean +ts_finalize_subtest + +ts_init_subtest quiet_output_option_short +$TS_CMD_GETOPT -Q -o a,b: -l long1,long2 -- -c --unknown --long -b >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +sed -i -e '1,4s/.*\///' -e "3s/ambiguous$/ambiguous; possibilities: '--long1' '--long2'/" $TS_OUTPUT $TS_ERRLOG +sed -i "3s/is ambiguous: long$/'--long' is ambiguous; possibilities: '--long1' '--long2'/" $TS_OUTPUT $TS_ERRLOG +gnu_getopt_clean +ts_finalize_subtest + +ts_init_subtest same_long_short_options +$TS_CMD_GETOPT -o a -l a -- -a --a >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +gnu_getopt_clean +ts_finalize_subtest + +ts_init_subtest test_for_enhanced_getopt +$TS_CMD_GETOPT -T >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +gnu_getopt_clean +ts_finalize_subtest + +ts_init_subtest unknown_options +$TS_CMD_GETOPT -o a -l long -- -b --long --whatever -a >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +sed -i '1,2s/.*\///' $TS_OUTPUT $TS_ERRLOG +gnu_getopt_clean +ts_finalize_subtest + +ts_init_subtest unquoted_option_bash +$TS_CMD_GETOPT -s bash -u -o a: -l long1: -- -a '$?!* ' --long \"\\\' 'More + than +one +line' >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +gnu_getopt_clean +ts_finalize_subtest + +ts_init_subtest unquoted_option_tcsh +$TS_CMD_GETOPT -s tcsh --unquoted -o a: -l long1: -- -a '$?!* ' --long \"\\\' 'More + than +one +line' >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +gnu_getopt_clean +ts_finalize_subtest + +ts_init_subtest weird_quoting_bash +$TS_CMD_GETOPT -s bash -o a: -l long1: -- -a '$?!* ' --long \"\\\' 'More + than +one +line' >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +gnu_getopt_clean +ts_finalize_subtest + +ts_init_subtest weird_quoting_tcsh +$TS_CMD_GETOPT --shell tcsh -o a: -l long1: -- -a '$?!* ' --long \"\\\' 'More + than +one +line' >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +gnu_getopt_clean +ts_finalize_subtest + +ts_init_subtest compatible +$TS_CMD_GETOPT >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +GETOPT_COMPATIBLE='' $TS_CMD_GETOPT >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +sed -i '1,1s/.*\///' $TS_OUTPUT $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest sh +$TS_CMD_GETOPT --shell=sh -o ab:c:: --long a-long,b-long:,c-long:: -n 'example.sh' -- -a -b 1 -c2 --a-long --b-long 3 --c-long foo bar >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest csh +$TS_CMD_GETOPT --shell=csh -o ab:c:: --long a-long,b-long:,c-long:: -n 'example.csh' -- -a -b 1 -c2 --a-long --b-long 3 --c-long foo bar >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest no-arguments +$TS_CMD_GETOPT >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +sed -i '1,1s/.*\///' $TS_OUTPUT $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest posix_correctly +$TS_CMD_GETOPT -o +ab:c:: --long a-long,b-long:,c-long:: -n 'example' -- -a -b 1 -c2 --a-long --b-long 3 --c-long foo bar xyxxy --a-long >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +POSIXLY_CORRECT='' $TS_CMD_GETOPT -o ab:c:: --long a-long,b-long:,c-long:: -n 'example' -- -a -b 1 -c2 --a-long --b-long 3 --c-long foo bar xyxxy --a-long >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest non-option +$TS_CMD_GETOPT -o +a:b: -- -a x y -b z w >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_GETOPT -o a:b: -- -a x y -b z w >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_GETOPT -o -a:b: -- -a x y -b z w >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit value: $?" >> $TS_OUTPUT +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/hardlink/options b/tests/ts/hardlink/options new file mode 100755 index 0000000..1000714 --- /dev/null +++ b/tests/ts/hardlink/options @@ -0,0 +1,107 @@ +#!/bin/bash +# +# Copyright (C) 2018 Ruediger Meier +# +# 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="options" + +. "$TS_TOPDIR"/functions.sh + +ts_init "$*" + +ts_check_test_command "$TS_CMD_HARDLINK" +ts_check_prog xz +ts_check_prog tar +ts_check_prog wc + +SRCDIR="$TS_OUTDIR/testdir1" + +create_srcdir() +{ + rm -rf "$SRCDIR" + tar -C "$TS_OUTDIR" -xJf "$TS_SELF/testdir1.tar.xz" +} + +show_srcdir() +{ + find "$SRCDIR" -type f -printf "%P\t%n\t%s\t%Ts\t%m\n" | sort +} + +summary_clean() +{ + sed -i \ + -e 's/^Duration:.*/Duration: [Redacted]/' \ + -e 's/^Method:.*/Method: [Redacted]/' \ + -e 's/^Compared:.*files/Compared: [Redacted] files/' \ + $TS_OUTPUT +} + +create_srcdir + +ts_init_subtest "orig" # just list original dir +show_srcdir >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "dryrun" +$TS_CMD_HARDLINK --quiet --dry-run "$SRCDIR" >> $TS_OUTPUT 2>> $TS_ERRLOG +show_srcdir >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "nargs" +$TS_CMD_HARDLINK --quiet "$SRCDIR"/dir-1/sdir-1 "$SRCDIR"/file-?-{1,2} >> $TS_OUTPUT 2>> $TS_ERRLOG +show_srcdir >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +# cases without and with -x support +tmp=$($TS_CMD_HARDLINK --quiet --exclude pattern "$SRCDIR"/dir-1/sdir-2 2>&1) +if test $? -ne 0; then + ts_init_subtest "noregex" + printf "%s\n" "$tmp" >> $TS_OUTPUT 2>> $TS_ERRLOG + ts_finalize_subtest +else + ts_init_subtest "regex-escapes" + $TS_CMD_HARDLINK --quiet --exclude '.*z-"§\$%&\(\)=\?\*\+$' "$SRCDIR" >> $TS_OUTPUT 2>> $TS_ERRLOG + show_srcdir >> $TS_OUTPUT 2>> $TS_ERRLOG + ts_finalize_subtest +fi + +ts_init_subtest "content" +$TS_CMD_HARDLINK --quiet --content "$SRCDIR" >> $TS_OUTPUT 2>> $TS_ERRLOG +# When using -c we need to cheat with sed because it's not deterministic which +# file (i.e. which timestamp and perms) wins. TODO at least the choice of the +# permissions should be sensitive by default and/or controllable by the user. +show_srcdir | sed 's/\(1540236\).*/\1xxx\tperm/' >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "maximum-size-8191" +create_srcdir +echo "Number of test files: $(find "$SRCDIR" -type f | wc -l)" >> $TS_OUTPUT +$TS_CMD_HARDLINK --maximum-size 8191 "$SRCDIR" >> $TS_OUTPUT 2>> $TS_ERRLOG +summary_clean +show_srcdir >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "maximum-size-8192" +create_srcdir +echo "Number of test files: $(find "$SRCDIR" -type f | wc -l)" >> $TS_OUTPUT +$TS_CMD_HARDLINK --maximum-size 8192 "$SRCDIR" >> $TS_OUTPUT 2>> $TS_ERRLOG +summary_clean +show_srcdir >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +rm -rf "$SRCDIR" +ts_finalize diff --git a/tests/ts/hardlink/testdir1.tar.xz b/tests/ts/hardlink/testdir1.tar.xz new file mode 100644 index 0000000..b9bc245 Binary files /dev/null and b/tests/ts/hardlink/testdir1.tar.xz differ diff --git a/tests/ts/hexdump/files/ascii.in b/tests/ts/hexdump/files/ascii.in new file mode 100644 index 0000000..4c2598b Binary files /dev/null and b/tests/ts/hexdump/files/ascii.in differ diff --git a/tests/ts/hexdump/format-strings b/tests/ts/hexdump/format-strings new file mode 100755 index 0000000..9f055ba --- /dev/null +++ b/tests/ts/hexdump/format-strings @@ -0,0 +1,69 @@ +#!/bin/bash + +# 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="format-strings" +FILES="$TS_TOPDIR/ts/hexdump/files" +#sample input consists of hexdump-ed results of the following py3script: +#for i in range(256): +# print(chr(i), end= ' ') + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_HEXDUMP" +ts_check_test_command "$TS_HELPER_SYSINFO" + +# on big endian systems some of the subtests have different expected output +BYTE_ORDER=$($TS_HELPER_SYSINFO byte-order) +BE_EXT=$(test "$BYTE_ORDER" = "BE" && echo ".BE") + +#885314 +ts_init_subtest "empty-format" +TS_EXPECTED+=$BE_EXT +INPUT=$(printf \\1) +$TS_CMD_HEXDUMP -n1 -ve '2 "" "%x"' <<< $INPUT >> $TS_OUTPUT 2>> $TS_ERRLOG + +$TS_CMD_HEXDUMP -n1 -ve '4 "%x"' -e '2 ""' <<< $INPUT >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +#basic formats +ts_init_subtest "1b_octal" +$TS_CMD_HEXDUMP -b $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "1b_char" +$TS_CMD_HEXDUMP -c $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "canon" +$TS_CMD_HEXDUMP -C $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "2b_dec" +TS_EXPECTED+=$BE_EXT +$TS_CMD_HEXDUMP -d $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "2b_octal" +TS_EXPECTED+=$BE_EXT +$TS_CMD_HEXDUMP -o $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "2b_hex" +TS_EXPECTED+=$BE_EXT +$TS_CMD_HEXDUMP -x $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/hexdump/highlighting b/tests/ts/hexdump/highlighting new file mode 100755 index 0000000..cb94615 --- /dev/null +++ b/tests/ts/hexdump/highlighting @@ -0,0 +1,267 @@ +#!/bin/bash + +# 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="highlighting" +FILES="$TS_TOPDIR/ts/hexdump/files" +OPTS="--color=always" +ADDRFMT='-e "%07.7_Ax\n"' +#sample input consists of hexdump-ed results of the following py3script: +#for i in range(256): +# print(chr(i), end= ' ') + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_HEXDUMP" +ts_check_test_command "$TS_HELPER_SYSINFO" + +# on big endian systems some of the subtests have different expected output +BYTE_ORDER=$($TS_HELPER_SYSINFO byte-order) +BE_EXT=$(test "$BYTE_ORDER" = "BE" && echo ".BE") + +# +# basic formats /w some highlighting tweaks +# + +# highlight 'A' and 'a' +ts_init_subtest "1b_octal-1" +$TS_CMD_HEXDUMP $OPTS $ADDRFMT \ + -e '"%07.7_ax " 16/1 "%03o_L[red:A,red:a] " "\n"' \ + $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +# highlight bytes with the value of 0x41 (A) and 0x61 (a) +ts_init_subtest "1b_octal-2" +TS_EXPECTED+=$BE_EXT +$TS_CMD_HEXDUMP $OPTS $ADDRFMT \ + -e '"%07.7_ax " 16/1 "%03o_L[red:0x41,red:0x61] " "\n"' \ + $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +# highlight the bytes at offsets 130 and 194 (decimal) +ts_init_subtest "1b_octal-3" +$TS_CMD_HEXDUMP $OPTS $ADDRFMT \ + -e '"%07.7_ax " 16/1 "%03o_L[red@130,red@194] " "\n"' \ + $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +# highlight the byte at offset 194 if it's value is 0x61 (a) +# and the byte at offset 130 if it's value is A (0x41) +ts_init_subtest "1b_octal-4" +TS_EXPECTED+=$BE_EXT +$TS_CMD_HEXDUMP $OPTS $ADDRFMT \ + -e '"%07.7_ax " 16/1 "%03o_L[red:A@130,red:0x61@194] " "\n"' \ + $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +# highlight the byte at offset 194 if it's value is 0x61 (a) +# and the byte at offset 130 if it's value is C (0x41) (false) +ts_init_subtest "1b_octal-5" +TS_EXPECTED+=$BE_EXT +$TS_CMD_HEXDUMP $OPTS $ADDRFMT \ + -e '"%07.7_ax " 16/1 "%03o_L[red:C@130,red:0x61@194] " "\n"' \ + $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +# highlight a range longer than the byte count of %o +ts_init_subtest "1b_octal-6" +$TS_CMD_HEXDUMP $OPTS $ADDRFMT \ + -e '"%07.7_ax " 16/1 "%03o_L[red@193-194] " "\n"' \ + $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +# highlight bytes with the value of 0101 (A) and 0141 (a) +ts_init_subtest "1b_octal-7" +TS_EXPECTED+=$BE_EXT +$TS_CMD_HEXDUMP $OPTS $ADDRFMT \ + -e '"%07.7_ax " 16/1 "%03o_L[red:0101,red:0141] " "\n"' \ + $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +# highlight bytes with the value of 0101 (A), 0x61 (a), or if the character is a caret +ts_init_subtest "1b_octal-8" +TS_EXPECTED+=$BE_EXT +$TS_CMD_HEXDUMP $OPTS $ADDRFMT \ + -e '"%07.7_ax " 16/1 "%03o_L[red:0101,blue:0x61,green:^] " "\n"' \ + $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +# highlight bytes with the value of 0101 (A), 0x61 (a), or if the character at 196 is not 'c' +ts_init_subtest "1b_octal-9" +TS_EXPECTED+=$BE_EXT +$TS_CMD_HEXDUMP $OPTS $ADDRFMT \ + -e '"%07.7_ax " 16/1 "%03o_L[red:0101,blue:0x61,!green:c@196] " "\n"' \ + $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +#color the addresses red and the characters in UTIL-LINUX green +ts_init_subtest "1b_char-1" +$TS_CMD_HEXDUMP $OPTS $ADDRFMT \ + -e '"%07.7_ax_L[red] " 16/1 "%3_c_L[green:-,green:I,green:L,green:N,green:T,green:U,green:X] " "\n"' \ + $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +#color the address 0xe0 red +ts_init_subtest "1b_char-2" +$TS_CMD_HEXDUMP $OPTS $ADDRFMT \ + -e '"%07.7_ax_L[red:0xe0] " 16/1 "%3_c " "\n"' \ + $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +#highlight ':' and '@' +ts_init_subtest "1b_char-3" +$TS_CMD_HEXDUMP $OPTS $ADDRFMT \ + -e '"%07.7_ax " 16/1 "%3_c_L[red::@116,red:@@128] " "\n"' \ + $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +# color last address gray, the null byte blue, the spaces brown(-ish) and the text cyan +ts_init_subtest "canon-1" +TS_EXPECTED+=$BE_EXT +$TS_CMD_HEXDUMP $OPTS \ + -e '"%08.8_Ax_L[gray]\n"' \ + -e '"%08.8_ax " 8/1 "%02x_L[blue:0x0,brown:0x20] " " " 8/1 "%02x_L[brown:0x20] " ' \ + -e '" |" 16/1 "%_p_L[cyan]" "|\n"' \ + $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +# color last address gray - if it's 0x280 or blue if it's 0x380 +# color A/a hex dumps blue and A/a in text green +ts_init_subtest "canon-2" +$TS_CMD_HEXDUMP $OPTS \ + -e '"%08.8_Ax_L[blue:0x380,red:0x280]\n"' \ + -e '"%08.8_ax " 8/1 "%02x_L[blue:A,blue:a] " " " 8/1 "%02x_L[blue:A,blue:a] " ' \ + -e '" |" 16/1 "%_p_L[green:A,green:a]" "|\n"' \ + $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +# color the current print unit if one of the bytes it prints is at offset 100 (0x64) +ts_init_subtest "2b_dec-1" +TS_EXPECTED+=$BE_EXT +$TS_CMD_HEXDUMP $OPTS $ADDRFMT \ + -e '"%07.7_ax " 8/2 " %05u_L[red@100] " "\n"' \ + $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +# color the current print unit if of the bytes it prints are at offsets 98 and 99 +ts_init_subtest "2b_dec-2" +TS_EXPECTED+=$BE_EXT +$TS_CMD_HEXDUMP $OPTS $ADDRFMT \ + -e '"%07.7_ax " 8/2 " %05u_L[red@98-99] " "\n"' \ + $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +# color the current print unit if some or all of the bytes it prints are at offsets 98 and 99 +ts_init_subtest "2b_dec-3" +TS_EXPECTED+=$BE_EXT +$TS_CMD_HEXDUMP $OPTS $ADDRFMT \ + -e '"%07.7_ax " 8/2 " %05u_L[red@97-99] " "\n"' \ + $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +# color the current print unit if it prints "A " at 130-131 +ts_init_subtest "2b_dec-4" +TS_EXPECTED+=$BE_EXT +$TS_CMD_HEXDUMP $OPTS $ADDRFMT \ + -e '"%07.7_ax " 8/2 " %05u_L[red:A @130-131] " "\n"' \ + $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +# color the current print unit if it doesn't print "B " at 130-131 +ts_init_subtest "2b_dec-5" +TS_EXPECTED+=$BE_EXT +$TS_CMD_HEXDUMP $OPTS $ADDRFMT \ + -e '"%07.7_ax " 8/2 " %05u_L[!red:B @130-131] " "\n"' \ + $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +# specify a string shorter than the range - error +ts_init_subtest "2b_dec-6" +$TS_CMD_HEXDUMP $OPTS $ADDRFMT \ + -e '"%07.7_ax " 8/2 " %05u_L[red:A@130-131] " "\n"' \ + $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +# specify a negative-length range +ts_init_subtest "2b_dec-7" +$TS_CMD_HEXDUMP $OPTS $ADDRFMT \ + -e '"%07.7_ax " 8/2 " %05u_L[red:A@131-130] " "\n"' \ + $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +# color the current print unit if of the bytes it prints are at offsets 98-102 (multiple print units) +ts_init_subtest "2b_dec-8" +TS_EXPECTED+=$BE_EXT +$TS_CMD_HEXDUMP $OPTS $ADDRFMT \ + -e '"%07.7_ax " 8/2 " %05u_L[red@98-102] " "\n"' \ + $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +# color the current print unit if some or all of the bytes it prints are at offsets 97 and 99 (true) +ts_init_subtest "4b_dec-1" +TS_EXPECTED+=$BE_EXT +$TS_CMD_HEXDUMP $OPTS $ADDRFMT \ + -e '"%07.7_ax " 8/4 " %05u_L[red@97-99] " "\n"' \ + $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +# color the current print unit if some or all of the bytes it prints are at offsets 96-99 +ts_init_subtest "4b_dec-2" +TS_EXPECTED+=$BE_EXT +$TS_CMD_HEXDUMP $OPTS $ADDRFMT \ + -e '"%07.7_ax " 8/4 " %05u_L[red@96-99] " "\n"' \ + $FILES/ascii.in &> $TS_OUTPUT +ts_finalize_subtest + +# look for @@@@ +ts_init_subtest "4b_dec-3" +TS_EXPECTED+=$BE_EXT +$TS_CMD_HEXDUMP $OPTS $ADDRFMT \ + -e '"%07.7_ax " 8/4 " %05u_L[red:@@@@] " "\n"' \ + &> $TS_OUTPUT <<< "@@@@" +ts_finalize_subtest + +# look for @@@@ at 0-3 +ts_init_subtest "4b_dec-4" +TS_EXPECTED+=$BE_EXT +$TS_CMD_HEXDUMP $OPTS $ADDRFMT \ + -e '"%07.7_ax " 8/4 " %05u_L[red:@@@@@0-3] " "\n"' \ + &> $TS_OUTPUT <<< "@@@@" +ts_finalize_subtest + +# look for @@@ at 0-3 (wrong byte count error) +ts_init_subtest "4b_dec-5" +$TS_CMD_HEXDUMP $OPTS $ADDRFMT \ + -e '"%07.7_ax " 8/4 " %05u_L[red:@@@@0-3] " "\n"' \ + &> $TS_OUTPUT <<< "@@@@" +ts_finalize_subtest + +# look for @@@ at 1-3 - in the format boundaries - correct +ts_init_subtest "4b_dec-6" +TS_EXPECTED+=$BE_EXT +$TS_CMD_HEXDUMP $OPTS $ADDRFMT \ + -e '"%07.7_ax " 8/4 " %05u_L[red:@@@@1-3] " "\n"' \ + &> $TS_OUTPUT <<< "@@@@" +ts_finalize_subtest + +# look for @@@ at 2-4 - correct range length, however steps over 2 print units - no colors +ts_init_subtest "4b_dec-7" +TS_EXPECTED+=$BE_EXT +$TS_CMD_HEXDUMP $OPTS $ADDRFMT \ + -e '"%07.7_ax " 8/4 " %05u_L[red:@@@@2-4] " "\n"' \ + &> $TS_OUTPUT <<< "@@@@" +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/hwclock/show b/tests/ts/hwclock/show new file mode 100755 index 0000000..d8cdc8e --- /dev/null +++ b/tests/ts/hwclock/show @@ -0,0 +1,38 @@ +#!/bin/bash + +# +# Copyright (C) 2023 Thomas Weißschuh +# +# 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="show" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_HWCLOCK" + +ts_skip_nonroot +ts_skip_qemu_user +ts_skip_docker + +# RTC interrupts are sometimes broken on GitHub Actions +if ts_is_virt "microsoft"; then + TS_KNOWN_FAIL="yes" +fi + +"$TS_CMD_HWCLOCK" --show > /dev/null 2> "$TS_ERRLOG" || ts_die + +ts_finalize diff --git a/tests/ts/hwclock/systohc b/tests/ts/hwclock/systohc new file mode 100755 index 0000000..fbd67ee --- /dev/null +++ b/tests/ts/hwclock/systohc @@ -0,0 +1,103 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="system to hw" +NTP_SERVER="0.fedora.pool.ntp.org" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_HWCLOCK" + +ts_skip_nonroot +if [ "$TRAVIS_DIST" == "precise" ]; then + ts_skip "https://github.com/util-linux/util-linux/issues/1082" +fi +if [ "$GITHUB_ACTIONS" == "true" ]; then + ts_skip "virtual machine" +fi + +ts_check_prog "bc" +ts_check_prog "sntp" + +function get_offset_sys_ntp +{ + local ip="$@" + local out + + # using hostname instead of IP could give us more than one offset + out=$(sntp --timeout 1 "$ip") || return 1 + + # sed must deliver a signed float or empty string for sure + out=$(echo "$out" | \ + sed -n 's/.* \(\(+\|-\)[0-9]\{1,\}\.[0-9]\{1,\}\).*/\1/1p') + + [ -n "$out" ] || return 1 + echo "$out" +} + +function check_diff_offset +{ + local a=${1#+} + local b=${2#+} + local max="$3" + local tmp + + tmp=$(echo "$a - $b" | bc | tr -d '-') + echo "$tmp" + + tmp=$(echo "$tmp < $max" | bc) + [ $tmp -eq 1 ] +} + + +# we need fixed ntp IP to get comparable offsets +NTP_IP=$(ts_resolve_host "$NTP_SERVER") \ + || ts_skip "can't resolve hostname $NTP_SERVER" + +OFFSET_A=$(get_offset_sys_ntp "$NTP_IP") \ + || ts_skip "can't get ntp offset 1st, $NTP_IP" +OFFSET_B=$(get_offset_sys_ntp "$NTP_IP") \ + || ts_skip "can't get ntp offset 2nd, $NTP_IP" + +diff=$(check_diff_offset $OFFSET_A $OFFSET_B 0.02) \ + || ts_skip "unreliable ntp or sys clock offsets: $NTP_IP $OFFSET_A $OFFSET_B +/-$diff" + +# hwclock --show should work if we have a hw clock +tmp=$($TS_CMD_HWCLOCK --show 2>&1) +if [ $? != "0" ]; then + echo "$tmp" | grep -q "Cannot access the Hardware Clock via" \ + && ts_skip "no hardware clock found" + ts_failed "hwclock --show" +fi + +# call hwclock +for i in `seq 1 10`; do + # only *skip* on failure for now + $TS_CMD_HWCLOCK --systohc || ts_skip "hwclock --systohc failed, $i" + $TS_CMD_HWCLOCK --hctosys || ts_skip "hwclock --hctosys failed, $i" +done + +OFFSET_C=$(get_offset_sys_ntp "$NTP_IP") \ + || ts_skip "can't get ntp offset 3rd, $NTP_IP" + +diff=$(check_diff_offset "$OFFSET_B" "$OFFSET_C" 1.0) \ + || ts_failed "offsets $NTP_IP: $OFFSET_B $OFFSET_C +/-$diff" + +ts_ok "offsets $NTP_IP: $OFFSET_B $OFFSET_C +/-$diff" diff --git a/tests/ts/ipcs/functions.sh b/tests/ts/ipcs/functions.sh new file mode 100644 index 0000000..e9b437e --- /dev/null +++ b/tests/ts/ipcs/functions.sh @@ -0,0 +1,114 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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. +# + +test -f /proc/sys/kernel/shmall || ts_skip "no /proc" + +PAGE_SIZE=$($TS_HELPER_SYSINFO pagesize) + +# kernel files +IPCS_PROCFILES=( + /proc/sys/kernel/shmmni + /proc/sys/kernel/shmall + /proc/sys/kernel/shmmax +) + +# raw data converted to ipcs-like format +# shmmni = same +# shmall = from pages to KBytes +# shmmax = from bytes to KBytes +# +IPCS_KERNEL_CMD=( + "cat /proc/sys/kernel/shmmni" + "echo \$(cat /proc/sys/kernel/shmall) / 1024 \* $PAGE_SIZE | bc -l | sed 's/\..*//'" + "echo \$(cat /proc/sys/kernel/shmmax) / 1024 | bc -l | sed 's/\..*//'" +) + +# data from the ipcs command +IPCS_CMD=( + "$TS_CMD_IPCS -m -l | awk '/max number of segments/ { print \$6 }'" + "$TS_CMD_IPCS -m -l | awk '/max total shared memory/ { print \$7 }'" + "$TS_CMD_IPCS -m -l | awk '/max seg size/ { print \$6 }'" +) + + +# The linux kernel accepts ULONG_MAX, but this value is same like ULLONG_MAX on +# 64-bit archs. So the ipcs command has to always overflow on 64-bit archs when +# shmall (=num of pages!) is same or almost same like ULONG_MAX. This is reason +# why we for the test uses 32-bit limits on all archs. +# +# (Don't worry that 64-bit ULONG_MAX makes ipcs useless ... +# ... it's a problem for admins who want to use 75557863725TB of RAM for shm) +# +IPCS_LIMITS=( + 32768 + $($TS_HELPER_SYSINFO ULONG_MAX32) + $($TS_HELPER_SYSINFO ULONG_MAX32) +) + +# list of indexes = 0..(sizeof Array - 1) +IPCS_IDX=$(seq 0 $(( ${#IPCS_PROCFILES[*]} - 1 ))) + +UINT64_MAX=$($TS_HELPER_SYSINFO UINT64_MAX) + +# checker +function ipcs_limits_check { + for i in $IPCS_IDX; do + + echo -n ${IPCS_PROCFILES[$i]} + + a=$(eval ${IPCS_KERNEL_CMD[$i]}) + b=$(eval ${IPCS_CMD[$i]}) + + # follow the way how ipcs handles u64 overflow + max_kbytes=$(bc <<< "$UINT64_MAX - ($UINT64_MAX % ($PAGE_SIZE / 1024))") + + #echo + #echo "kernel kbytes: $a" + #echo "lsipc kbytes: $b" + #echo "max kbytes: $max_kbytes" + #echo + + if [ $(bc <<<"$a > $max_kbytes") -eq 1 ]; then + a=$max_kbytes + fi + + if [ x"$a" == x"$b" ]; then + echo " OK" + else + echo " kernel=$a, ipcs=$b" + fi + done +} + +# Read 'ipcmk' output, such as 'Shared memory id: 22839299' and +# write the message to two files: (1) something what one can +# compare as test output, and (2) id which ipcrm later will use +# for deletion. +ipcmk_output_handler() { + awk -v text=$1 -v num=$2 ' + function isnum(x) { + return(x == x + 0) + } + { + if (isnum($NF)) { + print $NF >> num + $NF="" + } + print $0 >> text + }' +} diff --git a/tests/ts/ipcs/headers b/tests/ts/ipcs/headers new file mode 100755 index 0000000..2796f4b --- /dev/null +++ b/tests/ts/ipcs/headers @@ -0,0 +1,60 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="headers" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_IPCS" + +ts_init_subtest "shm-headers" +$TS_CMD_IPCS -m -t | grep -A1 "^---" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_IPCS -m -p | grep -A1 "^---" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_IPCS -m -c | grep -A1 "^---" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_IPCS -m -l | grep "^---" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_IPCS -m -u | grep "^---" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "mesg-headers" +$TS_CMD_IPCS -q -t | grep -A1 "^---" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_IPCS -q -p | grep -A1 "^---" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_IPCS -q -c | grep -A1 "^---" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_IPCS -q -l | grep "^---" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_IPCS -q -u | grep "^---" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "sem-headers" +$TS_CMD_IPCS -s -t | grep -A1 "^---" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_IPCS -s -p | grep -A1 "^---" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_IPCS -s -c | grep -A1 "^---" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_IPCS -s -l | grep "^---" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_IPCS -s -u | grep "^---" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "all-headers" +$TS_CMD_IPCS -a | grep -A1 "^---" >> $TS_OUTPUT 2>> $TS_ERRLOG + +$TS_CMD_IPCS -a -t | grep -A1 "^---" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_IPCS -a -p | grep -A1 "^---" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_IPCS -a -c | grep -A1 "^---" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_IPCS -a -l | grep "^---" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_IPCS -a -u | grep "^---" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/ipcs/limits b/tests/ts/ipcs/limits new file mode 100755 index 0000000..22add86 --- /dev/null +++ b/tests/ts/ipcs/limits @@ -0,0 +1,54 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="limits overflow" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_IPCS" +ts_check_test_command "$TS_HELPER_SYSINFO" + +ts_skip_nonroot +ts_check_prog "bc" + +. "$TS_SELF"/functions.sh + +ts_lock "ipcslimits" + +ts_log "load original values" +for i in $IPCS_IDX; do + SHM_ORG[$i]=$(cat ${IPCS_PROCFILES[$i]}) +done >> $TS_OUTPUT + +ts_log "maximize kernel setting" +for i in $IPCS_IDX; do + echo ${IPCS_LIMITS[$i]} >> ${IPCS_PROCFILES[$i]} +done >> $TS_OUTPUT + +ts_log "check for difference between kernel and IPC" +ipcs_limits_check >> $TS_OUTPUT + +ts_log "write original values to kernel" +for i in $IPCS_IDX; do + echo ${SHM_ORG[$i]} >> ${IPCS_PROCFILES[$i]} +done >> $TS_OUTPUT + +ts_finalize + diff --git a/tests/ts/ipcs/limits2 b/tests/ts/ipcs/limits2 new file mode 100755 index 0000000..6da8880 --- /dev/null +++ b/tests/ts/ipcs/limits2 @@ -0,0 +1,37 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="basic limits" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_IPCS" +ts_check_test_command "$TS_HELPER_SYSINFO" +ts_check_prog "bc" + +. "$TS_SELF"/functions.sh + +ts_lock "ipcslimits" + +ts_log "check for difference between kernel and IPC" +ipcs_limits_check >> $TS_OUTPUT + +ts_finalize + diff --git a/tests/ts/ipcs/mk-rm-msg b/tests/ts/ipcs/mk-rm-msg new file mode 100755 index 0000000..c588a0d --- /dev/null +++ b/tests/ts/ipcs/mk-rm-msg @@ -0,0 +1,44 @@ +#!/bin/bash + +# 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="mk-rm-msg" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_IPCS" +ts_check_test_command "$TS_CMD_IPCMK" +ts_check_test_command "$TS_CMD_IPCRM" +ts_check_test_command "$TS_HELPER_SYSINFO" + +. "$TS_SELF"/functions.sh + +rm -f $TS_OUTDIR/id-msg +$TS_CMD_IPCMK -Q 2>>$TS_OUTPUT | ipcmk_output_handler $TS_OUTPUT $TS_OUTDIR/id-msg +$TS_CMD_IPCS -q -i "$(cat $TS_OUTDIR/id-msg)" |\ + grep -c "^Message Queue msqid=$(cat $TS_OUTDIR/id-msg)$" >>$TS_OUTPUT +$TS_CMD_IPCRM -q $(cat $TS_OUTDIR/id-msg) >> $TS_OUTPUT 2>> $TS_ERRLOG + +rm -f $TS_OUTDIR/id-msg +$TS_CMD_IPCMK -Q 2>>$TS_OUTPUT | ipcmk_output_handler $TS_OUTPUT $TS_OUTDIR/id-msg +$TS_CMD_IPCRM -Q "$( + $TS_CMD_IPCS -q | + awk -v id=$(cat $TS_OUTDIR/id-msg) '{if ($2 == id){print $1}}' | + uniq +)" >> $TS_OUTPUT 2>> $TS_ERRLOG + +rm -f $TS_OUTDIR/id-msg + +ts_finalize diff --git a/tests/ts/ipcs/mk-rm-sem b/tests/ts/ipcs/mk-rm-sem new file mode 100755 index 0000000..beccee4 --- /dev/null +++ b/tests/ts/ipcs/mk-rm-sem @@ -0,0 +1,44 @@ +#!/bin/bash + +# 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="mk-rm-sem" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_IPCS" +ts_check_test_command "$TS_CMD_IPCMK" +ts_check_test_command "$TS_CMD_IPCRM" +ts_check_test_command "$TS_HELPER_SYSINFO" + +. "$TS_SELF"/functions.sh + +rm -f $TS_OUTDIR/id-sem +$TS_CMD_IPCMK -S 1 2>>$TS_OUTPUT | ipcmk_output_handler $TS_OUTPUT $TS_OUTDIR/id-sem +$TS_CMD_IPCS -s -i "$(cat $TS_OUTDIR/id-sem)" | grep "^nsems" >>$TS_OUTPUT +$TS_CMD_IPCRM -s $(cat $TS_OUTDIR/id-sem) >> $TS_OUTPUT 2>> $TS_ERRLOG + +rm -f $TS_OUTDIR/id-sem +$TS_CMD_IPCMK -S 2 2>>$TS_OUTPUT | ipcmk_output_handler $TS_OUTPUT $TS_OUTDIR/id-sem +$TS_CMD_IPCS -s -i "$(cat $TS_OUTDIR/id-sem)" | grep "^nsems" >>$TS_OUTPUT +$TS_CMD_IPCRM -S "$( + $TS_CMD_IPCS -s | + awk -v id=$(cat $TS_OUTDIR/id-sem) '{if ($2 == id){print $1}}' | + uniq +)" >> $TS_OUTPUT 2>> $TS_ERRLOG + +rm -f $TS_OUTDIR/id-sem + +ts_finalize diff --git a/tests/ts/ipcs/mk-rm-shm b/tests/ts/ipcs/mk-rm-shm new file mode 100755 index 0000000..81f40cf --- /dev/null +++ b/tests/ts/ipcs/mk-rm-shm @@ -0,0 +1,44 @@ +#!/bin/bash + +# 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="mk-rm-shm" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_IPCS" +ts_check_test_command "$TS_CMD_IPCMK" +ts_check_test_command "$TS_CMD_IPCRM" +ts_check_test_command "$TS_HELPER_SYSINFO" + +. "$TS_SELF"/functions.sh + +rm -f $TS_OUTDIR/id-shm +$TS_CMD_IPCMK -M 1 2>>$TS_OUTPUT | ipcmk_output_handler $TS_OUTPUT $TS_OUTDIR/id-shm +$TS_CMD_IPCS -m -i "$(cat $TS_OUTDIR/id-shm)" | sed -n '/^bytes/s/\t.*//p' >>$TS_OUTPUT +$TS_CMD_IPCRM -m $(cat $TS_OUTDIR/id-shm) >> $TS_OUTPUT 2>> $TS_ERRLOG +rm -f $TS_OUTDIR/id-shm + +$TS_CMD_IPCMK -M 12 2>>$TS_OUTPUT | ipcmk_output_handler $TS_OUTPUT $TS_OUTDIR/id-shm +$TS_CMD_IPCS -m -i "$(cat $TS_OUTDIR/id-shm)" | sed -n '/^bytes/s/\t.*//p' >>$TS_OUTPUT +$TS_CMD_IPCRM -M "$( + $TS_CMD_IPCS -m | + awk -v id=$(cat $TS_OUTDIR/id-shm) '{if ($2 == id){print $1}}' | + uniq +)" >> $TS_OUTPUT 2>> $TS_ERRLOG + +rm -f $TS_OUTDIR/id-shm + +ts_finalize diff --git a/tests/ts/isosize/print-size b/tests/ts/isosize/print-size new file mode 100755 index 0000000..33e0b3b --- /dev/null +++ b/tests/ts/isosize/print-size @@ -0,0 +1,37 @@ +#!/bin/bash + +# 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="print-size" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_ISOSIZE" + +gzip -cd $TS_SELF/sample.iso.gz >| $TS_OUTDIR/sample.iso + +ts_init_subtest "default_output" +$TS_CMD_ISOSIZE $TS_OUTDIR/sample.iso >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "sector_output" +$TS_CMD_ISOSIZE --sectors $TS_OUTDIR/sample.iso >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "divisor_output" +$TS_CMD_ISOSIZE --divisor=9 $TS_OUTDIR/sample.iso >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/isosize/sample.iso.gz b/tests/ts/isosize/sample.iso.gz new file mode 100644 index 0000000..17937a2 Binary files /dev/null and b/tests/ts/isosize/sample.iso.gz differ diff --git a/tests/ts/kill/all_processes b/tests/ts/kill/all_processes new file mode 100755 index 0000000..b228077 --- /dev/null +++ b/tests/ts/kill/all_processes @@ -0,0 +1,66 @@ +#!/bin/bash + +# 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="all_processes" + +. "$TS_TOPDIR/functions.sh" +ts_init "$*" + +ts_skip_nonroot + +# make sure we do not use shell built-in command +if [ "$TS_USE_SYSTEM_COMMANDS" == "yes" ]; then + TS_CMD_KILL="$(which kill)" +fi + +ts_check_test_command "$TS_CMD_KILL" +ts_check_test_command "$TS_HELPER_SIGRECEIVE" + +. "$TS_SELF/kill_functions.sh" + +HELPER_SYMLINK="$(mktemp "${TS_OUTDIR}/alXXXXXXXXXXXXX")" +ln -sf "$TS_HELPER_SIGRECEIVE" "$HELPER_SYMLINK" + +"$HELPER_SYMLINK" -s "$TS_TESTUSER" >> $TS_OUTPUT 2>> $TS_ERRLOG & +TEST_PID=$! + +check_test_sigreceive $TEST_PID +[ $? -eq 1 ] || echo "${HELPER_SYMLINK##*/} helper did not start" >> "$TS_OUTPUT" + + +ts_log_both "test 1" +"$TS_CMD_KILL" ${HELPER_SYMLINK##*/} >> $TS_OUTPUT 2>> $TS_ERRLOG +if [ $? -ne 1 ]; then + echo "kill did not return 1" >> "$TS_OUTPUT" +fi + +ts_log_both "test 2" +"$TS_CMD_KILL" -a ${HELPER_SYMLINK##*/} >> $TS_OUTPUT 2>> $TS_ERRLOG +if [ $? -ne 0 ]; then + echo "kill did not return 0" >> "$TS_OUTPUT" +fi +wait $TEST_PID + +ts_log_both "test 3" +"$TS_CMD_KILL" -a -p ${HELPER_SYMLINK##*/} >> $TS_OUTPUT 2>> $TS_ERRLOG +if [ $? -ne 1 ]; then + echo "kill -a -p did not return 1" >> "$TS_OUTPUT" +fi + +sed -i "s/${HELPER_SYMLINK##*/}/${TS_HELPER_SIGRECEIVE##*/}/" $TS_OUTPUT $TS_ERRLOG + +rm -f "$HELPER_SYMLINK" + +ts_finalize diff --git a/tests/ts/kill/kill_functions.sh b/tests/ts/kill/kill_functions.sh new file mode 100644 index 0000000..4ace3d9 --- /dev/null +++ b/tests/ts/kill/kill_functions.sh @@ -0,0 +1,29 @@ +# kill tests, or command, will not when /proc is missing. +test -d /proc || ts_skip "/proc not available" + +# The test_sigreceive is ready when signal process mask contains SIGHUP +function check_test_sigreceive { + local rc=0 + local pid=$1 + + for i in 0.01 0.1 1 1 1 1; do + if [ ! -f /proc/$pid/status ]; then + # The /proc exists, but not status file. Because the + # process already started it is unlikely the file would + # appear after any amount of waiting. Try to sleep for + # moment and hopefully test_sigreceive is ready to be + # killed. + echo "kill_functions.sh: /proc/$pid/status: No such file or directory" + sleep 2 + rc=1 + break + fi + sigmask=$((16#$( awk '/SigCgt/ { print $2}' /proc/$pid/status) )) + if [ $(( $sigmask & 1 )) == 1 ]; then + rc=1 + break + fi + sleep $i + done + return $rc +} diff --git a/tests/ts/kill/name_to_number b/tests/ts/kill/name_to_number new file mode 100755 index 0000000..955d861 --- /dev/null +++ b/tests/ts/kill/name_to_number @@ -0,0 +1,75 @@ +#!/bin/bash + +# 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="name_to_number" + +. "$TS_TOPDIR/functions.sh" +ts_init "$*" + +# make sure we do not use shell built-in command +if [ "$TS_USE_SYSTEM_COMMANDS" == "yes" ]; then + TS_CMD_KILL="$(which kill)" +fi + +ts_check_test_command "$TS_CMD_KILL" +ts_check_test_command "$TS_HELPER_SIGRECEIVE" + +# SIGRTMAX-0 and SIGRTMAX-1 are not usable under QEMU +ts_skip_qemu_user + +. "$TS_SELF/kill_functions.sh" + +all_ok=true + +HELPER_SYMLINK="$(mktemp "${TS_OUTDIR}/naXXXXXXXXXXXXX")" +ln -sf "$TS_HELPER_SIGRECEIVE" "$HELPER_SYMLINK" + +for SIG in $($TS_CMD_KILL -L); do + if [ "x${SIG//[0-9]/}" = "x" ]; then + EXPECTED=$SIG + continue + fi + if [ "$TS_ENABLE_ASAN" == "yes" ] && [ "x$SIG" = "xSEGV" ]; then + continue + fi + if [ "x$SIG" = "xSTOP" ] || [ "x$SIG" = "xKILL" ]; then + continue + fi + if [ "x$SIG" = "xRTMIN" ]; then + SIG="$SIG+0" + fi + if [ "x$SIG" = "xRTMAX" ]; then + SIG="$SIG-0" + fi + + "$HELPER_SYMLINK" >> $TS_OUTPUT 2>> $TS_ERRLOG & + TEST_PID=$! + check_test_sigreceive $TEST_PID + [ $? -eq 1 ] || echo "${HELPER_SYMLINK##*/} helper did not start" >> "$TS_OUTPUT" + + "$TS_CMD_KILL" -$SIG ${HELPER_SYMLINK##*/} >> $TS_OUTPUT 2>> $TS_ERRLOG + wait $TEST_PID + if [ $? -ne $EXPECTED ]; then + echo "$SIG returned $? while $EXPECTED was expected" >> "$TS_OUTPUT" + all_ok=false + fi +done + +if $all_ok; then + echo 'all ok' >> "$TS_OUTPUT" +fi +rm -f "$HELPER_SYMLINK" + +ts_finalize diff --git a/tests/ts/kill/options b/tests/ts/kill/options new file mode 100755 index 0000000..10653a5 --- /dev/null +++ b/tests/ts/kill/options @@ -0,0 +1,68 @@ +#!/bin/bash + +# 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="options" + +. "$TS_TOPDIR/functions.sh" +ts_init "$*" + +# make sure we do not use shell built-in command +if [ "$TS_USE_SYSTEM_COMMANDS" == "yes" ]; then + TS_CMD_KILL="$(which kill)" +fi + +ts_check_test_command "$TS_CMD_KILL" +ts_check_test_command "$TS_HELPER_SIGRECEIVE" + +. "$TS_SELF/kill_functions.sh" + +all_ok=true + +HELPER_SYMLINK="$(mktemp "${TS_OUTDIR}/opXXXXXXXXXXXXX")" +ln -sf "$TS_HELPER_SIGRECEIVE" "$HELPER_SYMLINK" + +try_option() +{ + "$HELPER_SYMLINK" >> $TS_OUTPUT 2>> $TS_ERRLOG & + TEST_PID=$! + check_test_sigreceive $TEST_PID + [ $? -eq 1 ] || echo "${HELPER_SYMLINK##*/} helper did not start" >> "$TS_OUTPUT" + + "$TS_CMD_KILL" "$@" $TEST_PID >> $TS_OUTPUT 2>> $TS_ERRLOG + if [ $? -ne 0 ]; then + echo "kill $@ did not work" >> "$TS_OUTPUT" + all_ok=false + fi + wait $TEST_PID + if [ $? -ne 1 ]; then + echo "wait $TEST_PID for $@ did not work" >> "$TS_OUTPUT" + all_ok=false + fi +} + +try_option -s 1 +try_option --signal 1 +try_option --signal HUP +try_option --signal SIGHUP +try_option -1 +try_option -HUP +try_option -SIGHUP + +if $all_ok; then + echo 'all ok' >> "$TS_OUTPUT" +fi +rm -f "$HELPER_SYMLINK" + +ts_finalize diff --git a/tests/ts/kill/print_pid b/tests/ts/kill/print_pid new file mode 100755 index 0000000..6e2db37 --- /dev/null +++ b/tests/ts/kill/print_pid @@ -0,0 +1,63 @@ +#!/bin/bash + +# 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="print_pid" + +. "$TS_TOPDIR/functions.sh" +ts_init "$*" + +# make sure we do not use shell built-in command +if [ "$TS_USE_SYSTEM_COMMANDS" == "yes" ]; then + TS_CMD_KILL="$(which kill)" +fi + +ts_check_test_command "$TS_CMD_KILL" +ts_check_test_command "$TS_HELPER_SIGRECEIVE" + +. "$TS_SELF/kill_functions.sh" + +all_ok=true + +HELPER_SYMLINK="$(mktemp "${TS_OUTDIR}/prXXXXXXXXXXXXX")" +ln -sf "$TS_HELPER_SIGRECEIVE" "$HELPER_SYMLINK" + +"$HELPER_SYMLINK" >> $TS_OUTPUT 2>> $TS_ERRLOG & +TEST_PID=$! +check_test_sigreceive $TEST_PID +[ $? -eq 1 ] || echo "${HELPER_SYMLINK##*/} helper did not start" >> "$TS_OUTPUT" + +KILL_PID=$("$TS_CMD_KILL" -p ${HELPER_SYMLINK##*/} 2>> $TS_OUTPUT 2>> $TS_ERRLOG) +if [ $? -ne 0 ]; then + echo "kill -p did not work" >> "$TS_OUTPUT" + all_ok=false +fi +if [ "x$TEST_PID" != "x$KILL_PID" ]; then + echo "jobs -p $TEST_PID != kill -p $KILL_PID" >> "$TS_OUTPUT" + all_ok=false +fi + +"$TS_CMD_KILL" -1 $TEST_PID +wait $TEST_PID +if [ $? -ne 1 ]; then + echo "wait $TEST_PID returned ${?}" >> "$TS_OUTPUT" + all_ok=false +fi + +if $all_ok; then + echo 'all ok' >> "$TS_OUTPUT" +fi +rm -f "$HELPER_SYMLINK" + +ts_finalize diff --git a/tests/ts/kill/queue b/tests/ts/kill/queue new file mode 100755 index 0000000..6c9e9ef --- /dev/null +++ b/tests/ts/kill/queue @@ -0,0 +1,58 @@ +#!/bin/bash + +# 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="queue" + +. "$TS_TOPDIR/functions.sh" +ts_init "$*" + +# make sure we do not use shell built-in command +if [ "$TS_USE_SYSTEM_COMMANDS" == "yes" ]; then + TS_CMD_KILL="$(which kill)" +fi + +ts_check_test_command "$TS_CMD_KILL" +ts_check_test_command "$TS_HELPER_SIGRECEIVE" + +. "$TS_SELF/kill_functions.sh" + +all_ok=true + +HELPER_SYMLINK="$(mktemp "${TS_OUTDIR}/quXXXXXXXXXXXXX")" +ln -sf "$TS_HELPER_SIGRECEIVE" "$HELPER_SYMLINK" + +"$HELPER_SYMLINK" >> $TS_OUTPUT 2>> $TS_ERRLOG & +TEST_PID=$! +check_test_sigreceive $TEST_PID +[ $? -eq 1 ] || echo "${HELPER_SYMLINK##*/} helper did not start" >> "$TS_OUTPUT" + +"$TS_CMD_KILL" -1 --queue 42 $TEST_PID >> $TS_OUTPUT 2>> $TS_ERRLOG +if [ $? -ne 0 ]; then + echo "kill --queue 42 failed" >> "$TS_OUTPUT" + all_ok=false +fi +wait $TEST_PID +if [ $? -ne 42 ]; then + echo "wait $TEST_PID returned $? instead of 42" >> "$TS_OUTPUT" + all_ok=false +fi + +if $all_ok; then + echo 'all ok' >> "$TS_OUTPUT" +fi + +rm -f "$HELPER_SYMLINK" + +ts_finalize diff --git a/tests/ts/lib/procfs b/tests/ts/lib/procfs new file mode 100755 index 0000000..998aa39 --- /dev/null +++ b/tests/ts/lib/procfs @@ -0,0 +1,57 @@ +#!/bin/bash +# +# Copyright (C) 2022 Thomas Weißschuh +# +# 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="procfs library" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_PROCFS" + +test_data="$TS_SELF/procfs-data" +test_cmd() { + "$TS_HELPER_PROCFS" --prefix "$test_data" "$@" \ + 2>> "$TS_ERRLOG" \ + | sed -e 's/ UID: .*/ UID: [redacted]/' \ + >> "$TS_OUTPUT" +} + +ts_init_subtest "one-process" + +test_cmd --one 1 +test_cmd --one 2 +test_cmd --one 3 + +ts_finalize_subtest + + +ts_init_subtest "stat-nth" + +test_cmd --stat-nth 1 1 +test_cmd --stat-nth 1 2 +test_cmd --stat-nth 1 3 +test_cmd --stat-nth 1 4 + +test_cmd --stat-nth 2 1 +test_cmd --stat-nth 2 4 + +test_cmd --stat-nth 3 1 +test_cmd --stat-nth 3 4 + +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/lib/procfs-data/proc/1/cmdline b/tests/ts/lib/procfs-data/proc/1/cmdline new file mode 100644 index 0000000..2baeb31 Binary files /dev/null and b/tests/ts/lib/procfs-data/proc/1/cmdline differ diff --git a/tests/ts/lib/procfs-data/proc/1/comm b/tests/ts/lib/procfs-data/proc/1/comm new file mode 100644 index 0000000..9daeafb --- /dev/null +++ b/tests/ts/lib/procfs-data/proc/1/comm @@ -0,0 +1 @@ +test diff --git a/tests/ts/lib/procfs-data/proc/1/stat b/tests/ts/lib/procfs-data/proc/1/stat new file mode 100644 index 0000000..35cb1bd --- /dev/null +++ b/tests/ts/lib/procfs-data/proc/1/stat @@ -0,0 +1 @@ +373850 (test) S 373752 373850 373752 34835 373850 4194304 83 0 0 0 0 0 0 0 20 0 1 0 6164479 2543616 320 18446744073709551615 94138801930240 94138801930657 140720370008720 0 0 0 0 0 0 1 0 0 17 1 0 0 0 0 0 94138801941968 94138801942568 94138832138240 140720370011239 140720370011246 140720370011246 140720370012145 0 diff --git a/tests/ts/lib/procfs-data/proc/2/cmdline b/tests/ts/lib/procfs-data/proc/2/cmdline new file mode 100644 index 0000000..5ca4218 Binary files /dev/null and b/tests/ts/lib/procfs-data/proc/2/cmdline differ diff --git a/tests/ts/lib/procfs-data/proc/2/comm b/tests/ts/lib/procfs-data/proc/2/comm new file mode 100644 index 0000000..3bd1f0e --- /dev/null +++ b/tests/ts/lib/procfs-data/proc/2/comm @@ -0,0 +1,2 @@ +foo +bar diff --git a/tests/ts/lib/procfs-data/proc/2/stat b/tests/ts/lib/procfs-data/proc/2/stat new file mode 100644 index 0000000..250e579 --- /dev/null +++ b/tests/ts/lib/procfs-data/proc/2/stat @@ -0,0 +1,2 @@ +1583 (foo +bar) S 1165 1583 1165 34818 1583 4194304 82 0 0 0 0 0 0 0 20 0 1 0 17487 2543616 215 18446744073709551615 93858497511424 93858497511841 140729173273328 0 0 0 0 0 0 1 0 0 17 0 0 0 0 0 0 93858497523152 93858497523752 93858527924224 140729173281886 140729173281896 140729173281896 140729173282798 0 diff --git a/tests/ts/lib/procfs-data/proc/3/cmdline b/tests/ts/lib/procfs-data/proc/3/cmdline new file mode 100644 index 0000000..4840b32 Binary files /dev/null and b/tests/ts/lib/procfs-data/proc/3/cmdline differ diff --git a/tests/ts/lib/procfs-data/proc/3/comm b/tests/ts/lib/procfs-data/proc/3/comm new file mode 100644 index 0000000..57bf5bb --- /dev/null +++ b/tests/ts/lib/procfs-data/proc/3/comm @@ -0,0 +1 @@ +foo )bar diff --git a/tests/ts/lib/procfs-data/proc/3/stat b/tests/ts/lib/procfs-data/proc/3/stat new file mode 100644 index 0000000..4b5f575 --- /dev/null +++ b/tests/ts/lib/procfs-data/proc/3/stat @@ -0,0 +1 @@ +4102 (foo )bar) S 1165 4102 1165 34818 4102 4194304 80 0 0 0 0 0 0 0 20 0 1 0 61909 2543616 215 18446744073709551615 94697631760384 94697631760801 140728832669632 0 0 0 0 0 0 1 0 0 17 0 0 0 0 0 0 94697631772112 94697631772712 94697662554112 140728832670811 140728832670822 140728832670822 140728832671725 0 diff --git a/tests/ts/lib/timeutils b/tests/ts/lib/timeutils new file mode 100755 index 0000000..13ec68b --- /dev/null +++ b/tests/ts/lib/timeutils @@ -0,0 +1,24 @@ +#!/bin/bash +# +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (C) 2023 Thomas Weißschuh +# +# This file may be distributed under the terms of the +# GNU Lesser General Public License. +# +TS_TOPDIR="${0%/*}/../.." +TS_DESC="timeutils library" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_TIMEUTILS" + +ts_init_subtest "timestamp" + +"$TS_HELPER_TIMEUTILS" --unittest-timestamp 2> "$TS_ERRLOG" + +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/libfdisk/gpt b/tests/ts/libfdisk/gpt new file mode 100755 index 0000000..b401929 --- /dev/null +++ b/tests/ts/libfdisk/gpt @@ -0,0 +1,65 @@ +#!/bin/bash +# +# 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="GPT" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +TESTPROG="$TS_HELPER_LIBFDISK_GPT" +ts_check_test_command "$TESTPROG" +ts_check_test_command "$TS_CMD_SFDISK" + +TEST_IMAGE_NAME=$(ts_image_init 10) + +ts_init_subtest "all-defaults" +$TS_CMD_SFDISK --unit S ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG <> $TS_OUTPUT 2>> $TS_ERRLOG <> $TS_OUTPUT 2>> $TS_ERRLOG +ts_run $TESTPROG --getattr ${TEST_IMAGE_NAME} 2 >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "setattr" +ts_run $TESTPROG --setattr ${TEST_IMAGE_NAME} 1 0xff00000000000000 >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_run $TESTPROG --setattr ${TEST_IMAGE_NAME} 2 0x4 >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --part-attrs ${TEST_IMAGE_NAME} 1 >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --part-attrs ${TEST_IMAGE_NAME} 2 >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/libfdisk/mkpart b/tests/ts/libfdisk/mkpart new file mode 100755 index 0000000..6038f26 --- /dev/null +++ b/tests/ts/libfdisk/mkpart @@ -0,0 +1,66 @@ +#!/bin/bash +# +# 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. +# +# Create partition in non-interactive mode. +# + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="mkpart" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +TESTPROG="$TS_HELPER_LIBFDISK_MKPART" +ts_check_test_command "$TESTPROG" +ts_check_test_command "$TS_CMD_SFDISK" +ts_check_test_command "$TS_CMD_WIPEFS" + +TEST_IMAGE_NAME=$(ts_image_init 15) + +ts_init_subtest "mbr" +$TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ + 1M 1M 1M - >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + +ts_init_subtest "mbr-logic" +$TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ + 1M 1M 1M - 1M 1M ->> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + +ts_init_subtest "mbr-nopartno" +$TESTPROG --nopartno --label mbr --device ${TEST_IMAGE_NAME} \ + 1M 1M 1M - 1M 1M ->> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + +ts_init_subtest "gpt" +$TESTPROG --label gpt --device ${TEST_IMAGE_NAME} \ + 1M 1M 1M 1M 1M 1M - >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + + +ts_finalize diff --git a/tests/ts/libfdisk/mkpart-full b/tests/ts/libfdisk/mkpart-full new file mode 100755 index 0000000..4c026ce --- /dev/null +++ b/tests/ts/libfdisk/mkpart-full @@ -0,0 +1,225 @@ +#!/bin/bash +# +# 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. +# +# +# Create partition in non-interactive mode; like mkpart, but partition is fully +# specifuied by partno, start and size. +# + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="mkpart-full" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +TESTPROG="$TS_HELPER_LIBFDISK_MKPART_FULLSPEC" +ts_check_test_command "$TESTPROG" +ts_check_test_command "$TS_CMD_SFDISK" +ts_check_test_command "$TS_CMD_WIPEFS" + +TEST_IMAGE_NAME=$(ts_image_init 15) + +ts_init_subtest "mbr-primary" +ts_run $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ + 1,2048,2048 \ + 2,4096,2048 \ + 3,6144,2048 \ + 4,8192,22528 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + + +ts_init_subtest "mbr-primary-nopartno" +ts_run $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} -- \ + -,2048,2048 \ + -,4096,2048 \ + -,6144,2048 \ + -,8192,22528 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + +## no extended but partno > 4 requested +ts_init_subtest "mbr-err-primary" +ts_run $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ + 1,2048,2048 \ + 2,4096,2048 \ + 7,6144,2048 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + +## no extended but partno > 4 requested +ts_init_subtest "mbr-err-nospace" +ts_run $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ + 1,2048,2048 \ + 2,4096,2048 \ + 3,4096,2048 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + + +ts_init_subtest "mbr-logical" +ts_run $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ + 1,2048,2048 \ + 2,4096,2048 \ + 3,6144,2048 \ + 4,8192,22528 \ + 5,10240,2048 \ + 6,14336,2048 \ + 7,18432,12288 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + +ts_init_subtest "mbr-nopartno" +ts_run $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} -- \ + -,2048,2048 \ + -,4096,2048 \ + -,6144,2048 \ + -,8192,22528 \ + -,10240,2048 \ + -,14336,2048 \ + -,18432,12288 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + +### 6th partition (logical) out of extended +ts_init_subtest "mbr-err-logical" +ts_run $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ + 1,2048,2048 \ + 2,4096,2048 \ + 3,6144,2048 \ + 4,8192,22528 \ + 5,10240,2048 \ + 6,4096,2048 \ + 7,18432,12288 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + +ts_init_subtest "mbr-space-gap" +ts_run $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ + 1,2048,2048 \ + 2,6144,2048 \ + 3,8192,2048 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + +ts_init_subtest "gpt" +ts_run $TESTPROG --label gpt --device ${TEST_IMAGE_NAME} \ + 1,2048,2048 \ + 2,4096,2048 \ + 3,6144,2048 \ + 4,8192,2048 \ + 5,10240,2048 \ + 6,12288,2048 \ + 7,14336,2048 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + +ts_init_subtest "gpt-nopartno" +ts_run $TESTPROG --label gpt --device ${TEST_IMAGE_NAME} -- \ + -,2048,2048 \ + -,4096,2048 \ + -,6144,2048 \ + -,8192,2048 \ + -,10240,2048 \ + -,12288,2048 \ + -,14336,2048 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + +### 4th partition overlap 4th and 5th +ts_init_subtest "gpt-err-overlap" +ts_run $TESTPROG --label gpt --device ${TEST_IMAGE_NAME} \ + 1,2048,2048 \ + 2,4096,2048 \ + 3,6144,2048 \ + 4,5000,2048 \ + 5,10240,2048 \ + 6,12288,2048 \ + 7,14336,2048 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + +ts_init_subtest "gpt-partno-gap" +ts_run $TESTPROG --label gpt --device ${TEST_IMAGE_NAME} \ + 1,2048,2048 \ + 2,4096,2048 \ + 4,6144,2048 \ + 5,8192,2048 \ + 7,10240,2048 \ + 8,12288,2048 \ + 9,14336,2048 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + +ts_init_subtest "gpt-space-gap" +ts_run $TESTPROG --label gpt --device ${TEST_IMAGE_NAME} \ + 1,2048,2048 \ + 2,6144,2048 \ + 3,8192,2048 \ + 4,12288,2048 \ + 5,14336,2048 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/libmount/context b/tests/ts/libmount/context new file mode 100755 index 0000000..a5d2e81 --- /dev/null +++ b/tests/ts/libmount/context @@ -0,0 +1,169 @@ +#!/bin/bash + +# Copyright (C) 2010 Karel Zak + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="context" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FDISK" +ts_check_test_command "$TS_CMD_FINDMNT" +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" +ts_check_test_command "$TS_CMD_UUIDGEN" + +ts_skip_nonroot +ts_check_prog "mkfs.ext2" +ts_check_prog "mkfs.ext4" + +TESTPROG="$TS_HELPER_LIBMOUNT_CONTEXT" +LABEL=libmount-test +UUID=$($TS_CMD_UUIDGEN) + +MOUNTPOINT="$TS_MOUNTPOINT" +[ -x $TESTPROG ] || ts_skip "test not compiled" + +ts_log "Init device" +$TS_CMD_UMOUNT $MOUNTPOINT &> /dev/null + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=100 +DEVNAME=$(basename $TS_DEVICE) + +ts_log "Create partitions" +$TS_CMD_FDISK --noauto-pt ${TS_DEVICE} &> /dev/null < /dev/null + +ts_log "Do tests..." + +function is_mounted { + ts_is_mounted "$1" + return $? +} + + +udevadm settle +ts_device_has "TYPE" "ext4" $DEVICE || ts_die "Cannot find ext2 on $DEVICE" + + +ts_init_subtest "mount-by-devname" +mkdir -p $MOUNTPOINT &> /dev/null +ts_run $TESTPROG --mount $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +is_mounted $DEVICE || echo "$DEVICE not mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +ts_init_subtest "umount-by-devname" +ts_run $TESTPROG --umount $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG +is_mounted $DEVICE && echo "$DEVICE still mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +ts_init_subtest "mount-by-label" +mkdir -p $MOUNTPOINT &> /dev/null +ts_run $TESTPROG --mount LABEL="$LABEL" $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +is_mounted $DEVICE || echo "$DEVICE not mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +ts_init_subtest "umount-by-mountpoint" +ts_run $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +is_mounted $DEVICE && echo "$DEVICE still mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +ts_init_subtest "mount-by-uuid" +mkdir -p $MOUNTPOINT &> /dev/null +ts_run $TESTPROG --mount UUID="$UUID" $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +is_mounted $DEVICE || echo "$DEVICE not mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG +sleep 1 +ts_run $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +sleep 1 +is_mounted $DEVICE && echo "$DEVICE still mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +ts_init_subtest "mount-flags" +mkdir -p $MOUNTPOINT &> /dev/null +ts_run $TESTPROG --mount -o ro,noexec,nosuid,strictatime $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_FINDMNT --kernel --mountpoint $MOUNTPOINT -o VFS-OPTIONS -n >> $TS_OUTPUT 2>> $TS_ERRLOG +is_mounted $DEVICE || echo "$DEVICE not mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_run $TESTPROG --mount -o remount,rw $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_FINDMNT --kernel --mountpoint $MOUNTPOINT -o VFS-OPTIONS -n >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_run $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +is_mounted $DEVICE && echo "$DEVICE still mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG + +# Test that the atime option works after the migration to use the new kernel mount APIs. +ts_run $TESTPROG --mount -o atime $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_FINDMNT --kernel --mountpoint $MOUNTPOINT -o VFS-OPTIONS -n >> $TS_OUTPUT 2>> $TS_ERRLOG +is_mounted $DEVICE || echo "$DEVICE not mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_run $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +is_mounted $DEVICE && echo "$DEVICE still mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_finalize_subtest + +ts_init_subtest "mount-loopdev" +mkdir -p $MOUNTPOINT &> /dev/null +img=$(ts_image_init) +mkfs.ext2 -F $img &> /dev/null +udevadm settle + +ts_run $TESTPROG --mount -o loop $img $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +is_mounted $MOUNTPOINT || echo "$MOUNTPOINT not mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle +ts_run $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +is_mounted $MOUNTPOINT && echo "$MOUNTPOINT still mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +# deprecated (x-* mount option maintained in userspace (e.g. utab) +ts_init_subtest "x-permanent" +TS_NOEXIST="$TS_OUTDIR/${TS_TESTNAME}-${TS_SUBNAME}-noex" +[ -d $TS_NOEXIST ] && rmdir $TS_NOEXIST + +$TS_CMD_MOUNT -o x-mount.mkdir --bind $MOUNTPOINT $TS_NOEXIST >> $TS_OUTPUT 2>> $TS_ERRLOG && + echo "successfully mounted" >> $TS_OUTPUT +ts_finalize_subtest + +$TS_CMD_UMOUNT $TS_NOEXIST +rmdir $TS_NOEXIST + + +# X-* comment +ts_init_subtest "X-comment" +TS_NOEXIST="$TS_OUTDIR/${TS_TESTNAME}-${TS_SUBNAME}-noex" +[ -d $TS_NOEXIST ] && rmdir $TS_NOEXIST + +$TS_CMD_MOUNT -o X-mount.mkdir --bind $MOUNTPOINT $TS_NOEXIST >> $TS_OUTPUT 2>> $TS_ERRLOG && + echo "successfully mounted" >> $TS_OUTPUT +ts_finalize_subtest + +$TS_CMD_UMOUNT $TS_NOEXIST +rmdir $TS_NOEXIST + +ts_log "...done." +ts_finalize diff --git a/tests/ts/libmount/context-py b/tests/ts/libmount/context-py new file mode 100755 index 0000000..53a211c --- /dev/null +++ b/tests/ts/libmount/context-py @@ -0,0 +1,152 @@ +#!/bin/bash + +# Copyright (C) 2010 Karel Zak + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="context-py" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FDISK" +ts_check_test_command "$TS_CMD_FINDMNT" +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" +ts_check_test_command "$TS_CMD_UUIDGEN" + +ts_skip_nonroot +ts_check_prog "mkfs.ext2" +ts_check_prog "mkfs.ext4" + +ts_init_py libmount + +if [ "$TS_ENABLE_ASAN" == "yes" -o "$TS_ENABLE_UBSAN" == "yes" ]; then + TS_KNOWN_FAIL="yes" +fi + +TESTPROG="$TS_HELPER_PYLIBMOUNT_CONTEXT" +[ -x $TESTPROG ] || ts_die "test script missing" + +PYDBG="$PYTHON -m pdb" +LABEL=libmount-test +UUID=$($TS_CMD_UUIDGEN) +MOUNTPOINT="$TS_MOUNTPOINT" +TS_NOEXIST="$TS_OUTDIR/${TS_TESTNAME}-${TS_SUBNAME}-noex" +[ -d $TS_NOEXIST ] && rmdir $TS_NOEXIST + +ts_log "Init device" +$TS_CMD_UMOUNT $MOUNTPOINT &> /dev/null + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=100 +DEVNAME=$(basename $TS_DEVICE) + +ts_log "Create partitions" +$TS_CMD_FDISK --noauto-pt ${TS_DEVICE} &> /dev/null < /dev/null + +ts_log "Do tests..." + +function is_mounted { + ts_is_mounted "$1" + return $? +} + + +udevadm settle +ts_device_has "TYPE" "ext4" $DEVICE || ts_die "Cannot find ext2 on $DEVICE" + + +ts_init_subtest "mount-by-devname" +mkdir -p $MOUNTPOINT &> /dev/null +$PYTHON $TESTPROG --mount $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +is_mounted $DEVICE || echo "$DEVICE not mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +ts_init_subtest "umount-by-devname" +$PYTHON $TESTPROG --umount $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG +is_mounted $DEVICE && echo "$DEVICE still mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +ts_init_subtest "mount-by-label" +mkdir -p $MOUNTPOINT &> /dev/null +$PYTHON $TESTPROG --mount LABEL="$LABEL" $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +is_mounted $DEVICE || echo "$DEVICE not mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +ts_init_subtest "umount-by-mountpoint" +$PYTHON $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +is_mounted $DEVICE && echo "$DEVICE still mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +ts_init_subtest "mount-by-uuid" +mkdir -p $MOUNTPOINT &> /dev/null +$PYTHON $TESTPROG --mount UUID="$UUID" $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +is_mounted $DEVICE || echo "$DEVICE not mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG +$PYTHON $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +is_mounted $DEVICE && echo "$DEVICE still mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +ts_init_subtest "mount-flags" +mkdir -p $MOUNTPOINT &> /dev/null +$PYTHON $TESTPROG --mount -o ro,noexec,nosuid,strictatime $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_FINDMNT --kernel $MOUNTPOINT -o VFS-OPTIONS -n >> $TS_OUTPUT 2>> $TS_ERRLOG +is_mounted $DEVICE || echo "$DEVICE not mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG + +$PYTHON $TESTPROG --mount -o remount,rw $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_FINDMNT --kernel $MOUNTPOINT -o VFS-OPTIONS -n >> $TS_OUTPUT 2>> $TS_ERRLOG + +$PYTHON $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +is_mounted $DEVICE && echo "$DEVICE still mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +ts_init_subtest "mount-loopdev" +mkdir -p $MOUNTPOINT &> /dev/null +img=$(ts_image_init) +mkfs.ext2 -F $img &> /dev/null +udevadm settle + +$PYTHON $TESTPROG --mount -o loop $img $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +is_mounted $MOUNTPOINT || echo "$MOUNTPOINT not mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle +$PYTHON $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +is_mounted $MOUNTPOINT && echo "$MOUNTPOINT still mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "x-mount.mkdir" +$TS_CMD_MOUNT -o x-mount.mkdir --bind $MOUNTPOINT $TS_NOEXIST >> $TS_OUTPUT 2>> $TS_ERRLOG && + echo "successfully mounted" >> $TS_OUTPUT +ts_finalize_subtest + + +$TS_CMD_UMOUNT $TS_NOEXIST +rmdir $TS_NOEXIST + +ts_log "...done." +ts_finalize diff --git a/tests/ts/libmount/context-utab b/tests/ts/libmount/context-utab new file mode 100755 index 0000000..c67017c --- /dev/null +++ b/tests/ts/libmount/context-utab @@ -0,0 +1,129 @@ +#!/bin/bash + +# Copyright (C) 2010 Karel Zak + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="context (utab)" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FDISK" +#ts_check_test_command "$TS_CMD_FINDMNT" +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" +ts_check_test_command "$TS_CMD_WIPEFS" +ts_check_test_command "$TS_CMD_UUIDGEN" + +ts_skip_nonroot +ts_check_prog "mkfs.ext4" + +TESTPROG="$TS_HELPER_LIBMOUNT_CONTEXT" +LABEL=libmount-test +UUID=$($TS_CMD_UUIDGEN) +MOUNTPOINT="$TS_MOUNTPOINT" + +[ -x $TESTPROG ] || ts_skip "test not compiled" + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=257 +DEVNAME=$(basename $TS_DEVICE) + +ts_log "Create partitions" +$TS_CMD_FDISK --noauto-pt ${TS_DEVICE} &> /dev/null < /dev/null + +ts_log "Do tests..." + +export LIBMOUNT_UTAB=$TS_OUTPUT.utab +rm -f $LIBMOUNT_UTAB +> $LIBMOUNT_UTAB + +udevadm settle + +ts_init_subtest "mount-by-devname" +mkdir -p $MOUNTPOINT &> /dev/null +ts_run $TESTPROG --mount $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted "$DEVICE" || \ + echo "(by device) cannot find $DEVICE in /proc/mounts" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +ts_init_subtest "umount-by-devname" +ts_run $TESTPROG --umount $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted "$DEVICE" && + echo "umount (device) failed: found $DEVICE in /proc/mounts" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +ts_init_subtest "mount-uhelper" +mkdir -p $MOUNTPOINT &> /dev/null +ts_run $TESTPROG --mount -o uhelper=foo,rw LABEL="$LABEL" $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +grep -q "SRC=$DEVICE\b" "$LIBMOUNT_UTAB" || \ + echo "(by label) cannot find $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +ts_init_subtest "umount" +ts_run $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +grep -q "SRC=$DEVICE\b" "$LIBMOUNT_UTAB" && \ + echo "umount (mountpoint) failed: found $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +if type "mkfs.btrfs" &>/dev/null && mkfs.btrfs --version &>/dev/null; then + $TS_CMD_WIPEFS -a $DEVICE &> /dev/null + #ts_log "Create filesystem [btrfs]" + mkfs.btrfs -L "$LABEL" $DEVICE &> /dev/null + udevadm settle + + $TS_CMD_MOUNT -t btrfs $DEVICE $MOUNTPOINT &> /dev/null + btrfs subvolume create $MOUNTPOINT/sub &> /dev/null + $TS_CMD_UMOUNT $MOUNTPOINT &> /dev/null + + udevadm settle + + ts_init_subtest "mount-uhelper-subvol" + mkdir -p $MOUNTPOINT &> /dev/null + ts_run $TESTPROG --mount -o uhelper=foo,rw,subvol=sub $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG + grep -q "SRC=$DEVICE\b" "$LIBMOUNT_UTAB" || \ + echo "cannot find $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>> $TS_ERRLOG + ts_finalize_subtest + + # Don't temporary write btrfs mount options to the test output, + # the options depend on kernel version (since 4.2 it contains + # subvol= and subvolid=). + # + #ts_log "All mount options (btrfs subvolume + utab) ---" + #$TS_CMD_FINDMNT --mtab --mountpoint $MOUNTPOINT -o OPTIONS -n >> $TS_OUTPUT 2>> $TS_ERRLOG + #ts_log "---" + + ts_init_subtest "umount-subvol" + ts_run $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG + grep -q "SRC=$DEVICE\b" "$LIBMOUNT_UTAB" && \ + echo "umount (mountpoint) failed: found $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>> $TS_ERRLOG + ts_finalize_subtest +fi + +ts_log "...done." +ts_finalize diff --git a/tests/ts/libmount/context-utab-py b/tests/ts/libmount/context-utab-py new file mode 100755 index 0000000..59c9e49 --- /dev/null +++ b/tests/ts/libmount/context-utab-py @@ -0,0 +1,134 @@ +#!/bin/bash + +# Copyright (C) 2010 Karel Zak +TS_TOPDIR="${0%/*}/../.." +TS_DESC="context-py (utab)" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FDISK" +ts_check_test_command "$TS_CMD_FINDMNT" +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" +ts_check_test_command "$TS_CMD_WIPEFS" +ts_check_test_command "$TS_CMD_UUIDGEN" + +ts_skip_nonroot +ts_check_prog "mkfs.ext4" + +ts_init_py libmount + +if [ "$TS_ENABLE_ASAN" == "yes" -o "$TS_ENABLE_UBSAN" == "yes" ]; then + TS_KNOWN_FAIL="yes" +fi + +TESTPROG="$TS_HELPER_PYLIBMOUNT_CONTEXT" +[ -x $TESTPROG ] || ts_die "test script missing" + +LABEL=libmount-test +UUID=$($TS_CMD_UUIDGEN) +MOUNTPOINT="$TS_MOUNTPOINT" + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=257 +DEVNAME=$(basename $TS_DEVICE) + +ts_log "Create partitions" +$TS_CMD_FDISK --noauto-pt ${TS_DEVICE} &> /dev/null < /dev/null + +ts_log "Do tests..." + +export LIBMOUNT_UTAB=$TS_OUTPUT.utab +rm -f $LIBMOUNT_UTAB +> $LIBMOUNT_UTAB + +udevadm settle + +ts_init_subtest "mount-by-devname" +mkdir -p $MOUNTPOINT &> /dev/null +$PYTHON $TESTPROG --mount $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted "$DEVICE" || \ + echo "(by device) cannot find $DEVICE in /proc/mounts" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +ts_init_subtest "umount-by-devname" +$PYTHON $TESTPROG --umount $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted "$DEVICE" && + echo "umount (device) failed: found $DEVICE in /proc/mounts" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +ts_init_subtest "mount-uhelper" +mkdir -p $MOUNTPOINT &> /dev/null +$PYTHON $TESTPROG --mount -o uhelper=foo,rw LABEL="$LABEL" $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +grep -q "SRC=$DEVICE\b" "$LIBMOUNT_UTAB" || \ + echo "(by label) cannot find $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +ts_init_subtest "umount" +$PYTHON $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +grep -q "SRC=$DEVICE\b" "$LIBMOUNT_UTAB" && \ + echo "umount (mountpoint) failed: found $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +if type "mkfs.btrfs" &>/dev/null && mkfs.btrfs --version &>/dev/null; then + $TS_CMD_WIPEFS -a $DEVICE &> /dev/null + #ts_log "Create filesystem [btrfs]" + mkfs.btrfs -L "$LABEL" $DEVICE &> /dev/null + udevadm settle + + $TS_CMD_MOUNT -t btrfs $DEVICE $MOUNTPOINT &> /dev/null + btrfs subvolume create $MOUNTPOINT/sub &> /dev/null + $TS_CMD_UMOUNT $MOUNTPOINT &> /dev/null + + udevadm settle + + ts_init_subtest "mount-uhelper-subvol" + mkdir -p $MOUNTPOINT &> /dev/null + $PYTHON $TESTPROG --mount -o uhelper=foo,rw,subvol=sub $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG + grep -q "SRC=$DEVICE\b" "$LIBMOUNT_UTAB" || \ + echo "cannot find $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>> $TS_ERRLOG + ts_finalize_subtest + + # Don't temporary write btrfs mount options to the test output, + # the options depend on kernel version (since 4.2 it contains + # subvol= and subvolid=). + # + #ts_log "All mount options (btrfs subvolume + utab) ---" + #$TS_CMD_FINDMNT --mtab $MOUNTPOINT -o OPTIONS -n >> $TS_OUTPUT 2>> $TS_ERRLOG + #ts_log "---" + + ts_init_subtest "umount-subvol" + $PYTHON $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG + grep -q $DEVICE $LIBMOUNT_UTAB && \ + echo "umount (mountpoint) failed: found $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>> $TS_ERRLOG + ts_finalize_subtest +fi + +ts_log "...done." +ts_finalize diff --git a/tests/ts/libmount/debug b/tests/ts/libmount/debug new file mode 100755 index 0000000..e98d922 --- /dev/null +++ b/tests/ts/libmount/debug @@ -0,0 +1,30 @@ +#!/bin/bash + +# Copyright (C) 2014 Ondrej Oprala &1 | grep -o '0x.*' &> $TS_OUTPUT +ts_finalize_subtest + +# CACHE | LOCKS +ts_init_subtest "set-from-env-str" +LIBMOUNT_DEBUG=cache,locks ts_run $TESTPROG 2>&1 | grep -o '0x.*' &> $TS_OUTPUT +ts_finalize_subtest + +# CACHE | LOCKS +ts_init_subtest "set-from-env-int" +LIBMOUNT_DEBUG=20 ts_run $TESTPROG 2>&1 | grep -o '0x.*' &> $TS_OUTPUT +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/libmount/files/fstab b/tests/ts/libmount/files/fstab new file mode 100644 index 0000000..a8f73bc --- /dev/null +++ b/tests/ts/libmount/files/fstab @@ -0,0 +1,14 @@ +UUID=d3a8f783-df75-4dc8-9163-975a891052c0 / ext3 noatime,defaults 1 1 +UUID=fef7ccb3-821c-4de8-88dc-71472be5946f /boot ext3 noatime,defaults 1 2 +UUID=1f2aa318-9c34-462e-8d29-260819ffd657 swap swap defaults 0 0 +tmpfs /dev/shm tmpfs defaults 0 0 +devpts /dev/pts devpts gid=5,mode=620 0 0 +sysfs /sys sysfs defaults 0 0 +proc /proc proc defaults 0 0 +# this is comment +/dev/mapper/foo /home/foo ext4 noatime,defaults 0 0 + +foo.com:/mnt/share /mnt/remote nfs noauto +//bar.com/gogogo /mnt/gogogo cifs user=SRGROUP/baby,noauto + +/dev/foo /any/foo/ auto defaults 0 0 diff --git a/tests/ts/libmount/files/fstab.broken b/tests/ts/libmount/files/fstab.broken new file mode 100644 index 0000000..c79f026 --- /dev/null +++ b/tests/ts/libmount/files/fstab.broken @@ -0,0 +1,14 @@ +bug +UUID=d3a8f783-df75-4dc8-9163-975a891052c0 / ext3 noatime,defaults 1 1 +UUID=fef7ccb3-821c-4de8-88dc-71472be5946f /boot ext3 noatime,defaults 1 2 + UUID=1f2aa318-9c34-462e-8d29-260819ffd657 swap swap defaults 0 0 +tmpfs /dev/shm tmpfs defaults 0 0 +devpts /dev/pts devpts gid=5,mode=620 + sysfs /sys sysfs defaults 0 0 +this is broken line with unexpected number of fields +proc /proc proc defaults 0 0 +# this is comment +/dev/mapper/foo /home/foo ext4 noatime,defaults 1 + +foo.com:/mnt/share /mnt/remote nfs noauto +//bar.com/gogogo /mnt/gogogo cifs user=SRGROUP/baby,noauto diff --git a/tests/ts/libmount/files/fstab.comment b/tests/ts/libmount/files/fstab.comment new file mode 100644 index 0000000..656e663 --- /dev/null +++ b/tests/ts/libmount/files/fstab.comment @@ -0,0 +1,22 @@ +# + # this is a leading comment +# + +# this comments belongs to the first fs +UUID=d3a8f783-df75-4dc8-9163-975a891052c0 / ext3 noatime,defaults 1 1 +UUID=fef7ccb3-821c-4de8-88dc-71472be5946f /boot ext3 noatime,defaults 1 2 + +# 3rd fs comment + newline padding + +UUID=1f2aa318-9c34-462e-8d29-260819ffd657 swap swap defaults 0 0 +tmpfs /dev/shm tmpfs defaults 0 0 +devpts /dev/pts devpts gid=5,mode=620 0 0 +sysfs /sys sysfs defaults 0 0 +proc /proc proc defaults 0 0 +# this is comment +/dev/mapper/foo /home/foo ext4 noatime,defaults 0 0 +foo.com:/mnt/share /mnt/remote nfs noauto +//bar.com/gogogo /mnt/gogogo cifs user=SRGROUP/baby,noauto +/dev/foo /any/foo/ auto defaults 0 0 + +#this is a trailing comment diff --git a/tests/ts/libmount/files/kernel_cmdline b/tests/ts/libmount/files/kernel_cmdline new file mode 100644 index 0000000..37a0c89 --- /dev/null +++ b/tests/ts/libmount/files/kernel_cmdline @@ -0,0 +1 @@ +rd.md=0 rd.lvm=0 rd.dm=0 KEYTABLE=us root=UUID=33230ae2-1093-4353-824c-f7ca09a2a882 rd.luks=0 SYSFONT=latarcyrheb-sun16 ro LANG=en_US.UTF-8 selinux=0 diff --git a/tests/ts/libmount/files/mountinfo b/tests/ts/libmount/files/mountinfo new file mode 100644 index 0000000..2b01740 --- /dev/null +++ b/tests/ts/libmount/files/mountinfo @@ -0,0 +1,33 @@ +15 20 0:3 / /proc rw,relatime - proc /proc rw +16 20 0:15 / /sys rw,relatime - sysfs /sys rw +17 20 0:5 / /dev rw,relatime - devtmpfs udev rw,size=1983516k,nr_inodes=495879,mode=755 +18 17 0:10 / /dev/pts rw,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000 +19 17 0:16 / /dev/shm rw,relatime - tmpfs tmpfs rw +20 1 8:4 / / rw,noatime - ext3 /dev/sda4 rw,errors=continue,user_xattr,acl,barrier=0,data=ordered +21 16 0:17 / /sys/fs/cgroup rw,nosuid,nodev,noexec,relatime - tmpfs tmpfs rw,mode=755 +22 21 0:18 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd +23 21 0:19 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpuset +24 21 0:20 / /sys/fs/cgroup/ns rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,ns +25 21 0:21 / /sys/fs/cgroup/cpu rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpu +26 21 0:22 / /sys/fs/cgroup/cpuacct rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpuacct +27 21 0:23 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,memory +28 21 0:24 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,devices +29 21 0:25 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,freezer +30 21 0:26 / /sys/fs/cgroup/net_cls rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,net_cls +31 21 0:27 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,blkio +32 16 0:28 / /sys/kernel/security rw,relatime - autofs systemd-1 rw,fd=22,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +33 17 0:29 / /dev/hugepages rw,relatime - autofs systemd-1 rw,fd=23,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +34 16 0:30 / /sys/kernel/debug rw,relatime - autofs systemd-1 rw,fd=24,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +35 15 0:31 / /proc/sys/fs/binfmt_misc rw,relatime - autofs systemd-1 rw,fd=25,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +36 17 0:32 / /dev/mqueue rw,relatime - autofs systemd-1 rw,fd=26,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +37 15 0:14 / /proc/bus/usb rw,relatime - usbfs /proc/bus/usb rw +38 33 0:33 / /dev/hugepages rw,relatime - hugetlbfs hugetlbfs rw +39 36 0:12 / /dev/mqueue rw,relatime - mqueue mqueue rw +40 20 8:6 / /boot rw,noatime - ext3 /dev/sda6 rw,errors=continue,barrier=0,data=ordered +41 20 253:0 / /home/kzak rw,noatime - ext4 /dev/mapper/kzak-home rw,barrier=1,data=ordered +42 35 0:34 / /proc/sys/fs/binfmt_misc rw,relatime - binfmt_misc none rw +43 16 0:35 / /sys/fs/fuse/connections rw,relatime - fusectl fusectl rw +44 41 0:36 / /home/kzak/.gvfs rw,nosuid,nodev,relatime - fuse.gvfs-fuse-daemon gvfs-fuse-daemon rw,user_id=500,group_id=500 +45 20 0:37 / /var/lib/nfs/rpc_pipefs rw,relatime - rpc_pipefs sunrpc rw +47 20 0:38 / /mnt/sounds rw,relatime - cifs //foo.home/bar/ rw,unc=\\foo.home\bar,username=kzak,domain=SRGROUP,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.111.1,posixpaths,serverino,acl,rsize=16384,wsize=57344 +49 20 0:56 / /mnt/test/foo bar rw,relatime shared:323 - tmpfs tmpfs rw diff --git a/tests/ts/libmount/files/mountinfo_mv b/tests/ts/libmount/files/mountinfo_mv new file mode 100644 index 0000000..3d55aff --- /dev/null +++ b/tests/ts/libmount/files/mountinfo_mv @@ -0,0 +1,32 @@ +15 20 0:3 / /proc rw,relatime - proc /proc rw +16 20 0:15 / /sys rw,relatime - sysfs /sys rw +17 20 0:5 / /dev rw,relatime - devtmpfs udev rw,size=1983516k,nr_inodes=495879,mode=755 +18 17 0:10 / /dev/pts rw,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000 +19 17 0:16 / /dev/shm rw,relatime - tmpfs tmpfs rw +20 1 8:4 / / rw,noatime - ext3 /dev/sda4 rw,errors=continue,user_xattr,acl,barrier=0,data=ordered +21 16 0:17 / /sys/fs/cgroup rw,nosuid,nodev,noexec,relatime - tmpfs tmpfs rw,mode=755 +22 21 0:18 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd +23 21 0:19 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpuset +24 21 0:20 / /sys/fs/cgroup/ns rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,ns +25 21 0:21 / /sys/fs/cgroup/cpu rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpu +26 21 0:22 / /sys/fs/cgroup/cpuacct rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpuacct +27 21 0:23 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,memory +28 21 0:24 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,devices +29 21 0:25 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,freezer +30 21 0:26 / /sys/fs/cgroup/net_cls rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,net_cls +31 21 0:27 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,blkio +32 16 0:28 / /sys/kernel/security rw,relatime - autofs systemd-1 rw,fd=22,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +33 17 0:29 / /dev/hugepages rw,relatime - autofs systemd-1 rw,fd=23,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +34 16 0:30 / /sys/kernel/debug rw,relatime - autofs systemd-1 rw,fd=24,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +35 15 0:31 / /proc/sys/fs/binfmt_misc rw,relatime - autofs systemd-1 rw,fd=25,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +36 17 0:32 / /dev/mqueue rw,relatime - autofs systemd-1 rw,fd=26,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +37 15 0:14 / /proc/bus/usb rw,relatime - usbfs /proc/bus/usb rw +38 33 0:33 / /dev/hugepages rw,relatime - hugetlbfs hugetlbfs rw +39 36 0:12 / /dev/mqueue rw,relatime - mqueue mqueue rw +40 20 8:6 / /boot rw,noatime - ext3 /dev/sda6 rw,errors=continue,barrier=0,data=ordered +41 20 253:0 / /home/kzak rw,noatime - ext4 /dev/mapper/kzak-home rw,barrier=1,data=ordered +42 35 0:34 / /proc/sys/fs/binfmt_misc rw,relatime - binfmt_misc none rw +43 16 0:35 / /sys/fs/fuse/connections rw,relatime - fusectl fusectl rw +44 41 0:36 / /home/kzak/.gvfs rw,nosuid,nodev,relatime - fuse.gvfs-fuse-daemon gvfs-fuse-daemon rw,user_id=500,group_id=500 +45 20 0:37 / /var/lib/nfs/rpc_pipefs rw,relatime - rpc_pipefs sunrpc rw +47 20 0:38 / /mnt/music rw,relatime - cifs //foo.home/bar/ rw,unc=\\foo.home\bar,username=kzak,domain=SRGROUP,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.111.1,posixpaths,serverino,acl,rsize=16384,wsize=57344 diff --git a/tests/ts/libmount/files/mountinfo_nosrc b/tests/ts/libmount/files/mountinfo_nosrc new file mode 100644 index 0000000..1ef7cf0 --- /dev/null +++ b/tests/ts/libmount/files/mountinfo_nosrc @@ -0,0 +1,7 @@ +15 20 0:3 / /proc rw,relatime - proc /proc rw +16 20 0:15 / /sys rw,relatime - sysfs /sys rw +17 20 0:5 / /dev rw,relatime - devtmpfs udev rw,size=1983516k,nr_inodes=495879,mode=755 +18 17 0:10 / /dev/pts rw,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000 +19 17 0:16 / /dev/shm rw,relatime - tmpfs tmpfs rw +20 1 8:4 / / rw,noatime - ext3 /dev/sda4 rw,errors=continue,user_xattr,acl,barrier=0,data=ordered +21 20 0:53 / /mnt/test rw,relatime shared:212 - tmpfs rw diff --git a/tests/ts/libmount/files/mountinfo_re b/tests/ts/libmount/files/mountinfo_re new file mode 100644 index 0000000..df379fa --- /dev/null +++ b/tests/ts/libmount/files/mountinfo_re @@ -0,0 +1,32 @@ +15 20 0:3 / /proc rw,relatime - proc /proc rw +16 20 0:15 / /sys rw,relatime - sysfs /sys rw +17 20 0:5 / /dev rw,relatime - devtmpfs udev rw,size=1983516k,nr_inodes=495879,mode=755 +18 17 0:10 / /dev/pts rw,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000 +19 17 0:16 / /dev/shm rw,relatime - tmpfs tmpfs rw +20 1 8:4 / / rw,noatime - ext3 /dev/sda4 rw,errors=continue,user_xattr,acl,barrier=0,data=ordered +21 16 0:17 / /sys/fs/cgroup rw,nosuid,nodev,noexec,relatime - tmpfs tmpfs rw,mode=755 +22 21 0:18 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd +23 21 0:19 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpuset +24 21 0:20 / /sys/fs/cgroup/ns rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,ns +25 21 0:21 / /sys/fs/cgroup/cpu rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpu +26 21 0:22 / /sys/fs/cgroup/cpuacct rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpuacct +27 21 0:23 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,memory +28 21 0:24 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,devices +29 21 0:25 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,freezer +30 21 0:26 / /sys/fs/cgroup/net_cls rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,net_cls +31 21 0:27 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,blkio +32 16 0:28 / /sys/kernel/security rw,relatime - autofs systemd-1 rw,fd=22,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +33 17 0:29 / /dev/hugepages rw,relatime - autofs systemd-1 rw,fd=23,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +34 16 0:30 / /sys/kernel/debug rw,relatime - autofs systemd-1 rw,fd=24,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +35 15 0:31 / /proc/sys/fs/binfmt_misc rw,relatime - autofs systemd-1 rw,fd=25,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +36 17 0:32 / /dev/mqueue rw,relatime - autofs systemd-1 rw,fd=26,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +37 15 0:14 / /proc/bus/usb rw,relatime - usbfs /proc/bus/usb rw +38 33 0:33 / /dev/hugepages rw,relatime - hugetlbfs hugetlbfs rw +39 36 0:12 / /dev/mqueue rw,relatime - mqueue mqueue rw +40 20 8:6 / /boot rw,noatime - ext3 /dev/sda6 rw,errors=continue,barrier=0,data=ordered +41 20 253:0 / /home/kzak ro,noatime - ext4 /dev/mapper/kzak-home rw,barrier=1,data=ordered +42 35 0:34 / /proc/sys/fs/binfmt_misc rw,relatime - binfmt_misc none rw +43 16 0:35 / /sys/fs/fuse/connections rw,relatime - fusectl fusectl rw +44 41 0:36 / /home/kzak/.gvfs rw,nosuid,nodev,relatime - fuse.gvfs-fuse-daemon gvfs-fuse-daemon rw,user_id=500,group_id=500 +45 20 0:37 / /var/lib/nfs/rpc_pipefs rw,relatime - rpc_pipefs sunrpc rw +47 20 0:38 / /mnt/sounds rw,relatime - cifs //foo.home/bar/ ro,unc=\\foo.home\bar,username=kzak,domain=SRGROUP,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.111.1,posixpaths,serverino,acl,rsize=16384,wsize=57344 diff --git a/tests/ts/libmount/files/mountinfo_u b/tests/ts/libmount/files/mountinfo_u new file mode 100644 index 0000000..a3dde97 --- /dev/null +++ b/tests/ts/libmount/files/mountinfo_u @@ -0,0 +1,31 @@ +15 20 0:3 / /proc rw,relatime - proc /proc rw +16 20 0:15 / /sys rw,relatime - sysfs /sys rw +17 20 0:5 / /dev rw,relatime - devtmpfs udev rw,size=1983516k,nr_inodes=495879,mode=755 +18 17 0:10 / /dev/pts rw,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000 +19 17 0:16 / /dev/shm rw,relatime - tmpfs tmpfs rw +20 1 8:4 / / rw,noatime - ext3 /dev/sda4 rw,errors=continue,user_xattr,acl,barrier=0,data=ordered +21 16 0:17 / /sys/fs/cgroup rw,nosuid,nodev,noexec,relatime - tmpfs tmpfs rw,mode=755 +22 21 0:18 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd +23 21 0:19 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpuset +24 21 0:20 / /sys/fs/cgroup/ns rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,ns +25 21 0:21 / /sys/fs/cgroup/cpu rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpu +26 21 0:22 / /sys/fs/cgroup/cpuacct rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpuacct +27 21 0:23 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,memory +28 21 0:24 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,devices +29 21 0:25 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,freezer +30 21 0:26 / /sys/fs/cgroup/net_cls rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,net_cls +31 21 0:27 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,blkio +32 16 0:28 / /sys/kernel/security rw,relatime - autofs systemd-1 rw,fd=22,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +33 17 0:29 / /dev/hugepages rw,relatime - autofs systemd-1 rw,fd=23,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +34 16 0:30 / /sys/kernel/debug rw,relatime - autofs systemd-1 rw,fd=24,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +35 15 0:31 / /proc/sys/fs/binfmt_misc rw,relatime - autofs systemd-1 rw,fd=25,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +36 17 0:32 / /dev/mqueue rw,relatime - autofs systemd-1 rw,fd=26,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +37 15 0:14 / /proc/bus/usb rw,relatime - usbfs /proc/bus/usb rw +38 33 0:33 / /dev/hugepages rw,relatime - hugetlbfs hugetlbfs rw +39 36 0:12 / /dev/mqueue rw,relatime - mqueue mqueue rw +40 20 8:6 / /boot rw,noatime - ext3 /dev/sda6 rw,errors=continue,barrier=0,data=ordered +42 35 0:34 / /proc/sys/fs/binfmt_misc rw,relatime - binfmt_misc none rw +43 16 0:35 / /sys/fs/fuse/connections rw,relatime - fusectl fusectl rw +44 41 0:36 / /home/kzak/.gvfs rw,nosuid,nodev,relatime - fuse.gvfs-fuse-daemon gvfs-fuse-daemon rw,user_id=500,group_id=500 +45 20 0:37 / /var/lib/nfs/rpc_pipefs rw,relatime - rpc_pipefs sunrpc rw +47 20 0:38 / /mnt/sounds rw,relatime - cifs //foo.home/bar/ rw,unc=\\foo.home\bar,username=kzak,domain=SRGROUP,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.111.1,posixpaths,serverino,acl,rsize=16384,wsize=57344 diff --git a/tests/ts/libmount/files/mtab b/tests/ts/libmount/files/mtab new file mode 100644 index 0000000..93bc90e --- /dev/null +++ b/tests/ts/libmount/files/mtab @@ -0,0 +1,12 @@ +/dev/sda4 / ext3 rw,noatime 0 0 +proc /proc proc rw 0 0 +sysfs /sys sysfs rw 0 0 +devpts /dev/pts devpts rw,gid=5,mode=620 0 0 +tmpfs /dev/shm tmpfs rw 0 0 +/dev/sda6 /boot ext3 rw,noatime 0 0 +/dev/mapper/kzak-home /home/kzak ext4 rw,noatime 0 0 +none /proc/sys/fs/binfmt_misc binfmt_misc rw 0 0 +fusectl /sys/fs/fuse/connections fusectl rw 0 0 +gvfs-fuse-daemon /home/kzak/.gvfs fuse.gvfs-fuse-daemon rw,nosuid,nodev,user=kzak 0 0 +sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw 0 0 +none /var/tmp/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011 overlay rw,relatime,lowerdir=lower,upperdir=upper,workdir=work 0 0 diff --git a/tests/ts/libmount/files/swaps b/tests/ts/libmount/files/swaps new file mode 100644 index 0000000..13ce933 --- /dev/null +++ b/tests/ts/libmount/files/swaps @@ -0,0 +1,4 @@ +Filename Type Size Used Priority +/dev/dm-2 partition 8151036 2283436 -2 +/some/swapfile file 111 111 0 +/some/swapfile2\040(deleted) file 111 111 0 diff --git a/tests/ts/libmount/lock b/tests/ts/libmount/lock new file mode 100755 index 0000000..e1d046b --- /dev/null +++ b/tests/ts/libmount/lock @@ -0,0 +1,41 @@ +#!/bin/bash + +# Copyright (C) 2010 Karel Zak + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="lock" + +TS_OPTIONAL="yes" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +TESTPROG="$TS_HELPER_LIBMOUNT_LOCK" + +[ -x $TESTPROG ] || ts_skip "test not compiled" + +# +# Be careful with number of processes. Don't forget that there is time limit +# when the mount waits on the mtab lock. If you define too much processes some +# of them will fail with timeout. +# +# Note: the original version (< 2.13) of util-linux is completely useless for +# this test (maximum for this old version is NLOOPS=10 and NPROCESSES=5 (2-way +# 2GHz machine)). It has terrible performance due a bad timeouts implementation +# in lock_mtab(). +# +NLOOPS=1000 +NPROCESSES=50 + + +> $TS_OUTPUT.debug +echo 0 > $TS_OUTPUT +SYNCTIME=$(( $(date +%s) + 5 )) + +for id in $(seq 0 $(( $NPROCESSES - 1 ))); do + ts_run $TESTPROG --lock --synctime $SYNCTIME $TS_OUTPUT $NLOOPS >> $TS_OUTPUT.debug 2>&1 & +done + +wait + +ts_finalize diff --git a/tests/ts/libmount/loop b/tests/ts/libmount/loop new file mode 100755 index 0000000..db807bd --- /dev/null +++ b/tests/ts/libmount/loop @@ -0,0 +1,152 @@ +#!/bin/bash + +# +# Copyright (C) 2016 Stanislav Brabec +# +# 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="losetup-loop" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" +ts_check_test_command "$TS_CMD_FINDMNT" +ts_check_test_command "$TS_CMD_LOSETUP" + +ts_skip_nonroot +ts_check_losetup +ts_check_prog "mkfs.ext2" + +function verify_mount_dev { + local dev=$1 + local mp=$2 + local dev_mounted=$($TS_CMD_FINDMNT -no SOURCE --mountpoint "$mp") + + if test "$dev" != "$dev_mounted" ; then + echo "Mounted incorrect device: have '$dev_mounted', want '$dev'" >&2 + return 1 + fi +} + +# +# file-* tests: Backing file is a regular file +# +BACKFILE=$(ts_image_init 10) + +mkfs.ext2 -F $BACKFILE &> /dev/null || ts_die "Cannot make ext2 on $BACKFILE" + +# All tests are separated by "udevadm settle" because loop device exists some time after +# "losetup -d". This device confuses some tests. And find-race-condition, tests, +# whether re-use of this device works. +udevadm settle + +ts_init_subtest "file" +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +$TS_CMD_MOUNT "$BACKFILE" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_UMOUNT "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle +ts_log "Success" +ts_finalize_subtest + +ts_init_subtest "file-o-loop" +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +$TS_CMD_MOUNT -oloop "$BACKFILE" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_UMOUNT "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle +ts_log "Success" +ts_finalize_subtest + +ts_init_subtest "dev-loop" +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +LODEV=$( $TS_CMD_LOSETUP --find --nooverlap --show $BACKFILE 2>> $TS_OUTPUT ) +$TS_CMD_MOUNT $LODEV "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG +verify_mount_dev "$LODEV" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_UMOUNT "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_LOSETUP --detach $LODEV >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle +ts_log "Success" +ts_finalize_subtest + +ts_init_subtest "o-loop-val" +if [ "$TS_PARALLEL" = "yes" ]; then + # There is a race in $LODEV is usage + ts_skip_subtest "no-reentrant" +else + [ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + LODEV=$( $TS_CMD_LOSETUP --find 2>> $TS_OUTPUT ) + $TS_CMD_MOUNT -oloop=$LODEV "$BACKFILE" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG + verify_mount_dev "$LODEV" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG + $TS_CMD_UMOUNT "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG + udevadm settle + ts_log "Success" + ts_finalize_subtest +fi + +ts_init_subtest "reuse" +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +LODEV=$( $TS_CMD_LOSETUP --find --nooverlap --show "$BACKFILE" 2>> $TS_OUTPUT ) +$TS_CMD_MOUNT "$BACKFILE" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG +verify_mount_dev "$LODEV" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_UMOUNT "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_LOSETUP --detach $LODEV >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle +ts_log "Success" +ts_finalize_subtest + +ts_init_subtest "conflict" +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +LODEV=$( $TS_CMD_LOSETUP --find --nooverlap --show --offset=1000 "$BACKFILE" 2>> $TS_OUTPUT ) +$TS_CMD_MOUNT "$BACKFILE" "$TS_MOUNTPOINT" 2>&1 \ + | sed 's/:.*:/: /; s/for .*/for /' > $TS_OUTPUT +$TS_CMD_LOSETUP --detach $LODEV >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle +ts_log "Success" +ts_finalize_subtest + +ts_init_subtest "o-loop-val-initialized" +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +LODEV=$( $TS_CMD_LOSETUP --show -f "$BACKFILE" 2>>$TS_OUTPUT) +$TS_CMD_MOUNT -oloop=$LODEV "$BACKFILE" "$TS_MOUNTPOINT" 2>&1 \ + | sed 's/:.*:/: /; s/for .*/for /' > $TS_OUTPUT +$TS_CMD_LOSETUP --detach $LODEV >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle +ts_log "Success" +ts_finalize_subtest + +ts_init_subtest "o-loop-val-conflict" +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +cp "$BACKFILE" "$BACKFILE"-2 +LODEV=$( $TS_CMD_LOSETUP --show -f "$BACKFILE"-2 2>> $TS_OUTPUT) +$TS_CMD_MOUNT -oloop=$LODEV "$BACKFILE" "$TS_MOUNTPOINT" 2>&1 \ + | sed 's/:.*:/: /; s/for .*/for /' > $TS_OUTPUT +$TS_CMD_LOSETUP --detach $LODEV >> $TS_OUTPUT 2>> $TS_ERRLOG +rm "$BACKFILE"-2 +udevadm settle +ts_log "Success" +ts_finalize_subtest + +ts_init_subtest "explicit-rw" +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +$TS_CMD_MOUNT -o rw "$BACKFILE" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_FINDMNT -no FS-OPTIONS --mountpoint "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_UMOUNT "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle +ts_log "Success" +ts_finalize_subtest + +ts_log "Success" +ts_finalize diff --git a/tests/ts/libmount/loop-overlay b/tests/ts/libmount/loop-overlay new file mode 100755 index 0000000..257ce8a --- /dev/null +++ b/tests/ts/libmount/loop-overlay @@ -0,0 +1,65 @@ +#!/bin/bash + +# +# Copyright (C) 2016 Stanislav Brabec +# +# 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="loop overlay" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_LOSETUP" +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" + +ts_skip_nonroot +ts_check_losetup +ts_check_prog "mkfs.ext2" +ts_check_prog "dd" +ts_check_prog "stat" + +IMG=$(ts_image_init 5) + +mkfs.ext2 -F "$IMG" &> /dev/null || ts_die "Cannot make extn on $IMG" +OFFSET=$(stat -c %s "$IMG") + +dd if="$IMG" of="$IMG" oflag=append bs=1024k count=5 conv=notrunc &>/dev/null + +[ -d "$TS_MOUNTPOINT-1" ] || mkdir -p $TS_MOUNTPOINT-1 +[ -d "$TS_MOUNTPOINT-2" ] || mkdir -p $TS_MOUNTPOINT-2 + +echo "second should fail" >>$TS_OUTPUT +$TS_CMD_MOUNT -oloop "$IMG" "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" 2>&1 \ + | sed 's/:.*:/: /; s/for .*/for /' >> $TS_OUTPUT +$TS_CMD_UMOUNT "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>> $TS_ERRLOG + +echo "should succeed" >>$TS_OUTPUT +$TS_CMD_MOUNT -oloop,sizelimit=$OFFSET "$IMG" "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_UMOUNT "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_UMOUNT "$TS_MOUNTPOINT-2" >> $TS_OUTPUT 2>> $TS_ERRLOG + +echo "both should fail" >>$TS_OUTPUT +LOOPDEV=$($TS_CMD_LOSETUP --show -f --offset 1 --sizelimit $OFFSET "$IMG") +$TS_CMD_MOUNT -oloop,sizelimit=$OFFSET "$IMG" "$TS_MOUNTPOINT-1" 2>&1 \ + | sed 's/:.*:/: /; s/for .*/for /' >> $TS_OUTPUT +$TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" 2>&1 \ + | sed 's/:.*:/: /; s/for .*/for /' >> $TS_OUTPUT +$TS_CMD_LOSETUP --detach $LOOPDEV + +ts_log "Success" +ts_finalize diff --git a/tests/ts/libmount/optstr b/tests/ts/libmount/optstr new file mode 100755 index 0000000..26d9b73 --- /dev/null +++ b/tests/ts/libmount/optstr @@ -0,0 +1,160 @@ +#!/bin/bash + +# Copyright (C) 2010 Karel Zak + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="options string" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +TESTPROG="$TS_HELPER_LIBMOUNT_OPTSTR" + +[ -x $TESTPROG ] || ts_skip "test not compiled" + +ts_init_subtest "append" +ts_run $TESTPROG --append "aaa,bbb=BBB,context=\"foo,bar,gogo\",ccc" "ddd" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "append-value" +ts_run $TESTPROG --append "aaa,bbb=BBB,ccc" "ddd" "DDD" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "append-empty-value" +ts_run $TESTPROG --append "aaa,bbb=BBB,ccc" "ddd" "" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "prepend" +ts_run $TESTPROG --prepend "aaa,bbb=BBB,ccc" "ddd" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "prepend-value" +ts_run $TESTPROG --prepend "aaa,bbb=BBB,ccc" "ddd" "DDD" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "prepend-empty-value" +ts_run $TESTPROG --prepend "aaa,bbb=BBB,ccc" "ddd" "" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "set-remove" +ts_run $TESTPROG --set "aaa,bbb=BBB,ccc" "bbb" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "set-small" +ts_run $TESTPROG --set "aaa,bbb=BBB,ccc" "bbb" "X" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "set-large" +ts_run $TESTPROG --set "aaa,bbb=BBB,ccc" "bbb" "XXX-YYY-ZZZ" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "set-empty" +ts_run $TESTPROG --set "aaa,bbb=BBB,ccc" "bbb" "" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "set-new" +ts_run $TESTPROG --set "aaa,bbb=BBB,ccc" "aaa" "XXX" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "set-new-empty" +ts_run $TESTPROG --set "aaa,bbb=BBB,ccc" "aaa" "" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "set-new-end" +ts_run $TESTPROG --set "aaa,bbb=BBB,ccc" "ccc" "XXX" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "set-new-end-empty" +ts_run $TESTPROG --set "aaa,bbb=BBB,ccc" "ccc" "" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "get" +ts_run $TESTPROG --get "aaa,bbb=BBB,ccc" "aaa" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "get-value" +ts_run $TESTPROG --get "aaa,bbb=BBB,ccc" "bbb" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "remove" +ts_run $TESTPROG --remove "aaa,bbb=BBB,ccc" "aaa" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "remove-quoted" +ts_run $TESTPROG --remove "aaa,context=\"foo,bar,gogo\",bbb=BBB,ccc" "context" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "remove-value" +ts_run $TESTPROG --remove "aaa,bbb=BBB,ccc" "bbb" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "remove-empty-value" +ts_run $TESTPROG --remove "aaa,bbb=,ccc" "bbb" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "split" +ts_run $TESTPROG --split "aaa,bbb=BBB,ccc,x-bar,x-foo=foodata,user=kzak,noexec,nosuid,loop=/dev/loop0" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "flags" +ts_run $TESTPROG --flags "aaa,bbb=BBB,x-foo,ccc,user=kzak,nodev,noexec,nosuid,loop=/dev/loop0" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "apply-linux" +# Use kernel mount options man (--linux), add noatime, remove noexec and nosuid, +# and keep unknown(e.g. user=kzak) +ts_run $TESTPROG --apply --linux "user=kzak,noexec,nosuid" 0x400 &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "apply-user" +# Use userspace options map (--user), add user and nofail, remove loop, +# and keep unknown (e.g. noexec, nosuid) +ts_run $TESTPROG --apply --user "noexec,nosuid,loop=/dev/looop0" 0x408 &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "apply-user-small-x" +# Use userspace options map (--user), remove X-* and loop=, keep unknown 'something' and +# keep by flags specified x-* +ts_run $TESTPROG --apply --user \ + "something,loop=/dev/looop0,x-gvfs-hide,x-gdu.hide,x-canary,X-foo" 0x00002000 &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "apply-user-large-X" +# Use userspace options map (--user), remove x-* and loop=, keep unknown 'something' and +# keep by flags specified X-* +ts_run $TESTPROG --apply --user \ + "something,loop=/dev/looop0,x-gvfs-hide,x-gdu.hide,x-canary,X-foo,X-bar" 0x00020000 &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "apply-user-Xx" +# Use userspace options map (--user), remove loop=, keep unknown 'something' and +# keep by flags specified X-* and x-*, add by flag specified nofail +ts_run $TESTPROG --apply --user \ + "something,loop=/dev/looop0,x-gvfs-hide,x-gdu.hide,x-canary,X-foo,X-bar" 0x00022400 &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "deduplicate" +ts_run $TESTPROG --dedup bbb,ccc,AAA,xxx,AAA=a,AAA=bbb,ddd,AAA=ccc,fff=eee AAA &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "deduplicate-empty" +ts_run $TESTPROG --dedup bbb,ccc,AAA,xxx,AAA=a,AAA=bbb,ddd,AAA=,fff=eee AAA &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "match" +ts_run $TESTPROG --match "xxx,yyy,zzz" "nozzz" &>> $TS_OUTPUT +ts_run $TESTPROG --match "xxx,yyy,zzz" "xxx,noeee" &>> $TS_OUTPUT +ts_run $TESTPROG --match "bar,zzz" "nofoo" &>> $TS_OUTPUT +ts_run $TESTPROG --match "nofoo,bar" "nofoo" &>> $TS_OUTPUT +ts_run $TESTPROG --match "nofoo,bar" "+nofoo" &>> $TS_OUTPUT +ts_run $TESTPROG --match "bar,zzz" "+nofoo" &>> $TS_OUTPUT +ts_run $TESTPROG --match "bar,zzz" "" &>> $TS_OUTPUT +ts_run $TESTPROG --match "bar,zzz" "+" &>> $TS_OUTPUT +ts_run $TESTPROG --match "" "" &>> $TS_OUTPUT +ts_run $TESTPROG --match "" "foo" &>> $TS_OUTPUT +ts_run $TESTPROG --match "" "nofoo" &>> $TS_OUTPUT +ts_run $TESTPROG --match "" "no,foo" &>> $TS_OUTPUT +ts_run $TESTPROG --match "no" "+no" &>> $TS_OUTPUT +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/libmount/tabdiff b/tests/ts/libmount/tabdiff new file mode 100755 index 0000000..2f9acb9 --- /dev/null +++ b/tests/ts/libmount/tabdiff @@ -0,0 +1,31 @@ +#!/bin/bash + +# Copyright (C) 2011 Karel Zak + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="table diffs" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +TESTPROG="$TS_HELPER_LIBMOUNT_TABDIFF" + +[ -x $TESTPROG ] || ts_skip "test not compiled" + +ts_init_subtest "mount" +ts_run $TESTPROG --diff $TS_SELF/files/mountinfo_u $TS_SELF/files/mountinfo &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "umount" +ts_run $TESTPROG --diff $TS_SELF/files/mountinfo $TS_SELF/files/mountinfo_u &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "remount" +ts_run $TESTPROG --diff $TS_SELF/files/mountinfo $TS_SELF/files/mountinfo_re &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "move" +ts_run $TESTPROG --diff $TS_SELF/files/mountinfo $TS_SELF/files/mountinfo_mv &> $TS_OUTPUT +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/libmount/tabfiles b/tests/ts/libmount/tabfiles new file mode 100755 index 0000000..1de740e --- /dev/null +++ b/tests/ts/libmount/tabfiles @@ -0,0 +1,85 @@ +#!/bin/bash + +# Copyright (C) 2010 Karel Zak + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="tab files" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +TESTPROG="$TS_HELPER_LIBMOUNT_TAB" + +[ -x $TESTPROG ] || ts_skip "test not compiled" + +ts_init_subtest "parse-fstab" +ts_run $TESTPROG --parse "$TS_SELF/files/fstab" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "parse-fstab-full" +ts_run $TESTPROG --parse "$TS_SELF/files/fstab.comment" --comments &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "parse-mtab" +ts_run $TESTPROG --parse "$TS_SELF/files/mtab" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "parse-fstab-broken" +ts_run $TESTPROG --parse "$TS_SELF/files/fstab.broken" &> $TS_OUTPUT +sed -i -e 's/.*fstab.broken:[[:digit:]]*: parse error//g; s/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "parse-mountinfo" +ts_run $TESTPROG --parse "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "parse-mountinfo-nosrc" +ts_run $TESTPROG --parse "$TS_SELF/files/mountinfo_nosrc" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "parse-swaps" +ts_run $TESTPROG --parse "$TS_SELF/files/swaps" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "copy" +ts_run $TESTPROG --copy-fs "$TS_SELF/files/fstab" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "find-source" +ts_run $TESTPROG --find-forward "$TS_SELF/files/fstab" source UUID=fef7ccb3-821c-4de8-88dc-71472be5946f &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "find-target" +ts_run $TESTPROG --find-forward "$TS_SELF/files/fstab" target /home/foo &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "find-target2" +ts_run $TESTPROG --find-forward "$TS_SELF/files/fstab" target /any/foo &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "find-target3" +ts_run $TESTPROG --find-forward "$TS_SELF/files/fstab" target /any/foo/ &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "find-pair" +ts_run $TESTPROG --find-pair "$TS_SELF/files/mtab" /dev/mapper/kzak-home /home/kzak &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "find-fs" +ts_run $TESTPROG --find-fs "$TS_SELF/files/mountinfo" /home/kzak &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/libmount/tabfiles-py b/tests/ts/libmount/tabfiles-py new file mode 100755 index 0000000..ba89ddf --- /dev/null +++ b/tests/ts/libmount/tabfiles-py @@ -0,0 +1,75 @@ +#!/bin/bash + +# Copyright (C) 2010 Karel Zak + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="tab files-py" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" +ts_init_py libmount + +if [ "$TS_ENABLE_ASAN" == "yes" -o "$TS_ENABLE_UBSAN" == "yes" ]; then + TS_KNOWN_FAIL="yes" +fi + +PYDBG="$PYTHON -m pdb" +TESTPROG="$TS_HELPER_PYLIBMOUNT_TAB" +[ -x $TESTPROG ] || ts_die "test script missing" + +ts_init_subtest "parse-fstab" +$PYTHON $TESTPROG --parse "$TS_SELF/files/fstab" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "parse-fstab-full" +$PYTHON $TESTPROG --parse "$TS_SELF/files/fstab.comment" --comments &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "parse-mtab" +$PYTHON $TESTPROG --parse "$TS_SELF/files/mtab" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "parse-fstab-broken" +$PYTHON $TESTPROG --parse "$TS_SELF/files/fstab.broken" &> $TS_OUTPUT +sed -i -e 's/.*fstab.broken:[[:digit:]]*: parse error//g; s/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "parse-mountinfo" +$PYTHON $TESTPROG --parse "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "copy" +$PYTHON $TESTPROG --copy-fs "$TS_SELF/files/fstab" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "find-source" +$PYTHON $TESTPROG --find-forward "$TS_SELF/files/fstab" source UUID=fef7ccb3-821c-4de8-88dc-71472be5946f &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "find-target" +$PYTHON $TESTPROG --find-forward "$TS_SELF/files/fstab" target /home/foo &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "find-target2" +$PYTHON $TESTPROG --find-forward "$TS_SELF/files/fstab" target /any/foo &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "find-target3" +$PYTHON $TESTPROG --find-forward "$TS_SELF/files/fstab" target /any/foo/ &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "find-pair" +$PYTHON $TESTPROG --find-pair "$TS_SELF/files/mtab" /dev/mapper/kzak-home /home/kzak &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/libmount/tabfiles-tags b/tests/ts/libmount/tabfiles-tags new file mode 100755 index 0000000..cc48429 --- /dev/null +++ b/tests/ts/libmount/tabfiles-tags @@ -0,0 +1,86 @@ +#!/bin/bash + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="tags" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_skip_nonroot + +if [ "$TS_ENABLE_ASAN" == "yes" ]; then + TS_KNOWN_FAIL="yes" +fi + +TESTPROG="$TS_HELPER_LIBMOUNT_TAB" + +[ -x $TESTPROG ] || ts_skip "test not compiled" +ts_check_prog "mkfs.ext2" + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=50 sector_size=512 +LABEL="testLibmount" +UUID="de1bc6e9-34ab-4151-a1d7-900042eee8d9" + +# +# Create filesystem +# +mkfs.ext2 -F -L $LABEL $TS_DEVICE -U $UUID &> /dev/null || ts_die "Cannot make ext2 on $TS_DEVICE" +ts_device_has "LABEL" "$LABEL" "$TS_DEVICE" || ts_die "Cannot find LABEL '$LABEL' on $TS_DEVICE" +ts_device_has "UUID" "$UUID" "$TS_DEVICE" || ts_die "Cannot find $UUID on $TS_DEVICE" + +FSTAB="$TS_OUTDIR/fstab" + +# +# Label in fstab +# +echo "LABEL=$LABEL /mnt/mountpoint auto defaults" > $FSTAB +ts_udevadm_settle "$TS_DEVICE" "LABEL" "UUID" + +ts_init_subtest "fstab-label2uuid" +ts_run $TESTPROG --find-forward $FSTAB source "UUID=$UUID" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "fstab-label2dev" +ts_run $TESTPROG --find-forward $FSTAB source $TS_DEVICE &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +# +# Add more enties for the same device +# +echo "UUID=$UUID /mnt/mountpoint2 auto defaults" >> $FSTAB + +ts_init_subtest "fstab-uuid" +# has to return /mnt/mountpoint2 +ts_run $TESTPROG --find-forward $FSTAB source "UUID=$UUID" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "fstab-label" +# has to return /mnt/mountpoint +ts_run $TESTPROG --find-forward $FSTAB source "LABEL=$LABEL" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + + +ts_init_subtest "fstab-dev2label" +# has to return /mnt/mountpoint +ts_run $TESTPROG --find-forward $FSTAB source $TS_DEVICE &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +# +# Add devname +# +echo "$TS_DEVICE /mnt/mountpoint3 auto defaults" >> $FSTAB + +ts_init_subtest "fstab-dev" +# has to return /mnt/mountpoint3 +ts_run $TESTPROG --find-forward $FSTAB source $TS_DEVICE &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +sed -i -e 's/source: .*//g' $TS_OUTPUT # devname is generated, remove it +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/libmount/tabfiles-tags-py b/tests/ts/libmount/tabfiles-tags-py new file mode 100755 index 0000000..5c5c7c3 --- /dev/null +++ b/tests/ts/libmount/tabfiles-tags-py @@ -0,0 +1,90 @@ +#!/bin/bash + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="tags-py" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_skip_nonroot + +ts_init_py libmount + +if [ "$TS_ENABLE_ASAN" == "yes" -o "$TS_ENABLE_UBSAN" == "yes" ]; then + TS_KNOWN_FAIL="yes" +fi + +TESTPROG="$TS_HELPER_PYLIBMOUNT_TAB" +[ -x $TESTPROG ] || ts_die "test script missing" + +ts_check_prog "mkfs.ext2" + +PYDBG="$PYTHON -m pdb" + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=50 sector_size=512 +LABEL="testLibmount" +UUID="de1bc6e9-34ab-4151-a1d7-900042eee8d9" + +# +# Create filesystem +# +mkfs.ext2 -F -L $LABEL $TS_DEVICE -U $UUID &> /dev/null || ts_die "Cannot make ext2 on $TS_DEVICE" +ts_device_has "LABEL" "$LABEL" "$TS_DEVICE" || ts_die "Cannot find LABEL '$LABEL' on $TS_DEVICE" +ts_device_has "UUID" "$UUID" "$TS_DEVICE" || ts_die "Cannot find $UUID on $TS_DEVICE" + +FSTAB="$TS_OUTDIR/fstab" + +# +# Label in fstab +# +echo "LABEL=$LABEL /mnt/mountpoint auto defaults" > $FSTAB +ts_udevadm_settle "$DEVICE" "LABEL" "UUID" + +ts_init_subtest "fstab-label2uuid" +$PYTHON $TESTPROG --find-forward $FSTAB source "UUID=$UUID" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "fstab-label2dev" +$PYTHON $TESTPROG --find-forward $FSTAB source $TS_DEVICE &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +# +# Add more enties for the same device +# +echo "UUID=$UUID /mnt/mountpoint2 auto defaults" >> $FSTAB + +ts_init_subtest "fstab-uuid" +# has to return /mnt/mountpoint2 +$PYTHON $TESTPROG --find-forward $FSTAB source "UUID=$UUID" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "fstab-label" +# has to return /mnt/mountpoint +$PYTHON $TESTPROG --find-forward $FSTAB source "LABEL=$LABEL" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + + +ts_init_subtest "fstab-dev2label" +# has to return /mnt/mountpoint +$PYTHON $TESTPROG --find-forward $FSTAB source $TS_DEVICE &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +# +# Add devname +# +echo "$TS_DEVICE /mnt/mountpoint3 auto defaults" >> $FSTAB + +ts_init_subtest "fstab-dev" +# has to return /mnt/mountpoint3 +$PYTHON $TESTPROG --find-forward $FSTAB source $TS_DEVICE &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +sed -i -e 's/source: .*//g' $TS_OUTPUT # devname is generated, remove it +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/libmount/update b/tests/ts/libmount/update new file mode 100755 index 0000000..ba93e0b --- /dev/null +++ b/tests/ts/libmount/update @@ -0,0 +1,69 @@ +#!/bin/bash + +# Copyright (C) 2010 Karel Zak + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="tab update" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" +ts_skip_nonroot + +TESTPROG="$TS_HELPER_LIBMOUNT_UPDATE" + +[ -x $TESTPROG ] || ts_skip "test not compiled" + +# IMPORTANT notes: +# +# - the $TS_OUTPUT variable is between ts_init_subtest and ts_finalize_subtest +# redefined to subtest specific namespace -- it means that $TS_OUTPUT is a +# different file within a subtest. +# +# - all this test uses global $TS_OUTPUT.mountinfo + +# +# utab +# +export LIBMOUNT_UTAB=$TS_OUTPUT.utab +rm -f $LIBMOUNT_UTAB +> $LIBMOUNT_UTAB + +ts_init_subtest "utab-mount" +ts_run $TESTPROG --add /dev/sda1 /mnt/foo ext3 "rw,bbb,ccc,fff=FFF,ddd,noexec" +ts_run $TESTPROG --add /dev/sdb1 /mnt/bar ext3 "ro,user" +ts_run $TESTPROG --add /dev/sda2 /mnt/xyz ext3 "rw,loop=/dev/loop0,uhelper=hal" +ts_run $TESTPROG --add none /proc proc "rw,user" +cp $LIBMOUNT_UTAB $TS_OUTPUT # save the utab aside +ts_finalize_subtest # checks the utab + +ts_init_subtest "utab-move" +ts_run $TESTPROG --move /mnt/bar /mnt/newbar +ts_run $TESTPROG --move /mnt/xyz /mnt/newxyz +cp $LIBMOUNT_UTAB $TS_OUTPUT # save the utab aside +ts_finalize_subtest # checks the utab + +ts_init_subtest "utab-remount" +ts_run $TESTPROG --remount /mnt/newbar "ro,noatime" +ts_run $TESTPROG --remount /mnt/newxyz "rw,user" +cp $LIBMOUNT_UTAB $TS_OUTPUT # save the utab aside +ts_finalize_subtest # checks the utab + +ts_init_subtest "utab-umount" +ts_run $TESTPROG --remove /mnt/newbar +ts_run $TESTPROG --remove /proc +cp $LIBMOUNT_UTAB $TS_OUTPUT # save the utab aside +ts_finalize_subtest # checks the utab + +# +# fstab - replace +# +export LIBMOUNT_FSTAB=$TS_OUTPUT.fstab +rm -f $LIBMOUNT_FSTAB +cp "$TS_SELF/files/fstab.comment" $LIBMOUNT_FSTAB + +ts_init_subtest "fstab-replace" +ts_run $TESTPROG --replace "LABEL=foo" "/mnt/foo" +cp $LIBMOUNT_FSTAB $TS_OUTPUT # save the fstab aside +ts_finalize_subtest #checks the fstab + +ts_finalize diff --git a/tests/ts/libmount/update-py b/tests/ts/libmount/update-py new file mode 100755 index 0000000..bfb8441 --- /dev/null +++ b/tests/ts/libmount/update-py @@ -0,0 +1,32 @@ +#!/bin/bash + +# Copyright (C) 2010 Karel Zak + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="tab update-py" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" +ts_init_py libmount +ts_skip_nonroot + +if [ "$TS_ENABLE_ASAN" == "yes" -o "$TS_ENABLE_UBSAN" == "yes" ]; then + TS_KNOWN_FAIL="yes" +fi + +TESTPROG="$TS_HELPER_PYLIBMOUNT_UPDATE" +[ -x $TESTPROG ] || ts_die "test script missing" + +# +# fstab - replace +# +export LIBMOUNT_FSTAB=$TS_OUTPUT.fstab +rm -f $LIBMOUNT_FSTAB +cp "$TS_SELF/files/fstab.comment" $LIBMOUNT_FSTAB + +ts_init_subtest "fstab-replace" +$PYTHON $TESTPROG --replace "LABEL=foo" "/mnt/foo" >/dev/null 2>&1 +cp $LIBMOUNT_FSTAB $TS_OUTPUT # save the fstab aside +ts_finalize_subtest #checks the fstab + +ts_finalize diff --git a/tests/ts/libmount/utils b/tests/ts/libmount/utils new file mode 100755 index 0000000..1fed2a7 --- /dev/null +++ b/tests/ts/libmount/utils @@ -0,0 +1,84 @@ +#!/bin/bash + +# Copyright (C) 2010 Karel Zak + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="utils" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +TESTPROG="$TS_HELPER_LIBMOUNT_UTILS" + +[ -x $TESTPROG ] || ts_skip "test not compiled" + +ts_init_subtest "match-fstype" +ts_run $TESTPROG --match-fstype ext3 "ext2,ext3,cifs" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "match-fstype-neg" +ts_run $TESTPROG --match-fstype cifs "ext2,ext3,nocifs" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "match-fstype-neg2" +ts_run $TESTPROG --match-fstype cifs "noext2,ext3,cifs" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "match-options" +ts_run $TESTPROG --match-options "aaa,bbb=BBB,ccc,ddd" "ccc" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "match-options-list" +ts_run $TESTPROG --match-options "aaa,bbb=BBB,ccc,ddd" "ccc,aaa,ddd" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "match-options-neg" +ts_run $TESTPROG --match-options "aaa,bbb=BBB,ccc,ddd" "noxxx" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "match-options-neg-list" +ts_run $TESTPROG --match-options "aaa,bbb=BBB,ccc,ddd" "ddd,noaaa" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "match-options-neg-list2" +ts_run $TESTPROG --match-options "aaa,bbb=BBB,ccc,ddd" "noxxx,ccc,aaa" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "starts-with" +ts_run $TESTPROG --starts-with "AAAbbbCCC" "AAA" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "ends-with" +ts_run $TESTPROG --ends-with "AAAbbbCCC" "CCC" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "mountpoint" +if [ -d /proc ]; then + ts_run $TESTPROG --mountpoint /proc &> $TS_OUTPUT + ts_finalize_subtest +else + ts_skip_subtest "no /proc" +fi + +ts_init_subtest "mountpoint-subdir" +if [ -d /proc/sys/kernel ]; then + ts_run $TESTPROG --mountpoint /proc/sys/kernel &> $TS_OUTPUT + ts_finalize_subtest +else + ts_skip_subtest "no /proc" +fi + +ts_init_subtest "mountpoint-root" +ts_run $TESTPROG --mountpoint / &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "kernel-cmdline" +export LIBMOUNT_KERNEL_CMDLINE="$TS_SELF/files/kernel_cmdline" +ts_run $TESTPROG --kernel-cmdline selinux= >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_run $TESTPROG --kernel-cmdline selinux >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_run $TESTPROG --kernel-cmdline ro >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_run $TESTPROG --kernel-cmdline ro= >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_run $TESTPROG --kernel-cmdline root= >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/libsmartcols/files/col-hidden b/tests/ts/libsmartcols/files/col-hidden new file mode 100644 index 0000000..83182a8 --- /dev/null +++ b/tests/ts/libsmartcols/files/col-hidden @@ -0,0 +1,3 @@ +FOO +0 +hidden diff --git a/tests/ts/libsmartcols/files/col-id b/tests/ts/libsmartcols/files/col-id new file mode 100644 index 0000000..0188f42 --- /dev/null +++ b/tests/ts/libsmartcols/files/col-id @@ -0,0 +1,3 @@ +ID +0 +right diff --git a/tests/ts/libsmartcols/files/col-name b/tests/ts/libsmartcols/files/col-name new file mode 100644 index 0000000..0a98f29 --- /dev/null +++ b/tests/ts/libsmartcols/files/col-name @@ -0,0 +1,3 @@ +NAME +0 +none diff --git a/tests/ts/libsmartcols/files/col-noextremes b/tests/ts/libsmartcols/files/col-noextremes new file mode 100644 index 0000000..715edce --- /dev/null +++ b/tests/ts/libsmartcols/files/col-noextremes @@ -0,0 +1,3 @@ +NOEXTREME +0 +noextremes diff --git a/tests/ts/libsmartcols/files/col-number b/tests/ts/libsmartcols/files/col-number new file mode 100644 index 0000000..34a70e4 --- /dev/null +++ b/tests/ts/libsmartcols/files/col-number @@ -0,0 +1,3 @@ +NUM +0 +right diff --git a/tests/ts/libsmartcols/files/col-parent b/tests/ts/libsmartcols/files/col-parent new file mode 100644 index 0000000..86fe08c --- /dev/null +++ b/tests/ts/libsmartcols/files/col-parent @@ -0,0 +1,3 @@ +PARENT +0 +right diff --git a/tests/ts/libsmartcols/files/col-strict b/tests/ts/libsmartcols/files/col-strict new file mode 100644 index 0000000..62bb96b --- /dev/null +++ b/tests/ts/libsmartcols/files/col-strict @@ -0,0 +1,3 @@ +STRICT +20 +strictwidth,right diff --git a/tests/ts/libsmartcols/files/col-string b/tests/ts/libsmartcols/files/col-string new file mode 100644 index 0000000..7e2904b --- /dev/null +++ b/tests/ts/libsmartcols/files/col-string @@ -0,0 +1,3 @@ +STRINGS +0 +none diff --git a/tests/ts/libsmartcols/files/col-tree b/tests/ts/libsmartcols/files/col-tree new file mode 100644 index 0000000..5076880 --- /dev/null +++ b/tests/ts/libsmartcols/files/col-tree @@ -0,0 +1,3 @@ +TREE +0 +tree diff --git a/tests/ts/libsmartcols/files/col-trunc b/tests/ts/libsmartcols/files/col-trunc new file mode 100644 index 0000000..2887b43 --- /dev/null +++ b/tests/ts/libsmartcols/files/col-trunc @@ -0,0 +1,3 @@ +TRUNC +0 +trunc diff --git a/tests/ts/libsmartcols/files/col-wrap b/tests/ts/libsmartcols/files/col-wrap new file mode 100644 index 0000000..dc4ca34 --- /dev/null +++ b/tests/ts/libsmartcols/files/col-wrap @@ -0,0 +1,3 @@ +WRAP +0 +wrap diff --git a/tests/ts/libsmartcols/files/col-wrapnl b/tests/ts/libsmartcols/files/col-wrapnl new file mode 100644 index 0000000..0a18fd1 --- /dev/null +++ b/tests/ts/libsmartcols/files/col-wrapnl @@ -0,0 +1,3 @@ +WRAPNL +0 +wrapnl diff --git a/tests/ts/libsmartcols/files/data-id b/tests/ts/libsmartcols/files/data-id new file mode 100644 index 0000000..f00c965 --- /dev/null +++ b/tests/ts/libsmartcols/files/data-id @@ -0,0 +1,10 @@ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 diff --git a/tests/ts/libsmartcols/files/data-number b/tests/ts/libsmartcols/files/data-number new file mode 100644 index 0000000..562d750 --- /dev/null +++ b/tests/ts/libsmartcols/files/data-number @@ -0,0 +1,10 @@ +0 +100 +21 +3 +411 +5111 +678993321 +7666666 +8765 +987456 diff --git a/tests/ts/libsmartcols/files/data-number-tiny b/tests/ts/libsmartcols/files/data-number-tiny new file mode 100644 index 0000000..8b1acc1 --- /dev/null +++ b/tests/ts/libsmartcols/files/data-number-tiny @@ -0,0 +1,10 @@ +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 diff --git a/tests/ts/libsmartcols/files/data-parent b/tests/ts/libsmartcols/files/data-parent new file mode 100644 index 0000000..aa50716 --- /dev/null +++ b/tests/ts/libsmartcols/files/data-parent @@ -0,0 +1,10 @@ +0 +1 +1 +1 +2 +2 +3 +7 +8 +7 diff --git a/tests/ts/libsmartcols/files/data-string b/tests/ts/libsmartcols/files/data-string new file mode 100644 index 0000000..dff6e9c --- /dev/null +++ b/tests/ts/libsmartcols/files/data-string @@ -0,0 +1,10 @@ +aaaa +bbb +ccccc +dddddd +ee +ffff +gggggg +hhh +iiiiii +jj diff --git a/tests/ts/libsmartcols/files/data-string-empty b/tests/ts/libsmartcols/files/data-string-empty new file mode 100644 index 0000000..1f8ad34 --- /dev/null +++ b/tests/ts/libsmartcols/files/data-string-empty @@ -0,0 +1,10 @@ +aaaa +bbb +ccccc +dddddd +ee + +gggggg +hhh +iiiiii +jj diff --git a/tests/ts/libsmartcols/files/data-string-extreme b/tests/ts/libsmartcols/files/data-string-extreme new file mode 100644 index 0000000..6fb395d --- /dev/null +++ b/tests/ts/libsmartcols/files/data-string-extreme @@ -0,0 +1,10 @@ +qqqqqqX +ddddddddX +ffffffffffffffffffffffffffffffffffX +sssX +ddX +jjjjjX +mmmmmmmX +llllllllllX +yyyyyyX +pppppX diff --git a/tests/ts/libsmartcols/files/data-string-long b/tests/ts/libsmartcols/files/data-string-long new file mode 100644 index 0000000..1b5683a --- /dev/null +++ b/tests/ts/libsmartcols/files/data-string-long @@ -0,0 +1,10 @@ +qqqqqqqqqqqqqqqqqX +dddddddddddddX +ffffffffffffffffffffffffffffffffffffffffX +ssssssssssX +ddddddddddddddddddddddddddX +jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjX +mmmmmmmmmmmmmmmmmmmX +lllllllllllllllllllllllllllllllllllllX +yyyyyyyyyyyyyyyyyyyyyyyyyyyyX +pppppppppX diff --git a/tests/ts/libsmartcols/files/data-string-nl b/tests/ts/libsmartcols/files/data-string-nl new file mode 100644 index 0000000..7822e57 --- /dev/null +++ b/tests/ts/libsmartcols/files/data-string-nl @@ -0,0 +1,10 @@ +aaa +bbbbb +cccc\nCCCC +dddddddd\nDDDD\nDD +hello\nbaby +aaa\nbbb\nccc\nddd +eee +fffff +g\nhhhhh +ppppppppp diff --git a/tests/ts/libsmartcols/fromfile b/tests/ts/libsmartcols/fromfile new file mode 100755 index 0000000..45b8471 --- /dev/null +++ b/tests/ts/libsmartcols/fromfile @@ -0,0 +1,286 @@ +#!/bin/bash +# +# 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="fromfile" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +TESTPROG="$TS_HELPER_LIBSMARTCOLS_FROMFILE" +ts_check_test_command "$TESTPROG" + +ts_init_subtest "tree" +ts_run $TESTPROG --nlines 10 \ + --tree-id-column 1 \ + --tree-parent-column 2 \ + --column $TS_SELF/files/col-tree \ + --column $TS_SELF/files/col-id \ + --column $TS_SELF/files/col-parent \ + --column $TS_SELF/files/col-string \ + $TS_SELF/files/data-string \ + $TS_SELF/files/data-id \ + $TS_SELF/files/data-parent \ + $TS_SELF/files/data-string-long \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "tree-json" +ts_run $TESTPROG --nlines 10 --json \ + --tree-id-column 1 \ + --tree-parent-column 2 \ + --column $TS_SELF/files/col-tree \ + --column $TS_SELF/files/col-id \ + --column $TS_SELF/files/col-parent \ + --column $TS_SELF/files/col-string \ + $TS_SELF/files/data-string \ + $TS_SELF/files/data-id \ + $TS_SELF/files/data-parent \ + $TS_SELF/files/data-string-long \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "tree-middle" +ts_run $TESTPROG --nlines 10 \ + --tree-id-column 0 \ + --tree-parent-column 1 \ + --column $TS_SELF/files/col-id \ + --column $TS_SELF/files/col-parent \ + --column $TS_SELF/files/col-tree \ + --column $TS_SELF/files/col-string \ + $TS_SELF/files/data-id \ + $TS_SELF/files/data-parent \ + $TS_SELF/files/data-string \ + $TS_SELF/files/data-string-long \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "tree-end" +ts_run $TESTPROG --nlines 10 \ + --tree-id-column 0 \ + --tree-parent-column 1 \ + --column $TS_SELF/files/col-id \ + --column $TS_SELF/files/col-parent \ + --column $TS_SELF/files/col-string \ + --column $TS_SELF/files/col-tree \ + $TS_SELF/files/data-id \ + $TS_SELF/files/data-parent \ + $TS_SELF/files/data-string-long \ + $TS_SELF/files/data-string \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "trunc" +ts_run $TESTPROG --nlines 10 --width 40 \ + --column $TS_SELF/files/col-name \ + --column $TS_SELF/files/col-number \ + --column $TS_SELF/files/col-trunc \ + $TS_SELF/files/data-string \ + $TS_SELF/files/data-number \ + $TS_SELF/files/data-string-long \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "right" +ts_run $TESTPROG --nlines 10 \ + --column $TS_SELF/files/col-name \ + --column $TS_SELF/files/col-number \ + --column $TS_SELF/files/col-string \ + $TS_SELF/files/data-string \ + $TS_SELF/files/data-number \ + $TS_SELF/files/data-string-long \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "right-maxout" +ts_run $TESTPROG --nlines 10 --maxout --width 80\ + --column $TS_SELF/files/col-name \ + --column $TS_SELF/files/col-number \ + $TS_SELF/files/data-string \ + $TS_SELF/files/data-number \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "padding-default" +export LIBSMARTCOLS_DEBUG_PADDING=on +ts_run $TESTPROG --nlines 10 --width 80 \ + --column $TS_SELF/files/col-name \ + --column $TS_SELF/files/col-number \ + --column $TS_SELF/files/col-string \ + --column $TS_SELF/files/col-string \ + $TS_SELF/files/data-string \ + $TS_SELF/files/data-number \ + $TS_SELF/files/data-string-empty \ + $TS_SELF/files/data-string-empty \ + >> $TS_OUTPUT 2> /dev/null +ts_finalize_subtest + +ts_init_subtest "padding-maxout" +export LIBSMARTCOLS_DEBUG_PADDING=on +ts_run $TESTPROG --nlines 10 --width 80 \ + --maxout \ + --column $TS_SELF/files/col-name \ + --column $TS_SELF/files/col-number \ + --column $TS_SELF/files/col-string \ + --column $TS_SELF/files/col-string \ + $TS_SELF/files/data-string \ + $TS_SELF/files/data-number \ + $TS_SELF/files/data-string-empty \ + $TS_SELF/files/data-string-empty \ + >> $TS_OUTPUT 2> /dev/null +ts_finalize_subtest + +ts_init_subtest "padding-minout" +export LIBSMARTCOLS_DEBUG_PADDING=on +ts_run $TESTPROG --nlines 10 --width 80 \ + --minout \ + --column $TS_SELF/files/col-name \ + --column $TS_SELF/files/col-number \ + --column $TS_SELF/files/col-string \ + --column $TS_SELF/files/col-string \ + $TS_SELF/files/data-string \ + $TS_SELF/files/data-number \ + $TS_SELF/files/data-string-empty \ + $TS_SELF/files/data-string-empty \ + >> $TS_OUTPUT 2> /dev/null +ts_finalize_subtest + +unset LIBSMARTCOLS_DEBUG_PADDING + +ts_init_subtest "strictwidth" +ts_run $TESTPROG --nlines 10 \ + --column $TS_SELF/files/col-name \ + --column $TS_SELF/files/col-strict \ + --column $TS_SELF/files/col-number \ + $TS_SELF/files/data-string \ + $TS_SELF/files/data-number-tiny \ + $TS_SELF/files/data-number \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "noextremes" +ts_run $TESTPROG --nlines 10 --width 45 \ + --column $TS_SELF/files/col-name \ + --column $TS_SELF/files/col-noextremes \ + --column $TS_SELF/files/col-number \ + --column $TS_SELF/files/col-name \ + --column $TS_SELF/files/col-number \ + $TS_SELF/files/data-string \ + $TS_SELF/files/data-string-extreme \ + $TS_SELF/files/data-number \ + $TS_SELF/files/data-string \ + $TS_SELF/files/data-number \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "hidden" +ts_run $TESTPROG --nlines 10 \ + --column $TS_SELF/files/col-name \ + --column $TS_SELF/files/col-hidden \ + --column $TS_SELF/files/col-number \ + $TS_SELF/files/data-string \ + $TS_SELF/files/data-string-long \ + $TS_SELF/files/data-number \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "wrap" +ts_run $TESTPROG --nlines 10 --width 40 \ + --column $TS_SELF/files/col-name \ + --column $TS_SELF/files/col-number \ + --column $TS_SELF/files/col-wrap \ + $TS_SELF/files/data-string \ + $TS_SELF/files/data-number \ + $TS_SELF/files/data-string-long \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "wrap-tree" +ts_run $TESTPROG --nlines 10 --width 45 \ + --tree-id-column 1 \ + --tree-parent-column 2 \ + --column $TS_SELF/files/col-tree \ + --column $TS_SELF/files/col-id \ + --column $TS_SELF/files/col-parent \ + --column $TS_SELF/files/col-wrap \ + $TS_SELF/files/data-string \ + $TS_SELF/files/data-id \ + $TS_SELF/files/data-parent \ + $TS_SELF/files/data-string-long \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "wrapnl" +ts_run $TESTPROG --nlines 10 \ + --column $TS_SELF/files/col-name \ + --column $TS_SELF/files/col-number \ + --column $TS_SELF/files/col-wrapnl \ + $TS_SELF/files/data-string \ + $TS_SELF/files/data-number \ + $TS_SELF/files/data-string-nl \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "wrapnl-tree" +ts_run $TESTPROG --nlines 10 \ + --tree-id-column 1 \ + --tree-parent-column 2 \ + --column $TS_SELF/files/col-tree \ + --column $TS_SELF/files/col-id \ + --column $TS_SELF/files/col-parent \ + --column $TS_SELF/files/col-wrapnl \ + $TS_SELF/files/data-string \ + $TS_SELF/files/data-id \ + $TS_SELF/files/data-parent \ + $TS_SELF/files/data-string-nl \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "raw" +ts_run $TESTPROG --nlines 10 --raw \ + --column $TS_SELF/files/col-name \ + --column $TS_SELF/files/col-number \ + --column $TS_SELF/files/col-trunc \ + $TS_SELF/files/data-string \ + $TS_SELF/files/data-number \ + $TS_SELF/files/data-string-long \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "export" +ts_run $TESTPROG --nlines 10 --export \ + --column $TS_SELF/files/col-name \ + --column $TS_SELF/files/col-number \ + --column $TS_SELF/files/col-trunc \ + $TS_SELF/files/data-string \ + $TS_SELF/files/data-number \ + $TS_SELF/files/data-string-long \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "column-separator" +ts_run $TESTPROG --nlines 10 --colsep \| \ + --column $TS_SELF/files/col-name \ + --column $TS_SELF/files/col-number \ + --column $TS_SELF/files/col-trunc \ + $TS_SELF/files/data-string \ + $TS_SELF/files/data-number \ + $TS_SELF/files/data-string-long \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_log "...done." +ts_finalize diff --git a/tests/ts/libsmartcols/title b/tests/ts/libsmartcols/title new file mode 100755 index 0000000..5a1c178 --- /dev/null +++ b/tests/ts/libsmartcols/title @@ -0,0 +1,28 @@ +#!/bin/bash +# +# 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="title" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +TESTPROG="$TS_HELPER_LIBSMARTCOLS_TITLE" +ts_check_test_command "$TESTPROG" + +ts_run $TESTPROG --width 80 >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_finalize diff --git a/tests/ts/logger/errors b/tests/ts/logger/errors new file mode 100755 index 0000000..f6d0d7b --- /dev/null +++ b/tests/ts/logger/errors @@ -0,0 +1,116 @@ +#!/bin/bash + +# +# Copyright (C) 2015 Sami Kerola +# +# 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="errors" + +. "$TS_TOPDIR"/functions.sh + +ts_init "$*" + +ts_check_test_command "$TS_HELPER_LOGGER" +ts_check_prog "socat" +ts_check_prog "mktemp" + +export TZ="GMT" +export LOGGER_TEST_TIMEOFDAY="1234567890.123456" +export LOGGER_TEST_HOSTNAME="test-hostname" +export LOGGER_TEST_GETPID="98765" + +DEVLOG="$(mktemp "/tmp/ultest-$TS_COMPONENT-$TS_TESTNAME-XXXXXX")" \ + || ts_die "mktemp failed" +SOCKIN="${TS_OUTDIR}/${TS_TESTNAME}_socketin" +ts_init_socket_to_file $DEVLOG $SOCKIN +SOCAT_PID="$!" + +function logger_fun { + # logger without --no-act to write all data to the socket + echo "socket data, ${TS_SUBNAME}:" |socat -u - UNIX-CONNECT:$DEVLOG + $TS_HELPER_LOGGER -u $DEVLOG --stderr "$@" >> $TS_OUTPUT 2>> $TS_ERRLOG + echo "ret: $?" >> "$TS_OUTPUT" + echo |socat -u - UNIX-CONNECT:$DEVLOG +} + +function logger_printf { + # logger without --no-act to write all data to the socket + local fmt="$1" + shift + echo "socket data, ${TS_SUBNAME}:" |socat -u - UNIX-CONNECT:$DEVLOG + printf "$fmt" | $TS_HELPER_LOGGER -u $DEVLOG --stderr "$@" >> $TS_OUTPUT 2>> $TS_ERRLOG + echo "ret: $?" >> "$TS_OUTPUT" + echo |socat -u - UNIX-CONNECT:$DEVLOG +} + +ts_init_subtest "kern_priority" +logger_fun -t "prio" -p kern.emerg "message" +ts_finalize_subtest + +ts_init_subtest "kern_priority_numeric" +logger_fun -t "prio" -p 0 "message" +ts_finalize_subtest + +ts_init_subtest "invalid_prio" +logger_fun -t "prio" -p 8 "message" +ts_finalize_subtest + +# should truncate +ts_init_subtest "rfc5424_exceed_size" +logger_fun -t "rfc5424_exceed_size" --rfc5424 --size 3 "abcd" +ts_finalize_subtest + +ts_init_subtest "id_with_space" +logger_fun -t "id_with_space" --id="A B" "message" +logger_fun -t "rfc5424_id_with_space" --rfc5424 --id="A B" "message" +logger_fun -t "id_with_space" --id="1 23" "message" +logger_fun -t "id_with_leading space" --id=" 123" "message" +logger_fun -t "id_with_trailing space" --id="123 " "message" + +ts_finalize_subtest + +# should not fail +ts_init_subtest "tag_with_space" +logger_fun -t "A B" "tag_with_space" +logger_fun -t "A B" --rfc5424 "tag_with_space_rfc5424" +ts_finalize_subtest + +ts_init_subtest "tcp" +logger_fun --tcp -t "tcp" "message" +ts_finalize_subtest + +ts_init_subtest "multi-line" +logger_printf "AAA\nBBB\nCCC\n" -t "multi" +ts_finalize_subtest + +ts_init_subtest "rfc5424_msgid_with_space" +logger_fun -t "rfc5424_msgid_with_space" --rfc5424 --msgid="A B" "message" +ts_finalize_subtest + +ts_init_subtest "invalid_socket" +logger_fun -u /bad/boy -t "invalid_socket" "message" +ts_finalize_subtest + +ts_init_subtest "check_socket" +ts_log "Check written socket data of all subtests." +sleep 1 +kill $SOCAT_PID +wait $SOCAT_PID &>/dev/null +cat "$SOCKIN" >> $TS_OUTPUT 2>> $TS_ERRLOG +rm -f "$DEVLOG" "$SOCKIN" +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/logger/formats b/tests/ts/logger/formats new file mode 100755 index 0000000..0c46b69 --- /dev/null +++ b/tests/ts/logger/formats @@ -0,0 +1,85 @@ +#!/bin/bash + +# +# Copyright (C) 2015 Sami Kerola +# +# 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="formats" + +. "$TS_TOPDIR"/functions.sh + +ts_init "$*" + +ts_check_test_command "$TS_HELPER_LOGGER" + +export TZ="GMT" +export LOGGER_TEST_TIMEOFDAY="1234567890.123456" +export LOGGER_TEST_HOSTNAME="test-hostname" +export LOGGER_TEST_GETPID="98765" + +DEVLOG="$(mktemp "/tmp/ultest-$TS_COMPONENT-$TS_TESTNAME-XXXXXX")" \ + || ts_die "mktemp failed" +SOCKIN="${TS_OUTDIR}/${TS_TESTNAME}_socketin" +ts_init_socket_to_file $DEVLOG $SOCKIN +SOCAT_PID="$!" + +function logger_fun { + $TS_HELPER_LOGGER -u $DEVLOG --stderr --no-act "$@" >> $TS_OUTPUT 2>> $TS_ERRLOG + echo "ret: $?" >> "$TS_ERRLOG" # keep all in stderr +} + +ts_init_subtest "rfc3164" +logger_fun -t "rfc3164" --rfc3164 "message" +ts_finalize_subtest + +ts_init_subtest "rfc5424_simple" +logger_fun -t "rfc5424" --rfc5424 "message" +ts_finalize_subtest + +ts_init_subtest "rfc5424_notime" +logger_fun -t "rfc5424" --rfc5424=notime "message" +ts_finalize_subtest + +ts_init_subtest "rfc5424_nohost" +logger_fun -t "rfc5424" --rfc5424=nohost "message" +ts_finalize_subtest + +ts_init_subtest "rfc5424_msgid" +logger_fun -t "rfc5424" --rfc5424 --msgid "MSGID" "message" +ts_finalize_subtest + +ts_init_subtest "octet_counting" +logger_fun -t "octen" --octet-count "message" +ts_finalize_subtest + +ts_init_subtest "priorities" +for facility in auth authpriv cron daemon ftp lpr mail news syslog user uucp local{0..7}; do + for level in emerg alert crit err warning notice info debug; do + logger_fun -t "prio" -p "$facility.$level" "$facility.$level" + done +done +ts_finalize_subtest + +ts_init_subtest "check_socket" +# Check written socket data of all subtests +sleep 1 +kill $SOCAT_PID +wait $SOCAT_PID &>/dev/null +cat "$SOCKIN" >> $TS_OUTPUT 2>> $TS_ERRLOG +rm -f "$DEVLOG" "$SOCKIN" +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/logger/journald b/tests/ts/logger/journald new file mode 100755 index 0000000..abed3e7 --- /dev/null +++ b/tests/ts/logger/journald @@ -0,0 +1,35 @@ +#!/bin/bash + +# +# Copyright (C) 2015 Sami Kerola +# +# 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="journald" + +. "$TS_TOPDIR"/functions.sh + +ts_init "$*" + +ts_check_test_command "$TS_HELPER_LOGGER" + +if ! $TS_HELPER_LOGGER --help | grep -q journald; then + ts_skip "unsupported" +fi + +printf "%s\n%s\n%s\n" MESSAGE_ID=b8f74e14bc714bfc8040a5106dc9376a MESSAGE="a b c 1 2 3" | +$TS_HELPER_LOGGER -u /bad/boy --no-act --journald --stderr >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "ret: $?" >> $TS_ERRLOG # keep it on stderr too +ts_finalize diff --git a/tests/ts/logger/options b/tests/ts/logger/options new file mode 100755 index 0000000..c5a4c36 --- /dev/null +++ b/tests/ts/logger/options @@ -0,0 +1,82 @@ +#!/bin/bash + +# +# Copyright (C) 2015 Sami Kerola +# +# 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="options" + +. "$TS_TOPDIR"/functions.sh + +ts_init "$*" + +ts_check_test_command "$TS_HELPER_LOGGER" + +# Create --file option input files. +echo {a..c}{1..5} > $TS_OUTDIR/input_simple +echo {a..c}{1..5} > $TS_OUTDIR/input_empty_line +echo "" >> $TS_OUTDIR/input_empty_line +echo {5..1}{c..1} >> $TS_OUTDIR/input_empty_line +echo "<66>" prio_prefix > $TS_OUTDIR/input_prio_prefix + +# bash 4 might not be available, use go-around hash +tests_array=( + "simple:test" + "log_pid:-i test" + "log_pid_long:--id test" + "log_pid_define:--id=12345 test" + "log_pid_no_arg:-is test" + "input_file_simple:-f $TS_OUTDIR/input_simple" + "input_file_empty_line:-f $TS_OUTDIR/input_empty_line" + "input_file_skip_empty:--file $TS_OUTDIR/input_empty_line -e" + "input_file_prio_prefix:--file $TS_OUTDIR/input_prio_prefix --skip-empty --prio-prefix" +) + +export TZ="GMT" +export LOGGER_TEST_TIMEOFDAY="1234567890.123456" +export LOGGER_TEST_HOSTNAME="test-hostname" +export LOGGER_TEST_GETPID="98765" + +DEVLOG="$(mktemp "/tmp/ultest-$TS_COMPONENT-$TS_TESTNAME-XXXXXX")" \ + || ts_die "mktemp failed" +SOCKIN="${TS_OUTDIR}/${TS_TESTNAME}_socketin" +ts_init_socket_to_file $DEVLOG $SOCKIN +SOCAT_PID="$!" + +function logger_fun { + $TS_HELPER_LOGGER -u $DEVLOG --stderr --no-act "$@" >> $TS_OUTPUT 2>> $TS_ERRLOG + echo "ret: $?" >> "$TS_ERRLOG" # keep all on stderr +} + +for i in "${tests_array[@]}"; do + name="${i%%:*}" + options="${i##*:}" + + ts_init_subtest "$name" + logger_fun -t "test_tag" $options + ts_finalize_subtest +done + +ts_init_subtest "check_socket" +# Check written socket data of all subtests +sleep 1 +kill $SOCAT_PID +wait $SOCAT_PID &>/dev/null +cat "$SOCKIN" >> $TS_OUTPUT 2>> $TS_ERRLOG +rm -f "$DEVLOG" "$SOCKIN" +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/login/islocal b/tests/ts/login/islocal new file mode 100755 index 0000000..013999e --- /dev/null +++ b/tests/ts/login/islocal @@ -0,0 +1,29 @@ +#!/bin/bash + +# +# Copyright (C) 2008 James Youngman +# +# 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="islocal" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_ISLOCAL" + +$TS_HELPER_ISLOCAL "$TS_SELF/islocal.data" root nobody "" youngman youngman2 \ + abcdefghx nobo long rot al malformed \ + nonl znobody >> $TS_OUTPUT +ts_finalize diff --git a/tests/ts/login/islocal.data b/tests/ts/login/islocal.data new file mode 100644 index 0000000..916a8a9 --- /dev/null +++ b/tests/ts/login/islocal.data @@ -0,0 +1,10 @@ +root:x:0:0:root:/root:/bin/bash +sys:x:3:3:sys:/dev:/bin/sh +orac:x:33:33:sys:/dev:/bin/youngman +long:x:4:4:foo:/home/loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooonnnggg:/bin/sh +al:x:5:5:fnord:/dev:/bin/sh +abcdefgh:x:6:3:fnord:/dev:/bin/sh +malformed + +nobody:x:65534:65534:nobody:/nonexistent:/bin/sh +nonl:x:65532:65532:no newline:/:/bin/false diff --git a/tests/ts/login/logindefs b/tests/ts/login/logindefs new file mode 100755 index 0000000..2ab9ce4 --- /dev/null +++ b/tests/ts/login/logindefs @@ -0,0 +1,26 @@ +#!/bin/bash +# +# Copyright (C) 2011 Karel Zak +# +# This file is part of util-linux. +# +TS_TOPDIR="${0%/*}/../.." +TS_DESC="defs" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_LOGINDEFS" + +# list all items +$TS_HELPER_LOGINDEFS "$TS_SELF/logindefs.data" | sed 's:'$TS_SELF'/::g' >> $TS_OUTPUT + +# search +$TS_HELPER_LOGINDEFS "$TS_SELF/logindefs.data" str STRING >> $TS_OUTPUT +$TS_HELPER_LOGINDEFS "$TS_SELF/logindefs.data" num NUMBER >> $TS_OUTPUT +$TS_HELPER_LOGINDEFS "$TS_SELF/logindefs.data" bool BOOLEAN >> $TS_OUTPUT +$TS_HELPER_LOGINDEFS "$TS_SELF/logindefs.data" str EMPTY >> $TS_OUTPUT + +$TS_HELPER_LOGINDEFS "$TS_SELF/logindefs.data" str UNKNOWN >> $TS_OUTPUT + +ts_finalize diff --git a/tests/ts/login/logindefs.data b/tests/ts/login/logindefs.data new file mode 100644 index 0000000..b899ff7 --- /dev/null +++ b/tests/ts/login/logindefs.data @@ -0,0 +1,16 @@ +# +# this is /etc/login.defs sample +# + +HELLO_WORLD "hello world!" +STRING this_is_string # another comment +NUMBER 123456 +BOOLEAN yEs + +CRAZY1 = "this is crazy format" +CRAZY2=fooBar +CRAZY3 FoooBaaar + +EMPTY + +END "the is end" diff --git a/tests/ts/look/separator b/tests/ts/look/separator new file mode 100755 index 0000000..d32a343 --- /dev/null +++ b/tests/ts/look/separator @@ -0,0 +1,41 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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. +# + +# +# WARNING: the look command expects that the /usr/share/dict/words uses +# directory order! +# +# for example: +# +# cat words.raw | grep -E --invert-match "'s$" | \ +# grep -E "^[[:alnum:]'&!,./-]+$" | \ +# sort --ignore-case --dictionary-order | \ +# uniq > words +# + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="separator" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_LOOK" + +$TS_CMD_LOOK apple-pie $TS_TOPDIR/ts/look/words >> $TS_OUTPUT +ts_finalize + diff --git a/tests/ts/look/words b/tests/ts/look/words new file mode 100644 index 0000000..b67ba9a --- /dev/null +++ b/tests/ts/look/words @@ -0,0 +1,3 @@ +apple +apple-pie +oranges diff --git a/tests/ts/losetup/losetup b/tests/ts/losetup/losetup new file mode 100755 index 0000000..9bae618 --- /dev/null +++ b/tests/ts/losetup/losetup @@ -0,0 +1,86 @@ +#!/bin/bash + +# +# Copyright (C) 2013 Karel Zak +# +# 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="losetup" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_LOSETUP" +ts_check_test_command "$TS_CMD_LSBLK" + +# Before checking for loop support we would need to test if losetup -f works at +# all. At least we do a simple executable test for now. +$TS_CMD_LOSETUP --version >/dev/null 2>$TS_OUTPUT || ts_failed +$TS_CMD_LOSETUP --unknownopt >>$TS_OUTPUT 2>/dev/null && ts_failed +test -s $TS_OUTPUT && ts_failed + +ts_skip_nonroot +ts_check_losetup + +. "$TS_SELF/losetup_functions.sh" + +# +# file-* tests: Backing file is a regular file +# +BACKFILE=$(ts_image_init 10) + +ts_init_subtest "file-show" +LODEV=$( $TS_CMD_LOSETUP --find --show $BACKFILE ) +if [ -z "$LODEV" ]; then + ts_log "Failed to create loop device" +fi +lo_print $LODEV >> $TS_OUTPUT +$TS_CMD_LOSETUP -d $LODEV +ts_finalize_subtest + +ts_init_subtest "file-offset" +LODEV=$( $TS_CMD_LOSETUP --offset 1MiB --find --show $BACKFILE ) +if [ -z "$LODEV" ]; then + ts_log "Failed to create loop device" +fi +lo_print $LODEV >> $TS_OUTPUT +$TS_CMD_LOSETUP -d $LODEV +ts_finalize_subtest + + +ts_init_subtest "file-sizelimit" +LODEV=$( $TS_CMD_LOSETUP --sizelimit 3MiB --find --show $BACKFILE ) +if [ -z "$LODEV" ]; then + ts_log "Failed to create loop device" +fi +lo_print $LODEV >> $TS_OUTPUT +$TS_CMD_LOSETUP -d $LODEV +ts_finalize_subtest + + +ts_init_subtest "file-section" +LODEV=$( $TS_CMD_LOSETUP --offset 1MiB --sizelimit 3MiB --find --show $BACKFILE ) +if [ -z "$LODEV" ]; then + ts_log "Failed to create loop device" +fi +lo_print $LODEV >> $TS_OUTPUT +$TS_CMD_LOSETUP -d $LODEV +ts_finalize_subtest + +rm -rf $BACKFILE + +udevadm settle + +ts_finalize diff --git a/tests/ts/losetup/losetup-blkdev b/tests/ts/losetup/losetup-blkdev new file mode 100755 index 0000000..93eb732 --- /dev/null +++ b/tests/ts/losetup/losetup-blkdev @@ -0,0 +1,81 @@ +#!/bin/bash + +# +# Copyright (C) 2013 Karel Zak +# +# 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="losetup-blkdev" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_LOSETUP" +ts_check_test_command "$TS_CMD_LSBLK" + +ts_skip_nonroot +ts_check_losetup + +. "$TS_SELF/losetup_functions.sh" + +# +# Backing file is a block device +# +ts_scsi_debug_init dev_size_mb=11 +BACKFILE="$TS_DEVICE" + +ts_init_subtest "show" +LODEV=$( $TS_CMD_LOSETUP --find --show $BACKFILE ) +if [ -z "$LODEV" ]; then + ts_log "Failed to create loop device" +fi +lo_print $LODEV >> $TS_OUTPUT +udevadm settle +$TS_CMD_LOSETUP -d $LODEV +ts_finalize_subtest + +ts_init_subtest "offset" +LODEV=$( $TS_CMD_LOSETUP --offset 1MiB --find --show $BACKFILE ) +if [ -z "$LODEV" ]; then + ts_log "Failed to create loop device" +fi +lo_print $LODEV >> $TS_OUTPUT +udevadm settle +$TS_CMD_LOSETUP -d $LODEV +ts_finalize_subtest + + +ts_init_subtest "sizelimit" +LODEV=$( $TS_CMD_LOSETUP --sizelimit 3MiB --find --show $BACKFILE ) +if [ -z "$LODEV" ]; then + ts_log "Failed to create loop device" +fi +lo_print $LODEV >> $TS_OUTPUT +udevadm settle +$TS_CMD_LOSETUP -d $LODEV +ts_finalize_subtest + + +ts_init_subtest "section" +LODEV=$( $TS_CMD_LOSETUP --offset 1MiB --sizelimit 3MiB --find --show $BACKFILE ) +if [ -z "$LODEV" ]; then + ts_log "Failed to create loop device" +fi +lo_print $LODEV >> $TS_OUTPUT +udevadm settle +$TS_CMD_LOSETUP -d $LODEV +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/losetup/losetup-loop b/tests/ts/losetup/losetup-loop new file mode 100755 index 0000000..d6ba902 --- /dev/null +++ b/tests/ts/losetup/losetup-loop @@ -0,0 +1,247 @@ +#!/bin/bash + +# +# Copyright (C) 2016 Stanislav Brabec +# +# 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="losetup-loop" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_LOSETUP" +ts_check_test_command "$TS_CMD_LSBLK" + +ts_skip_nonroot +ts_check_losetup + +. "$TS_SELF/losetup_functions.sh" + +# +# Backing file is a block device +# +ts_scsi_debug_init dev_size_mb=11 +BACKFILE="$TS_DEVICE" + +# All tests are separated by "udevadm settle" because loop device exists some time after +# "losetup -d". This device confuses some tests. And find-race-condition, tests, +# whether re-use of this device works. + +ts_init_subtest "find-race-condition" +LODEV=$( $TS_CMD_LOSETUP --find --nooverlap --show $BACKFILE ) +$TS_CMD_LOSETUP -d "$LODEV" +# The loop device may or may not exist here because no "udevadm settle". +LODEV=$( $TS_CMD_LOSETUP --find --nooverlap --show $BACKFILE ) +udevadm settle +dd if=/dev/zero of="$LODEV" count=1 bs=1 >/dev/null 2>&1 +$TS_CMD_LOSETUP --list | grep -q "$LODEV\b" +ts_log $? +udevadm settle +$TS_CMD_LOSETUP -d "$LODEV" >/dev/null 2>&1 +ts_log "Success" +ts_finalize_subtest + +udevadm settle + +ts_init_subtest "find-re-use" +LODEV=$( $TS_CMD_LOSETUP --find --nooverlap --show $BACKFILE ) +if [ -z "$LODEV" ]; then + ts_log "Failed to create loop device" +fi +LODEVR=$( $TS_CMD_LOSETUP --find --nooverlap --show $BACKFILE ) +if [ -z "$LODEVR" ]; then + ts_log "Failed to create loop device" +fi +udevadm settle +if test "$LODEV" = "$LODEVR" ; then + echo "equal" >>$TS_OUTPUT +else + echo "different" >>$TS_OUTPUT + if test -n "$LODEVR" ; then + $TS_CMD_LOSETUP -d "$LODEVR" + fi +fi +$TS_CMD_LOSETUP -d "$LODEV" +ts_log "Success" +ts_finalize_subtest + +udevadm settle + +ts_init_subtest "find-no-re-use" +LODEV=$( $TS_CMD_LOSETUP --find --nooverlap --show --offset=0 --sizelimit=1MiB $BACKFILE ) +if [ -z "$LODEV" ]; then + ts_log "Failed to create loop device" +fi +LODEVR=$( $TS_CMD_LOSETUP --find --nooverlap --show --offset=1MiB --sizelimit=1MiB $BACKFILE ) +if [ -z "$LODEVR" ]; then + ts_log "Failed to create loop device" +fi +udevadm settle +if test "$LODEV" = "$LODEVR" ; then + echo "equal" >>$TS_OUTPUT +else + echo "different" >>$TS_OUTPUT + if test -n "$LODEVR" ; then + $TS_CMD_LOSETUP -d "$LODEVR" + fi +fi +$TS_CMD_LOSETUP -d "$LODEV" +ts_log "Success" +ts_finalize_subtest + +udevadm settle + +ts_init_subtest "find-conflict" +LODEV=$( $TS_CMD_LOSETUP --find --nooverlap --show --offset=1MiB --sizelimit=2MiB $BACKFILE ) +if [ -z "$LODEV" ]; then + ts_log "Failed to create loop device" +fi +LODEVR=$( $TS_CMD_LOSETUP --find --nooverlap --show --offset=2MiB --sizelimit=2MiB $BACKFILE >/dev/null 2>&1 ) +if [ -z "$LODEVR" ]; then + ts_log "Failed to create loop device" +fi +udevadm settle +if test "$LODEV" = "$LODEVR" ; then + echo "equal" >>$TS_OUTPUT +else + echo "different" >>$TS_OUTPUT + if test -n "$LODEVR" ; then + $TS_CMD_LOSETUP -d "$LODEVR" + fi +fi +$TS_CMD_LOSETUP -d "$LODEV" +ts_log "Success" +ts_finalize_subtest + +udevadm settle + +ts_init_subtest "find-conflict-no-sizelimit" +LODEV=$( $TS_CMD_LOSETUP --find --nooverlap --show --offset=1MiB $BACKFILE ) +if [ -z "$LODEV" ]; then + ts_log "Failed to create loop device" +fi +LODEVR=$( $TS_CMD_LOSETUP --find --nooverlap --show --offset=2MiB --sizelimit=2MiB $BACKFILE >/dev/null 2>&1 ) +if [ -z "$LODEVR" ]; then + ts_log "Failed to create loop device" +fi +udevadm settle +if test "$LODEV" = "$LODEVR" ; then + echo "equal" >>$TS_OUTPUT +else + echo "different" >>$TS_OUTPUT + if test -n "$LODEVR" ; then + $TS_CMD_LOSETUP -d "$LODEVR" + fi +fi +$TS_CMD_LOSETUP -d "$LODEV" +ts_log "Success" +ts_finalize_subtest + +udevadm settle + +ts_init_subtest "find-conflict-readonly" +LODEV=$( $TS_CMD_LOSETUP --find --nooverlap --show --read-only $BACKFILE ) +if [ -z "$LODEV" ]; then + ts_log "Failed to create loop device" +fi +LODEVR=$( $TS_CMD_LOSETUP --find --nooverlap --show --offset=2MiB --sizelimit=2MiB $BACKFILE >/dev/null 2>&1 ) +if [ -z "$LODEVR" ]; then + ts_log "Failed to create loop device" +fi +udevadm settle +if test "$LODEV" = "$LODEVR" ; then + echo "equal" >>$TS_OUTPUT +else + echo "different" >>$TS_OUTPUT + if test -n "$LODEVR" ; then + $TS_CMD_LOSETUP -d "$LODEVR" + fi +fi +$TS_CMD_LOSETUP -d "$LODEV" +$TS_CMD_LOSETUP -d "$LODEVR" >/dev/null 2>&1 +ts_log "Success" +ts_finalize_subtest + +udevadm settle + +ts_init_subtest "find-ok-no-sizelimit" +LODEV=$( $TS_CMD_LOSETUP --find --nooverlap --show --offset=1MiB --sizelimit=1MiB $BACKFILE ) +if [ -z "$LODEV" ]; then + ts_log "Failed to create loop device" +fi +LODEVR=$( $TS_CMD_LOSETUP --find --nooverlap --show --offset=2MiB $BACKFILE ) +if [ -z "$LODEVR" ]; then + ts_log "Failed to create loop device" +fi +udevadm settle +if test "$LODEV" = "$LODEVR" ; then + echo "equal" >>$TS_OUTPUT +else + echo "different" >>$TS_OUTPUT + if test -n "$LODEVR" ; then + $TS_CMD_LOSETUP -d "$LODEVR" + fi +fi +$TS_CMD_LOSETUP -d "$LODEV" +ts_log "Success" +ts_finalize_subtest + +udevadm settle + +ts_init_subtest "plain-conflict" +if [ "$TS_PARALLEL" = "yes" ]; then + # There is a race in $LODEV is usage + ts_skip_subtest "no-reentrant" +else + LODEV=$( $TS_CMD_LOSETUP --find --nooverlap --show $BACKFILE ) + if [ -z "$LODEV" ]; then + ts_log "Failed to create loop device" + fi + LODEVR=$( $TS_CMD_LOSETUP --find ) + $TS_CMD_LOSETUP --nooverlap "$LODEVR" $BACKFILE >/dev/null 2>&1 + ts_log $? + udevadm settle + $TS_CMD_LOSETUP -d "$LODEV" + $TS_CMD_LOSETUP -d "$LODEVR" >/dev/null 2>&1 + ts_log "Success" + ts_finalize_subtest +fi + +udevadm settle + +ts_init_subtest "plain-readonly" +if [ "$TS_PARALLEL" = "yes" ]; then + # There is a race in $LODEV is usage + ts_skip_subtest "no-reentrant" +else + LODEV=$( $TS_CMD_LOSETUP --find --nooverlap --show --read-only $BACKFILE ) + if [ -z "$LODEV" ]; then + ts_log "Failed to create loop device" + fi + LODEVR=$( $TS_CMD_LOSETUP --find ) + $TS_CMD_LOSETUP --nooverlap "$LODEVR" $BACKFILE >/dev/null 2>&1 + ts_log $? + udevadm settle + $TS_CMD_LOSETUP -d "$LODEV" + $TS_CMD_LOSETUP -d "$LODEVR" >/dev/null 2>&1 + ts_log "Success" + ts_finalize_subtest +fi + +udevadm settle + +ts_log "Success" +ts_finalize diff --git a/tests/ts/losetup/losetup_functions.sh b/tests/ts/losetup/losetup_functions.sh new file mode 100644 index 0000000..d17c82a --- /dev/null +++ b/tests/ts/losetup/losetup_functions.sh @@ -0,0 +1,7 @@ + +function lo_print { + local lo=$1 + echo "offset: $( $TS_CMD_LOSETUP --list --raw -n -O OFFSET $lo )" + echo "sizelimit: $( $TS_CMD_LOSETUP --list --raw -n -O SIZELIMIT $lo )" + echo "size: $( $TS_CMD_LSBLK -o SIZE -b -n -r $lo )" +} diff --git a/tests/ts/lsblk/README b/tests/ts/lsblk/README new file mode 100644 index 0000000..6f93710 --- /dev/null +++ b/tests/ts/lsblk/README @@ -0,0 +1,19 @@ + +Howto add new lsblk test: + +* run mk-input.sh + +* copy testname.tar.xz file to tests/ts/lsblk/dumps + +* copy lsblk-* files from the tarball to tests/expected/lsblk/ + +* run ./tests/run.sh lsblk + +* git add tests/ts/lsblk/testname.tar.xz + git add tests/expected/lsblk/lsblk-testname* + + +Note that we do not use directly lsblk-* from the tarball. It's better to keep +copy of the files in the tests/expected/lsblk/, because output formatting may +be different in the current version. The version in the tarball is just initial +hint only. diff --git a/tests/ts/lsblk/dumps/simple-lvm.tar.xz b/tests/ts/lsblk/dumps/simple-lvm.tar.xz new file mode 100644 index 0000000..b0c8c34 Binary files /dev/null and b/tests/ts/lsblk/dumps/simple-lvm.tar.xz differ diff --git a/tests/ts/lsblk/dumps/simple-nvme.tar.xz b/tests/ts/lsblk/dumps/simple-nvme.tar.xz new file mode 100644 index 0000000..47229b3 Binary files /dev/null and b/tests/ts/lsblk/dumps/simple-nvme.tar.xz differ diff --git a/tests/ts/lsblk/lsblk b/tests/ts/lsblk/lsblk new file mode 100755 index 0000000..926f62d --- /dev/null +++ b/tests/ts/lsblk/lsblk @@ -0,0 +1,56 @@ +#!/bin/bash +# +# Copyright (C) 2018 Karel Zak +# +# 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 3 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. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +TS_TOPDIR="${0%/*}/../.." +. "$TS_TOPDIR"/functions.sh + +ts_init "$*" + +ts_check_test_command "$TS_CMD_LSBLK" +ts_check_prog xz +ts_check_prog tar + +for dump in $(ls $TS_SELF/dumps/*.tar.xz | sort); do + name=$(basename $dump .tar.xz) + dumpdir="$TS_OUTDIR/dumps" + + mkdir -p $dumpdir + tar -C $dumpdir --xz -xf $dump + + # + # Read *.cols from the tarball, but the expected output is not used + # from the tarball due to changes in lsblk fomatting etc. We keep up to + # date version in tests/expected/lsblk. + # + for cols_file in $(ls $dumpdir/$name/*.cols | sort); do + subname=$(basename $cols_file .cols) + subtestname="${name}-${subname}" + + ts_init_subtest $subtestname + cols=$(cat $cols_file) + ${TS_CMD_LSBLK} --sysroot "${dumpdir}/${name}" \ + --output $cols \ + >> ${TS_OUTPUT} 2>> $TS_ERRLOG + + ts_finalize_subtest + done +done + +ts_finalize + diff --git a/tests/ts/lsblk/mk-input.sh b/tests/ts/lsblk/mk-input.sh new file mode 100755 index 0000000..2bbd9e3 --- /dev/null +++ b/tests/ts/lsblk/mk-input.sh @@ -0,0 +1,124 @@ +#!/bin/bash +# +# Copyright (C) 2018 Karel Zak +# +# This script makes a copy of relevant files from /sys and /proc. +# The files are useful for lsblk(1) regression tests. +# +progname=$(basename $0) + +if [ -z "$1" ]; then + echo -e "\nusage: $progname \n" + exit 1 +fi + +TS_DUMP="$1" +TS_NAME=$(basename ${TS_DUMP}) +TS_TARBALL="$TS_DUMP.tar.xz" +TS_CMD_LSBLK=${TS_CMD_LSBLK:-"lsblk"} + +# +# procfs +# +mkdir -p $TS_DUMP/proc +mkdir -p $TS_DUMP/proc/self +cp /proc/self/mountinfo ${TS_DUMP}/proc/self +cp /proc/swaps ${TS_DUMP}/proc/swaps +cp /proc/version ${TS_DUMP}/proc/version + + +# +# sysfs +# +mkdir -p $TS_DUMP/sys/{block,dev/block} +cp --no-dereference /sys/dev/block/* ${TS_DUMP}/sys/dev/block +cp --no-dereference /sys/block/* ${TS_DUMP}/sys/block + +DEVS=$(find /sys/dev/block/ -type l) +for x in ${DEVS}; do + DEV="/sys/dev/block/$(readlink $x)" + + mkdir -p ${TS_DUMP}/${DEV} + + # attributes + for f in $(find ${DEV} -type f -not -path '*/trace/*' -not -path '*/uevent'); do + if [ ! -f ${TS_DUMP}/${f} ]; then + SUB=$(dirname $f) + mkdir -p ${TS_DUMP}/${SUB} + cp $f ${TS_DUMP}/$f 2> /dev/null + fi + done + + # symlinks (slave, holders, etc.) + for f in $(find ${DEV} -type l -not -path '*/subsystem' -not -path '*/bdi'); do + if [ ! -f ${TS_DUMP}/${f} ]; then + SUB=$(dirname $f) + mkdir -p ${TS_DUMP}/${SUB} + cp --no-dereference $f ${TS_DUMP}/$f + fi + done + + # device/ files + if [ -d ${DEV}/device/ ]; then + for f in $(find ${DEV}/device/ -maxdepth 1 -type f -not -path '*/uevent'); do + if [ ! -f ${TS_DUMP}/${f} ]; then + SUB=$(dirname $f) + cp $f ${TS_DUMP}/$f 2> /dev/null + fi + done + fi + +done + +# +# udev a lsblk specific +# +mkdir -p $TS_DUMP/dev +DEVS=$(lsblk --noheadings --output PATH) +for d in $DEVS; do + + # udev + udevadm info --query=property $d > $TS_DUMP/$d + + # lsblk + echo "OWNER=$($TS_CMD_LSBLK --noheadings --nodeps --output OWNER $d)" >> $TS_DUMP/$d + echo "GROUP=$($TS_CMD_LSBLK --noheadings --nodeps --output GROUP $d)" >> $TS_DUMP/$d + echo "MODE=$($TS_CMD_LSBLK --noheadings --nodeps --output MODE $d)" >> $TS_DUMP/$d +done + +function mk_output { + local cols="NAME,${2}" + local subname="$1" + + echo "$cols" > ${TS_DUMP}/${subname}.cols + $TS_CMD_LSBLK -o ${cols} > ${TS_DUMP}/lsblk-${TS_NAME}-${subname} +} + + +LANG="POSIX" +LANGUAGE="POSIX" +LC_ALL="POSIX" +CHARSET="UTF-8" + +export LANG LANGUAGE LC_ALL CHARSET + +# +# lsblk info +# +$TS_CMD_LSBLK -V &> ${TS_DUMP}/version + +mk_output basic KNAME,MAJ:MIN,RM,SIZE,TYPE,MOUNTPOINT +mk_output vendor MODEL,VENDOR,REV +mk_output state RO,RM,HOTPLUG,RAND,STATE,ROTA,TYPE,PKNAME,SCHED +mk_output rw RA,WSAME +mk_output topo SIZE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,RQ-SIZE +mk_output discard DISC-ALN,DISC-GRAN,DISC-MAX,DISC-ZERO +mk_output zone ZONED + + +tar --xz -cvf ${TS_TARBALL} $TS_DUMP +rm -rf $TS_DUMP + +echo -e "\nPlease, send ${TS_TARBALL} to util-linux upstream. Thanks!\n" + + diff --git a/tests/ts/lscpu/dumps/armv7.tar.gz b/tests/ts/lscpu/dumps/armv7.tar.gz new file mode 100644 index 0000000..67a2c66 Binary files /dev/null and b/tests/ts/lscpu/dumps/armv7.tar.gz differ diff --git a/tests/ts/lscpu/dumps/loongarch-loongson_3a5000_hv.tar.gz b/tests/ts/lscpu/dumps/loongarch-loongson_3a5000_hv.tar.gz new file mode 100644 index 0000000..ee29d80 Binary files /dev/null and b/tests/ts/lscpu/dumps/loongarch-loongson_3a5000_hv.tar.gz differ diff --git a/tests/ts/lscpu/dumps/ppc-qemu.tar.gz b/tests/ts/lscpu/dumps/ppc-qemu.tar.gz new file mode 100644 index 0000000..a428271 Binary files /dev/null and b/tests/ts/lscpu/dumps/ppc-qemu.tar.gz differ diff --git a/tests/ts/lscpu/dumps/ppc64-POWER7-64cpu.tar.gz b/tests/ts/lscpu/dumps/ppc64-POWER7-64cpu.tar.gz new file mode 100644 index 0000000..ea8b79a Binary files /dev/null and b/tests/ts/lscpu/dumps/ppc64-POWER7-64cpu.tar.gz differ diff --git a/tests/ts/lscpu/dumps/ppc64-POWER7.tar.gz b/tests/ts/lscpu/dumps/ppc64-POWER7.tar.gz new file mode 100644 index 0000000..c8fcc23 Binary files /dev/null and b/tests/ts/lscpu/dumps/ppc64-POWER7.tar.gz differ diff --git a/tests/ts/lscpu/dumps/rv64-linux.tar.gz b/tests/ts/lscpu/dumps/rv64-linux.tar.gz new file mode 100644 index 0000000..e108d85 Binary files /dev/null and b/tests/ts/lscpu/dumps/rv64-linux.tar.gz differ diff --git a/tests/ts/lscpu/dumps/s390-kvm.tar.gz b/tests/ts/lscpu/dumps/s390-kvm.tar.gz new file mode 100644 index 0000000..340f7ea Binary files /dev/null and b/tests/ts/lscpu/dumps/s390-kvm.tar.gz differ diff --git a/tests/ts/lscpu/dumps/s390-lpar-drawer.tar.gz b/tests/ts/lscpu/dumps/s390-lpar-drawer.tar.gz new file mode 100644 index 0000000..ca1bc96 Binary files /dev/null and b/tests/ts/lscpu/dumps/s390-lpar-drawer.tar.gz differ diff --git a/tests/ts/lscpu/dumps/s390-lpar.tar.gz b/tests/ts/lscpu/dumps/s390-lpar.tar.gz new file mode 100644 index 0000000..59aea6a Binary files /dev/null and b/tests/ts/lscpu/dumps/s390-lpar.tar.gz differ diff --git a/tests/ts/lscpu/dumps/s390-nested-virt.tar.gz b/tests/ts/lscpu/dumps/s390-nested-virt.tar.gz new file mode 100644 index 0000000..7992699 Binary files /dev/null and b/tests/ts/lscpu/dumps/s390-nested-virt.tar.gz differ diff --git a/tests/ts/lscpu/dumps/s390-zvm.tar.gz b/tests/ts/lscpu/dumps/s390-zvm.tar.gz new file mode 100644 index 0000000..b13594d Binary files /dev/null and b/tests/ts/lscpu/dumps/s390-zvm.tar.gz differ diff --git a/tests/ts/lscpu/dumps/sparc64.tar.gz b/tests/ts/lscpu/dumps/sparc64.tar.gz new file mode 100644 index 0000000..7edfba8 Binary files /dev/null and b/tests/ts/lscpu/dumps/sparc64.tar.gz differ diff --git a/tests/ts/lscpu/dumps/vbox-win.tar.gz b/tests/ts/lscpu/dumps/vbox-win.tar.gz new file mode 100644 index 0000000..e8204fe Binary files /dev/null and b/tests/ts/lscpu/dumps/vbox-win.tar.gz differ diff --git a/tests/ts/lscpu/dumps/vmware_fpe.tar.gz b/tests/ts/lscpu/dumps/vmware_fpe.tar.gz new file mode 100644 index 0000000..1fc6aed Binary files /dev/null and b/tests/ts/lscpu/dumps/vmware_fpe.tar.gz differ diff --git a/tests/ts/lscpu/dumps/x86_64-64cpu-linux6.2.tar.gz b/tests/ts/lscpu/dumps/x86_64-64cpu-linux6.2.tar.gz new file mode 100644 index 0000000..05d0aa6 Binary files /dev/null and b/tests/ts/lscpu/dumps/x86_64-64cpu-linux6.2.tar.gz differ diff --git a/tests/ts/lscpu/dumps/x86_64-64cpu.tar.gz b/tests/ts/lscpu/dumps/x86_64-64cpu.tar.gz new file mode 100644 index 0000000..4d7516e Binary files /dev/null and b/tests/ts/lscpu/dumps/x86_64-64cpu.tar.gz differ diff --git a/tests/ts/lscpu/dumps/x86_64-dell_e4310.tar.gz b/tests/ts/lscpu/dumps/x86_64-dell_e4310.tar.gz new file mode 100644 index 0000000..2988cbc Binary files /dev/null and b/tests/ts/lscpu/dumps/x86_64-dell_e4310.tar.gz differ diff --git a/tests/ts/lscpu/dumps/x86_64-epyc_7451.tar.gz b/tests/ts/lscpu/dumps/x86_64-epyc_7451.tar.gz new file mode 100644 index 0000000..cb7cbd9 Binary files /dev/null and b/tests/ts/lscpu/dumps/x86_64-epyc_7451.tar.gz differ diff --git a/tests/ts/lscpu/lscpu b/tests/ts/lscpu/lscpu new file mode 100755 index 0000000..03249c3 --- /dev/null +++ b/tests/ts/lscpu/lscpu @@ -0,0 +1,61 @@ +#!/bin/bash +# +# Copyright (C) 2008 Cai Qian +# +# 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 3 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. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +TS_TOPDIR="${0%/*}/../.." +. "$TS_TOPDIR"/functions.sh + +ts_init "$*" + +ts_check_prog "tar" +ts_check_prog "gzip" +ts_check_test_command "$TS_CMD_LSCPU" + +for dump in $(ls $TS_SELF/dumps/*.tar.gz | sort); do + name=$(basename $dump .tar.gz) + dumpdir="$TS_OUTDIR/dumps" + + ts_init_subtest $name + mkdir -p $dumpdir + + tar -C $dumpdir -zxf $dump + + # Architecture information is not applicable with -s. + "${TS_CMD_LSCPU}" -s "${dumpdir}/${name}" | \ + grep -v "Architecture" >> ${TS_OUTPUT} 2>> $TS_ERRLOG + + echo >>"${TS_OUTPUT}" + + "${TS_CMD_LSCPU}" -p -s "${dumpdir}/${name}" \ + >> ${TS_OUTPUT} 2>> $TS_ERRLOG + + echo >>"${TS_OUTPUT}" + + "${TS_CMD_LSCPU}" -p -y -s "${dumpdir}/${name}" \ + >> ${TS_OUTPUT} 2>> $TS_ERRLOG + + if [[ ! -e "${dumpdir}/${name}/sys/kernel/cpu_byteorder" ]]; then + # LE/BE depends on binary if we can't read it from the dump + sed -i -e '/Byte Order:.*/d' $TS_OUTPUT + fi + + ts_finalize_subtest +done + +ts_finalize + diff --git a/tests/ts/lscpu/mk-input.sh b/tests/ts/lscpu/mk-input.sh new file mode 100755 index 0000000..a19bad3 --- /dev/null +++ b/tests/ts/lscpu/mk-input.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# +# Copyright (C) 2008-2009 Karel Zak +# +# This script makes a copy of relevant files from /sys and /proc. +# The files are useful for lscpu(1) regression tests. +# +progname=$(basename $0) + +if [ -z "$1" ]; then + echo -e "\nusage: $progname \n" + exit 1 +fi + +TS_NAME="$1" +TS_DUMP="$TS_NAME" +CP="cp -r --parents" + +mkdir -p $TS_DUMP/{proc,sys} + +$CP /proc/cpuinfo $TS_DUMP + +mkdir -p $TS_DUMP/proc/bus/pci +$CP /proc/bus/pci/devices $TS_DUMP + +if [ -d "/proc/xen" ]; then + mkdir -p $TS_DUMP/proc/xen + if [ -f "/proc/xen/capabilities" ]; then + $CP /proc/xen/capabilities $TS_DUMP + fi +fi + +if [ -e "/proc/sysinfo" ]; then + $CP /proc/sysinfo $TS_DUMP +fi + +$CP /sys/devices/system/cpu/* $TS_DUMP +$CP /sys/devices/system/node/*/cpumap $TS_DUMP + +if [ -e "/sys/kernel/cpu_byteorder" ]; then + $CP /sys/kernel/cpu_byteorder $TS_DUMP +fi + + +tar zcvf $TS_NAME.tar.gz $TS_DUMP +rm -rf $TS_DUMP + + diff --git a/tests/ts/lsfd/column-ainodeclass b/tests/ts/lsfd/column-ainodeclass new file mode 100755 index 0000000..6391c48 --- /dev/null +++ b/tests/ts/lsfd/column-ainodeclass @@ -0,0 +1,52 @@ +#!/bin/bash +# +# Copyright (C) 2022 Masatake YAMATO +# +# 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="ainodeclass column" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +. "$TS_SELF/lsfd-functions.bash" +ts_check_test_command "$TS_CMD_LSFD" +ts_check_test_command "$TS_HELPER_MKFDS" + +ts_cd "$TS_OUTDIR" + +PID= +FD=3 +EXPR="(FD == 3)" + +for C in pidfd inotify; do + ts_init_subtest $C + { + coproc MKFDS { "$TS_HELPER_MKFDS" $C $FD ; } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n -o ASSOC,STTYPE,AINODECLASS -p "${PID}" -Q "${EXPR}" + echo "$C"':ASSOC,STTYPE,AINODECLASS': $? + + kill -CONT "${PID}" + fi + wait "${MKFDS_PID}" + } > "$TS_OUTPUT" 2>&1 + if [ "$C-$?" == "pidfd-$ENOSYS" ]; then + ts_skip_subtest "pidfd_open(2) is not available" + continue + fi + ts_finalize_subtest +done + +ts_finalize diff --git a/tests/ts/lsfd/column-kthread b/tests/ts/lsfd/column-kthread new file mode 100755 index 0000000..0b093e9 --- /dev/null +++ b/tests/ts/lsfd/column-kthread @@ -0,0 +1,41 @@ +#!/bin/bash +# +# Copyright (C) 2021 Masatake YAMATO +# +# 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="kthread column" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" +ts_skip_nonroot + +ts_check_test_command "$TS_CMD_LSFD" +ts_check_prog "ps" + +[ "$(ps --no-headers -o comm 1)" = 'systemd' ] || ts_skip "pid 1 is not systemd" +[ "$(ps --no-headers -o comm 2)" = 'kthreadd' ] || ts_skip "pid 2 is not kthreadd" + +ts_cd "$TS_OUTDIR" + +{ + "$TS_CMD_LSFD" -o COMMAND,PID,USER,MODE,TYPE,NAME,KTHREAD \ + -Q '(PID < 3) and ((ASSOC == "cwd") or (ASSOC == "rtd"))' + echo $? +} > $TS_OUTPUT 2>&1 + +ts_finalize + + diff --git a/tests/ts/lsfd/column-name b/tests/ts/lsfd/column-name new file mode 100755 index 0000000..5dc491a --- /dev/null +++ b/tests/ts/lsfd/column-name @@ -0,0 +1,74 @@ +#!/bin/bash +# +# Copyright (C) 2022 Masatake YAMATO +# +# 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="NAME and KNAME column" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +. "$TS_SELF/lsfd-functions.bash" +ts_check_test_command "$TS_CMD_LSFD" +ts_check_test_command "$TS_HELPER_MKFDS" +ts_check_prog "sed" + +ts_cd "$TS_OUTDIR" + +PID= +FD=3 +EXPR="(FD == 3)" + +make_state_connected() +{ + if [ "$1" = "socketpair" ]; then + lsfd_make_state_connected + else + cat + fi +} + +for C in ro-regular-file pidfd socketpair; do + ts_init_subtest $C + { + coproc MKFDS { + argv=() + case $C in + socketpair) + argv[0]="$((FD + 1))" + argv[1]="socktype=DGRAM" + esac + "$TS_HELPER_MKFDS" $C $FD "${argv[@]}" + } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n -o ASSOC,KNAME,NAME -p "${PID}" -Q "${EXPR}" | { + # Replace the unpredictable an inode number for the socket + # with "INODENUM". + sed -e 's/\[[0-9]\+\]/[INODENUM]/g' | make_state_connected $C + } + echo "$C"':ASSOC,KNAME,NAME': ${PIPESTATUS[0]} + + kill -CONT "${PID}" + fi + } > "$TS_OUTPUT" 2>&1 + wait "${MKFDS_PID}" + if [ "$C-$?" == "pidfd-$ENOSYS" ]; then + ts_skip_subtest "pidfd_open(2) is not available" + continue + fi + ts_finalize_subtest +done + +ts_finalize diff --git a/tests/ts/lsfd/column-type b/tests/ts/lsfd/column-type new file mode 100755 index 0000000..cf6175e --- /dev/null +++ b/tests/ts/lsfd/column-type @@ -0,0 +1,60 @@ +#!/bin/bash +# +# Copyright (C) 2022 Masatake YAMATO +# +# 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="TYPE and STTYPE column" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +. "$TS_SELF/lsfd-functions.bash" +ts_check_test_command "$TS_CMD_LSFD" +ts_check_test_command "$TS_HELPER_MKFDS" + +ts_cd "$TS_OUTDIR" + +PID= +FD=3 +EXPR="(FD == 3)" + +for C in ro-regular-file pidfd inotify socketpair; do + ts_init_subtest $C + { + coproc MKFDS { + argv=() + case $C in + socketpair) + argv[0]="$((FD + 1))" + argv[1]="socktype=DGRAM" + esac + "$TS_HELPER_MKFDS" $C $FD "${argv[@]}" + } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n -o ASSOC,STTYPE,TYPE -p "${PID}" -Q "${EXPR}" + echo "$C"':ASSOC,STTYPE,TYPE': $? + + kill -CONT "${PID}" + fi + wait "${MKFDS_PID}" + } > "$TS_OUTPUT" 2>&1 + if [ "$C-$?" == "pidfd-$ENOSYS" ]; then + ts_skip_subtest "pidfd_open(2) is not available" + continue + fi + ts_finalize_subtest +done + +ts_finalize diff --git a/tests/ts/lsfd/lsfd-functions.bash b/tests/ts/lsfd/lsfd-functions.bash new file mode 100644 index 0000000..d9a3595 --- /dev/null +++ b/tests/ts/lsfd/lsfd-functions.bash @@ -0,0 +1,85 @@ +#!/bin/bash +# +# Copyright (C) 2021 Masatake YAMATO +# +# 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. +# + +# The exit-status used in a test target. +readonly ENOSYS=17 +readonly EPERM=18 +readonly ENOPROTOOPT=19 +readonly EPROTONOSUPPORT=20 +readonly EACCESS=21 + +function lsfd_wait_for_pausing { + ts_check_prog "sleep" + + local PID=$1 + until [[ $(ps --no-headers -ostat "${PID}") =~ S.* ]]; do + sleep 1 + done +} + +function lsfd_compare_dev { + local LSFD=$1 + local FILE=$2 + local EXPR=$3 + + ts_check_prog "grep" + ts_check_prog "expr" + ts_check_prog "stat" + + local DEV=$("${LSFD}" --raw -n -o DEV -Q "${EXPR}") + echo 'DEV[RUN]:' $? + local MAJ=${DEV%:*} + local MIN=${DEV#*:} + local DEVNUM=$(( ( MAJ << 8 ) + MIN )) + local STAT_DEVNUM=$(stat -c "%d" "$FILE") + echo 'STAT[RUN]:' $? + if [ "${DEVNUM}" == "${STAT_DEVNUM}" ]; then + echo 'DEVNUM[STR]:' 0 + else + echo 'DEVNUM[STR]:' 1 + # Print more information for debugging + echo 'DEV:' "${DEV}" + echo 'MAJ:MIN' "${MAJ}:${MIN}" + echo 'DEVNUM:' "${DEVNUM}" + echo 'STAT_DEVNUM:' "${STAT_DEVNUM}" + fi +} + +lsfd_strip_type_stream() +{ + # lsfd changes the output of NAME column for a unix stream socket + # whether the kernel reports it is a "UNIX-STREAM" socket or a + # "UNIX" socket. For "UNIX", lsfd appends "type=stream" to the + # NAME column. Let's delete the appended string before comparing. + sed -e 's/ type=stream//' +} + +lsfd_make_state_connected() +{ + # Newer kernels report the states of unix dgram sockets created by + # sockerpair(2) are "connected" via /proc/net/unix though Older + # kernels report "unconnected". + # + # Newer kernels report the states of unix dgram sockets already + # connect(2)'ed are "connected", too. + # + # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=83301b5367a98c17ec0d76c7bc0ccdc3c7e7ad6d + # + # This rewriting adjusts the output of lsfd running on older kernels + # to that on newer kernels. + sed -e 's/state=unconnected/state=connected/' +} diff --git a/tests/ts/lsfd/mkfds-directory b/tests/ts/lsfd/mkfds-directory new file mode 100755 index 0000000..ef769c9 --- /dev/null +++ b/tests/ts/lsfd/mkfds-directory @@ -0,0 +1,109 @@ +#!/bin/bash +# +# Copyright (C) 2021 Masatake YAMATO +# +# 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="directory" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_LSFD" +ts_check_test_command "$TS_CMD_FINDMNT" +ts_check_test_command "$TS_HELPER_MKFDS" + +ts_check_prog "stat" +ts_check_prog "id" +ts_check_prog "sed" + +ts_cd "$TS_OUTDIR" + +PID= +FD=3 +EXPR= +DIR=/ + +mntflag=$(findmnt -n -o OPTIONS -T $DIR) +noatime= +case "${mntflag}" in + *noatime*) + noatime=1 +esac + +{ + coproc MKFDS { "$TS_HELPER_MKFDS" directory $FD dir=$DIR; } + if read -u ${MKFDS[0]} PID; then + EXPR='(PID == '"${PID}"') and (FD == '"$FD"')' + ${TS_CMD_LSFD} -n -o ASSOC,MODE,TYPE,FLAGS,NAME -Q "${EXPR}" | { + # + # Normalize the output: + # + # See https://github.com/util-linux/util-linux/issues/1511#issuecomment-1029968595 + # It seems that syscalls opening a directory on mips64 GNU/Linux take the + # O_LARGEFILE flag. + # + sed -e 's/largefile,\|,largefile//' + } | { + # + # Normalize the output: + # + # See https://github.com/util-linux/util-linux/issues/1709#issuecomment-1156333293 + # If the file system where the target directory ($DIR) is mounted with + # "noatime" flag, Linux kernel may set O_NOATIME to the fd associated with $DIR. + # + if [ "$noatime" = 1 ]; then + sed -e 's/noatime,\|,noatime//' + else + cat + fi + } + echo 'ASSOC,MODE,TYPE,FLAGS,NAME': $? + + LSFD_PID=$(${TS_CMD_LSFD} --raw -n -o PID -Q "${EXPR}") + echo 'PID[RUN]:' $? + [ "${LSFD_PID}" == "${PID}" ] + echo 'PID[STR]:' $? + + LSFD_INODE=$(${TS_CMD_LSFD} --raw -n -o INODE -Q "${EXPR}") + echo 'INODE[RUN]:' $? + [ "${LSFD_INODE}" == "$(stat -c %i /)" ] + echo 'INODE[STR]:' $? + + LSFD_UID=$(${TS_CMD_LSFD} --raw -n -o UID -Q "${EXPR}") + echo 'UID[RUN]:' $? + [ "${LSFD_UID}" == $(id -u) ] + echo 'UID[STR]:' $? + + LSFD_USER=$(${TS_CMD_LSFD} --raw -n -o USER -Q "${EXPR}") + echo 'USER[RUN]:' $? + [ "${LSFD_USER}" == $(id -u -n) ] + echo 'USER[STR]:' $? + + LSFD_NLINK=$(${TS_CMD_LSFD} --raw -n -o NLINK -Q "${EXPR}") + echo 'NLINK[RUN]:' $? + if [ "${LSFD_NLINK}" == $(stat -c %h /) ]; then + echo 'NLINK[STR]:' 0 + else + echo 'NLINK[STR]:' 1 + echo 'LSFD_NLINK:' "${LSFD_NLINK}" + echo 'stat reports:' "$(stat -c %h /)" + fi + + kill -CONT ${PID} + fi + wait ${MKFDS_PID} +} > $TS_OUTPUT 2>&1 + +ts_finalize diff --git a/tests/ts/lsfd/mkfds-mapped-packet-socket b/tests/ts/lsfd/mkfds-mapped-packet-socket new file mode 100755 index 0000000..a1fb68f --- /dev/null +++ b/tests/ts/lsfd/mkfds-mapped-packet-socket @@ -0,0 +1,65 @@ +#!/bin/bash +# +# Copyright (C) 2022 Masatake YAMATO +# +# 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="mmap'ed AF_PACKET socket" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" +ts_skip_nonroot +ts_skip_docker + +. "$TS_SELF"/lsfd-functions.bash + +ts_check_test_command "$TS_CMD_LSFD" + +ts_check_test_command "$TS_HELPER_MKFDS" + +ts_cd "$TS_OUTDIR" + +PID= +FD=3 +EXPR= +INTERFACE=lo +SOCKTYPE= +ERR= + +for SOCKTYPE in RAW DGRAM; do + coproc MKFDS { "$TS_HELPER_MKFDS" mapped-packet-socket $FD \ + interface=${INTERFACE} socktype=${SOCKTYPE}; } + if read -u ${MKFDS[0]} PID; then + EXPR='(ASSOC == "shm") and (STTYPE == "SOCK") and (MODE == "-w-")' + ${TS_CMD_LSFD} -p "$PID" -n -o SOCK.PROTONAME -Q "${EXPR}" + echo 'SOCK.PROTONAME': $? + + EXPR="(FD == $FD)" + ${TS_CMD_LSFD} -p "$PID" -n -o NAME,SOCK.TYPE,SOCK.PROTONAME,PACKET.IFACE,PACKET.PROTOCOL -Q "${EXPR}" + echo 'NAME,SOCK.TYPE,SOCK.PROTONAME,PACKET.IFACE,PACKET.PROTOCOL': $? + + kill -CONT ${PID} + fi + wait ${MKFDS_PID} + ERR=$? + if [ $ERR != 0 ]; then + break + fi +done > $TS_OUTPUT 2>&1 + +if [[ "$ERR" == "$ENOPROTOOPT" ]]; then + ts_skip "packet socket doesn't support attaching a buffer on this platform" +fi + +ts_finalize diff --git a/tests/ts/lsfd/mkfds-netlink-groups b/tests/ts/lsfd/mkfds-netlink-groups new file mode 100755 index 0000000..896b50c --- /dev/null +++ b/tests/ts/lsfd/mkfds-netlink-groups @@ -0,0 +1,59 @@ +#!/bin/bash +# +# Copyright (C) 2023 Masatake YAMATO +# +# 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="NETLINK sockets" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" +ts_skip_nonroot + +. "$TS_SELF"/lsfd-functions.bash +ts_check_test_command "$TS_CMD_LSFD" +ts_check_test_command "$TS_HELPER_MKFDS" + +ts_cd "$TS_OUTDIR" + +PID= +FD=3 +EXPR='(TYPE == "NETLINK") and (FD == 3)' +NETLINK_PROTOCOL=4 +NETLINK_LPORT= +NETLINK_GROUPS=5 + +{ + coproc MKFDS { "$TS_HELPER_MKFDS" netlink $FD protocol=$NETLINK_PROTOCOL groups=$NETLINK_GROUPS; } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n \ + -o ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,NETLINK.PROTOCOL,NETLINK.GROUPS \ + -p "${PID}" -Q "${EXPR}" | sed -e "s/lport=${PID}/lport=/g" + echo 'ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,NETLINK.PROTOCOL,NETLINK.GROUPS': ${PIPESTATUS[0]} + NETLINK_LPORT=$(${TS_CMD_LSFD} --raw -n -o NETLINK.LPORT -p "${PID}" -Q "${EXPR}") + if [ "${NETLINK_LPORT}" == "${PID}" ]; then + echo 'LPORT: OK' + else + printf "LPORT: FAILED (PID: %d != NETLINK.LPORT: %d)\n" "${PID}" "${NETLINK_LPORT}" + fi + kill -CONT "${PID}" + fi + wait "${MKFDS_PID}" +} > "$TS_OUTPUT" 2>&1 + +if [[ $? == "$EPROTONOSUPPORT" ]]; then + ts_skip "It seems that this platform doesn't support making a netlink socket" +fi + +ts_finalize diff --git a/tests/ts/lsfd/mkfds-netlink-protocol b/tests/ts/lsfd/mkfds-netlink-protocol new file mode 100755 index 0000000..c1a5ffc --- /dev/null +++ b/tests/ts/lsfd/mkfds-netlink-protocol @@ -0,0 +1,58 @@ +#!/bin/bash +# +# Copyright (C) 2023 Masatake YAMATO +# +# 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="NETLINK sockets" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +. "$TS_SELF"/lsfd-functions.bash +ts_check_test_command "$TS_CMD_LSFD" +ts_check_test_command "$TS_HELPER_MKFDS" + +ts_cd "$TS_OUTDIR" + +PID= +FD=3 +EXPR='(TYPE == "NETLINK") and (FD == 3)' +NETLINK_PROTOCOL=4 +NETLINK_LPORT= +NETLINK_GROUPS=5 + +{ + coproc MKFDS { "$TS_HELPER_MKFDS" netlink $FD protocol=$NETLINK_PROTOCOL; } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n \ + -o ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,NETLINK.PROTOCOL,NETLINK.GROUPS \ + -p "${PID}" -Q "${EXPR}" | sed -e "s/lport=${PID}/lport=/g" + echo 'ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,NETLINK.PROTOCOL': ${PIPESTATUS[0]} + NETLINK_LPORT=$(${TS_CMD_LSFD} --raw -n -o NETLINK.LPORT -p "${PID}" -Q "${EXPR}") + if [ "${NETLINK_LPORT}" == "${PID}" ]; then + echo 'LPORT: OK' + else + printf "LPORT: FAILED (PID: %d != NETLINK.LPORT: %d)\n" "${PID}" "${NETLINK_LPORT}" + fi + kill -CONT "${PID}" + fi + wait "${MKFDS_PID}" +} > "$TS_OUTPUT" 2>&1 + +if [[ $? == "$EPROTONOSUPPORT" ]]; then + ts_skip "It seems that this platform doesn't support making a netlink socket" +fi + +ts_finalize diff --git a/tests/ts/lsfd/mkfds-netns b/tests/ts/lsfd/mkfds-netns new file mode 100755 index 0000000..cd110f6 --- /dev/null +++ b/tests/ts/lsfd/mkfds-netns @@ -0,0 +1,72 @@ +#!/bin/bash +# +# Copyright (C) 2022 Masatake YAMATO +# +# 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="netns associated with a fd" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" +ts_skip_nonroot +ts_skip_docker + +. "$TS_SELF/lsfd-functions.bash" +ts_check_test_command "$TS_CMD_LSFD" +ts_check_test_command "$TS_HELPER_MKFDS" + +ts_cd "$TS_OUTDIR" + +PID= +FD=3 +NAME_FD= +NAME_NS= +INO_FD= +INO_NS= +{ + coproc MKFDS { "$TS_HELPER_MKFDS" netns "$FD"; } + if read -r -u "${MKFDS[0]}" PID; then + "${TS_CMD_LSFD}" -n -oNS.TYPE -p "${PID}" -Q "(FD == $FD)" + NAME_FD=$("${TS_CMD_LSFD}" -n -oNS.NAME -p "${PID}" -Q "(FD == $FD)") + NAME_NS=$("${TS_CMD_LSFD}" -n -oNS.NAME -p "${PID}" -Q '(ASSOC == "net")') + INO_FD=$( "${TS_CMD_LSFD}" -n -oINODE -p "${PID}" -Q "(FD == $FD)") + INO_NS=$( "${TS_CMD_LSFD}" -n -oINODE -p "${PID}" -Q '(ASSOC == "net")') + + if [[ "$NAME_FD" = "$NAME_NS" ]]; then + echo "NAME_FD" == "NAME_NS": $? + else + echo "NAME_FD: $NAME_FD" == "NAME_NS: $NAME_NS": $? + fi + + if [[ "$NAME_FD" = "net:[$INO_FD]" ]]; then + echo "NAME_FD" == "net:[INO_FD]": $? + else + echo "NAME_FD: $NAME_FD" == "net:[INO_FD: $INO_FD]": $? + fi + + if [[ "$NAME_FD" = "net:[$INO_NS]" ]]; then + echo "NAME_FD" == "net:[INO_NS]": $? + else + echo "NAME_FD: $NAME_FD" == "net:[INO_NS: $INO_NS]": $? + fi + + kill -CONT ${PID} + fi + wait "${MKFDS_PID}" +} > "$TS_OUTPUT" 2>&1 +if [ "$?" == "$ENOSYS" ]; then + ts_skip "ioctl(fd, SIOCGSKNS) is not available" +fi + +ts_finalize diff --git a/tests/ts/lsfd/mkfds-pidfd b/tests/ts/lsfd/mkfds-pidfd new file mode 100755 index 0000000..aad693f --- /dev/null +++ b/tests/ts/lsfd/mkfds-pidfd @@ -0,0 +1,51 @@ +#!/bin/bash +# +# Copyright (C) 2022 Masatake YAMATO +# +# 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="pidfd" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +. "$TS_SELF/lsfd-functions.bash" +ts_check_test_command "$TS_CMD_LSFD" +ts_check_test_command "$TS_HELPER_MKFDS" +ts_check_prog "ps" + +ts_cd "$TS_OUTDIR" + +[ "$(ps --no-headers -o comm 1)" = 'systemd' ] || ts_skip "pid 1 is not systemd" + +PID= +FD=3 +TARGET=1 +EXPR="(PID != ${TARGET}) and (FD == 3) and (PIDFD.PID == ${TARGET})" + +{ + coproc MKFDS { "$TS_HELPER_MKFDS" pidfd $FD target-pid=${TARGET} ; } + if read -u ${MKFDS[0]} PID; then + ${TS_CMD_LSFD} -n -o ASSOC,STTYPE,SOURCE,NAME,PIDFD.COMM,PIDFD.PID -p "${PID}" -p ${TARGET} -Q "${EXPR}" + echo 'ASSOC,STTYPE,SOURCE,NAME,PIDFD.COMM,PIDFD.PID': $? + + kill -CONT ${PID} + fi + wait ${MKFDS_PID} +} > $TS_OUTPUT 2>&1 +if [ "$?" == "$ENOSYS" ]; then + ts_skip "pidfd_open(2) is not available" +fi + +ts_finalize diff --git a/tests/ts/lsfd/mkfds-ping b/tests/ts/lsfd/mkfds-ping new file mode 100755 index 0000000..c2ca049 --- /dev/null +++ b/tests/ts/lsfd/mkfds-ping @@ -0,0 +1,142 @@ +#!/bin/bash +# +# Copyright (C) 2023 Masatake YAMATO +# +# 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="PING and PINGv6 sockets" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_skip_nonroot + +. "$TS_SELF"/lsfd-functions.bash + +ts_check_test_command "$TS_CMD_LSFD" +ts_check_test_command "$TS_HELPER_MKFDS" +ts_check_prog "id" + +ts_check_native_byteorder + +ts_cd "$TS_OUTDIR" + +PID= +FD=3 +EXPR=( + '(TYPE == "PING") and (FD == 3)' + '(TYPE == "PINGv6") and (FD == 3)' +) +FACTORY=( + ping + ping6 +) +TYPE=( + 'PING' + 'PINGv6' +) +COLNS=( + INET + INET6 +) +ID=9999 + +range_check() +{ + local v=$1 + local min=$2 + local max=$3 + + [[ $min -le $v && $v -le $max ]] + return $? +} + +ping_group_range_check() +{ + local g + local group_min group_max + + if ! read group_min group_max < /proc/sys/net/ipv4/ping_group_range; then + # We can say nothing. Just allow to go ahead. + return 0 + fi + + if [[ -z "$group_min" || -z "$group_max" ]]; then + # We can say nothing. Just allow to go ahead. + return 0 + fi + + for g in $(id -G); do + if range_check "$g" "$group_min" "$group_max"; then + return 0 + fi + done + + return 1 +} + +ERRMSG= +for i in 0 1; do + ERRMSG=$("$TS_HELPER_MKFDS" -c -q "${FACTORY[$i]}" 3 id=$ID 2>&1) + ERR="$?" + if [[ "$ERR" == "$EACCESS" ]]; then + case "$ERRMSG" in + *bind*) + MSG="making ${TYPE[$i]} socket with specifying id is not allowed (blocked by SELinux?)" + ;; + *socket*) + if ! ping_group_range_check; then + MSG="the group(s) ($(id -G)) of the process is not in the expected range" + MSG+=" [$(cat /proc/sys/net/ipv4/ping_group_range)])" + else + MSG="$ERRMSG" + fi + ;; + *) + MSG="$ERRMSG" + ;; + esac + ts_skip "${MSG}" + elif [[ "$ERR" != 0 ]]; then + ts_skip "making ${TYPE[$i]} socket is failed ($ERR: $ERRMSG)" + fi +done + +for i in 0 1; do + ts_init_subtest "${FACTORY[$i]}" + { + coproc MKFDS { "$TS_HELPER_MKFDS" "${FACTORY[$i]}" $FD id=$ID; } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n \ + -o ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,${COLNS[$i]}.LADDR,${COLNS[$i]}.RADDR,PING.ID \ + -p "${PID}" -Q "${EXPR[$i]}" + echo "ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,${COLNS[$i]}.LADDR,${COLNS[$i]}.RADDR,PING.ID": $? + kill -CONT "${PID}" + fi + wait "${MKFDS_PID}" + + coproc MKFDS { "$TS_HELPER_MKFDS" "${FACTORY[$i]}" $FD id=$ID connect=0; } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n \ + -o ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,${COLNS[$i]}.LADDR,${COLNS[$i]}.RADDR,PING.ID \ + -p "${PID}" -Q "${EXPR[$i]}" + echo "ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,${COLNS[$i]}.LADDR,${COLNS[$i]}.RADDR,PING.ID": $? + kill -CONT "${PID}" + fi + } > "$TS_OUTPUT" 2>&1 + wait "${MKFDS_PID}" + ts_finalize_subtest +done + +ts_finalize diff --git a/tests/ts/lsfd/mkfds-pipe-no-fork b/tests/ts/lsfd/mkfds-pipe-no-fork new file mode 100755 index 0000000..e28aa9d --- /dev/null +++ b/tests/ts/lsfd/mkfds-pipe-no-fork @@ -0,0 +1,124 @@ +#!/bin/bash +# +# Copyright (C) 2021 Masatake YAMATO +# +# 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="pipe, no fork" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_LSFD" +ts_check_test_command "$TS_HELPER_MKFDS" + +ts_check_prog "stat" +ts_check_prog "readlink" + +ts_cd "$TS_OUTDIR" + +pipe_name() +{ + readlink /proc/$1/fd/$2 +} + +pipe_inode() +{ + stat -L -c %i /proc/$1/fd/$2 +} + +PID= +FD0=3 +FD1=4 +EXPR= + +{ + coproc MKFDS { "$TS_HELPER_MKFDS" pipe-no-fork $FD0 $FD1 nonblock=-w rdup=$((FD0 + 2)) wdup=$((FD1 + 2)); } + if read -u ${MKFDS[0]} PID; then + EXPR='(PID == '"${PID}"') and ((FD == '"$FD0"') or (FD =='"$FD1"'))' + ${TS_CMD_LSFD} -n -o ASSOC,MODE,TYPE,SOURCE,FLAGS -Q "${EXPR}" + echo 'ASSOC,MODE,TYPE,SOURCE,FLAGS': $? + + LSFD_PIDS=$(${TS_CMD_LSFD} --raw -n -o PID -Q "${EXPR}") + echo 'PID[RUN]:' $? + [ "${LSFD_PIDS}" == "$(printf '%d\n%d' ${PID} ${PID})" ] + echo 'PID[STR]:' $? + + LSFD_NAMES=$(${TS_CMD_LSFD} --raw -n -o NAME -Q "${EXPR}") + echo 'NAMES[RUN]:' $? + [ "${LSFD_NAMES}" == "$(printf '%s\n%s' $(pipe_name $PID $FD0) $(pipe_name $PID $FD1))" ] + echo 'NAMES[STR]:' $? + + LSFD_INODES=$(${TS_CMD_LSFD} --raw -n -o INODE -Q "${EXPR}") + echo 'INODES[RUN]:' $? + [ "${LSFD_INODES}" == "$(printf '%d\n%d' $(pipe_inode $PID $FD0) $(pipe_inode $PID $FD1))" ] + echo 'INODES[STR]:' $? + + LSFD_ENDPOINTS=$(${TS_CMD_LSFD} --raw -n -o ASSOC,ENDPOINTS -Q "${EXPR}") + echo 'ENDPOINTS[RUN]:' $? + mkfds=${TS_HELPER_MKFDS##*/} + + line0=$(printf '%d ' $FD0) + line0+=$(printf '%d,%s,%d%c%c' $PID $mkfds $FD1 - w) + line0+='\x0a' + line0+=$(printf '%d,%s,%d%c%c' $PID $mkfds $((FD0 + 2)) r -) + line0+='\x0a' + line0+=$(printf '%d,%s,%d%c%c' $PID $mkfds $((FD1 + 2)) - w) + + line1=$(printf '%d ' $FD1) + line1+=$(printf '%d,%s,%d%c%c' $PID $mkfds $FD0 r -) + line1+='\x0a' + line1+=$(printf '%d,%s,%d%c%c' $PID $mkfds $((FD0 + 2)) r -) + line1+='\x0a' + line1+=$(printf '%d,%s,%d%c%c' $PID $mkfds $((FD1 + 2)) - w) + + expected=$(printf '%s\n%s' "${line0}" "${line1}") + if [ "${LSFD_ENDPOINTS}" == "${expected}" ]; then + echo 'ENDPOINTS[STR]:' $? + else + echo "lsfd output:" + echo "${LSFD_ENDPOINTS}" + echo "expectation:" + echo "${expected}" + fi + + EXPR='(PID == '"${PID}"') and (FD == '"$FD0"')' + LSFD_ENDPOINTS_JSON=$(${TS_CMD_LSFD} -J --raw -n -o ASSOC,ENDPOINTS -Q "${EXPR}") + echo 'ASSOC,ENDPOINTS (JSON)': $? + EXPECTED_LSFD_ENDPOINTS_JSON=$(cat< $TS_OUTPUT 2>&1 + +ts_finalize diff --git a/tests/ts/lsfd/mkfds-raw b/tests/ts/lsfd/mkfds-raw new file mode 100755 index 0000000..0260ba1 --- /dev/null +++ b/tests/ts/lsfd/mkfds-raw @@ -0,0 +1,49 @@ +#!/bin/bash +# +# Copyright (C) 2023 Masatake YAMATO +# +# 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="RAW sockets" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_skip_nonroot + +ts_check_test_command "$TS_CMD_LSFD" +ts_check_test_command "$TS_HELPER_MKFDS" +ts_check_native_byteorder + +ts_cd "$TS_OUTDIR" + +PID= +FD=3 +EXPR='(TYPE == "RAW") and (FD == 3)' +PROTOCOL=5 + +{ + coproc MKFDS { "$TS_HELPER_MKFDS" raw $FD protocol=$PROTOCOL; } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n \ + -o ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,INET.LADDR,INET.RADDR,RAW.PROTOCOL \ + -p "${PID}" -Q "${EXPR}" + echo 'ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,INET.LADDR,INET.RADDR,RAW.PROTOCOL': $? + kill -CONT "${PID}" + fi + + wait "${MKFDS_PID}" +} > "$TS_OUTPUT" 2>&1 + +ts_finalize diff --git a/tests/ts/lsfd/mkfds-raw6 b/tests/ts/lsfd/mkfds-raw6 new file mode 100755 index 0000000..0b82fff --- /dev/null +++ b/tests/ts/lsfd/mkfds-raw6 @@ -0,0 +1,50 @@ +#!/bin/bash +# +# Copyright (C) 2023 Masatake YAMATO +# +# 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="RAW6 sockets" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_skip_nonroot + +ts_check_test_command "$TS_CMD_LSFD" +ts_check_test_command "$TS_HELPER_MKFDS" +ts_check_native_byteorder +ts_skip_docker + +ts_cd "$TS_OUTDIR" + +PID= +FD=3 +EXPR='(TYPE == "RAWv6") and (FD == 3)' +PROTOCOL=5 + +{ + coproc MKFDS { "$TS_HELPER_MKFDS" raw6 $FD protocol=$PROTOCOL; } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n \ + -o ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,INET6.LADDR,INET6.RADDR,RAW.PROTOCOL \ + -p "${PID}" -Q "${EXPR}" + echo 'ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,INET6.LADDR,INET6.RADDR,RAW.PROTOCOL': $? + kill -CONT "${PID}" + fi + + wait "${MKFDS_PID}" +} > "$TS_OUTPUT" 2>&1 + +ts_finalize diff --git a/tests/ts/lsfd/mkfds-ro-block-device b/tests/ts/lsfd/mkfds-ro-block-device new file mode 100755 index 0000000..ad5a492 --- /dev/null +++ b/tests/ts/lsfd/mkfds-ro-block-device @@ -0,0 +1,80 @@ +#!/bin/bash +# +# Copyright (C) 2021 Masatake YAMATO +# +# 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="block device with O_RDONLY" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" +ts_skip_nonroot +ts_skip_docker + +# losetup cannot find an unused loop device. +ts_skip_qemu_user + +. "$TS_SELF"/lsfd-functions.bash + +ts_check_test_command "$TS_CMD_LSFD" + +ts_check_test_command "$TS_CMD_LOSETUP" +ts_check_test_command "$TS_HELPER_MKFDS" + +ts_cd "$TS_OUTDIR" + +ts_device_init +LSFD_LOOP_BDEV=$TS_LODEV +LSFD_LOOP_BDEV_BASENAME=${LSFD_LOOP_BDEV##*/} +LSFD_LOOP_BDEV_NUM=${LSFD_LOOP_BDEV_BASENAME#loop} + +PID= +FD=3 +EXPR= + +{ + coproc MKFDS { "$TS_HELPER_MKFDS" ro-block-device $FD blkdev=${LSFD_LOOP_BDEV}; } + if read -u ${MKFDS[0]} PID; then + EXPR='(PID == '"${PID}"') and (FD == '"$FD"')' + ${TS_CMD_LSFD} -n -o ASSOC,MODE,TYPE,POS,BLKDRV,DEVTYPE -Q "${EXPR}" + echo 'ASSOC,MODE,TYPE,,POS,,BLKDRV,DEVTYPE': $? + + LSFD_NAME=$(${TS_CMD_LSFD} --raw -n -o NAME -Q "${EXPR}") + echo 'NAME[RUN]:' $? + [ "${LSFD_NAME}" == "${LSFD_LOOP_BDEV}" ] + echo 'NAME[STR]:' $? + + LSFD_SOURCE=$(${TS_CMD_LSFD} --raw -n -o SOURCE -Q "${EXPR}") + echo 'SOURCE[RUN]:' $? + [ "${LSFD_SOURCE}" == "${LSFD_LOOP_BDEV_BASENAME}" ] + echo 'SOURCE[STR]:' $? + + LSFD_MAJ_MIN=$(${TS_CMD_LSFD} --raw -n -o MAJ:MIN -Q "${EXPR}") + echo 'MAJ_MIN[RUN]:' $? + [ "${LSFD_MAJ_MIN}" == 7:"${LSFD_LOOP_BDEV_NUM}" ] + echo 'MAJ_MIN[STR]:' $? + + LSFD_RDEV=$(${TS_CMD_LSFD} --raw -n -o RDEV -Q "${EXPR}") + echo 'RDEV[RUN]:' $? + [ "${LSFD_RDEV}" == 7:"${LSFD_LOOP_BDEV_NUM}" ] + echo 'RDEV[STR]:' $? + + lsfd_compare_dev "${TS_CMD_LSFD}" "${LSFD_LOOP_BDEV}" "${EXPR}" + + kill -CONT ${PID} + fi + wait ${MKFDS_PID} +} > $TS_OUTPUT 2>&1 + +ts_finalize diff --git a/tests/ts/lsfd/mkfds-ro-regular-file b/tests/ts/lsfd/mkfds-ro-regular-file new file mode 100755 index 0000000..a2c4c26 --- /dev/null +++ b/tests/ts/lsfd/mkfds-ro-regular-file @@ -0,0 +1,78 @@ +#!/bin/bash +# +# Copyright (C) 2021 Masatake YAMATO +# +# 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="read-only regular file" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +. "$TS_SELF"/lsfd-functions.bash + +ts_check_test_command "$TS_CMD_LSFD" + +ts_check_test_command "$TS_HELPER_MKFDS" + +ts_check_prog "stat" +ts_check_prog "id" + +ts_cd "$TS_OUTDIR" + +PID= +FD=3 +EXPR= + +{ + target=/etc/passwd + coproc MKFDS { "$TS_HELPER_MKFDS" --comm ABC ro-regular-file $FD offset=1 file=$target; } + if read -u ${MKFDS[0]} PID; then + EXPR='(PID == '"${PID}"') and (FD == '"$FD"')' + ${TS_CMD_LSFD} -n -o COMMAND,ASSOC,MODE,TYPE,NAME,POS -Q "${EXPR}" + echo 'COMMAND,ASSOC,MODE,TYPE,NAME,POS': $? + + LSFD_PID=$(${TS_CMD_LSFD} --raw -n -o PID -Q "${EXPR}") + echo 'PID[RUN]:' $? + [ "${LSFD_PID}" == "${PID}" ] + echo 'PID[STR]:' $? + + LSFD_INODE=$(${TS_CMD_LSFD} --raw -n -o INODE -Q "${EXPR}") + echo 'INODE[RUN]:' $? + [ "${LSFD_INODE}" == "$(stat -c %i $target)" ] + echo 'INODE[STR]:' $? + + LSFD_UID=$(${TS_CMD_LSFD} --raw -n -o UID -Q "${EXPR}") + echo 'UID[RUN]:' $? + [ "${LSFD_UID}" == $(id -u) ] + echo 'UID[STR]:' $? + + LSFD_USER=$(${TS_CMD_LSFD} --raw -n -o USER -Q "${EXPR}") + echo 'USER[RUN]:' $? + [ "${LSFD_USER}" == $(id -u -n) ] + echo 'USER[STR]:' $? + + LSFD_SIZE=$(${TS_CMD_LSFD} --raw -n -o SIZE -Q "${EXPR}") + echo 'SIZE[RUN]:' $? + [ "${LSFD_SIZE}" == $(stat -c %s $target) ] + echo 'SIZE[STR]:' $? + + lsfd_compare_dev "${TS_CMD_LSFD}" $target "${EXPR}" + + kill -CONT ${PID} + fi + wait ${MKFDS_PID} +} > $TS_OUTPUT 2>&1 + +ts_finalize diff --git a/tests/ts/lsfd/mkfds-rw-character-device b/tests/ts/lsfd/mkfds-rw-character-device new file mode 100755 index 0000000..85dd29c --- /dev/null +++ b/tests/ts/lsfd/mkfds-rw-character-device @@ -0,0 +1,50 @@ +#!/bin/bash +# +# Copyright (C) 2021 Masatake YAMATO +# +# 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="character device with O_RDWR" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +. "$TS_SELF"/lsfd-functions.bash + +ts_check_test_command "$TS_CMD_LSFD" + +ts_check_test_command "$TS_HELPER_MKFDS" + +ts_cd "$TS_OUTDIR" + +PID= +FD=3 +EXPR= + +{ + target=/dev/zero + coproc MKFDS { "$TS_HELPER_MKFDS" rw-character-device $FD chrdev=$target; } + if read -u ${MKFDS[0]} PID; then + EXPR='(PID == '"${PID}"') and (FD == '"$FD"')' + ${TS_CMD_LSFD} -n -o ASSOC,MODE,TYPE,NAME,SOURCE,POS,MAJ:MIN,CHRDRV,DEVTYPE,RDEV -Q "${EXPR}" + echo 'ASSOC,MODE,TYPE,NAME,SOURCE,POS,MAJ:MIN,CHRDRV,DEVTYPE,RDEV': $? + + lsfd_compare_dev "${TS_CMD_LSFD}" $target "${EXPR}" + + kill -CONT ${PID} + fi + wait ${MKFDS_PID} +} > $TS_OUTPUT 2>&1 + +ts_finalize diff --git a/tests/ts/lsfd/mkfds-socketpair b/tests/ts/lsfd/mkfds-socketpair new file mode 100755 index 0000000..3ffd088 --- /dev/null +++ b/tests/ts/lsfd/mkfds-socketpair @@ -0,0 +1,48 @@ +#!/bin/bash +# +# Copyright (C) 2021 Masatake YAMATO +# +# 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="AF_UNIX socket pair created with socketpair(2)" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_LSFD" + +ts_check_test_command "$TS_HELPER_MKFDS" + +ts_check_prog "sed" + +ts_cd "$TS_OUTDIR" + +PID= +FD0=3 +FD1=4 +EXPR= + +{ + coproc MKFDS { "$TS_HELPER_MKFDS" socketpair $FD0 $FD1 socktype=DGRAM; } + if read -u ${MKFDS[0]} PID; then + EXPR='(PID == '"${PID}"') and ((FD == '"$FD0"') or (FD == '"$FD1"'))' + ${TS_CMD_LSFD} -n -o ASSOC,MODE,STTYPE,SOURCE,SOCK.PROTONAME -Q "${EXPR}" | sed -e 's/UNIX-DGRAM/UNIX/' + echo 'ASSOC,MODE,STTYPE,SOURCE,SOCK.PROTONAME': ${PIPESTATUS[0]} + + kill -CONT ${PID} + fi + wait ${MKFDS_PID} +} > $TS_OUTPUT 2>&1 + +ts_finalize diff --git a/tests/ts/lsfd/mkfds-symlink b/tests/ts/lsfd/mkfds-symlink new file mode 100755 index 0000000..4825645 --- /dev/null +++ b/tests/ts/lsfd/mkfds-symlink @@ -0,0 +1,45 @@ +#!/bin/bash +# +# Copyright (C) 2021 Masatake YAMATO +# +# 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="symbolic link itself opened with O_PATH" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_LSFD" + +ts_check_test_command "$TS_HELPER_MKFDS" + +ts_cd "$TS_OUTDIR" + +PID= +FD=3 +EXPR= + +{ + coproc MKFDS { "$TS_HELPER_MKFDS" symlink $FD path=/dev/stdin; } + if read -u ${MKFDS[0]} PID; then + EXPR='(PID == '"${PID}"') and (FD == '"$FD"')' + ${TS_CMD_LSFD} -n -o ASSOC,MODE,TYPE,NAME,FLAGS -Q "${EXPR}" + echo 'ASSOC,MODE,TYPE,NAME,FLAGS': $? + + kill -CONT ${PID} + fi + wait ${MKFDS_PID} +} > $TS_OUTPUT 2>&1 + +ts_finalize diff --git a/tests/ts/lsfd/mkfds-tcp b/tests/ts/lsfd/mkfds-tcp new file mode 100755 index 0000000..e531a7b --- /dev/null +++ b/tests/ts/lsfd/mkfds-tcp @@ -0,0 +1,50 @@ +#!/bin/bash +# +# Copyright (C) 2022 Masatake YAMATO +# +# 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="TCP sockets" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_LSFD" +ts_check_test_command "$TS_HELPER_MKFDS" +ts_check_native_byteorder + +ts_cd "$TS_OUTDIR" + +PID= +FDS=3 +FDC=4 +FDA=5 +EXPR='(TYPE == "TCP") and (FD >= 3) and (FD <= 5)' + +{ + coproc MKFDS { "$TS_HELPER_MKFDS" tcp $FDS $FDC $FDA \ + server-port=34567 \ + client-port=23456 ; } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n \ + -o ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET.LADDR,INET.RADDR,TCP.LADDR,TCP.LPORT,TCP.RADDR,TCP.RPORT \ + -p "${PID}" -Q "${EXPR}" + echo 'ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET.LADDR,INET.RADDR,TCP.LADDR,TCP.LPORT,TCP.RADDR,TCP.RPORT': $? + + kill -CONT "${PID}" + fi + wait "${MKFDS_PID}" +} > "$TS_OUTPUT" 2>&1 + +ts_finalize diff --git a/tests/ts/lsfd/mkfds-tcp6 b/tests/ts/lsfd/mkfds-tcp6 new file mode 100755 index 0000000..7368bfa --- /dev/null +++ b/tests/ts/lsfd/mkfds-tcp6 @@ -0,0 +1,51 @@ +#!/bin/bash +# +# Copyright (C) 2023 Masatake YAMATO +# +# 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="TCP6 sockets" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_LSFD" +ts_check_test_command "$TS_HELPER_MKFDS" +ts_check_native_byteorder +ts_skip_docker + +ts_cd "$TS_OUTDIR" + +PID= +FDS=3 +FDC=4 +FDA=5 +EXPR='(TYPE == "TCPv6") and (FD >= 3) and (FD <= 5)' + +{ + coproc MKFDS { "$TS_HELPER_MKFDS" tcp6 $FDS $FDC $FDA \ + server-port=34567 \ + client-port=23456 ; } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n \ + -o ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET6.LADDR,INET6.RADDR,TCP.LADDR,TCP.LPORT,TCP.RADDR,TCP.RPORT \ + -p "${PID}" -Q "${EXPR}" + echo 'ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET6.LADDR,INET6.RADDR,TCP.LADDR,TCP.LPORT,TCP.RADDR,TCP.RPORT': $? + + kill -CONT "${PID}" + fi + wait "${MKFDS_PID}" +} > "$TS_OUTPUT" 2>&1 + +ts_finalize diff --git a/tests/ts/lsfd/mkfds-udp b/tests/ts/lsfd/mkfds-udp new file mode 100755 index 0000000..e6e1f1c --- /dev/null +++ b/tests/ts/lsfd/mkfds-udp @@ -0,0 +1,138 @@ +#!/bin/bash +# +# Copyright (C) 2022 Masatake YAMATO +# +# 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="UDP and UDP-Lite sockets" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_LSFD" +ts_check_test_command "$TS_HELPER_MKFDS" +ts_check_native_byteorder + +ts_cd "$TS_OUTDIR" + +PID= +FDS=3 +FDC=4 +EXPR=( + '(TYPE == "UDP") and (FD >= 3) and (FD <= 4)' + '(TYPE == "UDP-Lite") and (FD >= 3) and (FD <= 4)' +) +EXPR_server=( + '(TYPE == "UDP") and (FD == 3)' + '(TYPE == "UDP-Lite") and (FD == 3)' +) +EXPR_client=( + '(TYPE == "UDP") and (FD == 4)' + '(TYPE == "UDP-Lite") and (FD == 4)' +) +COLNS=( + 'UDP' + 'UDPLite' +) +NAME= +LADDR= +LPORT= + +for lite in 0 1; do + coproc MKFDS { "$TS_HELPER_MKFDS" udp $FDS $FDC \ + server-port=34567 \ + client-port=23456 \ + lite=$lite; } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n \ + -o ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET.LADDR,INET.RADDR,${COLNS[$lite]}.LADDR,${COLNS[$lite]}.LPORT,${COLNS[$lite]}.RADDR,${COLNS[$lite]}.RPORT \ + -p "${PID}" -Q "${EXPR[$lite]}" + echo "ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET.LADDR,INET.RADDR,${COLNS[$lite]}.LADDR,${COLNS[$lite]}.LPORT,${COLNS[$lite]}.RADDR,${COLNS[$lite]}.RPORT": $? + + kill -CONT "${PID}" + fi + wait "${MKFDS_PID}" + + coproc MKFDS { "$TS_HELPER_MKFDS" udp $FDS $FDC \ + server-port=34567 \ + client-port=23456 \ + server-do-bind=no \ + lite=$lite; } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n \ + -o ASSOC,TYPE,STTYPE,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET.LADDR,INET.RADDR,${COLNS[$lite]}.LADDR,${COLNS[$lite]}.LPORT,${COLNS[$lite]}.RADDR,${COLNS[$lite]}.RPORT \ + -p "${PID}" -Q "${EXPR_server[$lite]}" + echo "ASSOC,TYPE,STTYPE,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET.LADDR,INET.RADDR,${COLNS[$lite]}.LADDR,${COLNS[$lite]}.LPORT,${COLNS[$lite]}.RADDR,${COLNS[$lite]}.RPORT": $? + + NAME=$(${TS_CMD_LSFD} -n \ + --raw \ + -o NAME \ + -p "${PID}" -Q "${EXPR_server[$lite]}") + if [[ "$NAME" =~ ^socket:\[[[:digit:]]+\]$ ]]; then + echo "NAME pattern match: OK" + else + echo "NAME pattern match: FAILED (NAME=$NAME)" + fi + + kill -CONT "${PID}" + fi + wait "${MKFDS_PID}" + + coproc MKFDS { "$TS_HELPER_MKFDS" udp $FDS $FDC \ + server-port=34567 \ + client-port=23456 \ + client-do-bind=no \ + lite=$lite; } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n \ + -o ASSOC,TYPE,STTYPE,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET.LADDR,INET.RADDR,${COLNS[$lite]}.RADDR,${COLNS[$lite]}.RPORT \ + -p "${PID}" -Q "${EXPR_client[$lite]}" + echo "ASSOC,TYPE,STTYPE,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET.LADDR,INET.RADDR,${COLNS[$lite]}.RADDR,${COLNS[$lite]}.RPORT": $? + + LADDR=$(${TS_CMD_LSFD} -n \ + --raw \ + -o ${COLNS[$lite]}.LADDR \ + -p "${PID}" -Q "${EXPR_client[$lite]}") + LPORT=$(${TS_CMD_LSFD} -n \ + --raw \ + -o ${COLNS[$lite]}.LPORT \ + -p "${PID}" -Q "${EXPR_client[$lite]}") + + if [[ 127.0.0.1:$LPORT == ${LADDR} ]]; then + echo "LADDR/LPORT pattern match: OK" + else + echo "LADDR/LPORT pattern match: FAILED (LADDR=$LADDR, LPORT=$LPORT)" + fi + + kill -CONT "${PID}" + fi + wait "${MKFDS_PID}" + + coproc MKFDS { "$TS_HELPER_MKFDS" udp $FDS $FDC \ + server-port=34567 \ + client-port=23456 \ + client-do-connect=no \ + lite=$lite; } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n \ + -o ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET.LADDR,INET.RADDR,UDP.LADDR,UDP.LPORT,UDP.RADDR,UDP.RPORT \ + -p "${PID}" -Q "${EXPR[$lite]}" + echo 'ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET.LADDR,INET.RADDR,UDP.LADDR,UDP.LPORT,UDP.RADDR,UDP.RPORT': $? + + kill -CONT "${PID}" + fi + wait "${MKFDS_PID}" +done > "$TS_OUTPUT" 2>&1 + +ts_finalize diff --git a/tests/ts/lsfd/mkfds-udp6 b/tests/ts/lsfd/mkfds-udp6 new file mode 100755 index 0000000..75381ba --- /dev/null +++ b/tests/ts/lsfd/mkfds-udp6 @@ -0,0 +1,139 @@ +#!/bin/bash +# +# Copyright (C) 2023 Masatake YAMATO +# +# 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="UDP6 and UDPLITEv6 sockets" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_LSFD" +ts_check_test_command "$TS_HELPER_MKFDS" +ts_check_native_byteorder +ts_skip_docker + +ts_cd "$TS_OUTDIR" + +PID= +FDS=3 +FDC=4 +EXPR=( + '(TYPE == "UDPv6") and (FD >= 3) and (FD <= 4)' + '(TYPE == "UDPLITEv6") and (FD >= 3) and (FD <= 4)' +) +EXPR_server=( + '(TYPE == "UDPv6") and (FD == 3)' + '(TYPE == "UDPLITEv6") and (FD == 3)' +) +EXPR_client=( + '(TYPE == "UDPv6") and (FD == 4)' + '(TYPE == "UDPLITEv6") and (FD == 4)' +) +COLNS=( + 'UDP' + 'UDPLite' + ) +NAME= +LADDR= +LPORT= + +for lite in 0 1; do + coproc MKFDS { "$TS_HELPER_MKFDS" udp6 $FDS $FDC \ + server-port=34567 \ + client-port=23456 \ + lite=$lite; } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n \ + -o ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET6.LADDR,INET6.RADDR,${COLNS[$lite]}.LADDR,${COLNS[$lite]}.LPORT,${COLNS[$lite]}.RADDR,${COLNS[$lite]}.RPORT \ + -p "${PID}" -Q "${EXPR[$lite]}" + echo "ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET6.LADDR,INET6.RADDR,${COLNS[$lite]}.LADDR,${COLNS[$lite]}.LPORT,${COLNS[$lite]}.RADDR,${COLNS[$lite]}.RPORT": $? + + kill -CONT "${PID}" + fi + wait "${MKFDS_PID}" + + coproc MKFDS { "$TS_HELPER_MKFDS" udp6 $FDS $FDC \ + server-port=34567 \ + client-port=23456 \ + server-do-bind=no \ + lite=$lite; } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n \ + -o ASSOC,TYPE,STTYPE,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET6.LADDR,INET6.RADDR,${COLNS[$lite]}.LADDR,${COLNS[$lite]}.LPORT,${COLNS[$lite]}.RADDR,${COLNS[$lite]}.RPORT \ + -p "${PID}" -Q "${EXPR_server[$lite]}" + echo "ASSOC,TYPE,STTYPE,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET6.LADDR,INET6.RADDR,${COLNS[$lite]}.LADDR,${COLNS[$lite]}.LPORT,${COLNS[$lite]}.RADDR,${COLNS[$lite]}.RPORT": $? + + NAME=$(${TS_CMD_LSFD} -n \ + --raw \ + -o NAME \ + -p "${PID}" -Q "${EXPR_server[$lite]}") + if [[ "$NAME" =~ ^socket:\[[[:digit:]]+\]$ ]]; then + echo "NAME pattern match: OK" + else + echo "NAME pattern match: FAILED (NAME=$NAME)" + fi + + kill -CONT "${PID}" + fi + wait "${MKFDS_PID}" + + coproc MKFDS { "$TS_HELPER_MKFDS" udp6 $FDS $FDC \ + server-port=34567 \ + client-port=23456 \ + client-do-bind=no \ + lite=$lite; } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n \ + -o ASSOC,TYPE,STTYPE,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET6.LADDR,INET6.RADDR,${COLNS[$lite]}.RADDR,${COLNS[$lite]}.RPORT \ + -p "${PID}" -Q "${EXPR_client[$lite]}" + echo "ASSOC,TYPE,STTYPE,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET6.LADDR,INET6.RADDR,${COLNS[$lite]}.RADDR,${COLNS[$lite]}.RPORT": $? + + LADDR=$(${TS_CMD_LSFD} -n \ + --raw \ + -o ${COLNS[$lite]}.LADDR \ + -p "${PID}" -Q "${EXPR_client[$lite]}") + LPORT=$(${TS_CMD_LSFD} -n \ + --raw \ + -o ${COLNS[$lite]}.LPORT \ + -p "${PID}" -Q "${EXPR_client[$lite]}") + + if [[ '[::1]':$LPORT == "${LADDR}" ]]; then + echo "LADDR/LPORT pattern match: OK" + else + echo "LADDR/LPORT pattern match: FAILED (LADDR=$LADDR, LPORT=$LPORT)" + fi + + kill -CONT "${PID}" + fi + wait "${MKFDS_PID}" + + coproc MKFDS { "$TS_HELPER_MKFDS" udp6 $FDS $FDC \ + server-port=34567 \ + client-port=23456 \ + client-do-connect=no \ + lite=$lite; } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n \ + -o ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET6.LADDR,INET6.RADDR,${COLNS[$lite]}.LADDR,${COLNS[$lite]}.LPORT,${COLNS[$lite]}.RADDR,${COLNS[$lite]}.RPORT \ + -p "${PID}" -Q "${EXPR[$lite]}" + echo "ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET6.LADDR,INET6.RADDR,${COLNS[$lite]}.LADDR,${COLNS[$lite]}.LPORT,${COLNS[$lite]}.RADDR,${COLNS[$lite]}.RPORT": $? + + kill -CONT "${PID}" + fi + wait "${MKFDS_PID}" +done > "$TS_OUTPUT" 2>&1 + +ts_finalize diff --git a/tests/ts/lsfd/mkfds-unix-dgram b/tests/ts/lsfd/mkfds-unix-dgram new file mode 100755 index 0000000..c8b40eb --- /dev/null +++ b/tests/ts/lsfd/mkfds-unix-dgram @@ -0,0 +1,68 @@ +#!/bin/bash +# +# Copyright (C) 2022 Masatake YAMATO +# +# 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="UNIX dgram sockets" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +. "$TS_SELF/lsfd-functions.bash" +ts_check_test_command "$TS_CMD_LSFD" +ts_check_test_command "$TS_HELPER_MKFDS" + +ts_cd "$TS_OUTDIR" + +PID= +FDS=3 +FDC=4 +EXPR='(TYPE == "UNIX") and ((FD == 3) or (FD == 4))' + +make_state_connected() +{ + # The first one is for rewriting NAME column. + # The second one is for rewriting STATE column. + lsfd_make_state_connected | sed -e 's/unconnected/ connected/' +} + +{ + coproc MKFDS { "$TS_HELPER_MKFDS" unix-dgram $FDS $FDC \ + path=test_mkfds-unix-dgram ; } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n \ + -o ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH \ + -p "${PID}" -Q "${EXPR}" | make_state_connected + echo 'ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH': ${PIPESTATUS[0]} + + kill -CONT "${PID}" + fi + wait "${MKFDS_PID}" + + coproc MKFDS { "$TS_HELPER_MKFDS" unix-dgram $FDS $FDC \ + path=test_mkfds-unix-dgram \ + abstract=true ; } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n \ + -o ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH \ + -p "${PID}" -Q "${EXPR}" | make_state_connected + echo 'ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH': $? + + kill -CONT "${PID}" + fi + wait "${MKFDS_PID}" +} > "$TS_OUTPUT" 2>&1 + +ts_finalize diff --git a/tests/ts/lsfd/mkfds-unix-in-netns b/tests/ts/lsfd/mkfds-unix-in-netns new file mode 100755 index 0000000..cfca087 --- /dev/null +++ b/tests/ts/lsfd/mkfds-unix-in-netns @@ -0,0 +1,109 @@ +#!/bin/bash +# +# Copyright (C) 2022 Masatake YAMATO +# +# 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="UNIX sockets made in a differenct net namespace" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" +ts_skip_nonroot + +. "$TS_SELF/lsfd-functions.bash" + +ts_check_test_command "$TS_CMD_LSFD" + +ts_check_test_command "$TS_HELPER_MKFDS" + +ts_cd "$TS_OUTDIR" + +PID= +FDSELFNS=3 +FDALTNS=4 +FDSOCK=5 + +EXPR='((TYPE == "UNIX") or (TYPE == "UNIX-STREAM")) and (FD == 5)' + +compare_net_namespaces() +{ + local type=$1 + local pid=$2 + local altns_inode + local sock_netns + + altns_inode=$(${TS_CMD_LSFD} -n -o INODE -p "${pid}" -Q '(FD == 4)') + sock_netns=$(${TS_CMD_LSFD} -n -o SOCK.NETNS -p "${pid}" -Q '(FD == 5)') + + if [[ "${altns_inode}" == "${sock_netns}" ]]; then + echo "the netns for the $type socket is extracted as expectedly" + else + echo "the netns for the $type socket is not extracted well" + echo "altns_inode=${altns_inode}" + echo "sock_netns=${sock_netns}" + fi +} + +strip_type_stream() +{ + if [ "$1" = stream ]; then + lsfd_strip_type_stream + else + cat + fi +} + +for t in stream dgram seqpacket; do + ts_init_subtest "$t" + { + coproc MKFDS { "$TS_HELPER_MKFDS" unix-in-netns $FDSELFNS $FDALTNS $FDSOCK \ + path=test_mkfds-unix-$t-ns \ + type=$t ; } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n \ + -o ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH \ + -p "${PID}" -Q "${EXPR}" | strip_type_stream $t + echo 'ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH': ${PIPESTATUS[0]} + + compare_net_namespaces "$t" "${PID}" + + kill -CONT "${PID}" + fi + wait "${MKFDS_PID}" + + coproc MKFDS { "$TS_HELPER_MKFDS" unix-in-netns $FDSELFNS $FDALTNS $FDSOCK \ + path=test_mkfds-unix-$t-ns \ + abstract=true \ + type=$t ; } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n \ + -o ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH \ + -p "${PID}" -Q "${EXPR}" | strip_type_stream $t + echo 'ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH': ${PIPESTATUS[0]} + + compare_net_namespaces "abstract $t" "${PID}" + + kill -CONT "${PID}" + fi + wait "${MKFDS_PID}" + } > "$TS_OUTPUT" 2>&1 + if [ "$?" == "$EPERM" ]; then + ts_skip_subtest "unshare(2) is not permitted on this platform" + continue + fi + ts_finalize_subtest +done + + +ts_finalize diff --git a/tests/ts/lsfd/mkfds-unix-stream b/tests/ts/lsfd/mkfds-unix-stream new file mode 100755 index 0000000..fe08e72 --- /dev/null +++ b/tests/ts/lsfd/mkfds-unix-stream @@ -0,0 +1,98 @@ +#!/bin/bash +# +# Copyright (C) 2022 Masatake YAMATO +# +# 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="UNIX stream sockets" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +. "$TS_SELF/lsfd-functions.bash" + +ts_check_test_command "$TS_CMD_LSFD" +ts_check_test_command "$TS_HELPER_MKFDS" + +ts_cd "$TS_OUTDIR" + +PID= +FDS=3 +FDC=4 +FDA=5 +EXPR='(((TYPE == "UNIX-STREAM") or (TYPE == "UNIX")) and (FD >= 3) and (FD <= 5))' + +{ + for t in stream seqpacket; do + # TYPE is not tested here; AF_UNIX+SOCK_STREAM socket type was changed from "UNIX" + # to "UNIX-STREAM" at a time in Linux kernel development history. + coproc MKFDS { "$TS_HELPER_MKFDS" unix-stream $FDS $FDC $FDA \ + path=test_mkfds-unix-${t} \ + type=$t ; } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n \ + -o ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH \ + -p "${PID}" -Q "${EXPR}" | lsfd_strip_type_stream + echo 'ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH': ${PIPESTATUS[0]} + + kill -CONT "${PID}" + fi + wait "${MKFDS_PID}" + + coproc MKFDS { "$TS_HELPER_MKFDS" unix-stream $FDS $FDC $FDA \ + path=test_mkfds-unix-${t}-abs \ + abstract=true ; } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n \ + -o ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH \ + -p "${PID}" -Q "${EXPR}" | lsfd_strip_type_stream + echo '(abs) ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH': ${PIPESTATUS[0]} + + kill -CONT "${PID}" + fi + wait "${MKFDS_PID}" + + coproc MKFDS { "$TS_HELPER_MKFDS" unix-stream $FDS $FDC $FDA \ + path=test_mkfds-unix-${t}-shutdown \ + server-shutdown=3 \ + client-shutdown=3 \ + type=$t ; } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n \ + -o ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH \ + -p "${PID}" -Q "${EXPR}" | lsfd_strip_type_stream + echo '(shutdown) ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH': ${PIPESTATUS[0]} + # Surprisingly, the socket status doesn't change at all. + + kill -CONT "${PID}" + fi + wait "${MKFDS_PID}" + + coproc MKFDS { "$TS_HELPER_MKFDS" unix-stream $FDS $FDC $FDA \ + path="test_mkfds-unix with spaces ${t}" \ + type=$t ; } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n \ + -o ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH \ + -p "${PID}" -Q "${EXPR}" | lsfd_strip_type_stream + echo 'ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH': ${PIPESTATUS[0]} + + kill -CONT "${PID}" + fi + wait "${MKFDS_PID}" + + done +} > "$TS_OUTPUT" 2>&1 + +ts_finalize diff --git a/tests/ts/lsfd/option-filter-broken-exp b/tests/ts/lsfd/option-filter-broken-exp new file mode 100755 index 0000000..bedf439 --- /dev/null +++ b/tests/ts/lsfd/option-filter-broken-exp @@ -0,0 +1,36 @@ +#!/bin/bash +# +# Copyright (C) 2022 Masatake YAMATO +# +# 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="passing broken expressions to -Q option" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_LSFD" + +ts_cd "$TS_OUTDIR" + +{ + $TS_CMD_LSFD -Q '' + $TS_CMD_LSFD -Q '(' + $TS_CMD_LSFD -Q ')' + $TS_CMD_LSFD -Q '(FD == 1)garbage' + $TS_CMD_LSFD -Q 'FD' + $TS_CMD_LSFD -Q 'NOSUCHCOLUMN' +} > $TS_OUTPUT 2>&1 + +ts_finalize diff --git a/tests/ts/lsfd/option-inet b/tests/ts/lsfd/option-inet new file mode 100755 index 0000000..011a9b3 --- /dev/null +++ b/tests/ts/lsfd/option-inet @@ -0,0 +1,98 @@ +#!/bin/bash +# +# Copyright (C) 2023 Masatake YAMATO +# +# 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="--inet option" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" +ts_skip_qemu_user +ts_skip_docker + +ts_check_test_command "$TS_CMD_LSFD" +ts_check_test_command "$TS_HELPER_MKFDS" + +ts_cd "$TS_OUTDIR" + +{ + "$TS_HELPER_MKFDS" -q tcp 3 4 5 server-port=34567 client-port=23456 & + PID0=$! + + "$TS_HELPER_MKFDS" -q tcp6 3 4 5 server-port=34567 client-port=23456 & + PID1=$! + + "$TS_HELPER_MKFDS" -q ro-regular-file 3 file=/etc/passwd & + PID2=$! + + "$TS_HELPER_MKFDS" -q udp 3 4 server-port=34567 client-port=23456 server-do-bind=1 client-do-bind=1 client-do-connect=1& + PID3=$! + + "$TS_HELPER_MKFDS" -q udp6 3 4 lite=1 server-port=34567 client-port=23456 server-do-bind=1 client-do-bind=1 client-do-connect=1& + PID4=$! + + OPT='--inet' + echo "# $OPT" + ${TS_CMD_LSFD} -n \ + $OPT \ + -o ASSOC,TYPE,NAME \ + -Q "(PID == $PID0) or (PID == $PID1) or (PID == $PID2) or (PID == $PID3) or (PID == $PID4)" + + OPT='--inet=4' + echo "# $OPT" + ${TS_CMD_LSFD} -n \ + $OPT \ + -o ASSOC,TYPE,NAME \ + -Q "(PID == $PID0) or (PID == $PID1) or (PID == $PID2) or (PID == $PID3) or (PID == $PID4)" + + OPT='--inet=6' + echo "# $OPT" + ${TS_CMD_LSFD} -n \ + $OPT \ + -o ASSOC,TYPE,NAME \ + -Q "(PID == $PID0) or (PID == $PID1) or (PID == $PID2) or (PID == $PID3) or (PID == $PID4)" + + OPT='-i' + echo "# $OPT" + ${TS_CMD_LSFD} -n \ + $OPT \ + -o ASSOC,TYPE,NAME \ + -Q "(PID == $PID0) or (PID == $PID1) or (PID == $PID2) or (PID == $PID3) or (PID == $PID4)" + + OPT='-i4' + echo "# $OPT" + ${TS_CMD_LSFD} -n \ + $OPT \ + -o ASSOC,TYPE,NAME \ + -Q "(PID == $PID0) or (PID == $PID1) or (PID == $PID2) or (PID == $PID3) or (PID == $PID4)" + + OPT='-i6' + echo "# $OPT" + ${TS_CMD_LSFD} -n \ + $OPT \ + -o ASSOC,TYPE,NAME \ + -Q "(PID == $PID0) or (PID == $PID1) or (PID == $PID2) or (PID == $PID3) or (PID == $PID4)" + + kill -CONT "${PID0}" + wait "${PID0}" + + kill -CONT "${PID1}" + wait "${PID1}" + + kill -CONT "${PID2}" + wait "${PID2}" +} > "$TS_OUTPUT" 2>&1 + +ts_finalize diff --git a/tests/ts/lsfd/option-pid b/tests/ts/lsfd/option-pid new file mode 100755 index 0000000..0ea4353 --- /dev/null +++ b/tests/ts/lsfd/option-pid @@ -0,0 +1,80 @@ +#!/bin/bash +# +# Copyright (C) 2021 Masatake YAMATO +# +# 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="--pid option" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" +ts_skip_nonroot + +ts_check_test_command "$TS_CMD_LSFD" +ts_check_test_command "$TS_HELPER_MKFDS" +ts_check_prog "ps" + +ts_cd "$TS_OUTDIR" + +[ "$(ps --no-headers -o comm 1)" = 'systemd' ] || ts_skip "pid 1 is not systemd" + +PID= +FD=3 +EXPR= +QOUT= +POUT= + +{ + coproc MKFDS { "$TS_HELPER_MKFDS" ro-regular-file $FD file=/etc/group; } + if read -u ${MKFDS[0]} PID; then + EXPR='((PID == '"${PID}"') or (PID == 1)) and (FD == '"$FD"')' + QOUT=$(${TS_CMD_LSFD} -n -o ASSOC,MODE,TYPE,FLAGS,NAME -Q "${EXPR}") + echo "QOUT:" $? + + POUT=$(${TS_CMD_LSFD} --pid="1 $PID" -n -o ASSOC,MODE,TYPE,FLAGS,NAME -Q "(FD == $FD)") + echo "POUT[--pid=1 PID]:" $? + [ "${QOUT}" = "${POUT}" ] + echo "EQ[--pid=1 PID]:" $? + + POUT=$(${TS_CMD_LSFD} --pid="$PID 1" -n -o ASSOC,MODE,TYPE,FLAGS,NAME -Q "(FD == $FD)") + echo "POUT[--pid=PID 1]:" $? + [ "${QOUT}" = "${POUT}" ] + echo "EQ[--pid=PID 1]:" $? + + POUT=$(${TS_CMD_LSFD} --pid="1,$PID" -n -o ASSOC,MODE,TYPE,FLAGS,NAME -Q "(FD == $FD)") + echo "POUT[--pid=1,PID]:" $? + [ "${QOUT}" = "${POUT}" ] + echo "EQ[--pid=1,PID]:" $? + + POUT=$(${TS_CMD_LSFD} --pid="$PID,1" -n -o ASSOC,MODE,TYPE,FLAGS,NAME -Q "(FD == $FD)") + echo "POUT[--pid=PID,1]:" $? + [ "${QOUT}" = "${POUT}" ] + echo "EQ[--pid=PID,1]:" $? + + POUT=$(${TS_CMD_LSFD} -p 1 --pid="$PID" -n -o ASSOC,MODE,TYPE,FLAGS,NAME -Q "(FD == $FD)") + echo "POUT[-p 1 --pid=PID]:" $? + [ "${QOUT}" = "${POUT}" ] + echo "EQ[-p 1 --pid=PID]:" $? + + POUT=$(${TS_CMD_LSFD} -p "$PID" --pid=1 -n -o ASSOC,MODE,TYPE,FLAGS,NAME -Q "(FD == $FD)") + echo "POUT[-p PID --pid=1]:" $? + [ "${QOUT}" = "${POUT}" ] + echo "EQ[-p PID --pid=1]:" $? + + kill -CONT ${PID} + fi + wait ${MKFDS_PID} +} > $TS_OUTPUT 2>&1 + +ts_finalize diff --git a/tests/ts/lsfd/option-summary b/tests/ts/lsfd/option-summary new file mode 100755 index 0000000..64bf54b --- /dev/null +++ b/tests/ts/lsfd/option-summary @@ -0,0 +1,62 @@ +#!/bin/bash +# +# Copyright (C) 2021 Masatake YAMATO +# +# 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="--summary option" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +. "$TS_SELF"/lsfd-functions.bash + +ts_check_test_command "$TS_CMD_LSFD" +ts_check_test_command "$TS_HELPER_MKFDS" +ts_check_prog "ps" + +ts_cd "$TS_OUTDIR" + +FD=3 +F_GROUP=/etc/group +F_PASSWD=/etc/passwd +PIDS= +PID= + +for i in {1..10}; do + "$TS_HELPER_MKFDS" -q ro-regular-file $FD file=$F_GROUP & + PID=$! + PIDS="${PIDS} ${PID} " + lsfd_wait_for_pausing "${PID}" +done + +for i in {1..3}; do + "$TS_HELPER_MKFDS" -q ro-regular-file $FD file=$F_PASSWD & + PID=$! + PIDS="${PIDS} ${PID} " + lsfd_wait_for_pausing "${PID}" +done + +${TS_CMD_LSFD} -n --summary=only \ + --pid="${PIDS}" \ + --counter=GROUP:'(NAME == "/etc/group")' \ + --counter=PASSWD:'(NAME == "/etc/passwd")' \ + --counter=PROC:'(ASSOC == "exe")' \ + > $TS_OUTPUT 2>&1 + +for PID in ${PIDS}; do + kill -CONT "${PID}" +done + +ts_finalize diff --git a/tests/ts/lsmem/dumps/s390-zvm-6g.tar.bz2 b/tests/ts/lsmem/dumps/s390-zvm-6g.tar.bz2 new file mode 100644 index 0000000..b4dab8e Binary files /dev/null and b/tests/ts/lsmem/dumps/s390-zvm-6g.tar.bz2 differ diff --git a/tests/ts/lsmem/dumps/x86_64-16g.tar.bz2 b/tests/ts/lsmem/dumps/x86_64-16g.tar.bz2 new file mode 100644 index 0000000..ebcf6e7 Binary files /dev/null and b/tests/ts/lsmem/dumps/x86_64-16g.tar.bz2 differ diff --git a/tests/ts/lsmem/lsmem b/tests/ts/lsmem/lsmem new file mode 100755 index 0000000..7dce0f2 --- /dev/null +++ b/tests/ts/lsmem/lsmem @@ -0,0 +1,60 @@ +#!/bin/bash +# +# 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 3 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. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +TS_TOPDIR="${0%/*}/../.." +. "$TS_TOPDIR"/functions.sh + +ts_init "$*" + +ts_check_test_command "$TS_CMD_LSMEM" +ts_check_prog "tar" +ts_check_prog "bzip2" + +LSCOLUMNS="RANGE,SIZE,STATE,REMOVABLE,BLOCK,NODE" + + +function do_lsmem { + local opts="$*" + + echo -e "\n---\n" >>${TS_OUTPUT} + echo "\$ lsmem $opts" >>${TS_OUTPUT} + ${TS_CMD_LSMEM} $opts --sysroot "${dumpdir}/${name}" >> $TS_OUTPUT 2>> $TS_ERRLOG + +} + +for dump in $(ls $TS_SELF/dumps/*.tar.bz2 | sort); do + name=$(basename $dump .tar.bz2) + dumpdir="$TS_OUTDIR/dumps" + + ts_init_subtest $name + mkdir -p $dumpdir + + tar -C $dumpdir -jxf $dump + + do_lsmem --split=STATE,REMOVABLE + do_lsmem --output RANGE,SIZE --split none + do_lsmem --output RANGE,SIZE,STATE --split STATE + do_lsmem --all --output $LSCOLUMNS + do_lsmem --raw --output $LSCOLUMNS --split $LSCOLUMNS + do_lsmem --json --output $LSCOLUMNS --split $LSCOLUMNS + do_lsmem -o +ZONES + do_lsmem + + ts_finalize_subtest +done + +ts_finalize diff --git a/tests/ts/lsmem/mk-input.sh b/tests/ts/lsmem/mk-input.sh new file mode 100755 index 0000000..bbdfff0 --- /dev/null +++ b/tests/ts/lsmem/mk-input.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# +# This script makes a copy of relevant files from /sys. +# The files are useful for lsmem(1) regression tests. +# +progname=$(basename $0) + +if [ -z "$1" ]; then + echo -e "\nusage: $progname \n" + exit 1 +fi + +TS_NAME="$1" +TS_DUMP="$TS_NAME" +CP="cp -r --parent" + +mkdir -p $TS_DUMP/sys/devices/system + +$CP /sys/devices/system/memory $TS_DUMP + +tar jcvf $TS_NAME.tar.bz2 $TS_DUMP +rm -rf $TS_DUMP diff --git a/tests/ts/lsns/ioctl_ns b/tests/ts/lsns/ioctl_ns new file mode 100755 index 0000000..6f306d5 --- /dev/null +++ b/tests/ts/lsns/ioctl_ns @@ -0,0 +1,118 @@ +#!/bin/bash +# +# Copyright (C) 2021 Masatake YAMATO +# +# 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="ownership and hierarchy" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +# ts_skip_nonroot +grep -q '#define HAVE_LINUX_NSFS_H' ${top_builddir}/config.h || ts_skip "no ioctl_ns support" + +[ -r /proc/self/ns/user ] || ts_skip "no USER namespace kernel support" +[ -r /proc/self/ns/pid ] || ts_skip "no PID namespace kernel support" + +ts_check_test_command "$TS_CMD_LSNS" +ts_check_test_command "$TS_CMD_UNSHARE" +ts_check_prog "stat" +ts_check_prog "mkfifo" +ts_check_prog "touch" +ts_check_prog "uniq" + +"$TS_CMD_LSNS" > /dev/null 2>&1 +if [ $? -eq 2 ]; then + ts_skip "ioctl not supported" +fi + +$TS_CMD_UNSHARE --user --pid --mount-proc --fork true &> /dev/null || ts_skip "no namespace support" + +ts_cd "$TS_OUTDIR" + +# The parent process receives namespaces ids via FIFO_DATA from bash +# run by unshare. The parent can wait till the bash process provides +# data. +FIFO_DATA=$TS_OUTDIR/FIFO_DATA-HIERARCHY + +# The bash process run by unshare waits with this fifo till the parent +# process exits. As a result, namespaecs referred by the bash +# process can be alive till the parent process exits. +FIFO_WAIT=$TS_OUTDIR/FIFO_WAIT-HIERARCHY + +function cleanup { + rm -f $FIFO_DATA + rm -f $FIFO_WAIT +} + +function init { + cleanup + mkfifo $FIFO_DATA + mkfifo $FIFO_WAIT +} + +init +( + exec 4> $FIFO_WAIT + my_userns=$(stat -c %i -L /proc/self/ns/user) + my_pidns=$(stat -c %i -L /proc/self/ns/pid) + read child_userns < $FIFO_DATA + read child_pidns < $FIFO_DATA + + expected="$child_userns $my_userns $my_userns" + actual=$("$TS_CMD_LSNS" -t user -n -o NS,PNS,ONS "$child_userns" | uniq) + test "$expected" = "$actual" + RESULT=$? + if [ $RESULT -ne 0 ]; then + echo + echo userns expected: "$expected" + echo userns actual: "$actual" + cleanup + exit $RESULT + fi + + expected="$child_pidns $my_pidns $child_userns" + actual=$("$TS_CMD_LSNS" -t pid -n -o NS,PNS,ONS "$child_pidns" | uniq) + test "$expected" = "$actual" + RESULT=$? + if [ $RESULT -ne 0 ]; then + echo + echo pidns expected: "$expected" + echo pidns actual: "$actual" + cleanup + fi + exit $RESULT +) & +mainpid=$! +( + exec 4< $FIFO_WAIT + $TS_CMD_UNSHARE --user --pid --mount-proc --fork bash -s > $FIFO_DATA <<'EOF' + stat -c %i -L /proc/self/ns/user + stat -c %i -L /proc/self/ns/pid + # Wait till FIFO_WAIT is clsoed. + read -u 4 +EOF +) & +subpid=$! + +wait $subpid +wait $mainpid + +RESULT=$? +echo $RESULT >> $TS_OUTPUT + +cleanup +ts_finalize diff --git a/tests/ts/lsns/netnsid b/tests/ts/lsns/netnsid new file mode 100755 index 0000000..80ccd9b --- /dev/null +++ b/tests/ts/lsns/netnsid @@ -0,0 +1,97 @@ +#!/bin/bash +# +# Copyright (C) 2017 Masatake YAMATO +# +# 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="NETNSID compare to ip-link" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_LSNS" +ts_check_prog "ip" +ts_check_prog "dd" +ts_check_prog "mkfifo" +ts_check_prog "sed" +ts_skip_nonroot + +grep -q '#define HAVE_LINUX_NET_NAMESPACE_H' ${top_builddir}/config.h || ts_skip "no netns support" +ts_cd "$TS_OUTDIR" + +vetha=lsns-vetha +vethb=lsns-vethb +NS=LSNS-TEST-NETNSID-NS +FIFO=$TS_OUTDIR/FIFO-NETNSID +NULL=/dev/null +LOG=/dev/null #/root/foo.log + +function cleanup { + ip link delete $vetha 2> $NULL || : + ip netns delete $NS 2> $NULL || : + rm -f $FIFO +} + +echo "==Cleanup" >> $LOG +cleanup + +echo "==Create FIFO" >> $LOG +mkfifo $FIFO + +echo "==Netns ADD" >> $LOG +if ip netns add $NS && + ip link add name $vetha type veth peer name $vethb && + ip link set $vethb netns $NS && + ! (ip -o link show dev $vetha 2>&1 >$NULL | grep 'Cannot talk to rtnetlink' > $NULL); then + echo "===Netns EXEC" >> $LOG + ip netns exec $NS dd if=$FIFO bs=1 count=2 of=$NULL 2> $NULL & + PID=$! + echo "====PID=$PID" >> $LOG +else + cleanup + ts_skip "failed to initialize" +fi +{ + echo "==Write to FIFO" >> $LOG + dd if=/dev/zero bs=1 count=1 2> $NULL + { + echo "===IP output" >> $LOG + ip -o link show dev $vetha >> $LOG + + IP_ID=$(ip -o link show dev $vetha | sed -ne 's/.* *link-netnsid *\([0-9]*\)/\1/p') + echo "====ip show: IP_ID=$IP_ID" >> $LOG + + if [ "x$IP_ID" = "x" ]; then + echo "===IP output list id" >> $LOG + ip netns list-id >> $LOG + + IP_ID=$(ip netns list-id | awk "/name: $NS/ { print \$2 }") + echo "====ip list-id: IP_ID=$IP_ID" >> $LOG + fi + + echo "===LSNS output" >> $LOG + $TS_CMD_LSNS -o+NETNSID,NSFS --type net >> $LOG + + LSNS_ID=$($TS_CMD_LSNS -n -o NETNSID --type net --task $PID | { read VAL; echo $VAL; } ) + echo "===LSNS_ID=$LSNS_ID" >> $LOG + } + dd if=/dev/zero bs=1 count=1 2> $NULL +} > $FIFO + +test "$IP_ID" = "$LSNS_ID" +echo $? >> $TS_OUTPUT + +cleanup +ts_finalize diff --git a/tests/ts/lsns/nsfs b/tests/ts/lsns/nsfs new file mode 100755 index 0000000..caa81dc --- /dev/null +++ b/tests/ts/lsns/nsfs @@ -0,0 +1,95 @@ +#!/bin/bash +# +# Copyright (C) 2017 Masatake YAMATO +# +# 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="NSFS for ip-netns-add" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_skip_nonroot + +ts_check_enotty +ts_check_test_command "$TS_CMD_LSNS" +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" +ts_check_prog "ip" +ts_check_prog "dd" +ts_check_prog "touch" +ts_check_prog "mkfifo" +ts_check_prog "sed" + +grep -q '#define HAVE_LINUX_NET_NAMESPACE_H' ${top_builddir}/config.h || ts_skip "no netns support" + +ts_cd "$TS_OUTDIR" + +NAME1=ABC +NAME2=XYZ +PATH1=/run/netns/$NAME1 +PATH2=$TS_OUTDIR/$NAME2 +FIFO=$TS_OUTDIR/FIFO-NSFS +NULL=/dev/null + +function cleanup { + rm -f $FIFO + $TS_CMD_UMOUNT $PATH2 2> /dev/null || : + rm -f $PATH2 + ip netns delete $NAME1 2> /dev/null || : +} + +cleanup +mkfifo $FIFO + +if ip netns add $NAME1 && + touch ${PATH2} && + $TS_CMD_MOUNT -o bind ${PATH1} ${PATH2}; then + ip netns exec $NAME1 dd if=$FIFO bs=1 count=2 of=$NULL 2> $NULL & + PID=$! +else + cleanup + ts_skip "failed to initialize" +fi +{ + dd if=/dev/zero bs=1 count=1 2> $NULL + LSNS_FULL=$($TS_CMD_LSNS --type net) + NSFS_NAMES_MLINES=$($TS_CMD_LSNS -n -o NSFS --type net --task $PID | { while read VAL; do echo $VAL; done; } ) + NSFS_NAMES_1LINE=$($TS_CMD_LSNS -n -o NSFS --nowrap --type net --task $PID | { while read VAL; do echo $VAL; done; } ) + dd if=/dev/zero bs=1 count=1 2> $NULL +} > $FIFO + +test "$NSFS_NAMES_MLINES" = "$PATH1 +$PATH2" && test "$NSFS_NAMES_1LINE" = "$PATH1,$PATH2" + +RESULT=$? +echo $RESULT >> $TS_OUTPUT + +if [ $RESULT -ne 0 ]; then + echo + echo "**Full-report**" + echo "$LSNS_FULL" + echo "**Paths**" + echo "PATH1: $PATH1" + echo "PATH2: $PATH2" + echo "**Multi-line:**" + echo "$NSFS_NAMES_MLINES" + echo "**One-line:**" + echo "$NSFS_NAMES_1LINE" + echo "****" +fi + +cleanup +ts_finalize diff --git a/tests/ts/md5/data b/tests/ts/md5/data new file mode 100644 index 0000000..1eed05a --- /dev/null +++ b/tests/ts/md5/data @@ -0,0 +1,7 @@ + +abc +qazxswedc +1qazxsw23edc +a a a a a a a a a a +KUWIOJDNWQKLFDHQUWEDAYCNAUIWSYDUQUICBSKLBCLUWIGDF +EASC6545642432132SDECSESCEACSJKDWIOUDOIWIDOQPWUDQWIOSNXCSASCA diff --git a/tests/ts/md5/md5 b/tests/ts/md5/md5 new file mode 100755 index 0000000..3c89b73 --- /dev/null +++ b/tests/ts/md5/md5 @@ -0,0 +1,31 @@ +#!/bin/bash + +# +# Copyright (C) 2009 Karel Zak +# +# 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_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_MD5" + +cat $TS_SELF/data | while read data +do + echo -n $data | $TS_HELPER_MD5 >> $TS_OUTPUT +done + +ts_finalize + diff --git a/tests/ts/minix/broken-root b/tests/ts/minix/broken-root new file mode 100644 index 0000000..37ee84e Binary files /dev/null and b/tests/ts/minix/broken-root differ diff --git a/tests/ts/minix/debian.bug.773892 b/tests/ts/minix/debian.bug.773892 new file mode 100644 index 0000000..db97848 Binary files /dev/null and b/tests/ts/minix/debian.bug.773892 differ diff --git a/tests/ts/minix/fsck b/tests/ts/minix/fsck new file mode 100755 index 0000000..9d4aa0d --- /dev/null +++ b/tests/ts/minix/fsck @@ -0,0 +1,59 @@ +#!/bin/bash +# +# Copyright (C) 2009 Karel Zak +# +# 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="mkfs fsck" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MKMINIX" +ts_check_test_command "$TS_CMD_FSCKMINIX" + +mkfs_and_fsck_minix() { + local ret + ts_log "#####################################" + ts_log_both "$ mkfs.minix $1 image" + $TS_CMD_MKMINIX $1 $img >> $TS_OUTPUT 2>> $TS_ERRLOG + ret=$? + echo "return mkfs: $ret" >> $TS_OUTPUT + test $ret = 0 || return $ret + + ts_log_both "$ fsck.minix -lavsf image" + $TS_CMD_FSCKMINIX -lavsf $img >> $TS_OUTPUT 2>> $TS_ERRLOG + ret=$? + echo "return fsck: $ret" >> $TS_OUTPUT + return $ret +} + +img=$(ts_image_init) + +# TODO looping over arbitrary badblock files (-l bad) gives a lot segfaults +for ver in "" "-1" "-2" "-3"; do +for n in "" "-n 14" "-n 30" "-n 60"; do + mkfs_and_fsck_minix "$ver $n" +done +done + +rm -f $img + +# escape "@" with "\@" in $img. This way sed correctly +# replaces paths containing "@" characters +sed -i "s@${img//\@/\\\@}@image@g" $TS_OUTPUT + + +ts_finalize + diff --git a/tests/ts/minix/fsck-images b/tests/ts/minix/fsck-images new file mode 100755 index 0000000..17d7704 --- /dev/null +++ b/tests/ts/minix/fsck-images @@ -0,0 +1,90 @@ +#!/bin/bash +# +# 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="fsck images" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +# inode contains UID and GID, use always UID=0 to get the same checksum +# TODO any mkfs should use UID=0 per default (custom uid optionally) like mk2fs +ts_skip_nonroot + +ts_check_test_command "$TS_CMD_FSCKMINIX" +ts_check_test_command "$TS_HELPER_MKFS_MINIX" +ts_check_test_command "$TS_CMD_HEXDUMP" + +# on big endian systems some of the subtests have different expected output +BYTE_ORDER=$($TS_HELPER_SYSINFO byte-order) +BE_EXT=$(test "$BYTE_ORDER" = "BE" && echo ".BE") + +export MKFS_MINIX_TEST_SECOND_SINCE_EPOCH='1438460212' + +check_minix_fs_type() { + ts_init_subtest $1 + TS_EXPECTED+=$BE_EXT + img=${TS_OUTPUT}.img + dd if=/dev/zero bs=1024 count=16 of=$img >/dev/null 2>&1 + $TS_HELPER_MKFS_MINIX $2 $img >> $TS_OUTPUT 2>> $TS_ERRLOG + echo "mkfs return value: $?" >> $TS_OUTPUT + $TS_CMD_FSCKMINIX $img >> $TS_OUTPUT 2>> $TS_ERRLOG + echo "fsck return value: $?" >> $TS_OUTPUT + $TS_CMD_HEXDUMP -C $img >> $TS_OUTPUT 2>> $TS_ERRLOG + rm -f $img + ts_finalize_subtest +} + +check_minix_fs_type 'v1c14' '-1 -n 14' +check_minix_fs_type 'v1c30' '-1 -n 30' +check_minix_fs_type 'v2c14' '-2 -n 14' +check_minix_fs_type 'v2c30' '-2 -n 30' +check_minix_fs_type 'v3c60' '-3 -n 60' + +bad="$TS_OUTDIR/${TS_TESTNAME}.badlist" +# TODO seems that mkfs produces non-sense if badblocks are greater than device. +echo -e "8\n9" > $bad + +# NOTE, -c with -l ignores -l. +check_minix_fs_type 'check-blocks' "-l $bad -c" +check_minix_fs_type 'badblocks' "-l $bad" + +rm -f $bad + +# no more big endian tests below +if test "$BYTE_ORDER" = "BE"; then + ts_finalize +fi + +# NOTE this seems odd: a 2nd fsck run would again modify the FS +ts_init_subtest "auto-fix" +img=${TS_OUTPUT}.img +cp "$TS_SELF/broken-root" $img +$TS_CMD_FSCKMINIX -sav $img >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "fsck reports changed and uncorrected: $?" >> $TS_OUTPUT +$TS_CMD_HEXDUMP -C $img >> $TS_OUTPUT 2>> $TS_ERRLOG +sed -i 's/Filesystem on .* is dirty/Filesystem auto-fix is dirty/' $TS_OUTPUT $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "bug.773892" +"$TS_CMD_FSCKMINIX" -f "$TS_SELF/debian.bug.773892" 2>&1 >/dev/null +echo "fsck reports uncorrected: $?" >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "broken-root" +"$TS_CMD_FSCKMINIX" "$TS_SELF/broken-root" >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "fsck reports uncorrected: $?" >> $TS_OUTPUT +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/minix/mkfs b/tests/ts/minix/mkfs new file mode 100755 index 0000000..e5ee596 --- /dev/null +++ b/tests/ts/minix/mkfs @@ -0,0 +1,57 @@ +#!/bin/bash +# +# Copyright (C) 2009 Karel Zak +# +# 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="mkfs mount" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MKMINIX" +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" +ts_skip_nonroot + +ts_scsi_debug_init dev_size_mb=10 num_parts=1 +dev=${TS_DEVICE}1 + +# hotfix, wait for partition to appear (slow on Debian 7/linux-3.2) +test -b $dev || sleep 1 + +mkfs_and_mount_minix() { + ts_init_subtest $1 + ts_log "create minix fs $2" + $TS_CMD_MKMINIX $2 $dev >> $TS_OUTPUT 2>> $TS_ERRLOG + echo "mkfs return value: $?" >> $TS_OUTPUT + udevadm settle + [ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + ts_mount "minix" $dev $TS_MOUNTPOINT + ts_is_mounted $dev || ts_die "Cannot find $dev in /proc/mounts" + ts_log "umount the image" + udevadm settle + $TS_CMD_UMOUNT $dev + ts_finalize_subtest +} + +mkfs_and_mount_minix 'v1c14' '-1 -n 14' +mkfs_and_mount_minix 'v1c30' '-1 -n 30' +mkfs_and_mount_minix 'v2c14' '-2 -n 14' +mkfs_and_mount_minix 'v2c30' '-2 -n 30' +mkfs_and_mount_minix 'v2i65535' '-2 -i 65535' +mkfs_and_mount_minix 'v3c60' '-3 -n 60' + +ts_finalize + diff --git a/tests/ts/misc/fallocate b/tests/ts/misc/fallocate new file mode 100755 index 0000000..07efd98 --- /dev/null +++ b/tests/ts/misc/fallocate @@ -0,0 +1,39 @@ +#!/bin/bash + +# 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="fallocate" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FALLOCATE" +ts_check_test_command "$TS_CMD_FINDMNT" + +IMAGE=${TS_OUTDIR}/${TS_TESTNAME}.file +rm -f $IMAGE + +if $TS_CMD_FALLOCATE -o 128 -l 256 $IMAGE >> $TS_OUTPUT 2>> $TS_ERRLOG; then + stat -c "%s" $IMAGE >> $TS_OUTPUT 2>> $TS_ERRLOG +else + # fs type of $TS_OUTDIR, could be used to skip this test early + fs_type=$(${TS_CMD_FINDMNT} -n -o FSTYPE -T ${TS_OUTDIR}) + + grep -qi "fallocate: fallocate failed:.*not supported" $TS_ERRLOG \ + && ts_skip "'${fs_type}' not supported" +fi + +rm -f $IMAGE + +ts_finalize diff --git a/tests/ts/misc/flock b/tests/ts/misc/flock new file mode 100755 index 0000000..0c6ac0b --- /dev/null +++ b/tests/ts/misc/flock @@ -0,0 +1,124 @@ +#!/bin/bash + +# 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="flock" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FLOCK" +ts_check_prog "pgrep" +ts_check_prog "timeout" + + +function do_lock { + local opts="$1" + local expected_rc="$2" + local mesg="$3" + + $TS_CMD_FLOCK $1 $TS_OUTDIR/lockfile \ + echo "$mesg" \ + >> $TS_OUTPUT 2>> $TS_ERRLOG + + local rc="$?" + + if [ "$rc" == "$expected_rc" ]; then + ts_log "Success" + else + ts_log "Failed [rc=$rc]" + fi +} + +# general lock +GEN_OUTPUT="$TS_OUTPUT" +START=$(date '+%s') +# running flock in background is not the best usage example +$TS_CMD_FLOCK --shared $TS_OUTDIR/lockfile \ + bash -c 'echo "Locking"; sleep 3; echo "Unlocking"' \ + > $GEN_OUTPUT 2>&1 & +pid=$! + +# check for running background process +if [ "$pid" -le "0" ] || ! kill -s 0 "$pid" &>/dev/null; then + ts_die "unable to run flock" +fi +# the lock should be established when flock has a child +timeout 1s bash -c "while ! pgrep -P $pid >/dev/null; do sleep 0.1 ;done" \ + || ts_die "timeout waiting for flock child" + +ts_init_subtest "non-block" +do_lock "--nonblock --conflict-exit-code 123" 123 "You will never see this!" +ts_finalize_subtest + + +ts_init_subtest "no-fork" +do_lock "--no-fork --nonblock --conflict-exit-code 123" 123 "You will never see this!" +ts_finalize_subtest + + +ts_init_subtest "shared" +do_lock "--shared" 0 "Have shared lock" +ts_finalize_subtest + + +# this is the same as non-block test (exclusive lock is the default), but here +# we explicitly specify --exclusive on command line +ts_init_subtest "exclusive" +do_lock "--nonblock --exclusive --conflict-exit-code 123" 123 "You will never see this!" +ts_finalize_subtest + + +ts_init_subtest "fd" +cd "$TS_OUTDIR" +rm 4 2> /dev/null +exec 4<>$TS_OUTDIR/lockfile || ts_log "Could not open lockfile" +$TS_CMD_FLOCK --nonblock --exclusive --conflict-exit-code 123 4 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG + +rc="$?" + +if [ "$rc" == "123" ]; then + ts_log "Success" +else + ts_log "Failed [rc=$rc]" +fi +[ -f 4 ] && ts_log "fd file should not exist" +ts_finalize_subtest + + +ts_init_subtest "timeout" +do_lock "--timeout 5 --conflict-exit-code 5" 0 "After timeout." +END=$(date '+%s') +ts_finalize_subtest + + +# expected is 3 seconds (see "sleep 3" for the general lock), but we should not +# rely on exact number due to scheduler, machine load, etc. Let's check for +# inmterval <3,5>. +# +ts_init_subtest "time-check" +TIMEDIFF=$(( $END - $START )) +if [ $TIMEDIFF -lt 3 ]; then + ts_log "general lock failed [$TIMEDIFF sec]" +elif [ $TIMEDIFF -gt 5 ]; then + ts_log "wait too long [$TIMEDIFF sec]" +else + ts_log "success" +fi +ts_finalize_subtest "diff ${TIMEDIFF} sec" + + +echo "Unlocked" >> $GEN_OUTPUT +ts_finalize diff --git a/tests/ts/misc/ionice b/tests/ts/misc/ionice new file mode 100755 index 0000000..0114979 --- /dev/null +++ b/tests/ts/misc/ionice @@ -0,0 +1,30 @@ +#!/bin/bash + +# 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="ionice" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_IONICE" + +$TS_CMD_IONICE -p $$ -n 0 -c 0 >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_IONICE -p $$ -n 3 -c 7 >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_IONICE -p $$ -n 4 -c 7 >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_IONICE -p $$ -n 1 -c 8 >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_IONICE -n 3 ls /etc/passwd >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_IONICE -p $$ >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_finalize diff --git a/tests/ts/misc/line b/tests/ts/misc/line new file mode 100755 index 0000000..97a415c --- /dev/null +++ b/tests/ts/misc/line @@ -0,0 +1,65 @@ +#!/bin/bash + +# 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="line" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_LINE" +ts_check_test_command "$TS_CMD_HEXDUMP" + +ts_init_subtest 'one-call' +printf "a\nb\n" | + $TS_CMD_LINE >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "ret: $?" >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest 'two-calls' +printf "1\n2\n" | + ($TS_CMD_LINE && $TS_CMD_LINE) >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "ret: $?" >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest 'text-without-eol' +printf "abc" | + $TS_CMD_LINE >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "ret: $?" >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest 'empty-input' +printf "" | + $TS_CMD_LINE >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "ret: $?" >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest 'wait-for-eof' +(printf "xyz" && cat > $TS_OUTPUT 2>> $TS_ERRLOG +echo "ret: $?" >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest 'empty-input-wait-for-eof' +$TS_CMD_LINE > $TS_OUTPUT 2>> $TS_ERRLOG +echo "ret: $?" >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest 'large-line' +dd if=/dev/zero bs=1k count=1k 2>/dev/null | + $TS_CMD_LINE line | $TS_CMD_HEXDUMP -C >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "ret: $?" >> $TS_OUTPUT +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/misc/mbsencode b/tests/ts/misc/mbsencode new file mode 100755 index 0000000..39f9510 --- /dev/null +++ b/tests/ts/misc/mbsencode @@ -0,0 +1,85 @@ +#!/bin/bash + +# +# Copyright (C) 2018 Vaclav Dolezal +# +# 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="mbsencode" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command $TS_HELPER_MBSENCODE + +# These test may fail on some machines (locales, other libc...) +TS_KNOWN_FAIL="yes" + +STRINGS=( +# ASCII + $'foo\tbar baz' + '\\foo.local\bar' + '\\foo.local\xbar' + +# UNICODE + 'über' + $'c\xcc\x8ca\xcc\x81rka' # 'c\u030Ca\u0301rka' + 'МоÑкваÌ' + '北京' + $'\xc2\x83' # U+0083 + +# INVALID UNICODE + $'\xff' + $'\xe8\xe1\xf9\xa7' +) + +if grep -q '^#define HAVE_WIDECHAR' ${top_builddir}/config.h ;then + HAVE_WIDECHAR=true +else + HAVE_WIDECHAR=false +fi + +ts_init_subtest "safe-ascii" +$TS_HELPER_MBSENCODE --safe "${STRINGS[@]}" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "invalid-ascii" +if [ "$HAVE_WIDECHAR" = true ]; then + $TS_HELPER_MBSENCODE --invalid "${STRINGS[@]}" >> $TS_OUTPUT 2>> $TS_ERRLOG + ts_finalize_subtest +else + ts_skip_subtest 'No widechar support' +fi + +ts_init_subtest "safe-utf8" +if [ "$HAVE_WIDECHAR" = true ]; then + LC_ALL=C.UTF-8 \ + $TS_HELPER_MBSENCODE --safe "${STRINGS[@]}" >> $TS_OUTPUT 2>> $TS_ERRLOG + ts_finalize_subtest +else + ts_skip_subtest 'No widechar support' +fi + +ts_init_subtest "invalid-utf8" +if [ "$HAVE_WIDECHAR" = true ]; then + LC_ALL=C.UTF-8 \ + $TS_HELPER_MBSENCODE --invalid "${STRINGS[@]}" >> $TS_OUTPUT 2>> $TS_ERRLOG + ts_finalize_subtest +else + ts_skip_subtest 'No widechar support' +fi + +ts_finalize + diff --git a/tests/ts/misc/mcookie b/tests/ts/misc/mcookie new file mode 100755 index 0000000..a8c54f3 --- /dev/null +++ b/tests/ts/misc/mcookie @@ -0,0 +1,28 @@ +#!/bin/bash + +# 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="mcookie" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MCOOKIE" + +$TS_CMD_MCOOKIE -f /etc/services | + # The sed will convert only 32 characters long hexadecimal string + # to expected string, but nothing else. + sed 's/^[0-9a-f]\{32\}$/the string meets expecations/' >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_finalize diff --git a/tests/ts/misc/mountpoint b/tests/ts/misc/mountpoint new file mode 100755 index 0000000..19e6cfc --- /dev/null +++ b/tests/ts/misc/mountpoint @@ -0,0 +1,36 @@ +#!/bin/bash + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="mountpoint" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNTPOINT" +ts_check_test_command "$TS_CMD_FINDMNT" + +# / is not always a mountpoint (chroots etc.), so check if it is and otherwise +# fallback to the first available mountpoint. +FIRST_MOUNTPOINT=$($TS_CMD_FINDMNT -no TARGET / || $TS_CMD_FINDMNT -fno TARGET) + +[ -z "$FIRST_MOUNTPOINT" ] && ts_skip "no mountpoint found for symlink tests" + +ln -s $FIRST_MOUNTPOINT ./symlink-to-mountpoint + +ts_init_subtest "default" +$TS_CMD_MOUNTPOINT ./symlink-to-mountpoint >> $TS_OUTPUT 2>> $TS_ERRLOG +echo $? >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "nofollow" +$TS_CMD_MOUNTPOINT --nofollow ./symlink-to-mountpoint >> $TS_OUTPUT 2>> $TS_ERRLOG +echo $? >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "mutually-exclusive" +$TS_CMD_MOUNTPOINT --devno --nofollow / >> $TS_OUTPUT 2>> $TS_ERRLOG +echo $? >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +rm -f ./symlink-to-mountpoint +ts_finalize diff --git a/tests/ts/misc/pipesz b/tests/ts/misc/pipesz new file mode 100755 index 0000000..e3c31f6 --- /dev/null +++ b/tests/ts/misc/pipesz @@ -0,0 +1,80 @@ +#!/bin/bash + +# 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="pipesz" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_PIPESZ" +ts_check_test_command "$TS_HELPER_SYSINFO" + +set -o pipefail + +DEFAULT_PIPE_SIZE=$(($($TS_HELPER_SYSINFO pagesize) * 16)) + +ts_init_subtest "set-fd-bad" +$TS_CMD_PIPESZ --check --set 4096 --fd 42 >> $TS_OUTPUT 2>> $TS_ERRLOG +[[ $? -eq 0 ]] && ts_logerr "expected failure" +ts_finalize_subtest + +ts_init_subtest "set-fd" +echo -n | $TS_CMD_PIPESZ --check --set 4096 --stdin >> $TS_OUTPUT 2>> $TS_ERRLOG +[[ $? -ne 0 ]] && ts_logerr "expected success" +ts_finalize_subtest + +ts_init_subtest "set-file-bad" +$TS_CMD_PIPESZ --check --set 4096 --file "/dev/null" >> $TS_OUTPUT 2>> $TS_ERRLOG +[[ $? -eq 0 ]] && ts_logerr "expected failure" +ts_finalize_subtest + +ts_init_subtest "set-file" +echo -n | $TS_CMD_PIPESZ --check --set 4096 --file "/dev/stdin" >> $TS_OUTPUT 2>> $TS_ERRLOG +[[ $? -ne 0 ]] && ts_logerr "expected success" +ts_finalize_subtest + +ts_init_subtest "get-fd-bad" +$TS_CMD_PIPESZ --check --get --fd 42 >> $TS_OUTPUT 2>> $TS_ERRLOG +[[ $? -eq 0 ]] && ts_logerr "expected failure" +ts_finalize_subtest + +ts_init_subtest "get-fd" +echo -n | $TS_CMD_PIPESZ --check --get --stdin 2>> $TS_ERRLOG | sed "s/$DEFAULT_PIPE_SIZE/DEFAULT_PIPE_SIZE/g" >> $TS_OUTPUT +[[ $? -ne 0 ]] && ts_logerr "expected success" +ts_finalize_subtest + +ts_init_subtest "get-file-bad" +$TS_CMD_PIPESZ --check --get --file "/dev/null" >> $TS_OUTPUT 2>> $TS_ERRLOG +[[ $? -eq 0 ]] && ts_logerr "expected failure" +ts_finalize_subtest + +ts_init_subtest "get-file" +echo -n | $TS_CMD_PIPESZ --check --get --file "/dev/stdin" 2>> $TS_ERRLOG | sed "s/$DEFAULT_PIPE_SIZE/DEFAULT_PIPE_SIZE/g" >> $TS_OUTPUT +[[ $? -ne 0 ]] && ts_logerr "expected success" +ts_finalize_subtest + +ts_init_subtest "pipe-max-size" +echo -n | $TS_CMD_PIPESZ --check --stdin >> $TS_OUTPUT 2>> $TS_ERRLOG +[[ $? -ne 0 ]] && ts_logerr "expected success" +ts_finalize_subtest + +ts_init_subtest "exec" +echo this_should_be_output_by_cat | $TS_CMD_PIPESZ --check --stdin cat >> $TS_OUTPUT 2>> $TS_ERRLOG +[[ $? -ne 0 ]] && ts_logerr "expected success" +ts_finalize_subtest + +set +o pipefail + +ts_finalize diff --git a/tests/ts/misc/rev b/tests/ts/misc/rev new file mode 100755 index 0000000..b13f79c --- /dev/null +++ b/tests/ts/misc/rev @@ -0,0 +1,34 @@ +#!/bin/bash + +# 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="rev" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_REV" +ts_check_test_command "$TS_HELPER_MD5" + +for I in {0..512}; do printf "%s " {a..z}; done | "$TS_HELPER_MD5" >> $TS_OUTPUT 2>> $TS_ERRLOG + +for I in {0..512}; do printf "%s " {a..z}; done | \ + $TS_CMD_REV | "$TS_HELPER_MD5" >> $TS_OUTPUT 2>> $TS_ERRLOG + +printf "abc\n123" | $TS_CMD_REV >> $TS_OUTPUT 2>> $TS_ERRLOG +echo >> $TS_OUTPUT +printf "abc\000123" | $TS_CMD_REV -0 | tr '\0' '|' >> $TS_OUTPUT 2>> $TS_ERRLOG +echo >> $TS_OUTPUT + +ts_finalize diff --git a/tests/ts/misc/setarch b/tests/ts/misc/setarch new file mode 100755 index 0000000..e7b6ff3 --- /dev/null +++ b/tests/ts/misc/setarch @@ -0,0 +1,109 @@ +#!/bin/bash + +# 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="setarch" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_SETARCH" +ts_skip_docker + +ARCH=$(uname -m) + +ts_init_subtest options +ts_log_both "###### unknown arch" +$TS_CMD_SETARCH qubit -v echo "success" >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit: $?" >>$TS_OUTPUT + +ts_log_both "###### unknown command" +$TS_CMD_SETARCH $ARCH -v /das/gibs/nicht >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "exit: $?" >>$TS_OUTPUT + +echo "###### noop uname -a" >>$TS_OUTPUT +uname_a=$(uname -srm) +$TS_CMD_SETARCH $ARCH -v uname -srm >> $TS_OUTPUT 2>> $TS_ERRLOG +sed -i "$ s@${uname_a}@uname -a unchanged@" $TS_OUTPUT + +echo "###### almost all options" >>$TS_OUTPUT +$TS_CMD_SETARCH $ARCH -vRFZLXBIST3 echo "success" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +ts_init_subtest uname26 +finmsg="" # for debugging 2.6 issues + +echo "###### --uname-2.6 echo" >>$TS_OUTPUT +$TS_CMD_SETARCH $ARCH -v --uname-2.6 echo "2.6 worked" >> $TS_OUTPUT 2>&1 +if [ $? -eq 0 ]; then + expected='^2.6 worked$' +else + # this may happen after execvp - gets written to stderr + expected="^FATAL: kernel too old$" + finmsg+=" echo" +fi +sed -i "$ s/$expected/2.6 works or kernel too old/" $TS_OUTPUT + +echo "###### --uname-2.6 true, non-verbose" >>$TS_OUTPUT +$TS_CMD_SETARCH $ARCH --uname-2.6 true >> $TS_OUTPUT 2>&1 +if [ $? -eq 0 ]; then + echo "2.6 works or kernel too old" >> $TS_OUTPUT +else + # this may happen after execvp - gets written to stderr + expected="^FATAL: kernel too old$" + sed -i "$ s/$expected/2.6 works or kernel too old/" $TS_OUTPUT + finmsg+=" true" +fi + +if [ -n "$finmsg" ]; then + finmsg=$(echo unsupported --uname-2.6: $finmsg) +else + uname26_seems_supported=yes +fi +ts_finalize_subtest "$finmsg" + + +# conditional subtest +if [ "$uname26_seems_supported" = "yes" ]; then +ts_init_subtest uname26-version + tmp=$($TS_CMD_SETARCH $ARCH --uname-2.6 uname -r) + if echo "$tmp" | grep -q "^2\.6\."; then + echo "kernel version changed to 2.6" >> $TS_OUTPUT + else + echo "uname26 failed" >> $TS_OUTPUT + echo "original kernel: $(uname -r)" >> $TS_OUTPUT + echo "uname26 kernel: $tmp" >> $TS_OUTPUT + fi +ts_finalize_subtest +fi # conditional subtest + +ts_init_subtest show +echo "###### --show" >>$TS_OUTPUT + +show() { + echo -n "$1: " >> $TS_OUTPUT + $TS_CMD_SETARCH --show=$1 >> $TS_OUTPUT 2> $TS_ERRLOG +} + +show 0x00000000 +show 0x00800000 +show 0x00880000 +show 0x00000008 +show 0x08000008 +show 0x000040ff + +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/misc/setsid b/tests/ts/misc/setsid new file mode 100755 index 0000000..9f04717 --- /dev/null +++ b/tests/ts/misc/setsid @@ -0,0 +1,25 @@ +#!/bin/bash + +# 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="setsid" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_SETSID" + +$TS_CMD_SETSID echo "success" >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_finalize diff --git a/tests/ts/misc/strtosize b/tests/ts/misc/strtosize new file mode 100755 index 0000000..e6233d5 --- /dev/null +++ b/tests/ts/misc/strtosize @@ -0,0 +1,62 @@ +#!/bin/bash + +# +# Copyright (C) 2010 Karel Zak +# +# 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="strtosize" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_STRUTILS" + +$TS_HELPER_STRUTILS --size -1 >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_HELPER_STRUTILS --size 0 >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_HELPER_STRUTILS --size 1 >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_HELPER_STRUTILS --size 123 >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_HELPER_STRUTILS --size 18446744073709551615 >> $TS_OUTPUT 2>> $TS_ERRLOG + +$TS_HELPER_STRUTILS --size 1K >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_HELPER_STRUTILS --size 1KiB >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_HELPER_STRUTILS --size 1M >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_HELPER_STRUTILS --size 1MiB >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_HELPER_STRUTILS --size 1G >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_HELPER_STRUTILS --size 1GiB >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_HELPER_STRUTILS --size 1T >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_HELPER_STRUTILS --size 1TiB >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_HELPER_STRUTILS --size 1P >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_HELPER_STRUTILS --size 1PiB >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_HELPER_STRUTILS --size 1E >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_HELPER_STRUTILS --size 1EiB >> $TS_OUTPUT 2>> $TS_ERRLOG + +$TS_HELPER_STRUTILS --size 1KB >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_HELPER_STRUTILS --size 1MB >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_HELPER_STRUTILS --size 1GB >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_HELPER_STRUTILS --size 1TB >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_HELPER_STRUTILS --size 1PB >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_HELPER_STRUTILS --size 1EB >> $TS_OUTPUT 2>> $TS_ERRLOG + +$TS_HELPER_STRUTILS --size "" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_HELPER_STRUTILS --size " " >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_HELPER_STRUTILS --size " 1" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_HELPER_STRUTILS --size "1 " >> $TS_OUTPUT 2>> $TS_ERRLOG + +$TS_HELPER_STRUTILS --size 0x0a >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_HELPER_STRUTILS --size 0xff00 >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_HELPER_STRUTILS --size 0x80000000 >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_finalize + diff --git a/tests/ts/misc/swaplabel b/tests/ts/misc/swaplabel new file mode 100755 index 0000000..9db7d2b --- /dev/null +++ b/tests/ts/misc/swaplabel @@ -0,0 +1,69 @@ +#!/bin/bash + +# 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="swaplabel" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MKSWAP" +ts_check_test_command "$TS_CMD_SWAPLABEL" +ts_check_test_command "$TS_HELPER_SYSINFO" + +# fallocate does not work on most file systems +function fallocate_or_skip() +{ + $TS_CMD_FALLOCATE -x -l $1 $2 2>/dev/null || \ + truncate -s $1 $2 || \ + ts_skip "no way to create test image" +} + +IMAGE=${TS_OUTDIR}/${TS_TESTNAME}.file + +PAGE_SIZE=$($TS_HELPER_SYSINFO pagesize) +PAGE_SIZE_KB=$(( $PAGE_SIZE / 1024 )) +MIN_SWAP_SIZE=$(( 10 * $PAGE_SIZE )) +MIN_SWAP_SIZE_KB=$(( MIN_SWAP_SIZE / 1024 )) + +rm -f $IMAGE +fallocate_or_skip $(( $MIN_SWAP_SIZE - 1 )) $IMAGE +$TS_CMD_MKSWAP \ + --label 1234567890abcdef \ + --uuid 12345678-abcd-abcd-abcd-1234567890ab \ + $IMAGE >> $TS_OUTPUT 2>> $TS_ERRLOG + +sed -i -e "s/ $MIN_SWAP_SIZE_KB KiB/ 10 pages/" \ + -e "s:$IMAGE::g" \ + -e "s/insecure permissions [0-9]*/insecure permissions /g" \ + $TS_OUTPUT $TS_ERRLOG + +rm -f $IMAGE +fallocate_or_skip $MIN_SWAP_SIZE $IMAGE +$TS_CMD_MKSWAP \ + --label 1234567890abcdef \ + --uuid 12345678-abcd-abcd-abcd-1234567890ab \ + $IMAGE >> $TS_OUTPUT 2>> $TS_ERRLOG + +sed -i -e "s/ $(( $MIN_SWAP_SIZE_KB - $PAGE_SIZE_KB )) KiB/ 9 pages/" \ + -e "s/($(( $MIN_SWAP_SIZE - $PAGE_SIZE )) bytes)/(9xPGSZ bytes)/" \ + -e "s:$IMAGE::g" \ + -e "s/insecure permissions [0-9]*/insecure permissions /g" \ + $TS_OUTPUT $TS_ERRLOG + +$TS_CMD_SWAPLABEL $IMAGE >> $TS_OUTPUT 2>> $TS_ERRLOG + +#rm -f $IMAGE + +ts_finalize diff --git a/tests/ts/misc/waitpid b/tests/ts/misc/waitpid new file mode 100755 index 0000000..ae5ab6f --- /dev/null +++ b/tests/ts/misc/waitpid @@ -0,0 +1,59 @@ +#!/bin/bash + +# Copyright (C) 2022 Thomas Weißschuh +# +# 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="waitpid" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_WAITPID" + +ts_init_subtest normal + +(sleep 0.2; echo 1 >> "$TS_OUTPUT") & +BG1="$!" + +(sleep 0.1; echo 2 >> "$TS_OUTPUT") & +BG2="$!" + +echo 3 >> "$TS_OUTPUT" +"$TS_CMD_WAITPID" "$BG1" "$BG2" +ts_skip_exitcode_not_supported + +echo 4 >> "$TS_OUTPUT" + +ts_finalize_subtest + +ts_init_subtest timeout +"$TS_CMD_WAITPID" -v -t 0.1 1 >> "$TS_OUTPUT" 2>> "$TS_ERRLOG" +echo $? >> "$TS_OUTPUT" +ts_finalize_subtest + +ts_init_subtest exited +"$TS_CMD_WAITPID" -e 2147483647 >> "$TS_OUTPUT" 2>> "$TS_ERRLOG" +echo $? >> "$TS_ERRLOG" +ts_finalize_subtest + +ts_init_subtest count +(sleep 0.2; echo 1 >> "$TS_OUTPUT") & +BG1="$!" + +"$TS_CMD_WAITPID" -c 1 1 "$BG1" >> "$TS_OUTPUT" 2>> "$TS_ERRLOG" +echo $? >> "$TS_ERRLOG" +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/misc/whereis b/tests/ts/misc/whereis new file mode 100755 index 0000000..a799be0 --- /dev/null +++ b/tests/ts/misc/whereis @@ -0,0 +1,50 @@ +#!/bin/bash + +# 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="whereis" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_WHEREIS" + +BIN_DIR="$(mktemp -d "${TS_OUTDIR}/binXXXXXXXXXXXXX")" +MAN_DIR="$(mktemp -d "${TS_OUTDIR}/manXXXXXXXXXXXXX")" +touch "$BIN_DIR/fsck" +touch "$MAN_DIR/fsck.8.zst" +touch "$BIN_DIR/fsck.ext4" +touch "$MAN_DIR/fsck.ext4.8.zst" +touch "$BIN_DIR/fsck.minix" +touch "$BIN_DIR/python" +touch "$MAN_DIR/python.1.gz" +touch "$BIN_DIR/python3" +touch "$MAN_DIR/python3.1" +touch "$BIN_DIR/python3.8" +touch "$BIN_DIR/python3.8-config" +touch "$MAN_DIR/python3.8.1" + +for COMMAND in fsck fsck.ext4 python python3 python3.8 +do + COUNT=$($TS_CMD_WHEREIS -B $BIN_DIR -M $MAN_DIR -f $COMMAND | wc -w) + if [ $COUNT -eq 3 ]; then + echo "$COMMAND success" >> $TS_OUTPUT + else + echo "$COMMAND failure" >> $TS_OUTPUT + fi +done + +rm -rf "$BIN_DIR" "$MAN_DIR" + +ts_finalize diff --git a/tests/ts/mkswap/BE-4096.img.xz b/tests/ts/mkswap/BE-4096.img.xz new file mode 100644 index 0000000..97bb3a2 Binary files /dev/null and b/tests/ts/mkswap/BE-4096.img.xz differ diff --git a/tests/ts/mkswap/BE-8192.img.xz b/tests/ts/mkswap/BE-8192.img.xz new file mode 100644 index 0000000..ffb671d Binary files /dev/null and b/tests/ts/mkswap/BE-8192.img.xz differ diff --git a/tests/ts/mkswap/LE-4096.img.xz b/tests/ts/mkswap/LE-4096.img.xz new file mode 100644 index 0000000..ad33ce0 Binary files /dev/null and b/tests/ts/mkswap/LE-4096.img.xz differ diff --git a/tests/ts/mkswap/LE-8192.img.xz b/tests/ts/mkswap/LE-8192.img.xz new file mode 100644 index 0000000..b3187fb Binary files /dev/null and b/tests/ts/mkswap/LE-8192.img.xz differ diff --git a/tests/ts/mkswap/mkswap b/tests/ts/mkswap/mkswap new file mode 100755 index 0000000..fa4856b --- /dev/null +++ b/tests/ts/mkswap/mkswap @@ -0,0 +1,65 @@ +#!/bin/bash + +# +# Copyright (C) 2022 Thomas Weißschuh +# +# 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" + +UUID=4c08e1cd-3c82-46bf-a55b-0c3270d6dfeb + +for PAGESIZE in 4096 8192; do + for ENDIANNESS in native little big; do + case "$ENDIANNESS" in + native) BYTE_ORDER="$("$TS_HELPER_SYSINFO" byte-order)";; + little) BYTE_ORDER=LE;; + big) BYTE_ORDER=BE;; + esac + + if [ "$ENDIANNESS" == "native" ]; then + name="NATIVE-${PAGESIZE}" + else + name="${BYTE_ORDER}-${PAGESIZE}" + fi + outimg="$TS_OUTDIR/${BYTE_ORDER}-${PAGESIZE}.img" + origimg="$TS_OUTDIR/${BYTE_ORDER}-${PAGESIZE}.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" -e "$ENDIANNESS" -p "$PAGESIZE" "$outimg" \ + > "$TS_OUTPUT" 2>/dev/null \ + || ts_log "mkswap failed" + xz -dc "$TS_SELF/${BYTE_ORDER}-${PAGESIZE}.img.xz" > "$origimg" + + cmp "$origimg" "$outimg" > "$TS_ERRLOG" 2>&1 + + ts_finalize_subtest + done +done + +ts_finalize diff --git a/tests/ts/more/regexp b/tests/ts/more/regexp new file mode 100755 index 0000000..c6feeee --- /dev/null +++ b/tests/ts/more/regexp @@ -0,0 +1,27 @@ +#!/bin/bash + +# 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="regexp" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_MORE" + +export TERM=linux +printf "abba\nbar\nfoo\nxyzzy\n" | + $TS_HELPER_MORE +/foo >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_finalize diff --git a/tests/ts/more/squeeze b/tests/ts/more/squeeze new file mode 100755 index 0000000..9099b02 --- /dev/null +++ b/tests/ts/more/squeeze @@ -0,0 +1,26 @@ +#!/bin/bash + +# 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="squeeze" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_MORE" + +printf "a\n\n\nb\n" | + $TS_HELPER_MORE -s >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_finalize diff --git a/tests/ts/mount/complex b/tests/ts/mount/complex new file mode 100755 index 0000000..9aa6222 --- /dev/null +++ b/tests/ts/mount/complex @@ -0,0 +1,106 @@ +#!/bin/bash + +# +# Copyright (C) 2022 Karel Zak +# +# 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. +# +TS_TOPDIR="${0%/*}/../.." +TS_DESC="complex" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +ts_skip_nonroot +ts_skip_qemu_user + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_losetup + +$TS_CMD_MOUNT --version | grep -q 'fd-based' || ts_skip "no fd-based API" + +ts_device_init +DEVICE=$TS_LODEV + +mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE" +ts_udevadm_settle "$DEVICE" + +ROOT_MOUNTPOINT="$TS_MOUNTPOINT" +A_MOUNTPOINT="${ROOT_MOUNTPOINT}/A" +B_MOUNTPOINT="${ROOT_MOUNTPOINT}/B" + +[ -d "$ROOT_MOUNTPOINT" ] || mkdir -p $ROOT_MOUNTPOINT +[ -d "$A_MOUNTPOINT" ] || mkdir -p $A_MOUNTPOINT +[ -d "$B_MOUNTPOINT" ] || mkdir -p $B_MOUNTPOINT + +## create a private directory +ts_init_subtest "init" +$TS_CMD_MOUNT --bind --make-private $ROOT_MOUNTPOINT $ROOT_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_FINDMNT -nr --mountpoint $ROOT_MOUNTPOINT -o PROPAGATION | grep -q private \ + || ts_log "Cannot find private $ROOT_MOUNTPOINT" +ts_finalize_subtest + + +## mount the device +ts_init_subtest "rw-mount" +$TS_CMD_MOUNT -orw $DEVICE $A_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts" +ts_finalize_subtest + + +## move device and set it read-only for VFS (FS is still rw) +ts_init_subtest "ro-move" +$TS_CMD_MOUNT --move -o ro $A_MOUNTPOINT $B_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +findmnt -nr -o VFS-OPTIONS --mountpoint $B_MOUNTPOINT | grep -q 'ro' \ + || ts_log "Cannot find ro VFS" +findmnt -nr -o FS-OPTIONS --mountpoint $B_MOUNTPOINT | grep -q 'rw' \ + || ts_log "Cannot find rw FS" +ts_finalize_subtest + + +## remount to set FS to read-only (VFS is still ro) +ts_init_subtest "ro-remount" +$TS_CMD_MOUNT -oremount,ro,noexec $B_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +findmnt -nr -o VFS-OPTIONS --mountpoint $B_MOUNTPOINT | grep -q 'ro' \ + || ts_log "Cannot find ro VFS" +findmnt -nr -o FS-OPTIONS --mountpoint $B_MOUNTPOINT | grep -q 'ro' \ + || ts_log "Cannot find ro FS" +ts_finalize_subtest + + +## remount to set FS and VFS to read-write +ts_init_subtest "rw-remount" +$TS_CMD_MOUNT -oremount,rw $B_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +findmnt -nr -o VFS-OPTIONS --mountpoint $B_MOUNTPOINT | grep -q 'rw' \ + || ts_log "Cannot find rw VFS" +findmnt -nr -o FS-OPTIONS --mountpoint $B_MOUNTPOINT | grep -q 'rw' \ + || ts_log "Cannot find rw FS" +ts_finalize_subtest + + +## bind as read-only (VFS), set shared propagation, +## and remove noexec (but keep FS rw) +ts_init_subtest "ro-shared-bind" +$TS_CMD_MOUNT --make-shared --bind -oro,exec $B_MOUNTPOINT $A_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +findmnt -nr -o VFS-OPTIONS --mountpoint $A_MOUNTPOINT | grep -q 'ro' \ + || ts_log "Cannot find ro VFS" +findmnt -nr -o FS-OPTIONS --mountpoint $A_MOUNTPOINT | grep -q 'rw' \ + || ts_log "Cannot find rw FS" +findmnt -nr -o PROPAGATION --mountpoint $A_MOUNTPOINT | grep -q 'shared' \ + || ts_log "Cannot find shared flag" +findmnt -nr -o VFS-OPTIONS --mountpoint $A_MOUNTPOINT | grep -q 'noexec' \ + && ts_log "Found noexec flag" +ts_finalize_subtest + + +## cleanup +$TS_CMD_UMOUNT $A_MOUNTPOINT &> /dev/null +$TS_CMD_UMOUNT $B_MOUNTPOINT &> /dev/null +$TS_CMD_UMOUNT $ROOT_MOUNTPOINT &> /dev/null + +ts_finalize diff --git a/tests/ts/mount/devname b/tests/ts/mount/devname new file mode 100755 index 0000000..fcfa926 --- /dev/null +++ b/tests/ts/mount/devname @@ -0,0 +1,57 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="by devname" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" + +ts_skip_nonroot +ts_check_losetup +ts_check_prog "mkfs.ext2" + +ts_device_init +DEVICE=$TS_LODEV + +MTAB_FILE="/proc/mounts" + +mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE" + +ts_device_has "TYPE" "ext2" $DEVICE || ts_die "Cannot find ext2 on $DEVICE" + +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + +$TS_CMD_MOUNT $DEVICE $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts" + +grep -q "\(^\| \)$DEVICE " $MTAB_FILE || + echo "mount failed: cannot find $DEVICE in $MTAB_FILE" >> $TS_OUTPUT 2>> $TS_ERRLOG + +$TS_CMD_UMOUNT $DEVICE || ts_die "Cannot umount $DEVICE" + +grep -q "\(^\| \)$DEVICE " $MTAB_FILE && + echo "umount failed: found $DEVICE in $MTAB_FILE" >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/dm-verity b/tests/ts/mount/dm-verity new file mode 100755 index 0000000..dc8689d --- /dev/null +++ b/tests/ts/mount/dm-verity @@ -0,0 +1,72 @@ +#!/bin/bash + +# +# Copyright (C) 2021 Vojtech Eichler +# +# 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="dm-verity support" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +VERITY_OUTPUT="$TS_OUTPUT.log" +HASH_DEVICE="$TS_OUTDIR/dm-verity.hash" +SQUASHFS="$TS_OUTDIR/dm-verity.img" +VERITY_DEVICE="test_dm_verity" +VERITY_DEVICE_ABS="/dev/mapper/$VERITY_DEVICE" +ROOT_HASH_FILE="$TS_OUTDIR/root_hash_file.hash" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" + +ts_skip_nonroot +ts_check_prog "mksquashfs" +ts_check_prog "veritysetup" + +grep -q '#define HAVE_CRYPTSETUP' ${top_builddir}/config.h || ts_skip "no dm-verity support" + +# Make a squashfs and prepare verity device out of it +mksquashfs $TS_SELF $SQUASHFS &>/dev/null || ts_skip "error: mksquashfs on $TS_SELF" +veritysetup format $SQUASHFS $HASH_DEVICE > $VERITY_OUTPUT || ts_skip "cannot format $SQUASHFS" + +# Extract root hash out of veritysetup output +HASH=$(cat $VERITY_OUTPUT | awk '/Root hash:/ { print $3 }') || ts_die "error: extract hash" +echo $HASH > $ROOT_HASH_FILE +# Activate verity data device +veritysetup create $VERITY_DEVICE $SQUASHFS $HASH_DEVICE $HASH || ts_skip "cannot activate verity device" + + +ts_init_subtest "roothash" +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +$TS_CMD_MOUNT -o verity.hashdevice=$HASH_DEVICE,verity.roothash=$HASH,verity.hashoffset=0 \ + $VERITY_DEVICE_ABS \ + $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_UMOUNT -l $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +ts_init_subtest "roothashfile" +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +$TS_CMD_MOUNT -o verity.hashdevice=$HASH_DEVICE,verity.roothashfile=$ROOT_HASH_FILE \ + $VERITY_DEVICE_ABS \ + $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_UMOUNT -l $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +# Cleanup +dmsetup remove -f $VERITY_DEVICE + +ts_finalize diff --git a/tests/ts/mount/fallback b/tests/ts/mount/fallback new file mode 100755 index 0000000..e2a1de7 --- /dev/null +++ b/tests/ts/mount/fallback @@ -0,0 +1,86 @@ +#!/bin/bash + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="fstab-fallback" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" +ts_check_test_command "$TS_CMD_FINDMNT" +ts_check_test_command "$TS_CMD_LOSETUP" +ts_check_enosys_syscalls open_tree fsopen mount_setattr + +ts_skip_nonroot + +test_mount_fallback() { + ts_init_subtest "$1" + + MY_SOURCE="${TS_MOUNTPOINT}-src" + + mkdir -p "$MY_SOURCE" + mkdir -p "$TS_MOUNTPOINT" + + "$TS_HELPER_ENOSYS" $2 -- "$TS_CMD_MOUNT" --bind "$MY_SOURCE" "$TS_MOUNTPOINT" \ + >> "$TS_OUTPUT" 2>> "$TS_ERRLOG" + [ "$?" = "0" ] || ts_log "error: mount $TS_MOUNTPOINT" + + "$TS_CMD_FINDMNT" --mountpoint "$TS_MOUNTPOINT" &> /dev/null + [ $? -eq 0 ] || ts_die "Not found target (mount failed?)" + + "$TS_CMD_UMOUNT" "$TS_MOUNTPOINT" || ts_die "Cannot umount $TS_MOUNTPOINT" + + ts_finalize_subtest +} + +test_mount_fallback "open_tree" "-s open_tree" +test_mount_fallback "fsopen" "-s fsopen" + + +ts_device_init +DEVICE=$TS_LODEV +mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE" +ts_udevadm_settle "$DEVICE" + +# use the same in all next subtests +MOUNTPOINT=$TS_MOUNTPOINT +mkdir -p "$MOUNTPOINT" + + +ts_init_subtest "later-fsopen" +$TS_HELPER_ENOSYS -s fsopen -- "$TS_CMD_MOUNT" -t foo,bar,ext2 "$DEVICE" "$MOUNTPOINT" \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts" +mkdir -p ${MOUNTPOINT}/subdir +$TS_CMD_UMOUNT $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +ts_init_subtest "subdir" +$TS_HELPER_ENOSYS -s fsopen -s open_tree -- \ + "$TS_CMD_MOUNT" -o X-mount.subdir=subdir "$DEVICE" "$MOUNTPOINT" \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts" +$TS_CMD_UMOUNT $MOUNTPOINT +ts_finalize_subtest + + +ts_init_subtest "mount_setattr" +"$TS_CMD_MOUNT" "$DEVICE" "$MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts" +$TS_HELPER_ENOSYS -s mount_setattr -- \ + "$TS_CMD_MOUNT" -o remount,ro "$MOUNTPOINT" \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_FINDMNT --kernel --mountpoint "$MOUNTPOINT" --options "ro" &> /dev/null +[ "$?" == "0" ] || ts_die "Cannot find read-only in $MOUNTPOINT in /proc/self/mountinfo" +$TS_HELPER_ENOSYS -s mount_setattr -- \ + "$TS_CMD_MOUNT" --make-slave "$MOUNTPOINT" \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_FINDMNT -n --kernel --mountpoint "$MOUNTPOINT" -o PROPAGATION >> $TS_OUTPUT +$TS_CMD_UMOUNT $MOUNTPOINT +ts_finalize_subtest + + +ts_finalize + diff --git a/tests/ts/mount/fslists b/tests/ts/mount/fslists new file mode 100755 index 0000000..230186a --- /dev/null +++ b/tests/ts/mount/fslists @@ -0,0 +1,90 @@ +#!/bin/bash + +# +# Copyright (C) 2014 Karel Zak +# +# 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="fs lists" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" + +ts_skip_nonroot +ts_check_losetup +ts_check_prog "mkfs.ext2" + +ts_device_init +DEVICE=$TS_LODEV + +mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE" + +ts_device_has "TYPE" "ext2" $DEVICE || ts_die "Cannot find ext2 on $DEVICE" + +# Don't forget that $TS_MOUNTPOINT is subtest specific, don't create it +# globally! + + +ts_init_subtest "one-type" +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +$TS_CMD_MOUNT -t ext2 $DEVICE $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts" +$TS_CMD_UMOUNT $TS_MOUNTPOINT +ts_log "Success" +ts_finalize_subtest + + +ts_init_subtest "more-types" +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +$TS_CMD_MOUNT -t foo,bar,ext2 $DEVICE $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts" +$TS_CMD_UMOUNT $TS_MOUNTPOINT +ts_log "Success" +ts_finalize_subtest + + +ts_init_subtest "more-types-fstab" +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +ts_fstab_add $DEVICE $TS_MOUNTPOINT "foo,bar,ext2" +$TS_CMD_MOUNT $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fstab_clean +ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts" +$TS_CMD_UMOUNT $TS_MOUNTPOINT +ts_log "Success" +ts_finalize_subtest + + +ts_init_subtest "type-pattern" +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +$TS_CMD_MOUNT -i -t nofoo,bar $DEVICE $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts" +$TS_CMD_UMOUNT $TS_MOUNTPOINT +ts_log "Success" +ts_finalize_subtest + + +ts_init_subtest "type-pattern-neg" +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +$TS_CMD_MOUNT -i -t nofoo,bar,ext2,ext2,ext4 $DEVICE $TS_MOUNTPOINT &> /dev/null +ts_is_mounted $DEVICE && ts_die "$DEVICE unexpectedly mounted" +ts_log "Success" +ts_finalize_subtest + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/fstab-all b/tests/ts/mount/fstab-all new file mode 100755 index 0000000..83e1b63 --- /dev/null +++ b/tests/ts/mount/fstab-all @@ -0,0 +1,156 @@ +#!/bin/bash + +# Copyright (C) 2019 Karel Zak + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="all (fstab)" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" +ts_check_test_command "$TS_CMD_FDISK" + +ts_skip_nonroot +ts_check_prog "mkfs.ext2" +ts_check_prog "mkfs.ext4" + + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=50 + +ts_log "Create partitions" +$TS_CMD_FDISK --noauto-pt ${TS_DEVICE} &> /dev/null < /dev/null +ts_log "Create filesystem B" +mkfs.ext2 ${TS_DEVICE}2 &> /dev/null +ts_log "Create filesystem C" +mkfs.ext2 ${TS_DEVICE}3 &> /dev/null +ts_log "Create filesystem D" +mkfs.ext4 ${TS_DEVICE}4 &> /dev/null + +udevadm settle + +# use the same top-level mountpoint for all sub-tests +MOUNTPOINT=$TS_MOUNTPOINT + +[ -d "${MOUNTPOINT}A" ] || mkdir -p ${MOUNTPOINT}A +[ -d "${MOUNTPOINT}B" ] || mkdir -p ${MOUNTPOINT}B +[ -d "${MOUNTPOINT}C" ] || mkdir -p ${MOUNTPOINT}C +[ -d "${MOUNTPOINT}D" ] || mkdir -p ${MOUNTPOINT}D + +# generic fstab +MY_FSTAB="$TS_OUTDIR/${TS_TESTNAME}.fstab" +rm -rf $MY_FSTAB +echo "${TS_DEVICE}1 ${MOUNTPOINT}A ext2 rw,defaults 0 0" >> $MY_FSTAB +echo "${TS_DEVICE}2 ${MOUNTPOINT}B ext2 rw,defaults 0 0" >> $MY_FSTAB +echo "${TS_DEVICE}3 ${MOUNTPOINT}C ext2 ro,defaults 0 0" >> $MY_FSTAB +echo "${TS_DEVICE}4 ${MOUNTPOINT}D ext4 rw,defaults 0 0" >> $MY_FSTAB + + +ts_init_subtest "basic" +$TS_CMD_MOUNT --all --fstab $MY_FSTAB >> $TS_OUTPUT 2>> $TS_ERRLOG +[ $? == 0 ] || ts_log "mount failed" +udevadm settle +$TS_CMD_UMOUNT ${MOUNTPOINT}{A,B,C,D} +[ $? == 0 ] || ts_log "umount failed" +ts_finalize_subtest + + +ts_init_subtest "filter-type" +$TS_CMD_MOUNT --all --fstab $MY_FSTAB -t ext4 >> $TS_OUTPUT 2>> $TS_ERRLOG +[ $? == 0 ] || ts_log "mount failed" +udevadm settle +$TS_CMD_UMOUNT ${MOUNTPOINT}D +[ $? == 0 ] || ts_log "umount failed" +ts_finalize_subtest + + +ts_init_subtest "filter-notype" +$TS_CMD_MOUNT --all --fstab $MY_FSTAB -t noext4 >> $TS_OUTPUT 2>> $TS_ERRLOG +[ $? == 0 ] || ts_log "mount failed" +udevadm settle +$TS_CMD_UMOUNT ${MOUNTPOINT}{A,B,C} +[ $? == 0 ] || ts_log "umount failed" +ts_finalize_subtest + + +ts_init_subtest "filter-option" +$TS_CMD_MOUNT --all --fstab $MY_FSTAB -O ro >> $TS_OUTPUT 2>> $TS_ERRLOG +[ $? == 0 ] || ts_log "mount failed" +udevadm settle +$TS_CMD_UMOUNT ${MOUNTPOINT}C +[ $? == 0 ] || ts_log "umount failed" +ts_finalize_subtest + + +ts_init_subtest "override-option" +$TS_CMD_MOUNT --all --fstab $MY_FSTAB -o ro >> $TS_OUTPUT 2>> $TS_ERRLOG +[ $? == 0 ] || ts_log "mount failed" +udevadm settle +$TS_CMD_UMOUNT ${MOUNTPOINT}{A,B,C,D} +[ $? == 0 ] || ts_log "umount failed" +ts_finalize_subtest + + +ts_init_subtest "relative-path" +cd "$TS_OUTDIR" > /dev/null +$TS_CMD_MOUNT --all --fstab $(basename "$MY_FSTAB") >> $TS_OUTPUT 2>> $TS_ERRLOG +[ $? == 0 ] || ts_log "mount failed" +udevadm settle +$TS_CMD_UMOUNT ${MOUNTPOINT}{A,B,C,D} +[ $? == 0 ] || ts_log "umount failed" +cd - > /dev/null +ts_finalize_subtest + + +ts_init_subtest "prefix" +MY_ROOT="$TS_OUTDIR/${TS_TESTNAME}-rootdir" +[ -d "${MY_ROOT}" ] || mkdir -p ${MY_ROOT} +# sub-test specific fstab +MY_FSTAB="$TS_OUTDIR/${TS_TESTNAME}.fstab" +rm -rf $MY_FSTAB +echo "${TS_DEVICE}1 /foo/A ext2 rw,defaults 0 0" >> $MY_FSTAB +echo "${TS_DEVICE}2 /foo/B ext2 rw,defaults 0 0" >> $MY_FSTAB +echo "${TS_DEVICE}3 /foo/C ext2 rw,defaults 0 0" >> $MY_FSTAB +echo "${TS_DEVICE}4 /foo/D ext4 rw,defaults 0 0" >> $MY_FSTAB +# mount all to prefix +$TS_CMD_MOUNT --all \ + --fstab $MY_FSTAB \ + --target-prefix $MY_ROOT \ + -o X-mount.mkdir >> $TS_OUTPUT 2>> $TS_ERRLOG +[ $? == 0 ] || ts_log "mount failed" +udevadm settle +$TS_CMD_UMOUNT $MY_ROOT/foo/{A,B,C,D} +[ $? == 0 ] || ts_log "umount failed" +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/mount/fstab-bind b/tests/ts/mount/fstab-bind new file mode 100755 index 0000000..2c799df --- /dev/null +++ b/tests/ts/mount/fstab-bind @@ -0,0 +1,35 @@ +#!/bin/bash + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="fstab-bind" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" +ts_check_test_command "$TS_CMD_FINDMNT" + +ts_skip_nonroot +ts_skip_docker + +MY_SOURCE="${TS_MOUNTPOINT}-src" + +ts_fstab_add $MY_SOURCE "$TS_MOUNTPOINT" "none" "bind,default,noauto" + +mkdir -p $MY_SOURCE +mkdir -p $TS_MOUNTPOINT + +$TS_CMD_MOUNT $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +[ "$?" = "0" ] || ts_log "error: mount $TS_MOUNTPOINT" + +$TS_CMD_FINDMNT --mountpoint "$TS_MOUNTPOINT" &> /dev/null +[ $? -eq 0 ] || ts_die "Not found target (mount failed?)" + +$TS_CMD_UMOUNT $TS_MOUNTPOINT || ts_die "Cannot umount $TS_MOUNTPOINT" + +ts_fstab_clean + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/fstab-broken b/tests/ts/mount/fstab-broken new file mode 100755 index 0000000..19edc5f --- /dev/null +++ b/tests/ts/mount/fstab-broken @@ -0,0 +1,81 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="broken fstab" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" +ts_check_test_command "$TS_CMD_FINDMNT" + +ts_skip_nonroot +ts_skip_docker + +# Let's use the same mountpoint for all subtests +MNT=$TS_MOUNTPOINT +mkdir -p $MNT + +ts_fstab_lock +ts_fstab_open +echo "tmpd $MNT tmpfs" >> /etc/fstab +ts_fstab_close + +ts_init_subtest "mount" +$TS_CMD_MOUNT $MNT &> /dev/null +[ "$?" = "0" ] || ts_log "error: mount $MNT" +$TS_CMD_FINDMNT --kernel --mountpoint "$MNT" &> /dev/null +if [ "$?" != "0" ]; then + ts_log "Cannot find $MNT in /proc/self/mountinfo" +else + ts_log "OK" +fi +$TS_CMD_UMOUNT $MNT &> /dev/null +if [ "$?" = "0" ]; then + # for old systems with mtab and /sbin/mount.tmpfs + /bin/umount --fake "$MNT" &> /dev/null +else + ts_log "error: umount $MNT" +fi +ts_finalize_subtest + + +ts_init_subtest "mount-all" +$TS_CMD_MOUNT -a &> /dev/null +[ "$?" = "0" ] || ts_log "error: mount -a" +$TS_CMD_FINDMNT --kernel --mountpoint "$MNT" &> /dev/null +if [ "$?" != "0" ]; then + ts_log "Cannot find $MNT in /proc/self/mountinfo" +else + ts_log "OK" +fi +$TS_CMD_UMOUNT $MNT &> /dev/null +if [ "$?" = "0" ]; then + # for old systems with mtab and /sbin/mount.tmpfs + /bin/umount --fake $MNT &> /dev/null +else + ts_log "error: umount $MNT" +fi +ts_finalize_subtest + +ts_fstab_clean # this unlocks too + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/fstab-btrfs b/tests/ts/mount/fstab-btrfs new file mode 100755 index 0000000..a1003ab --- /dev/null +++ b/tests/ts/mount/fstab-btrfs @@ -0,0 +1,144 @@ +#!/bin/bash + +# +# Copyright (C) 2016 Stanislav Brabec +# +# 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="btrfs (fstab)" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" + +ts_skip_nonroot +ts_check_losetup +ts_check_enotty +ts_check_prog "mkfs.btrfs" +ts_check_prog "btrfs" + +# btrfs feature check +if ! btrfs inspect-internal --help &>/dev/null || \ + btrfs inspect-internal rootid bla 2>&1 | grep -q "unknown token"; then + ts_skip "btrfs too old" +fi + +TS_MOUNTPOINT_ANY="$TS_MOUNTPOINT" +TS_MOUNTPOINT_CREATE="$TS_MOUNTPOINT-create" +TS_MOUNTPOINT_DEFAULT="$TS_MOUNTPOINT-default" +TS_MOUNTPOINT_SUBVOL="$TS_MOUNTPOINT-subvol" +TS_MOUNTPOINT_SUBVOLID="$TS_MOUNTPOINT-subvolid" +TS_MOUNTPOINT_BIND="$TS_MOUNTPOINT-bind" + +ts_device_init 50 +DEVICE=$TS_LODEV +[ -d "$TS_MOUNTPOINT_CREATE" ] || mkdir -p "$TS_MOUNTPOINT_CREATE" +[ -d "$TS_MOUNTPOINT_DEFAULT" ] || mkdir -p "$TS_MOUNTPOINT_DEFAULT" +[ -d "$TS_MOUNTPOINT_SUBVOL" ] || mkdir -p "$TS_MOUNTPOINT_SUBVOL" +[ -d "$TS_MOUNTPOINT_SUBVOLID" ] || mkdir -p "$TS_MOUNTPOINT_SUBVOLID" +[ -d "$TS_MOUNTPOINT_BIND" ] || mkdir -p "$TS_MOUNTPOINT_BIND" +mkfs.btrfs -d single -m single $DEVICE &> /dev/null || ts_die "Cannot make btrfs on $DEVICE" + +btrfs device ready $DEVICE 2>/dev/null || ts_skip "btrfs kernel support is missing" + +$TS_CMD_MOUNT -o loop "$DEVICE" "$TS_MOUNTPOINT_CREATE" &> /dev/null +pushd . >/dev/null +cd "$TS_MOUNTPOINT_CREATE" +mkdir -p d0/dd0/ddd0 +cd ./d0/dd0/ddd0 +touch file{1..5} +btrfs subvol create s1 >/dev/null +cd ./s1 +touch file{1..5} +mkdir bind-point +mkdir -p d1/dd1/ddd1 +cd ./d1/dd1/ddd1 +btrfs subvol create s2 >/dev/null +DEFAULT_SUBVOLID=$(btrfs inspect-internal rootid s2) +btrfs subvol set-default $DEFAULT_SUBVOLID . >/dev/null +NON_DEFAULT_SUBVOLID=$(btrfs subvol list "$TS_MOUNTPOINT_CREATE" | while read dummy id rest ; do if test $id = $DEFAULT_SUBVOLID ; then continue ; fi ; echo $id ; done) +cd ../../../.. +mkdir -p d2/dd2/ddd2 +cd ./d2/dd2/ddd2 +btrfs subvol create s3 >/dev/null +mkdir -p s3/bind-mnt +popd >/dev/null +NON_DEFAULT_SUBVOL=d0/dd0/ddd0/d2/dd2/ddd2/s3 +$TS_CMD_UMOUNT "$TS_MOUNTPOINT_CREATE" + + +ts_init_subtest "btrfs" +ts_fstab_lock +ts_fstab_open +# Tests with fs == btrfs +# mounting default subvolume, deep in the structure, without entry in fstab +ts_fstab_addline "$DEVICE" "$TS_MOUNTPOINT_DEFAULT" "btrfs" "" +# mounting default subvolume, deep in the structure +ts_fstab_addline "$DEVICE" "$TS_MOUNTPOINT_SUBVOL" "btrfs" "subvol=$NON_DEFAULT_SUBVOL" +# mounting non-default subvolume +ts_fstab_addline "$DEVICE" "$TS_MOUNTPOINT_SUBVOLID" "btrfs" "subvolid=$NON_DEFAULT_SUBVOLID" +# test bind mount pointing to subvolume root +ts_fstab_addline "$TS_MOUNTPOINT_SUBVOLID" "$TS_MOUNTPOINT_BIND" "auto" "bind" +ts_fstab_close + +$TS_CMD_MOUNT -a >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_MOUNT -a >> $TS_OUTPUT 2>> $TS_ERRLOG + +$TS_CMD_UMOUNT "$TS_MOUNTPOINT_BIND" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_UMOUNT "$TS_MOUNTPOINT_DEFAULT" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_UMOUNT "$TS_MOUNTPOINT_SUBVOL" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_UMOUNT "$TS_MOUNTPOINT_SUBVOLID" >> $TS_OUTPUT 2>> $TS_ERRLOG + +# check that everything was unmounted +$TS_CMD_MOUNT | grep "$TS_MOUNTPOINT_ANY" >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_fstab_clean # this unlock too +ts_log "Success" +ts_finalize_subtest + + +ts_init_subtest "auto" +ts_fstab_lock +ts_fstab_open +# Tests with fs == auto +# mounting default subvolume, deep in the structure, without entry in fstab +ts_fstab_addline "$DEVICE" "$TS_MOUNTPOINT_DEFAULT" "auto" "" +# mounting default subvolume, deep in the structure +ts_fstab_addline "$DEVICE" "$TS_MOUNTPOINT_SUBVOL" "auto" "subvol=$NON_DEFAULT_SUBVOL" +# mounting non-default subvolume +ts_fstab_addline "$DEVICE" "$TS_MOUNTPOINT_SUBVOLID" "auto" "subvolid=$NON_DEFAULT_SUBVOLID" +# test bind mount pointing to subvolume sub-directory +ts_fstab_addline "$TS_MOUNTPOINT_SUBVOL/bind-mnt" "$TS_MOUNTPOINT_BIND" "auto" "bind" +ts_fstab_close + +$TS_CMD_MOUNT -a >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_MOUNT -a >> $TS_OUTPUT 2>> $TS_ERRLOG + +$TS_CMD_UMOUNT "$TS_MOUNTPOINT_BIND" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_UMOUNT "$TS_MOUNTPOINT_DEFAULT" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_UMOUNT "$TS_MOUNTPOINT_SUBVOL" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_UMOUNT "$TS_MOUNTPOINT_SUBVOLID" >> $TS_OUTPUT 2>> $TS_ERRLOG + +# check that everything was unmounted +$TS_CMD_MOUNT | grep "$TS_MOUNTPOINT_ANY" >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_fstab_clean # this unlock too +ts_log "Success" +ts_finalize_subtest + + +ts_finalize + diff --git a/tests/ts/mount/fstab-devname b/tests/ts/mount/fstab-devname new file mode 100755 index 0000000..5b64a32 --- /dev/null +++ b/tests/ts/mount/fstab-devname @@ -0,0 +1,58 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="by devname (fstab)" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" + +ts_skip_nonroot +ts_check_losetup +ts_check_prog "mkfs.ext2" + +ts_device_init +DEVICE=$TS_LODEV + +mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE" + +ts_device_has "TYPE" "ext2" $DEVICE || ts_die "Cannot find ext2 on $DEVICE" + +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +# Use one mountpoint for all subtests +MOUNTPOINT=$TS_MOUNTPOINT + +ts_fstab_add $DEVICE + +ts_init_subtest "mountpoint" +$TS_CMD_MOUNT $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts" +$TS_CMD_UMOUNT $DEVICE || >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "device-name" +$TS_CMD_MOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts" +$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_fstab_clean + +ts_finalize diff --git a/tests/ts/mount/fstab-devname2label b/tests/ts/mount/fstab-devname2label new file mode 100755 index 0000000..1d85621 --- /dev/null +++ b/tests/ts/mount/fstab-devname2label @@ -0,0 +1,52 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="by devname (fstab label)" +LABEL="testMountD2L" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" + +ts_skip_nonroot +ts_check_losetup +ts_check_prog "mkfs.ext2" + +ts_device_init +DEVICE=$TS_LODEV + +mkfs.ext2 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE" +ts_device_has "LABEL" $LABEL $DEVICE \ + || ts_die "Cannot find LABEL '$LABEL' on $DEVICE" + +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + +ts_fstab_add "LABEL=$LABEL" +ts_udevadm_settle "$DEVICE" "LABEL" + +$TS_CMD_MOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts" +$TS_CMD_UMOUNT $DEVICE || ts_die "Cannot umount $DEVICE" + +ts_fstab_clean + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/fstab-devname2uuid b/tests/ts/mount/fstab-devname2uuid new file mode 100755 index 0000000..8105fa0 --- /dev/null +++ b/tests/ts/mount/fstab-devname2uuid @@ -0,0 +1,50 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="by devname (fstab uuid)" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" + +ts_skip_nonroot +ts_check_losetup +ts_check_prog "mkfs.ext2" + +ts_device_init +DEVICE=$TS_LODEV + +mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE" +UUID=$(ts_uuid_by_devname "$DEVICE") || ts_die "Cannot find UUID on $DEVICE" + +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + +ts_fstab_add "UUID=$UUID" +ts_udevadm_settle "$DEVICE" "UUID" + +$TS_CMD_MOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts" +$TS_CMD_UMOUNT $DEVICE || ts_die "Cannot umount $DEVICE" + +ts_fstab_clean + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/fstab-label b/tests/ts/mount/fstab-label new file mode 100755 index 0000000..4b23e7f --- /dev/null +++ b/tests/ts/mount/fstab-label @@ -0,0 +1,63 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="by label (fstab)" +LABEL="testFstabLabel" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" + +ts_skip_nonroot +ts_check_losetup +ts_check_prog "mkfs.ext2" + +ts_device_init +DEVICE=$TS_LODEV + +mkfs.ext2 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE" +ts_device_has "LABEL" $LABEL $DEVICE \ + || ts_die "Cannot find LABEL '$LABEL' on $DEVICE" +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +MOUNTPOINT=$TS_MOUNTPOINT + +ts_fstab_add "LABEL=$LABEL" +ts_udevadm_settle "$DEVICE" "LABEL" + +ts_init_subtest "no-option" +$TS_CMD_MOUNT $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts" +$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "L-option" +$TS_CMD_MOUNT -L $LABEL >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts" +$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "LABEL-option" +$TS_CMD_MOUNT LABEL=$LABEL >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts" +$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +ts_finalize diff --git a/tests/ts/mount/fstab-label2devname b/tests/ts/mount/fstab-label2devname new file mode 100755 index 0000000..75ca05e --- /dev/null +++ b/tests/ts/mount/fstab-label2devname @@ -0,0 +1,60 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="by label (fstab devname)" +LABEL="testMountL2D" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" + +ts_skip_nonroot +ts_check_losetup +ts_check_prog "mkfs.ext2" + +ts_device_init +DEVICE=$TS_LODEV + +mkfs.ext2 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE" +ts_device_has "LABEL" $LABEL $DEVICE \ + || ts_die "Cannot find LABEL '$LABEL' on $DEVICE" + +ts_fstab_add "$DEVICE" +ts_udevadm_settle "$DEVICE" "LABEL" + +# Mountpoint has to be created here rather than in each subtest since ts_fstab_add writes +# this mountpoint to the /etc/fstab file and the mountpoint is needed in subtests +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + +ts_init_subtest "L-option" +$TS_CMD_MOUNT -L $LABEL >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts" +$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "LABEL-option" +$TS_CMD_MOUNT "LABEL=$LABEL" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts" +$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_fstab_clean + +ts_finalize diff --git a/tests/ts/mount/fstab-label2uuid b/tests/ts/mount/fstab-label2uuid new file mode 100755 index 0000000..4bfcae4 --- /dev/null +++ b/tests/ts/mount/fstab-label2uuid @@ -0,0 +1,63 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="by label (fstab uuid)" +LABEL="testMountL2U" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" + +ts_skip_nonroot +ts_check_losetup +ts_check_prog "mkfs.ext2" + +ts_device_init +DEVICE=$TS_LODEV + +mkfs.ext2 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE" +ts_device_has "LABEL" $LABEL $DEVICE \ + || ts_die "Cannot find LABEL '$LABEL' on $DEVICE" +UUID=$(ts_uuid_by_devname "$DEVICE") || ts_die "Cannot find UUID on $DEVICE" + +ts_fstab_add "UUID=$UUID" +ts_udevadm_settle "$DEVICE" "LABEL" "UUID" + +# Mountpoint has to be created here rather than in each subtest since ts_fstab_add writes +# this mountpoint to the /etc/fstab file and the mountpoint is needed in subtests +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + +ts_init_subtest "L-option" +$TS_CMD_MOUNT -L $LABEL >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts" +$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "LABEL-option" +$TS_CMD_MOUNT "LABEL=$LABEL" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts" +$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_fstab_clean + +ts_finalize + diff --git a/tests/ts/mount/fstab-loop b/tests/ts/mount/fstab-loop new file mode 100755 index 0000000..7cc589f --- /dev/null +++ b/tests/ts/mount/fstab-loop @@ -0,0 +1,56 @@ +#!/bin/bash + +# +# Copyright (C) 2016 Stanislav Brabec +# +# 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="loop (fstab)" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" + +ts_skip_nonroot +ts_check_losetup +ts_check_prog "mkfs.ext2" + +IMG=$(ts_image_init) + +mkfs.ext2 -F $IMG &> /dev/null || ts_die "Cannot make ext2 on $IMG" + +[ -d "$TS_MOUNTPOINT-1" ] || mkdir -p $TS_MOUNTPOINT-1 +[ -d "$TS_MOUNTPOINT-2" ] || mkdir -p $TS_MOUNTPOINT-2 + +ts_fstab_lock +ts_fstab_open + +ts_fstab_addline "$IMG" "$TS_MOUNTPOINT-1" "ext2" "loop" +$TS_CMD_MOUNT -a >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_fstab_addline "$IMG" "$TS_MOUNTPOINT-2" "ext2" "loop" +$TS_CMD_MOUNT -a >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_fstab_close + +$TS_CMD_UMOUNT "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_UMOUNT "$TS_MOUNTPOINT-2" >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_fstab_clean + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/fstab-none b/tests/ts/mount/fstab-none new file mode 100755 index 0000000..6a4d05b --- /dev/null +++ b/tests/ts/mount/fstab-none @@ -0,0 +1,38 @@ +#!/bin/bash + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="none" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" +ts_check_test_command "$TS_CMD_FINDMNT" + +ts_skip_nonroot +ts_skip_docker + +ts_fstab_add "none" "$TS_MOUNTPOINT" "tmpfs" "rw,nosuid,nodev,relatime" + +mkdir -p $TS_MOUNTPOINT + +$TS_CMD_MOUNT $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +[ "$?" = "0" ] || ts_log "error: mount $TS_MOUNTPOINT" + +$TS_CMD_FINDMNT --mountpoint "$TS_MOUNTPOINT" &> /dev/null +[ $? -eq 0 ] || ts_die "Not found target (mount failed?)" + +$TS_CMD_FINDMNT --source "none" --mountpoint "$TS_MOUNTPOINT" &> /dev/null +[ $? -eq 0 ] || ts_die "Not found source and target" + +$TS_CMD_UMOUNT $TS_MOUNTPOINT || ts_die "Cannot umount $TS_MOUNTPOINT" + +# for old systems with mtab and /sbin/mount.tmpfs +/bin/umount --fake "$TS_MOUNTPOINT" &> /dev/null + +ts_fstab_clean + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/fstab-symlink b/tests/ts/mount/fstab-symlink new file mode 100755 index 0000000..4d3e37b --- /dev/null +++ b/tests/ts/mount/fstab-symlink @@ -0,0 +1,71 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="by devname (fstab symlink)" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" + +ts_skip_nonroot +ts_check_losetup +ts_check_prog "mkfs.ext2" + +LINKNAME="$TS_OUTDIR/${TS_TESTNAME}_lnk" + +ts_device_init +DEVICE=$TS_LODEV + +mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE" + +ts_device_has "TYPE" "ext2" $DEVICE || ts_die "Cannot find ext2 on $DEVICE" + +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + +rm -rf $LINKNAME +ln -s $DEVICE $LINKNAME + +ts_fstab_add $LINKNAME $TS_MOUNTPOINT "auto" "defaults,user" + +# variant A) -- UID=0 +$TS_CMD_MOUNT $LINKNAME >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_die "A) Cannot find $DEVICE in /proc/mounts" +$TS_CMD_UMOUNT $LINKNAME || ts_die "A) Cannot umount $LINKNAME" + +# variant B) -- disabled, the $TS_CMD_MOUNT is usually not a real program, but +# libtool wrapper and the real mount is exec()ed with +# LD_LIBRARY_PATH. This all is bad for suid programs... + +#ts_init_suid $TS_CMD_MOUNT +#ts_init_suid $TS_CMD_UMOUNT +# +#su $TS_TESTUSER -c "$TS_CMD_MOUNT -v -v -v $LINKNAME" >> $TS_OUTPUT 2>> $TS_ERRLOG +#ts_is_mounted $DEVICE +# || ts_die "B) Cannot find $DEVICE in /proc/mounts" +#su $TS_TESTUSER -c "$TS_CMD_UMOUNT $LINKNAME" >> $TS_OUTPUT 2>> $TS_ERRLOG \ +# || ts_die "B) Cannot umount $LINKNAME" + +ts_fstab_clean +rm -f $LINKNAME + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/fstab-uuid b/tests/ts/mount/fstab-uuid new file mode 100755 index 0000000..03917b7 --- /dev/null +++ b/tests/ts/mount/fstab-uuid @@ -0,0 +1,64 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="by uuid (fstab)" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" + +ts_skip_nonroot +ts_check_losetup +ts_check_prog "mkfs.ext2" + +ts_device_init +DEVICE=$TS_LODEV + +mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE" +UUID=$(ts_uuid_by_devname "$DEVICE") || ts_die "Cannot find UUID on $DEVICE" + +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +# Use one mountpoint for all tests +MOUNTPOINT=$TS_MOUNTPOINT + +ts_fstab_add "UUID=$UUID" +ts_udevadm_settle "$DEVICE" "UUID" + +ts_init_subtest "no-option" +$TS_CMD_MOUNT $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts" +$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "U-option" +$TS_CMD_MOUNT -U $UUID >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts" +$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "UUID-option" +$TS_CMD_MOUNT UUID=$UUID >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts" +$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_fstab_clean + +ts_finalize diff --git a/tests/ts/mount/fstab-uuid2devname b/tests/ts/mount/fstab-uuid2devname new file mode 100755 index 0000000..9bf165e --- /dev/null +++ b/tests/ts/mount/fstab-uuid2devname @@ -0,0 +1,59 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="by uuid (fstab devname)" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" + +ts_skip_nonroot +ts_check_losetup +ts_check_prog "mkfs.ext2" + +ts_device_init +DEVICE=$TS_LODEV + +mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE" +UUID=$(ts_uuid_by_devname "$DEVICE") || ts_die "Cannot find UUID on $DEVICE" + +ts_fstab_add "$DEVICE" +ts_udevadm_settle "$DEVICE" "UUID" + +# Mountpoint has to be created here rather than in each subtest since ts_fstab_add writes +# this mountpoint to the /etc/fstab file and the mountpoint is needed in subtests +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + +ts_init_subtest "U-option" +$TS_CMD_MOUNT -U $UUID >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts" +$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "UUID-option" +$TS_CMD_MOUNT "UUID=$UUID" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts" +$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_fstab_clean + +ts_finalize + diff --git a/tests/ts/mount/fstab-uuid2label b/tests/ts/mount/fstab-uuid2label new file mode 100755 index 0000000..de10ff0 --- /dev/null +++ b/tests/ts/mount/fstab-uuid2label @@ -0,0 +1,61 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="by uuid (fstab label)" +LABEL="testMountU2L" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" + +ts_skip_nonroot +ts_check_losetup +ts_check_prog "mkfs.ext2" + +ts_device_init +DEVICE=$TS_LODEV + +mkfs.ext2 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE" +ts_device_has "LABEL" $LABEL $DEVICE \ + || ts_die "Cannot find LABEL '$LABEL' on $DEVICE" +UUID=$(ts_uuid_by_devname "$DEVICE") || ts_die "Cannot find UUID on $DEVICE" + +ts_fstab_add "LABEL=$LABEL" +ts_udevadm_settle "$DEVICE" "LABEL" "UUID" + +# Mountpoint has to be created here rather than in each subtest since ts_fstab_add writes +# this mountpoint to the /etc/fstab file and the mountpoint is needed in subtests +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + +ts_init_subtest "U-option" +$TS_CMD_MOUNT -U $UUID >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts" +$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "UUID-option" +$TS_CMD_MOUNT "UUID=$UUID" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts" +$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>>$TS_ERRLOG +ts_finalize_subtest + +ts_fstab_clean + +ts_finalize diff --git a/tests/ts/mount/label b/tests/ts/mount/label new file mode 100755 index 0000000..402eca6 --- /dev/null +++ b/tests/ts/mount/label @@ -0,0 +1,56 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="by label" +LABEL="testMountLabel" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" + +ts_skip_nonroot +ts_check_losetup +ts_check_prog "mkfs.ext2" + +ts_device_init +DEVICE=$TS_LODEV + +mkfs.ext2 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE" +ts_device_has "LABEL" $LABEL $DEVICE \ + || ts_die "Cannot find LABEL '$LABEL' on $DEVICE" + +ts_udevadm_settle "$DEVICE" "LABEL" + +ts_init_subtest "L-option" +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +$TS_CMD_MOUNT -L $LABEL $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts" +$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "LABEL-option" +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +$TS_CMD_MOUNT LABEL=$LABEL $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts" +$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/mount/move b/tests/ts/mount/move new file mode 100755 index 0000000..26b8f3d --- /dev/null +++ b/tests/ts/mount/move @@ -0,0 +1,95 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="move" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" +ts_check_test_command "$TS_CMD_FINDMNT" +ts_check_test_command "$TS_CMD_MOUNTPOINT" + +ts_skip_nonroot +ts_skip_docker + +function mount_and_check { + # last arg must be an existing or to-be-mounted mountpoint + local mountpoint="${@: -1}" + + $TS_CMD_MOUNT "$@" &> /dev/null \ + || ts_die "error: mount $*" + + $TS_CMD_MOUNTPOINT -q "$mountpoint" \ + || ts_die "error: mountpoint $mountpoint" +} + +DIR_PRIVATE="$TS_OUTDIR/mnt-move-private" + +DIR_SRC="$DIR_PRIVATE/mnt-move-src" +DIR_A="$DIR_PRIVATE/mnt-move-A" +DIR_B="$DIR_PRIVATE/mnt-move-B" + +# this may fail if there are mounted dirs left +rm -rf "$DIR_PRIVATE" || ts_die "cleanup failed, check manually!" +mkdir "$DIR_PRIVATE" || ts_die "error: mkdir DIR_PRIVATE" + +# create bind mount and make it private to be sure +# (kernel cannot move mount with shared parent) +mount_and_check --bind $DIR_PRIVATE $DIR_PRIVATE +mount_and_check --make-rprivate $DIR_PRIVATE + +# Is the bind mount still rw? +mkdir $DIR_SRC $DIR_A $DIR_B \ + || ts_die "error: mkdir on private bind mount" + +# bind +mount_and_check --bind $DIR_SRC $DIR_A + +# move +mount_and_check --move $DIR_A $DIR_B + +# BTW a basic test for findmnt(8) and mountpoint(1) +for f in `find $DIR_PRIVATE2 $DIR_PRIVATE`; do + xo="$($TS_CMD_MOUNTPOINT -q "$f" 2>&1)" + x=$? + # mountpoint(1) returns 32 if mountpoint does not exist, map it to 1 to + # be compatible with findmnt(8) + if [ "$x" = "32" ]; then + x=1 + fi + yo="$($TS_CMD_FINDMNT --kernel --mountpoint "$f" 2>&1)" + y=$? + + [ "$x" = "$y" ] || ts_log "error: findmount vs. mountpoint: $x, $y, $f" + [ -z "$xo" ] || ts_log "error: mountpoint is not quiet: $x, $y, $f" + if [ "$y" = "0" -a "$yo" = "" ] || [ "$y" = "1" -a "$yo" != "" ]; then + ts_log "error, findmount return value vs. output: $x, $y, $f" + fi +done + +# clean up +$TS_CMD_UMOUNT $DIR_B || ts_log "error: umount DIR_B" +rmdir $DIR_SRC $DIR_A $DIR_B || ts_log "error: rmdir DIR_B" +$TS_CMD_UMOUNT $DIR_PRIVATE || ts_log "error: umount DIR_PRIVATE" +rmdir $DIR_PRIVATE || ts_log "error: rmdir DIR_PRIVATE" + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/regfile b/tests/ts/mount/regfile new file mode 100755 index 0000000..c17c687 --- /dev/null +++ b/tests/ts/mount/regfile @@ -0,0 +1,41 @@ +#!/bin/bash + +# Copyright (C) 2011 Karel Zak +# This file is part of util-linux. + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="regular file" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" + +ts_skip_nonroot +ts_check_losetup +ts_check_prog "mkfs.ext2" + +IMAGE=$(ts_image_init) +mkfs.ext2 -F $IMAGE &> /dev/null || ts_die "Cannot make ext2 on $IMAGE" + +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + +$TS_CMD_MOUNT $IMAGE $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG + +DEVICE=$(awk '/regfile/ { print $1 }' /proc/mounts) + +ts_is_mounted "$TS_MOUNTPOINT" || ts_die "Cannot find $TS_MOUNTPOINT in /proc/mounts" + +if [ -f "/sys/block/$(basename $DEVICE)/loop/backing_file" ]; then + $TS_CMD_UMOUNT $IMAGE || ts_die "Cannot umount $IMAGE" +else + $TS_CMD_UMOUNT $TS_MOUNTPOINT &> /dev/null + ts_skip "too old kernel" +fi + +ts_is_mounted "$TS_MOUNTPOINT" && ts_die "$TS_MOUNTPOINT still in /proc/mounts" + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/remount b/tests/ts/mount/remount new file mode 100755 index 0000000..003f0dc --- /dev/null +++ b/tests/ts/mount/remount @@ -0,0 +1,59 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="remount" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_FINDMNT" + +ts_skip_nonroot +ts_check_losetup +ts_check_prog "mkfs.ext2" + +# mountpoint +[ -d $TS_MOUNTPOINT ] || mkdir -p $TS_MOUNTPOINT + +ts_device_init +DEVICE=$TS_LODEV + +MTAB_FILE="/proc/mounts" + +mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE" + +# mount read-write +$TS_CMD_MOUNT $DEVICE $TS_MOUNTPOINT &> /dev/null \ + || ts_die "Cannot mount $TS_MOUNTPOINT" + +# check the mount +grep -E -q "^$DEVICE $TS_MOUNTPOINT" $MTAB_FILE \ + || ts_die "Cannot find $TS_MOUNTPOINT in $MTAB_FILE" + +# remount +$TS_CMD_MOUNT -o remount,ro $TS_MOUNTPOINT &> /dev/null \ + || ts_die "Cannot remount $TS_MOUNTPOINT" + +# check the remount +$TS_CMD_FINDMNT --kernel --mountpoint "$TS_MOUNTPOINT" --options "ro" &> /dev/null +[ "$?" == "0" ] || ts_die "Cannot find read-only in $TS_MOUNTPOINT in /proc/self/mountinfo" + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/set_ugid_mode b/tests/ts/mount/set_ugid_mode new file mode 100755 index 0000000..8041354 --- /dev/null +++ b/tests/ts/mount/set_ugid_mode @@ -0,0 +1,64 @@ +#!/bin/bash +# SPDX-License-Identifier: 0BSD + + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="X-mount.{owner,group,mode}=" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" + +ts_skip_nonroot +ts_check_losetup +ts_check_prog "mkfs.ext2" +ts_check_prog "id" +ts_check_prog "stat" + + +do_one() { + expected="$1"; shift + what="$1"; shift + where="$1"; shift + $TS_CMD_MOUNT "$@" "$what" "$where" >> $TS_OUTPUT 2>> $TS_ERRLOG + actual=$(stat --format="%A %u %g" "$where") + [ "$actual" = "$expected" ] || echo "$*: $actual != $expected" >> $TS_ERRLOG + $TS_CMD_UMOUNT "$where" >> $TS_OUTPUT 2>> $TS_ERRLOG +} + +ts_device_init + +mkfs.ext2 "$TS_LODEV" > /dev/null 2>&1 || ts_die "Cannot make ext2 on $TS_LODEV" +ts_device_has "TYPE" "ext2" "$TS_LODEV" || ts_die "Cannot find ext2 on $TS_LODEV" + +user_1="$(id -un 1)" +group_2="$(id -gn 2)" + + +mkdir -p "$TS_MOUNTPOINT" + +do_one "drwxr-xr-x 0 0" "$TS_LODEV" "$TS_MOUNTPOINT" +do_one "drwxr-xr-x 1 0" "$TS_LODEV" "$TS_MOUNTPOINT" -o "X-mount.owner=$user_1" +do_one "drwxr-xr-x 1 2" "$TS_LODEV" "$TS_MOUNTPOINT" -o "X-mount.group=$group_2" +do_one "d-w--wxr-T 132 2" "$TS_LODEV" "$TS_MOUNTPOINT" -o "X-mount.owner=132,X-mount.mode=1234" +do_one "d-ws-w---x 132 123" "$TS_LODEV" "$TS_MOUNTPOINT" -o "X-mount.mode=4321,X-mount.group=123" +do_one "d-ws-w---x 1 321" "$TS_LODEV" "$TS_MOUNTPOINT" -o "X-mount.owner=$user_1,X-mount.group=321" + + +> "$TS_MOUNTPOINT/bind" +> "$TS_MOUNTPOINT/bindsrc" + +do_one "-rw-r--r-- 0 0" "$TS_MOUNTPOINT/bindsrc" "$TS_MOUNTPOINT/bind" --bind +do_one "-rw-r--r-- 1 0" "$TS_MOUNTPOINT/bindsrc" "$TS_MOUNTPOINT/bind" --bind -o "X-mount.owner=$user_1" +do_one "-rw-r--r-- 1 2" "$TS_MOUNTPOINT/bindsrc" "$TS_MOUNTPOINT/bind" --bind -o "X-mount.group=$group_2" +do_one "--w--wxr-T 132 2" "$TS_MOUNTPOINT/bindsrc" "$TS_MOUNTPOINT/bind" --bind -o "X-mount.owner=132,X-mount.mode=1234" +do_one "--ws-w---x 132 123" "$TS_MOUNTPOINT/bindsrc" "$TS_MOUNTPOINT/bind" --bind -o "X-mount.mode=4321,X-mount.group=123" +do_one "--wx-w---x 1 321" "$TS_MOUNTPOINT/bindsrc" "$TS_MOUNTPOINT/bind" --bind -o "X-mount.owner=$user_1,X-mount.group=321" + + +rm -fd "$TS_MOUNTPOINT/bind" "$TS_MOUNTPOINT/bindsrc" "$TS_MOUNTPOINT" + +ts_log "Success" +ts_finalize diff --git a/tests/ts/mount/shared-subtree b/tests/ts/mount/shared-subtree new file mode 100755 index 0000000..aaaaf64 --- /dev/null +++ b/tests/ts/mount/shared-subtree @@ -0,0 +1,87 @@ +#!/bin/bash + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="shared-subtree" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" +ts_check_test_command "$TS_CMD_FINDMNT" + +ts_skip_nonroot +ts_check_losetup +ts_check_prog "mkfs.ext2" + +[ -d $TS_MOUNTPOINT ] || mkdir -p $TS_MOUNTPOINT + +# bind +$TS_CMD_MOUNT --bind $TS_MOUNTPOINT $TS_MOUNTPOINT &> /dev/null +[ "$?" = "0" ] || ts_die "error: mount --bind" + +# check the bind +$TS_CMD_FINDMNT --kernel --mountpoint $TS_MOUNTPOINT &> /dev/null +[ "$?" == "0" ] || ts_die "Cannot find binded $TS_MOUNTPOINT in /proc/self/mountinfo" + +# use the same mounpoint for all sub-tests +MOUNTPOINT="$TS_MOUNTPOINT" + + +ts_init_subtest "make-shared" +$TS_CMD_MOUNT --make-shared $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_FINDMNT -nr --mountpoint $MOUNTPOINT -o PROPAGATION >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "make-private" +$TS_CMD_MOUNT --make-private $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_FINDMNT -nr --mountpoint $MOUNTPOINT -o PROPAGATION >> $TS_OUTPUT +ts_finalize_subtest + + +ts_init_subtest "make-unbindable" +$TS_CMD_MOUNT --make-unbindable $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_FINDMNT -nr --mountpoint $MOUNTPOINT -o PROPAGATION >> $TS_OUTPUT +ts_finalize_subtest + +# clean up +$TS_CMD_UMOUNT $MOUNTPOINT + + +ts_init_subtest "bind-shared" +$TS_CMD_MOUNT --make-shared \ + --bind $MOUNTPOINT $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_FINDMNT -nr --mountpoint $MOUNTPOINT -o PROPAGATION >> $TS_OUTPUT +$TS_CMD_UMOUNT $MOUNTPOINT +ts_finalize_subtest + + +# +# block dev based mounts +# +ts_device_init +DEVICE=$TS_LODEV + +mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE" +ts_device_has "TYPE" "ext2" $DEVICE || ts_die "Cannot find ext2 on $DEVICE" + + +ts_init_subtest "mount-private" +$TS_CMD_MOUNT --make-private --make-unbindable \ + $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_FINDMNT -nr --mountpoint $MOUNTPOINT -o PROPAGATION >> $TS_OUTPUT +$TS_CMD_UMOUNT $MOUNTPOINT +ts_finalize_subtest + +ts_init_subtest "mount-private-ro" +$TS_CMD_MOUNT $DEVICE $MOUNTPOINT -o ro,private >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_FINDMNT -nr --mountpoint $MOUNTPOINT -o PROPAGATION >> $TS_OUTPUT +$TS_CMD_FINDMNT -nr --mountpoint $MOUNTPOINT -o VFS-OPTIONS >> $TS_OUTPUT +$TS_CMD_UMOUNT $MOUNTPOINT +ts_finalize_subtest + +rmdir $MOUNTPOINT + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/special b/tests/ts/mount/special new file mode 100755 index 0000000..359d8aa --- /dev/null +++ b/tests/ts/mount/special @@ -0,0 +1,61 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="call mount." +MOUNTER="/sbin/mount.mytest" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" + +ts_skip_nonroot + +cat > $MOUNTER <<\EOF +#!/bin/bash +# This util-linux regression test component +# It's safe to remove me... +# +echo "$0 called with \"$*\"" +EOF +chmod +x $MOUNTER + +ts_init_subtest "basic" +$TS_CMD_MOUNT -t mytest /foo /bar &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "options" +$TS_CMD_MOUNT -t mytest -o foo,defaults /foo /bar &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "multi-types" +$TS_CMD_MOUNT -t mytest,invalid /foo /bar &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "user" +$TS_CMD_MOUNT -t mytest -ouser,abc /foo /bar &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "username" +$TS_CMD_MOUNT -t mytest -ouser=name,abc /foo /bar &> $TS_OUTPUT +ts_finalize_subtest + +rm -f $MOUNTER + +ts_finalize + diff --git a/tests/ts/mount/subdir b/tests/ts/mount/subdir new file mode 100755 index 0000000..a16a7d0 --- /dev/null +++ b/tests/ts/mount/subdir @@ -0,0 +1,66 @@ +#!/bin/bash + +# +# Copyright (C) 2022 Karel Zak +# +# 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="X-mount.subdir" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_FINDMNT" +ts_skip_nonroot +ts_check_losetup + +# unshared session is possible to support only on kernels with new mount API +if [ "$("$TS_HELPER_SYSINFO" fsopen-ok)" = "0" ]; then + prop=$($TS_CMD_FINDMNT --task "$$" -n -o PROPAGATION "/") + [[ "$prop" == *"private"* ]] && ts_skip "unsupported session" +fi + +ts_device_init +DEVICE=$TS_LODEV + +mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE" +ts_udevadm_settle "$DEVICE" + +# use the same mountpoiunt for all subtests +MOUNTPOINT="$TS_MOUNTPOINT" +[ -d "$MOUNTPOINT" ] || mkdir -p $MOUNTPOINT + + +# create subdirectory on the filesystem +ts_init_subtest "init" +$TS_CMD_MOUNT $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts" +mkdir -p $MOUNTPOINT/submnt +touch $MOUNTPOINT/submnt/file +$TS_CMD_UMOUNT $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +ts_init_subtest "subdir" +$TS_CMD_MOUNT -o X-mount.subdir=submnt $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts" +if [ ! -f "$MOUNTPOINT/file" ]; then + echo "$MOUNTPOINT/file not found" >> $TS_OUTPUT +fi +$TS_CMD_UMOUNT $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +ts_finalize diff --git a/tests/ts/mount/umount-alltargets b/tests/ts/mount/umount-alltargets new file mode 100755 index 0000000..3277d6e --- /dev/null +++ b/tests/ts/mount/umount-alltargets @@ -0,0 +1,120 @@ +#!/bin/bash + +# Copyright (C) 2013 Karel Zak + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="umount-all-targets" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" +ts_check_test_command "$TS_CMD_FDISK" + +ts_skip_nonroot +ts_check_prog "mkfs.ext2" + +$TS_CMD_UMOUNT --help | grep -q all-targets +[ $? -eq 1 ] && ts_skip "all-targets unsupported" + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=50 + +ts_log "Create partitions" +$TS_CMD_FDISK --noauto-pt ${TS_DEVICE} &> /dev/null < /dev/null +ts_log "Create filesystem B" +mkfs.ext2 ${TS_DEVICE}2 &> /dev/null +ts_log "Create filesystem C" +mkfs.ext2 ${TS_DEVICE}3 &> /dev/null +ts_log "Create filesystem D" +mkfs.ext2 ${TS_DEVICE}4 &> /dev/null + +udevadm settle + +function multi_mount() { + local DEV=$1 + local MNT=$2 + + ts_log "prepare: Mount dev to mnt1" + [ -d "${MNT}1" ] || mkdir -p ${MNT}1 + $TS_CMD_MOUNT $DEV ${MNT}1 >> $TS_OUTPUT 2>> $TS_ERRLOG + + ts_log "prepare: Mount dev to mnt2" + [ -d "${MNT}2" ] || mkdir -p ${MNT}2 + $TS_CMD_MOUNT $DEV ${MNT}2 >> $TS_OUTPUT 2>> $TS_ERRLOG + + ts_log "prepare: Mount /dev/xxx1 to mnt3" + [ -d "${MNT}3" ] || mkdir -p ${MNT}3 + $TS_CMD_MOUNT $DEV ${MNT}3 >> $TS_OUTPUT 2>> $TS_ERRLOG + + udevadm settle +} + +# use the same top-level mountpoint for all sub-tests +MOUNTPOINT=$TS_MOUNTPOINT + +# +# The same device mounted on more places, umount all by mountpoint name +# +ts_init_subtest "all-targets-mnt" +multi_mount ${TS_DEVICE}1 $MOUNTPOINT +$TS_CMD_UMOUNT --all-targets ${MOUNTPOINT}1 >> $TS_OUTPUT 2>> $TS_ERRLOG +[ $? == 0 ] || ts_log "umount failed" +ts_finalize_subtest + +# +# The same device mounted on more places, umount all by device name +# +ts_init_subtest "all-targets-dev" +multi_mount ${TS_DEVICE}1 $MOUNTPOINT +$TS_CMD_UMOUNT --all-targets ${TS_DEVICE}1 >> $TS_OUTPUT 2>> $TS_ERRLOG +[ $? == 0 ] || ts_log "umount failed" +ts_finalize_subtest + +# +# The same device mounted on more places, one of the mountpoints also contains +# sub-mounts. Umount all by one umount all by top-level device name. +# +ts_init_subtest "all-targets-recursive" +multi_mount ${TS_DEVICE}1 $MOUNTPOINT +[ -d "${MOUNTPOINT}1/subA" ] || mkdir -p ${MOUNTPOINT}1/subA +$TS_CMD_MOUNT ${TS_DEVICE}2 ${MOUNTPOINT}1/subA &> /dev/null +[ -d "${MOUNTPOINT}1/subA/subAB" ] || mkdir -p ${MOUNTPOINT}1/subA/subAB +$TS_CMD_MOUNT ${TS_DEVICE}3 ${MOUNTPOINT}1/subA/subAB &> /dev/null +[ -d "${MOUNTPOINT}1/subB" ] || mkdir -p ${MOUNTPOINT}1/subB +$TS_CMD_MOUNT ${TS_DEVICE}4 ${MOUNTPOINT}1/subB &> /dev/null +$TS_CMD_UMOUNT --recursive --all-targets ${TS_DEVICE}1 >> $TS_OUTPUT 2>> $TS_ERRLOG +[ $? == 0 ] || ts_log "umount failed" +ts_finalize_subtest + +ts_log "Success" +ts_finalize diff --git a/tests/ts/mount/umount-recursive b/tests/ts/mount/umount-recursive new file mode 100755 index 0000000..8b1fd47 --- /dev/null +++ b/tests/ts/mount/umount-recursive @@ -0,0 +1,100 @@ +#!/bin/bash + +# Copyright (C) 2012 Karel Zak + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="umount-recursive" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" +ts_check_test_command "$TS_CMD_FDISK" + +ts_skip_nonroot +ts_check_prog "mkfs.ext2" + +$TS_CMD_UMOUNT --help | grep -q recursive +[ $? -eq 1 ] && ts_skip "recursive unsupported" + +ts_log "Init device" +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=50 + +ts_log "Create partitions" +$TS_CMD_FDISK --noauto-pt ${TS_DEVICE} &> /dev/null < /dev/null +ts_log "Create filesystem B" +mkfs.ext2 ${TS_DEVICE}2 &> /dev/null +ts_log "Create filesystem C" +mkfs.ext2 ${TS_DEVICE}3 &> /dev/null +ts_log "Create filesystem D" +mkfs.ext2 ${TS_DEVICE}4 &> /dev/null + +udevadm settle + +ts_log "Do tests..." + +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + +ts_log "A) Mount root" +$TS_CMD_MOUNT ${TS_DEVICE}1 $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_MOUNT --make-shared $TS_MOUNTPOINT &> /dev/null + +ts_log "B) Mount child" +mkdir -p $TS_MOUNTPOINT/mntB +$TS_CMD_MOUNT ${TS_DEVICE}2 $TS_MOUNTPOINT/mntB >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_log "B2) Mount child-bind" +mkdir -p $TS_MOUNTPOINT/bindB +$TS_CMD_MOUNT --bind $TS_MOUNTPOINT/mntB $TS_MOUNTPOINT/bindB >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_log "C) Mount child/child" +mkdir -p $TS_MOUNTPOINT/mntB/mnt{C,D} +$TS_CMD_MOUNT ${TS_DEVICE}3 $TS_MOUNTPOINT/mntB/mntC >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_log "D) Mount child/child" +$TS_CMD_MOUNT ${TS_DEVICE}4 $TS_MOUNTPOINT/mntB/mntD >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_log "E) Mount child-bind" +mkdir -p $TS_MOUNTPOINT/bindC +$TS_CMD_MOUNT --bind $TS_MOUNTPOINT/mntB/mntC $TS_MOUNTPOINT/bindC &> /dev/nul + +ts_log "F) Mount mountpoint-bind" +$TS_CMD_MOUNT --bind $TS_MOUNTPOINT $TS_MOUNTPOINT &> /dev/null + +udevadm settle +$TS_CMD_UMOUNT --recursive $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +[ $? == 0 ] || ts_die "umount failed" + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/uuid b/tests/ts/mount/uuid new file mode 100755 index 0000000..f2edfe1 --- /dev/null +++ b/tests/ts/mount/uuid @@ -0,0 +1,53 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="by uuid" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" + +ts_skip_nonroot +ts_check_losetup +ts_check_prog "mkfs.ext2" + +ts_device_init +DEVICE=$TS_LODEV + +mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE" +UUID=$(ts_uuid_by_devname "$DEVICE") || ts_die "Cannot find UUID on $DEVICE" + +ts_udevadm_settle "$DEVICE" "UUID" + +ts_init_subtest "U-option" +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +$TS_CMD_MOUNT -U $UUID $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts" +$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "UUID-option" +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +$TS_CMD_MOUNT UUID=$UUID $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts" +$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/namei/logic b/tests/ts/namei/logic new file mode 100755 index 0000000..52ce9ac --- /dev/null +++ b/tests/ts/namei/logic @@ -0,0 +1,35 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="basic functionality" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_NAMEI" + +ts_cd "$TS_OUTDIR" + +mkdir -p namei1/namei2 +touch namei1/namei2/a namei1/namei2/b + +$TS_CMD_NAMEI namei1/namei2/a >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_NAMEI namei1/namei2/b >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_finalize + diff --git a/tests/ts/partx/partx b/tests/ts/partx/partx new file mode 100755 index 0000000..e202100 --- /dev/null +++ b/tests/ts/partx/partx @@ -0,0 +1,186 @@ +#!/bin/bash + +# +# Copyright (C) 2010 Davidlohr Bueso +# +# 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="partitions probing" +PARTS=3 + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_PARTX" +ts_check_test_command "$TS_CMD_ADDPART" +ts_check_test_command "$TS_CMD_DELPART" +ts_check_test_command "$TS_CMD_SFDISK" + +ts_skip_nonroot + +shopt -s nullglob + +function check_partition_count +{ + # this function needs shopt -s nullglob + local cnt_want=$1 + local devname=$(basename $TS_DEVICE) + local parts=(/sys/block/${devname}/${devname}*) + local cnt_have=${#parts[@]} + + if [ $cnt_have -eq $cnt_want ]; then + return 0 + fi + echo "error: expected $cnt_want partitions, have $cnt_have" >&2 + echo "${parts[@]}" >&2 + return 1 +} + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=50 + +ts_init_subtest "addpart" +{ + $TS_CMD_ADDPART ${TS_DEVICE} 1 0 1 && + echo OK || + echo "Unable to add partition" + check_partition_count 1 +} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +udevadm settle + +ts_init_subtest "delpart" +{ + $TS_CMD_DELPART ${TS_DEVICE} 1 && + echo OK || + echo "Unable to remove partition" + check_partition_count 0 +} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +udevadm settle +$TS_CMD_SFDISK $TS_DEVICE &> /dev/null <> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +udevadm settle + +ts_init_subtest "delete-all" +#delete partinfo +{ + $TS_CMD_PARTX --delete $TS_DEVICE && + echo "partitions deleted" || + echo "Unable to delete partitions on $TS_DEVICE" + check_partition_count 0 +} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +udevadm settle + +ts_init_subtest "add-all" +#read TS_DEVICE and restore the partinfo +{ + $TS_CMD_PARTX --add $TS_DEVICE && + echo "partitions added" || + echo "Unable to add partitions for $TS_DEVICE" + check_partition_count $PARTS +} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +udevadm settle + +ts_init_subtest "update-one" +#read TS_DEVICE and update second partition +{ + $TS_CMD_PARTX --update ${TS_DEVICE}2 && + echo "partitions updated" || + echo "Unable to update 2nd partition for $TS_DEVICE" + check_partition_count $PARTS +} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +udevadm settle + +ts_init_subtest "delete-one" +#remove last partition only +{ + $TS_CMD_PARTX -d --nr -1 $TS_DEVICE && + echo "last partition removed" || + echo "Unable to remove a partition on $TS_DEVICE" + check_partition_count $((PARTS-1)) +} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +udevadm settle + +ts_init_subtest "delete-non-existent" +#attempt to remove it again +{ + # remove non-existing partitions (ENXIO) is not error + # + # see ab025087f91b66ee8e23a16bc49eb0d9bd421d65 and + # 53ae7d60cfeacd4e87bfe6fcc015b58b78ef4555 + # + $TS_CMD_PARTX -d --nr $PARTS $TS_DEVICE && + echo "partx: OK" || + echo "partx failed: removed non-existing partition" +} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +udevadm settle + +ts_init_subtest "add-existing" +#try adding an existing partition +{ + $TS_CMD_PARTX -a --nr 1 $TS_DEVICE 2>/dev/null && + echo "partx failed: re-added an existing partition" || + echo "partx: OK" +} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +udevadm settle + +ts_init_subtest "change-by-range" +# {-a|-d} --nr 0 should handle all partitions +{ + $TS_CMD_PARTX -d --nr 0 $TS_DEVICE && + echo "partitions deleted" || + echo "Unable to delete partitions on $TS_DEVICE" + check_partition_count 0 + $TS_CMD_PARTX -a --nr 0 $TS_DEVICE && + echo "partitions added" || + echo "Failed to add $TS_DEVICE partitions" + check_partition_count $PARTS +} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/partx/partx-image b/tests/ts/partx/partx-image new file mode 100755 index 0000000..a0ecf2c --- /dev/null +++ b/tests/ts/partx/partx-image @@ -0,0 +1,43 @@ +#!/bin/bash + +# +# Copyright (C) 2010 Davidlohr Bueso +# +# 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="show images" +TS_IMGDIR="$TS_TOPDIR/ts/blkid/images-pt" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_PARTX" +ts_check_prog "xz" + +mkdir -p $TS_OUTDIR/images-pt +for img in $TS_IMGDIR/*.img.xz; do + name=$(basename $img .img.xz) + outimg=$TS_OUTDIR/images-pt/${name}.img + + ts_init_subtest $name + { + xz -dc $img > $outimg && + $TS_CMD_PARTX $outimg || + echo "failed: $?" + } >> $TS_OUTPUT 2>> $TS_ERRLOG + ts_finalize_subtest +done + +ts_finalize diff --git a/tests/ts/paths/built-in b/tests/ts/paths/built-in new file mode 100755 index 0000000..2301ffb --- /dev/null +++ b/tests/ts/paths/built-in @@ -0,0 +1,32 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="built-in" + +# Don't execute this test by default, --force required +TS_OPTIONAL="yes" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_PATHS" + +$TS_HELPER_PATHS &> $TS_OUTPUT + +ts_finalize + diff --git a/tests/ts/rename/basic b/tests/ts/rename/basic new file mode 100755 index 0000000..786b092 --- /dev/null +++ b/tests/ts/rename/basic @@ -0,0 +1,75 @@ +#!/bin/bash + +# +# Copyright (C) 2014 Sami Kerola +# +# 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="basic check" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_RENAME" +ts_cd "$TS_OUTDIR" + +touch rename_basic.{1..3} +$TS_CMD_RENAME -v basic test rename_basic.? >> $TS_OUTPUT 2>> $TS_ERRLOG + +for i in rename_basic.?; do + echo "what is $i doing here?" >> $TS_OUTPUT +done +for i in rename_test.{1..3}; do + if [ ! -f $i ]; then + echo "file $i is missing" >> $TS_OUTPUT + else + rm -f $i + fi +done + + +touch rename_all\ file\ with\ spaces.{1..3} +$TS_CMD_RENAME -v -a ' ' '_' rename_all*.? >> $TS_OUTPUT 2>> $TS_ERRLOG + +for i in rename_all*\ *.?; do + echo "what is $i doing here?" >> $TS_OUTPUT +done +for i in rename_all_file_with_spaces.{1..3}; do + if [ ! -f $i ]; then + echo "file $i is missing" >> $TS_OUTPUT + else + rm -f $i + fi +done + +touch rename_zz_last_{z,z{,z{,z}}}.{x..z} +$TS_CMD_RENAME -v -l zz AAzzBB rename_zz_last_* >> $TS_OUTPUT 2>> $TS_ERRLOG +for i in rename_AAzzBB_last_z.x rename_AAzzBB_last_z.y rename_AAzzBB_last_z.z \ + rename_zz_last_AAzzBB.x rename_zz_last_AAzzBB.y rename_zz_last_AAzzBB.z \ + rename_zz_last_zAAzzBB.x rename_zz_last_zAAzzBB.y rename_zz_last_zAAzzBB.z ; do + if [ ! -f $i ]; then + echo "file $i is missing" >> $TS_OUTPUT + else + rm -f $i + fi +done +for i in rename*last* ; do + echo "what is $i doing here?" >> $TS_OUTPUT +done + +touch rename_all_empty +$TS_CMD_RENAME -v -a '' _ rename_all_empty >> $TS_OUTPUT 2>> $TS_ERRLOG +rm -f _r_e_n_a_m_e___a_l_l___e_m_p_t_y_ + +ts_finalize diff --git a/tests/ts/rename/exit_codes b/tests/ts/rename/exit_codes new file mode 100755 index 0000000..2f79d55 --- /dev/null +++ b/tests/ts/rename/exit_codes @@ -0,0 +1,42 @@ +#!/bin/bash + +# +# Copyright (C) 2014 Sami Kerola +# +# 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="exit codes" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_RENAME" + +ts_cd "$TS_OUTDIR" + +touch rename_exit_codes.{1..2} +$TS_CMD_RENAME -v not_a_match impossible rename_exit_codes.? >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "RENAME_EXIT_NOTHING: $?" >> $TS_OUTPUT + +$TS_CMD_RENAME -v codes values rename_exit_codes.? >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "EXIT_SUCCESS: $?" >> $TS_OUTPUT + +mkdir rename_exit_codes.2 +$TS_CMD_RENAME -v values codes rename_exit_values.? >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "RENAME_EXIT_SOMEOK: $?" >> $TS_OUTPUT + +rmdir rename_exit_codes.2 +rm rename_exit_codes.? rename_exit_values.? + +ts_finalize diff --git a/tests/ts/rename/overwrite b/tests/ts/rename/overwrite new file mode 100755 index 0000000..96a524a --- /dev/null +++ b/tests/ts/rename/overwrite @@ -0,0 +1,31 @@ +#!/bin/bash + +# +# Copyright (C) 2017 Sami Kerola +# +# 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="overwrite" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_RENAME" +ts_cd "$TS_OUTDIR" + +touch rename_from rename_to +$TS_CMD_RENAME -v --no-overwrite from to rename_from >> $TS_OUTPUT 2>> $TS_ERRLOG +rm rename_from rename_to >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_finalize diff --git a/tests/ts/rename/subdir b/tests/ts/rename/subdir new file mode 100755 index 0000000..c3de0ac --- /dev/null +++ b/tests/ts/rename/subdir @@ -0,0 +1,95 @@ +#!/bin/bash + +# +# Copyright (C) 2014 Sami Kerola +# +# 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="subdir check" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_RENAME" +ts_cd "$TS_OUTDIR" + +echo "== files ==" >> $TS_OUTPUT +mkdir rename_a{a,b} +touch rename_a{a,b}/aa +$TS_CMD_RENAME -v a x rename_a?/aa >> $TS_OUTPUT 2>> $TS_ERRLOG +find rename_a{a,b} >> $TS_OUTPUT 2>> $TS_ERRLOG + +echo "== symlinks ==" >> $TS_OUTPUT +for i in rename_a{a,b}/sublink.{1..3}; do + ln -s rename/aa $i +done +$TS_CMD_RENAME -s -v a x rename_a{a,b}/sublink.? >> $TS_OUTPUT 2>> $TS_ERRLOG +for i in rename_a{a,b}/sublink.?; do + readlink $i >> $TS_OUTPUT 2>> $TS_ERRLOG +done + +rm -rf rename_a{a,b} + +echo "== fullpath ==" >> $TS_OUTPUT +touch rename_path1 +$TS_CMD_RENAME -v ./rename_path1 ./rename_path2 ./rename_path1 >> $TS_OUTPUT 2>> $TS_ERRLOG + +find . -name 'rename_path*' >> $TS_OUTPUT 2>> $TS_ERRLOG +rm -f ./rename_path* + +mkdir rename_path_a +touch rename_path_test1 + +$TS_CMD_RENAME -v rename_path_test1 rename_path_a/test1 rename_path_test1 >> $TS_OUTPUT 2>> $TS_ERRLOG + +find . -name '*test1*' >> $TS_OUTPUT 2>> $TS_ERRLOG +rm -f rename_path_test1 rename_path_a/test1 + +mkdir rename_path_b +touch rename_path_a/test2 +$TS_CMD_RENAME -v rename_path_a/test2 rename_path_b/test2 rename_path_a/test2 >> $TS_OUTPUT 2>> $TS_ERRLOG + +find rename_path_a rename_path_b >> $TS_OUTPUT 2>> $TS_ERRLOG +rm -f rename_path_a/test2 rename_path_b/test2 + +rmdir rename_path_a rename_path_b + +ln -s some/nonexistent/path rename_link +$TS_CMD_RENAME -s -v t/p _ rename_link >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_RENAME -s -v exist / rename_link >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_RENAME -s -v e x rename_link >> $TS_OUTPUT 2>> $TS_ERRLOG +readlink rename_link >> $TS_OUTPUT 2>> $TS_ERRLOG +rm rename_link + +echo "== empty 'from' ==" >> $TS_OUTPUT + +touch rename_test +$TS_CMD_RENAME -v '' _ rename_test >> $TS_OUTPUT 2>> $TS_ERRLOG +rm -f *rename_test + +touch rename_test +$TS_CMD_RENAME -v '' _ ./rename_test >> $TS_OUTPUT 2>> $TS_ERRLOG +rm -f *rename_test + +touch rename_test +mkdir rename_subdir +$TS_CMD_RENAME -v '' rename_subdir/ rename_test >> $TS_OUTPUT 2>> $TS_ERRLOG +rm -rf rename_subdir + +touch rename_test +mkdir rename_subdir +$TS_CMD_RENAME -v '' rename_subdir/ ./rename_test >> $TS_OUTPUT 2>> $TS_ERRLOG +rm -rf rename_subdir + +ts_finalize diff --git a/tests/ts/rename/symlink b/tests/ts/rename/symlink new file mode 100755 index 0000000..f775ada --- /dev/null +++ b/tests/ts/rename/symlink @@ -0,0 +1,57 @@ +#!/bin/bash + +# +# Copyright (C) 2014 Sami Kerola +# +# 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="symlink check" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_RENAME" +ts_cd "$TS_OUTDIR" + +for i in rename_slink.{1..3}; do + ln -s old $i +done + +$TS_CMD_RENAME -s -v old new rename_slink.? >> $TS_OUTPUT 2>> $TS_ERRLOG + +for i in rename_slink.{1..3}; do + where="$(readlink $i)" + if [ "$where" != "new" ]; then + echo "error: $i points to $where" >> $TS_OUTPUT + fi + rm -f $i +done + +touch target +ln -s target rename_slink.1 +$TS_CMD_RENAME -v slink symlink rename_slink.1 >> $TS_OUTPUT 2>> $TS_ERRLOG +readlink rename_symlink.1 >> $TS_OUTPUT 2>> $TS_ERRLOG +rm -f rename_slink.1 rename_symlink.1 + +rm target +ln -s target rename_slink.2 +$TS_CMD_RENAME -v slink symlink rename_slink.2 >> $TS_OUTPUT 2>> $TS_ERRLOG +readlink rename_symlink.2 >> $TS_OUTPUT 2>> $TS_ERRLOG +rm -f rename_slink.2 rename_symlink.2 + +$TS_CMD_RENAME -v slink symlink rename_slink.3 >> $TS_OUTPUT 2>> $TS_ERRLOG +# The error may differ on Mac OS X due to faccessat()/lstat(); normalize it. +sed -i -e 's/\(rename_slink.3\): not accessible/\1/' -e 's/stat of \(rename_slink.3\) failed/\1/' $TS_ERRLOG + +ts_finalize diff --git a/tests/ts/schedutils/chrt b/tests/ts/schedutils/chrt new file mode 100755 index 0000000..aca735f --- /dev/null +++ b/tests/ts/schedutils/chrt @@ -0,0 +1,110 @@ +#!/bin/bash +# +# 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="chrt" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_CHRT" +ts_skip_nonroot + +# TODO: drone.io does not like FIFO and RR (container restriction?) +TS_KNOWN_FAIL="yes" + +function do_chrt { + $TS_CMD_CHRT $* $TS_CMD_CHRT --pid 0 | sed 's/.* policy: //; s/.* priority: //' >> $TS_OUTPUT 2>> $TS_ERRLOG +} + +function skip_policy { + $TS_CMD_CHRT --max | grep $1 | grep 'priority' &> /dev/null + if [ $? == 1 ]; then + ts_skip_subtest "unsupported" + return 1 + fi + return 0 +} + +function cleanup_output { + sed -i -e 's/pid [0-9]*//' $TS_OUTPUT +} + + +ts_init_subtest "fifo" +skip_policy SCHED_FIFO +if [ $? == 0 ]; then + do_chrt --fifo 1 + do_chrt --fifo 99 + cleanup_output + ts_finalize_subtest +fi + + +ts_init_subtest "batch" +skip_policy SCHED_BATCH +if [ $? == 0 ]; then + do_chrt --batch 0 + cleanup_output + ts_finalize_subtest +fi + + +ts_init_subtest "other" +skip_policy SCHED_OTHER +if [ $? == 0 ]; then + do_chrt --other 0 + cleanup_output + ts_finalize_subtest +fi + + +ts_init_subtest "rr" +skip_policy SCHED_RR +if [ $? == 0 ]; then + do_chrt --rr 1 + do_chrt --rr 99 + cleanup_output + ts_finalize_subtest +fi + + +ts_init_subtest "idle" +skip_policy SCHED_IDLE +if [ $? == 0 ]; then + do_chrt --idle 0 + cleanup_output + ts_finalize_subtest +fi + + +ts_init_subtest "deadline" +skip_policy SCHED_DEADLINE +if [ $? == 0 ]; then + do_chrt --deadline --sched-period 13000 0 + do_chrt --deadline --sched-period 13000 --sched-deadline 12000 0 + do_chrt --deadline --sched-period 13000 --sched-deadline 12000 --sched-runtime 10000 0 + cleanup_output + ts_finalize_subtest +fi + +# failed -- let's report kernel limits +# +if [ $TS_NSUBFAILED -ne 0 ]; then + echo "Supported policies:" + $TS_CMD_CHRT --max +fi + +ts_finalize diff --git a/tests/ts/schedutils/chrt-non-root b/tests/ts/schedutils/chrt-non-root new file mode 100755 index 0000000..8600981 --- /dev/null +++ b/tests/ts/schedutils/chrt-non-root @@ -0,0 +1,61 @@ +#!/bin/bash +# +# 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="chrt-non-user" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_CHRT" + +# TODO: drone.io does not like FIFO and RR (container restriction?) +TS_KNOWN_FAIL="yes" + +function do_chrt { + $TS_CMD_CHRT $* $TS_CMD_CHRT --pid 0 | sed 's/.* policy: //; s/.* priority: //' >> $TS_OUTPUT 2>> $TS_ERRLOG +} + +function skip_policy { + $TS_CMD_CHRT --max | grep $1 | grep 'priority' &> /dev/null + if [ $? == 1 ]; then + ts_skip_subtest "unsupported" + return 1 + fi + return 0 +} + +function cleanup_output { + sed -i -e 's/pid [0-9]*//' $TS_OUTPUT + sed -i -e 's/[0-9]* (process/ (process/' $TS_OUTPUT +} + +ts_init_subtest "batch-vs-nice" +skip_policy SCHED_BATCH +if [ $? == 0 ]; then + renice -n 5 -p $$ >> $TS_OUTPUT 2>> $TS_ERRLOG + do_chrt --batch 0 + cleanup_output + ts_finalize_subtest +fi + +# failed -- let's report kernel limits +# +if [ $TS_NSUBFAILED -ne 0 ]; then + echo "Supported policies:" + $TS_CMD_CHRT --max +fi + +ts_finalize diff --git a/tests/ts/schedutils/cpuset b/tests/ts/schedutils/cpuset new file mode 100755 index 0000000..0e756ee --- /dev/null +++ b/tests/ts/schedutils/cpuset @@ -0,0 +1,59 @@ +#!/bin/bash + +# +# 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="cpuset" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_CPUSET" + +MASKS=" 0x00000001 \ + 0x00000002 \ + 0x00000003 \ + 0x00000004 \ + 0x00000005 \ + 0x00000006 \ + 0x00000007 \ + 0x00000008 \ + 0x00000009 \ + 0x00005555 \ + 0x00007777" + +RANGES="0 \ + 1 \ + 0,1 \ + 2 \ + 0,2 \ + 1,2 \ + 0-2 \ + 3 \ + 0,3 \ + 0,2,4,6,8,10,12,14 \ + 0-2,4-6,8-10,12-14" + +ts_log "masks:" +for i in $MASKS; do + $TS_HELPER_CPUSET --mask $i >> $TS_OUTPUT +done + +ts_log "strings:" +for i in $RANGES; do + $TS_HELPER_CPUSET --range $i >> $TS_OUTPUT +done + +ts_finalize diff --git a/tests/ts/script/buffering-race b/tests/ts/script/buffering-race new file mode 100755 index 0000000..a5f3d94 --- /dev/null +++ b/tests/ts/script/buffering-race @@ -0,0 +1,27 @@ +#!/bin/bash + +# 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="buffering race" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_SCRIPT" + +#SCRIPT_DEBUG=all ULPTY_DEBUG=all +$TS_CMD_SCRIPT -c "echo Hallo World" /dev/null $TS_OUTPUT + +ts_finalize + diff --git a/tests/ts/script/options b/tests/ts/script/options new file mode 100755 index 0000000..3cbd5c8 --- /dev/null +++ b/tests/ts/script/options @@ -0,0 +1,66 @@ +#!/bin/bash + +# 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="options" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +export SCRIPT_TEST_SECOND_SINCE_EPOCH=1432489398 +export TZ="GMT" + +ts_check_test_command "$TS_HELPER_SCRIPT" + +ts_init_subtest "append" +$TS_HELPER_SCRIPT --command "echo append1" $TS_OUTPUT /dev/null 2>&1 +$TS_HELPER_SCRIPT --append -c "echo append2" $TS_OUTPUT /dev/null 2>&1 +ts_finalize_subtest + +ts_init_subtest "force" +ln -s $TS_OUTPUT typescript +$TS_HELPER_SCRIPT --command "echo no force" /dev/null 2>> $TS_OUTPUT +echo $? >> $TS_OUTPUT +$TS_HELPER_SCRIPT -a --force --command "echo with force" /dev/null +echo $? >> $TS_OUTPUT +rm -f typescript +ln -s $TS_OUTPUT tpircsepyt +$TS_HELPER_SCRIPT -a --command "echo not typescript" tpircsepyt /dev/null +echo $? >> $TS_OUTPUT +rm -f tpircsepyt +ts_finalize_subtest + +ts_init_subtest "quiet" +$TS_HELPER_SCRIPT --quiet --command "echo quiet1" $TS_OUTPUT /dev/null 2>&1 +$TS_HELPER_SCRIPT -a -q --command "echo quiet2" $TS_OUTPUT /dev/null 2>&1 +ts_finalize_subtest + +ts_init_subtest "return" +$TS_HELPER_SCRIPT --command "exit 1" $TS_OUTPUT /dev/null 2>&1 +echo $? >> $TS_OUTPUT +$TS_HELPER_SCRIPT -a --command "exit 0" $TS_OUTPUT /dev/null 2>&1 +echo $? >> $TS_OUTPUT +$TS_HELPER_SCRIPT -e --append -c "exit 42" $TS_OUTPUT /dev/null 2>&1 +echo $? >> $TS_OUTPUT +$TS_HELPER_SCRIPT --return --append -c "exit 127" $TS_OUTPUT /dev/null 2>&1 +echo $? >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "size" +$TS_HELPER_SCRIPT --output-limit 9 --command "echo 1:1234567890" $TS_OUTPUT /dev/null 2>&1 +$TS_HELPER_SCRIPT -a -o 9 --command "echo 2:1234567890" $TS_OUTPUT /dev/null 2>&1 +echo $? >> $TS_OUTPUT +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/script/race b/tests/ts/script/race new file mode 100755 index 0000000..b4d2d8a --- /dev/null +++ b/tests/ts/script/race @@ -0,0 +1,48 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="race conditions" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_SCRIPT" + +# this test may fail on systems with very heavy load +# https://github.com/util-linux/util-linux/issues/296 +TS_KNOWN_FAIL="yes" + +bingofile="$TS_OUTDIR/${TS_TESTNAME}-bingo" + +count=1000 +for i in `seq 1 $count`; do + $TS_CMD_SCRIPT -q -c "printf 'Bingo\n'" $bingofile +done | grep -c Bingo >> $TS_OUTPUT + +seen=$(<$TS_OUTPUT) +if [ "$seen" = "$count" ]; then + echo "all bingos seen" > $TS_OUTPUT +else + echo "only $seen of $count bingos seen" > $TS_OUTPUT +fi + +rm -f $bingofile + +ts_finalize + diff --git a/tests/ts/script/replay b/tests/ts/script/replay new file mode 100755 index 0000000..384c5b3 --- /dev/null +++ b/tests/ts/script/replay @@ -0,0 +1,98 @@ +#!/bin/bash + +# 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="replay" + +. "$TS_TOPDIR/functions.sh" +ts_init "$*" + +ts_check_test_command "$TS_CMD_SCRIPT" +ts_check_test_command "$TS_CMD_SCRIPTREPLAY" +ts_check_test_command "$TS_CMD_SCRIPTLIVE" + +LOG_OUT_FILE="${TS_OUTDIR}/${TS_TESTNAME}-logfile-out" +LOG_IN_FILE="${TS_OUTDIR}/${TS_TESTNAME}-logfile-in" +LOG_IO_FILE="${TS_OUTDIR}/${TS_TESTNAME}-logfile-io" +TIMING_FILE="${TS_OUTDIR}/${TS_TESTNAME}-logfile-tm" + +rm -f $TIMING_FILE $LOG_IN_FILE $LOG_OUT_FILE $LOG_IO_FILE + + +# +# Old command line format +# +ts_init_subtest "basic" +echo "===recording" >"$TS_OUTPUT" +$TS_CMD_SCRIPT \ + --command "echo hello world; sleep 0.5; echo all done" \ + --timing="$TIMING_FILE" \ + "$LOG_OUT_FILE" >> $TS_OUTPUT 2>> $TS_ERRLOG + +echo "===replaying" >>"$TS_OUTPUT" +$TS_CMD_SCRIPTREPLAY "$TIMING_FILE" "$LOG_OUT_FILE" 1.5 >> $TS_OUTPUT 2>> $TS_ERRLOG + +sed -i "s|$TIMING_FILE|timingfile|g; s|$LOG_OUT_FILE|outlog|g" $TS_OUTPUT $TS_ERRLOG +ts_finalize_subtest + + +# +# New command line format +# +ts_init_subtest "output" +echo "===recording" >"$TS_OUTPUT" +NUMBER=1 $TS_CMD_SCRIPT \ + --command 'echo "result is $(($NUMBER + 1))"' \ + --log-out "$LOG_OUT_FILE" \ + --log-timing "$TIMING_FILE" >> $TS_OUTPUT 2>> $TS_ERRLOG + +echo "===replaying" >>"$TS_OUTPUT" +$TS_CMD_SCRIPTREPLAY \ + --log-out "$LOG_OUT_FILE" \ + --log-timing "$TIMING_FILE" >> $TS_OUTPUT 2>> $TS_ERRLOG + +sed -i "s|$TIMING_FILE|timingfile|g; s|$LOG_OUT_FILE|outlog|g" $TS_OUTPUT $TS_ERRLOG +ts_finalize_subtest + + +# +# Log input +# +ts_init_subtest "input" +echo "===recording" >"$TS_OUTPUT" +echo 'echo "result is $(($NUMBER + 1))"' | $TS_CMD_SCRIPT \ + --command 'sh' \ + --log-in "$LOG_IN_FILE" \ + --log-timing "$TIMING_FILE" >> /dev/null 2>> $TS_ERRLOG + +echo "===replaying" >>"$TS_OUTPUT" +$TS_CMD_SCRIPTREPLAY \ + --log-in "$LOG_IN_FILE" \ + --log-timing "$TIMING_FILE" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +# +# Live replay +# +ts_init_subtest "live" +TS_KNOWN_FAIL="yes" +NUMBER=123 $TS_CMD_SCRIPTLIVE \ + --command 'sh' \ + --log-in "$LOG_IN_FILE" \ + --log-timing "$TIMING_FILE" >> $TS_OUTPUT 2>> $TS_ERRLOG +sed -i 's/^[[:alnum:][:punct:][:blank:]]*[\$\#] /prompt> /g' $TS_OUTPUT +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/sfdisk/dos b/tests/ts/sfdisk/dos new file mode 100755 index 0000000..0cff511 --- /dev/null +++ b/tests/ts/sfdisk/dos @@ -0,0 +1,276 @@ +#!/bin/bash + +# +# 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="MBR" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_SFDISK" +ts_check_test_command "$TS_CMD_WIPEFS" + +ts_skip_nonroot + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=50 sector_size=512 physblk_exp=3 + + +ts_init_subtest "simple-commas" +$TS_CMD_SFDISK --unit S ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --unit S --list ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "simple-space" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK --unit S ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG < /dev/null +udevadm settle +$TS_CMD_SFDISK --unit S ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG < /dev/null +udevadm settle +$TS_CMD_SFDISK --unit S ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +ts_init_subtest "write-json" +$TS_CMD_SFDISK --json ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +# +# Test first LBA smaller than libfdisk default (~1MiB) and small gaps between +# logical partitions (just only one sector for EBR). +# +ts_init_subtest "explicit-size" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK --unit S ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG < /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} > /dev/null 2>&1 <> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "resize-empty-extended" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} > /dev/null 2>&1 <> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "reduce-empty-extended" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} > /dev/null 2>&1 <> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + +ts_init_subtest "resize-extended" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} > /dev/null 2>&1 <> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "resize-logical" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} > /dev/null 2>&1 <> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "dump-old" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} < $TS_SELF/files/dump-old >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "dump-gaps" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} < $TS_SELF/files/dump-gaps >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "default-vs-gap1" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG < /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG < /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG < /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +ts_init_subtest "v2.35" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +ts_init_subtest "current" +$TS_CMD_SFDISK --dump ${TS_DEVICE} > $TS_OUTPUT.dump 2>> $TS_ERRLOG +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +cat $TS_OUTPUT.dump | $TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle +$TS_CMD_SFDISK --list -o START,END,SIZE,UUID,TYPE,NAME ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/sfdisk/files/dump-gaps b/tests/ts/sfdisk/files/dump-gaps new file mode 100644 index 0000000..3aff9ca --- /dev/null +++ b/tests/ts/sfdisk/files/dump-gaps @@ -0,0 +1,7 @@ +# partition table of /dev/sdc +unit: sectors + +/dev/sdc1 : start= 2048, size= 49999, Id=83, bootable +/dev/sdc2 : start= 0, size= 0, Id= 0 +/dev/sdc3 : start= 52048, size= 49999, Id=83 +/dev/sdc4 : start= 0, size= 0, Id= 0 diff --git a/tests/ts/sfdisk/files/dump-old b/tests/ts/sfdisk/files/dump-old new file mode 100644 index 0000000..7708e5e --- /dev/null +++ b/tests/ts/sfdisk/files/dump-old @@ -0,0 +1,7 @@ +# partition table of /dev/sdc +unit: sectors + +/dev/sdc1 : start= 2048, size= 49999, Id=83, bootable +/dev/sdc2 : start= 0, size= 0, Id= 0 +/dev/sdc3 : start= 0, size= 0, Id= 0 +/dev/sdc4 : start= 0, size= 0, Id= 0 diff --git a/tests/ts/sfdisk/gpt b/tests/ts/sfdisk/gpt new file mode 100755 index 0000000..273d965 --- /dev/null +++ b/tests/ts/sfdisk/gpt @@ -0,0 +1,206 @@ +#!/bin/bash + +# +# 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="GPT" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_SFDISK" +ts_check_test_command "$TS_CMD_FDISK" +ts_check_test_command "$TS_CMD_WIPEFS" + +ts_skip_nonroot + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=50 sector_size=512 physblk_exp=3 + + +ts_init_subtest "all-defaults" +$TS_CMD_SFDISK --unit S ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG < /dev/null +$TS_CMD_SFDISK --part-uuid ${TS_DEVICE} 2 baa08adf-327e-4177-8953-98da1a5176c4 &> /dev/null +$TS_CMD_SFDISK --part-uuid ${TS_DEVICE} 3 cead8a87-ff1a-45cb-83e5-99b08d0ebc87 &> /dev/null +$TS_CMD_SFDISK --part-uuid ${TS_DEVICE} 4 d4fcdc60-765d-4bc3-bd84-0d0b9842c6db &> /dev/null +$TS_CMD_SFDISK --part-uuid ${TS_DEVICE} 5 60155bd7-bfd8-4e8c-b800-221900779373 &> /dev/null + +$TS_CMD_SFDISK --part-uuid ${TS_DEVICE} 1 >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "label" +$TS_CMD_SFDISK --part-label ${TS_DEVICE} 1 "EFI system" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --part-label ${TS_DEVICE} 1 >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "type" +$TS_CMD_SFDISK --part-type ${TS_DEVICE} 1 "C12A7328-F81F-11D2-BA4B-00A0C93EC93B" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --part-type ${TS_DEVICE} 1 >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "attrs" +$TS_CMD_SFDISK --part-attrs ${TS_DEVICE} 2 "RequiredPartition,NoBlockIOProtocol,48,51" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --part-attrs ${TS_DEVICE} 2 >> $TS_OUTPUT 2>> $TS_ERRLOG +echo -ne 'x\nD\n' | $TS_CMD_FDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "attrs-space" +$TS_CMD_SFDISK --part-attrs ${TS_DEVICE} 2 "RequiredPartition NoBlockIOProtocol 48 51" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --part-attrs ${TS_DEVICE} 2 >> $TS_OUTPUT 2>> $TS_ERRLOG +echo -ne 'x\nD\n' | $TS_CMD_FDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "attrs-guid" +$TS_CMD_SFDISK --part-attrs ${TS_DEVICE} 2 "GUID:48 GUID:51,52,63" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --part-attrs ${TS_DEVICE} 2 >> $TS_OUTPUT 2>> $TS_ERRLOG +echo -ne 'x\nD\n' | $TS_CMD_FDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "attrs-with-typo" +$TS_CMD_SFDISK --part-attrs ${TS_DEVICE} 2 "RequiredPartiton,NoBlockIOProtocol,48,51" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --part-attrs ${TS_DEVICE} 2 >> $TS_OUTPUT 2>> $TS_ERRLOG +echo -ne 'x\nD\n' | $TS_CMD_FDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "attrs-unsupported" +$TS_CMD_SFDISK --part-attrs ${TS_DEVICE} 2 "NoBlockIOProtocol FooBar 48 51" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +ts_init_subtest "attrs-broken-nosep" +$TS_CMD_SFDISK --part-attrs ${TS_DEVICE} 2 "NoBlockIOProtocolRequiredPartiton" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +ts_init_subtest "attrs-broken-guid" +$TS_CMD_SFDISK --part-attrs ${TS_DEVICE} 2 "GUID:NoBlockIOProtocol GUID:GUID:63 RequiredPartiton" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +ts_init_subtest "read-dump" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +ts_init_subtest "write-dump" +$TS_CMD_SFDISK --unit S --dump ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +ts_init_subtest "write-json" +$TS_CMD_SFDISK --json ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +ts_init_subtest "list-pmbr" +$TS_CMD_SFDISK --list --label-nested dos ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +ts_init_subtest "resize" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} > /dev/null 2>&1 <> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "reorder" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_finalize diff --git a/tests/ts/sfdisk/movedata b/tests/ts/sfdisk/movedata new file mode 100755 index 0000000..5b5232c --- /dev/null +++ b/tests/ts/sfdisk/movedata @@ -0,0 +1,75 @@ +#!/bin/bash + +# +# 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="movedata" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_SFDISK" +ts_check_test_command "$TS_HELPER_MD5" + +ts_skip_nonroot +ts_check_prog "mkfs.ext4" + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=100 sector_size=512 + +# create a partition +echo ',10M,L' | $TS_CMD_SFDISK --no-reread ${TS_DEVICE} &> /dev/null +udevadm settle + +mkfs.ext4 ${TS_DEVICE}1 &> /dev/null +udevadm settle +CHECKSUM=$("$TS_HELPER_MD5" < "${TS_DEVICE}1") + +function checksum() { + local dev="$1" + CHECK=$("$TS_HELPER_MD5" < "${dev}") + if [ "$CHECKSUM" != "$CHECK" ]; then + echo "Checksum does not match!" >> $TS_OUTPUT + fi +} + +ts_init_subtest "up" +echo '+1000,' | $TS_CMD_SFDISK --no-reread --move-data=$TS_OUTPUT.log -N1 ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +checksum ${TS_DEVICE}1 +ts_finalize_subtest + +udevadm settle + +ts_init_subtest "down" +echo "-500," | $TS_CMD_SFDISK --no-reread --move-data=$TS_OUTPUT.log -N1 ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +checksum ${TS_DEVICE}1 +ts_finalize_subtest + +udevadm settle + +ts_init_subtest "non-overlay" +echo "+30M," | $TS_CMD_SFDISK --no-reread --move-data=$TS_OUTPUT.log -N1 ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +checksum ${TS_DEVICE}1 +ts_finalize_subtest + + +ts_finalize diff --git a/tests/ts/sfdisk/resize b/tests/ts/sfdisk/resize new file mode 100755 index 0000000..664301d --- /dev/null +++ b/tests/ts/sfdisk/resize @@ -0,0 +1,154 @@ +#!/bin/bash + +# +# 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="resize" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_SFDISK" +ts_check_test_command "$TS_CMD_WIPEFS" + +ts_skip_nonroot + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=100 sector_size=512 + +declare -a COMM +declare -a NAME + +COMM[0]="3000," +NAME[0]="move-up-absolute" + +COMM[1]="2048," +NAME[1]="move-down-absolute" + +COMM[2]="+1M," +NAME[2]="move-up-relative" + +COMM[3]="-1M," +NAME[3]="move-down-relative" + +COMM[4]="-,15M" +NAME[4]="enlarge-absolute" + +COMM[5]=",5M," +NAME[5]="reduce-absolute" + +COMM[6]=", +10M" +NAME[6]="enlarge-relative" + +NAME[7]="reduce-relative" +COMM[7]=", -10M" + +NAME[8]="enlarge-all" +COMM[8]=",+" + +NAME[9]="up-preduce" +COMM[9]="+10M,-10M" + +NAME[10]="down-enlarge" +COMM[10]="-10M,+10M,,*" + +NAME[11]="absolute-move-resize" +COMM[11]="2048,10M,L" + +function test_label_resize { + local label="$1" + + $TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null + udevadm settle + + # create a partition + echo ',10M,L' | $TS_CMD_SFDISK --no-reread --label ${label} ${TS_DEVICE} &> /dev/null + udevadm settle + + for idx in $(seq 0 $(( ${#COMM[*]} - 1 ))); do + + cmd=${COMM[$idx]} + name=${NAME[$idx]} + + ts_init_subtest "$label-$idx-$name" + echo -e "$cmd\n" >> $TS_OUTPUT + echo "$cmd" | $TS_CMD_SFDISK --no-reread -N1 ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG + ts_fdisk_clean $TS_DEVICE + udevadm settle + ts_finalize_subtest + done + + echo ',10M,L' | $TS_CMD_SFDISK --no-reread --append ${TS_DEVICE} &> /dev/null + udevadm settle + + echo ',10M,L' | $TS_CMD_SFDISK --no-reread --append ${TS_DEVICE} &> /dev/null + udevadm settle + + idx=$(( $idx + 1 )) + ts_init_subtest "$label-$idx-reduce-midle" + cmd=',-5M' + echo -e "$cmd\n" >> $TS_OUTPUT + echo "$cmd" | $TS_CMD_SFDISK --no-reread -N2 ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG + ts_fdisk_clean $TS_DEVICE + udevadm settle + ts_finalize_subtest + + idx=$(( $idx + 1 )) + ts_init_subtest "$label-$idx-max-last" + cmd='-5M,+' + echo -e "$cmd\n" >> $TS_OUTPUT + echo $cmd | $TS_CMD_SFDISK --no-reread -N3 ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG + ts_fdisk_clean $TS_DEVICE + udevadm settle + ts_finalize_subtest +} + +# MBR +test_label_resize dos + +# GPT +test_label_resize gpt + + +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle + +ts_init_subtest "dos-unsorted" +# create layout where partition #4 is the last on disk (by offset) +# and there is freespace at the end of the disk. Note that #4 is not the last +# partno on the disk. The libfdisk has to be able to check for the free space +# independently on the partno, only offset+size matters. +$TS_CMD_SFDISK --no-reread ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/sfdisk/script b/tests/ts/sfdisk/script new file mode 100755 index 0000000..1e4bb2f --- /dev/null +++ b/tests/ts/sfdisk/script @@ -0,0 +1,157 @@ +#!/bin/bash + +# +# 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="script" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_SFDISK" +ts_check_test_command "$TS_CMD_WIPEFS" + +ts_skip_nonroot + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=50 sector_size=512 physblk_exp=3 + +ts_init_subtest "type-and-id" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + +ts_init_subtest "separator" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +ts_init_subtest "quotes" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +ts_init_subtest "broken-1" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG < /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG < /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG < /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG < /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle +ts_separator "Create DOS" +echo ',,L' | $TS_CMD_SFDISK $SFDISK_OPTS --wipe=always --label=dos ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_separator "Check content" +$TS_CMD_WIPEFS -O OFFSET,TYPE ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +# Same as previous test, but without --wipe=always, sfdisk has to wipe +# the device automatically when switch from one PT to another PT +# +ts_init_subtest "gpt-to-dos-auto" +ts_separator "Create GPT" +echo ',,L' | $TS_CMD_SFDISK $SFDISK_OPTS --label=gpt ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle +ts_separator "Create DOS" +echo ',,L' | $TS_CMD_SFDISK $SFDISK_OPTS --label=dos ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_separator "Check content" +$TS_CMD_WIPEFS -O OFFSET,TYPE ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +ts_init_subtest "fs-to-dos" +ts_separator "Create FS" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_MKSWAP ${TS_DEVICE} &> /dev/null +udevadm settle +ts_separator "Create DOS" +echo ',,L' | $TS_CMD_SFDISK $SFDISK_OPTS --wipe=always --label=dos ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_separator "Check content" +$TS_CMD_WIPEFS -O OFFSET,TYPE ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +ts_init_subtest "partition" +ts_separator "Create GPT" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +echo ',,L' | $TS_CMD_SFDISK --no-reread --label=gpt ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle +ts_separator "Create FS in partition" +$TS_CMD_MKSWAP ${TS_DEVICE}1 &> /dev/null +udevadm settle +ts_separator "Wipe whole-disk device" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +ts_separator "Create GPT (again)" +echo ',,L' | $TS_CMD_SFDISK --no-reread --wipe-partition=always --label=gpt ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle +ts_separator "Check content (disk)" +$TS_CMD_WIPEFS -O OFFSET,TYPE ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle +ts_separator "Check content (partition)" +$TS_CMD_WIPEFS -O OFFSET,TYPE ${TS_DEVICE}1 >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +udevadm settle +ts_finalize diff --git a/tests/ts/sha1/data b/tests/ts/sha1/data new file mode 100644 index 0000000..1eed05a --- /dev/null +++ b/tests/ts/sha1/data @@ -0,0 +1,7 @@ + +abc +qazxswedc +1qazxsw23edc +a a a a a a a a a a +KUWIOJDNWQKLFDHQUWEDAYCNAUIWSYDUQUICBSKLBCLUWIGDF +EASC6545642432132SDECSESCEACSJKDWIOUDOIWIDOQPWUDQWIOSNXCSASCA diff --git a/tests/ts/sha1/sha1 b/tests/ts/sha1/sha1 new file mode 100755 index 0000000..7d2413c --- /dev/null +++ b/tests/ts/sha1/sha1 @@ -0,0 +1,31 @@ +#!/bin/bash + +# +# Copyright (C) 2009 Karel Zak +# +# 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_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_SHA1" + +cat $TS_SELF/data | while read data +do + echo -n $data | $TS_HELPER_SHA1 >> $TS_OUTPUT +done + +ts_finalize + diff --git a/tests/ts/swapon/devname b/tests/ts/swapon/devname new file mode 100755 index 0000000..d62b9d9 --- /dev/null +++ b/tests/ts/swapon/devname @@ -0,0 +1,50 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="by devname" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MKSWAP" +ts_check_test_command "$TS_CMD_SWAPON" +ts_check_test_command "$TS_CMD_SWAPOFF" + +ts_skip_nonroot +ts_check_losetup + +ts_device_init +DEVICE=$TS_LODEV + +$TS_CMD_MKSWAP $DEVICE > /dev/null 2>> $TS_OUTPUT \ + || ts_die "Cannot make swap $DEVICE" + +ts_device_has "TYPE" "swap" $DEVICE || ts_die "Cannot find swap on $DEVICE" + +$TS_CMD_SWAPON $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG + +grep -q "^$DEVICE\b" /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps" + +$TS_CMD_SWAPOFF $DEVICE + +# swapon/mkswap warns if system sets different permissions for loop devices +sed --in-place '/insecure permissions .*, 0660 suggested/d' $TS_OUTPUT + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/swapon/fixpgsz b/tests/ts/swapon/fixpgsz new file mode 100755 index 0000000..68e17c1 --- /dev/null +++ b/tests/ts/swapon/fixpgsz @@ -0,0 +1,49 @@ +#!/bin/bash + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="fix page size" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MKSWAP" +ts_check_test_command "$TS_CMD_SWAPON" +ts_check_test_command "$TS_CMD_SWAPOFF" +ts_check_test_command "$TS_HELPER_SYSINFO" + +ts_skip_nonroot +ts_check_losetup + +PAGESIZE=$($TS_HELPER_SYSINFO pagesize) + +# +# Create a swap-area with incompatible page size +# +[ "$?" == 0 ] || ts_die "Cannot init device" + +if [ $(( 64 * 1024 )) -ne $PAGESIZE ]; then + BADSIZE=$(( 64 * 1024 )) +else + BADSIZE=4096 +fi + +ts_device_init +DEVICE=$TS_LODEV + +$TS_CMD_MKSWAP -L MyFooBarLabel --pagesize $BADSIZE $DEVICE > /dev/null &> /dev/null \ + || ts_die "Cannot make swap $DEVICE" + +ts_device_has "TYPE" "swap" $DEVICE || ts_die "Cannot find swap on $DEVICE" + +# +# Swapon +# +$TS_CMD_SWAPON --fixpgsz $DEVICE &> /dev/null + +grep -q "^$DEVICE\b" /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps" + +$TS_CMD_SWAPOFF $DEVICE + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/swapon/fixsig b/tests/ts/swapon/fixsig new file mode 100755 index 0000000..9648e6d --- /dev/null +++ b/tests/ts/swapon/fixsig @@ -0,0 +1,53 @@ +#!/bin/bash + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="fix signature" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MKSWAP" +ts_check_test_command "$TS_CMD_SWAPON" +ts_check_test_command "$TS_CMD_SWAPOFF" +ts_check_test_command "$TS_HELPER_SYSINFO" + +ts_skip_nonroot +ts_check_losetup + +PAGESIZE=$($TS_HELPER_SYSINFO pagesize) + +# +# Create a swap-area +# +ts_device_init +DEVICE=$TS_LODEV + +$TS_CMD_MKSWAP $DEVICE > /dev/null 2>> $TS_OUTPUT \ + || ts_die "Cannot make swap $DEVICE" + +ts_device_has "TYPE" "swap" $DEVICE || ts_die "Cannot find swap on $DEVICE" + +# +# Rewrite signature to swsuspend +# +echo "S2SUSPEND " > $TS_OUTPUT.signature +dd if=$TS_OUTPUT.signature of=$DEVICE \ + seek=$(( $PAGESIZE - 10 )) count=10 bs=1 conv=notrunc &> /dev/null + +ts_device_has "TYPE" "swsuspend" $DEVICE || ts_die "Cannot find swsuspend on $DEVICE" + +# +# Swapon +# +$TS_CMD_SWAPON $DEVICE &> /dev/null + +grep -q "^$DEVICE\b" /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps" + +$TS_CMD_SWAPOFF $DEVICE + +# swapon/mkswap warns if system sets different permissions for loop devices +sed --in-place '/insecure permissions .*, 0660 suggested/d' $TS_OUTPUT + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/swapon/label b/tests/ts/swapon/label new file mode 100755 index 0000000..0931fe0 --- /dev/null +++ b/tests/ts/swapon/label @@ -0,0 +1,52 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="by label" +LABEL="testSwapLabel" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MKSWAP" +ts_check_test_command "$TS_CMD_SWAPON" +ts_check_test_command "$TS_CMD_SWAPOFF" + +ts_skip_nonroot +ts_check_losetup + +ts_device_init +DEVICE=$TS_LODEV + +$TS_CMD_MKSWAP -L $LABEL $DEVICE > /dev/null 2>> $TS_OUTPUT \ + || ts_die "Cannot make swap on $DEVICE" +ts_device_has "LABEL" $LABEL $DEVICE \ + || ts_die "Cannot find LABEL '$LABEL' on $DEVICE" +ts_udevadm_settle "$DEVICE" "LABEL" + +$TS_CMD_SWAPON -L $LABEL >> $TS_OUTPUT 2>> $TS_ERRLOG + +grep -q "^$DEVICE\b" /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps" + +$TS_CMD_SWAPOFF $DEVICE + +# swapon/mkswap warns if system sets different permissions for loop devices +sed --in-place '/insecure permissions .*, 0660 suggested/d' $TS_OUTPUT + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/swapon/uuid b/tests/ts/swapon/uuid new file mode 100755 index 0000000..724cec2 --- /dev/null +++ b/tests/ts/swapon/uuid @@ -0,0 +1,50 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak +# +# 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="by uuid" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MKSWAP" +ts_check_test_command "$TS_CMD_SWAPON" +ts_check_test_command "$TS_CMD_SWAPOFF" + +ts_skip_nonroot +ts_check_losetup + +ts_device_init +DEVICE=$TS_LODEV + +$TS_CMD_MKSWAP $DEVICE > /dev/null 2>> $TS_OUTPUT \ + || ts_die "Cannot make swap $DEVICE" +UUID=$(ts_uuid_by_devname "$DEVICE") || ts_die "Cannot find UUID on $DEVICE" +ts_udevadm_settle "$DEVICE" "UUID" + +$TS_CMD_SWAPON -U $UUID >> $TS_OUTPUT 2>> $TS_ERRLOG + +grep -q "^$DEVICE\b" /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps" + +$TS_CMD_SWAPOFF $DEVICE + +# swapon/mkswap warns if system sets different permissions for loop devices +sed --in-place '/insecure permissions .*, 0660 suggested/d' $TS_OUTPUT + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/ul/basic b/tests/ts/ul/basic new file mode 100755 index 0000000..56138ab --- /dev/null +++ b/tests/ts/ul/basic @@ -0,0 +1,42 @@ +#!/bin/bash + +# +# Copyright (C) 2020 Sami Kerola +# +# 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="basic tests" + + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_UL" + +# This test provides different result on some terminals and virtual machines +TS_KNOWN_FAIL="yes" + +ts_init_subtest "printable-characters" +$TS_CMD_UL < $TS_SELF/basic.input >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "filter-input" +$TS_CMD_UL $TS_SELF/filter.input >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "indicated" +printf "u\b_l\b_\n" | ul --indicated >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/ul/basic.input b/tests/ts/ul/basic.input new file mode 100644 index 0000000..3bc7fbc --- /dev/null +++ b/tests/ts/ul/basic.input @@ -0,0 +1,95 @@ + +! +" +# +$ +% +& +' +( +) +* ++ +, +- +. +/ +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +: +; +< += +> +? +@ +A +B +C +D +E +F +G +H +I +J +K +L +M +N +O +P +Q +R +S +T +U +V +W +X +Y +Z +[ +\ +] +^ +_ +` +a +b +c +d +e +f +g +h +i +j +k +l +m +n +o +p +q +r +s +t +u +v +w +x +y +z +{ +| +} +~ diff --git a/tests/ts/ul/filter.input b/tests/ts/ul/filter.input new file mode 100644 index 0000000..4e5bd46 --- /dev/null +++ b/tests/ts/ul/filter.input @@ -0,0 +1,9 @@ +backspacexy + tab +R S +SO +SI +u_n_d_e_r_line +flush after flush +normal7reverse +eof diff --git a/tests/ts/ul/ul b/tests/ts/ul/ul new file mode 100755 index 0000000..7ba72a9 --- /dev/null +++ b/tests/ts/ul/ul @@ -0,0 +1,29 @@ +#!/bin/bash + +# 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="ul" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_UL" + +# This test provides different result on some terminals and virtual machines +TS_KNOWN_FAIL="yes" + +printf "a\x08ab\x5F\x08c\\n\\ttab\\f\\b\\r" | + $TS_CMD_UL -t xterm >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_finalize diff --git a/tests/ts/utmp/last b/tests/ts/utmp/last new file mode 100755 index 0000000..b125ce9 --- /dev/null +++ b/tests/ts/utmp/last @@ -0,0 +1,93 @@ +#!/bin/bash + +# 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="last" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_LAST" +ts_check_test_command "$TS_CMD_UTMPDUMP" +ts_check_prog "ln" + +$TS_CMD_LAST --version 2>&1 | grep -q "invalid option" \ + && ts_skip "deprecated last" + +. "$TS_SELF/utmp_functions.sh" + +WTMP_FILE=${TS_OUTDIR}/wtmp-a +rm -f $WTMP_FILE + +export LANG=C +export TZ=GMT + +if [ $SIZEOF_UTMP -eq 384 ]; then + ln -s ${TS_SELF}/wtmp-a.${BYTE_ORDER} $WTMP_FILE +else + $TS_CMD_UTMPDUMP -r ${TS_SELF}/txt-a > $WTMP_FILE 2>/dev/null \ + || ts_skip "can't create test data" +fi + +# there is no better way yet to skip a subtest +if ts_resolve_host "a.root-servers.net" >/dev/null; then +ts_init_subtest "dns" + +ts_log "~~~ dns short ~~~" +$TS_CMD_LAST -f $WTMP_FILE -d root >> $TS_OUTPUT 2>/dev/null + +ts_log "~~~ dns long ~~~" +$TS_CMD_LAST -f $WTMP_FILE -w -d root >> $TS_OUTPUT 2>/dev/null + +ts_log "~~~ dns host last ~~~" +$TS_CMD_LAST -f $WTMP_FILE -a -d root >> $TS_OUTPUT 2>/dev/null + +ts_finalize_subtest +fi + +ts_init_subtest "nodns" +ts_log "~~~ basic output ~~~" +$TS_CMD_LAST -f $WTMP_FILE >> $TS_OUTPUT 2>/dev/null + +ts_log "~~~ include system ~~~" +$TS_CMD_LAST -f $WTMP_FILE -x >> $TS_OUTPUT 2>/dev/null + +ts_log "~~~ show ip ~~~" +$TS_CMD_LAST -f $WTMP_FILE -i torvalds >> $TS_OUTPUT 2>/dev/null + +ts_log "~~~ no host ~~~" +$TS_CMD_LAST -f $WTMP_FILE -R torvalds >> $TS_OUTPUT 2>/dev/null + +ts_log "~~~ full times shortopt ~~~" +$TS_CMD_LAST -f $WTMP_FILE -F >> $TS_OUTPUT 2>/dev/null + +ts_log "~~~ full times longopt ~~~" +$TS_CMD_LAST -f $WTMP_FILE --time-format=full >> $TS_OUTPUT 2>/dev/null + +ts_log "~~~ no time ~~~" +$TS_CMD_LAST -f $WTMP_FILE --time-format=notime >> $TS_OUTPUT 2>/dev/null + +ts_log "~~~ iso-8601 time ~~~" +$TS_CMD_LAST -f $WTMP_FILE --time-format=iso -w >> $TS_OUTPUT 2>/dev/null + +ts_log "~~~ since and until ~~~" +$TS_CMD_LAST -f $WTMP_FILE -s "2013-08-28 02:20" -t "2013-08-28 08:20" >> $TS_OUTPUT 2>/dev/null + +ts_log "~~~ present ~~~" +$TS_CMD_LAST -f $WTMP_FILE -p "2013-08-28 11:20" >> $TS_OUTPUT 2>/dev/null +ts_finalize_subtest + +rm -f $WTMP_FILE + +ts_finalize diff --git a/tests/ts/utmp/last-ipv6 b/tests/ts/utmp/last-ipv6 new file mode 100755 index 0000000..4567612 --- /dev/null +++ b/tests/ts/utmp/last-ipv6 @@ -0,0 +1,66 @@ +#!/bin/bash + +# 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="last ipv6" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_LAST" +$TS_CMD_LAST --version 2>&1 | grep -q "invalid option" \ + && ts_skip "deprecated last" + +. "$TS_SELF/utmp_functions.sh" + +WTMP_FILE=${TS_OUTDIR}/wtmp-ipv6 +rm -f $WTMP_FILE + +export LANG=C +export TZ=GMT + +if [ $SIZEOF_UTMP -eq 384 ]; then + ln -s ${TS_SELF}/wtmp-ipv6.${BYTE_ORDER} $WTMP_FILE +else + $TS_CMD_UTMPDUMP -r ${TS_SELF}/txt-ipv6 > $WTMP_FILE 2>/dev/null \ + || ts_skip "can't create test data" +fi + +# there is no better way yet to skip a subtest +if ts_resolve_host "a.root-servers.net" >/dev/null; then +ts_init_subtest "dns" + +ts_log "~~~ dns short ~~~" +$TS_CMD_LAST -f $WTMP_FILE -d >> $TS_OUTPUT 2>/dev/null + +ts_log "~~~ dns long ~~~" +$TS_CMD_LAST -f $WTMP_FILE -d -w >> $TS_OUTPUT 2>/dev/null + +ts_log "~~~ dns host last ~~~" +$TS_CMD_LAST -f $WTMP_FILE -d -a >> $TS_OUTPUT 2>/dev/null + +ts_finalize_subtest +fi + +ts_init_subtest "nodns" +ts_log "~~~ show ip ~~~" +$TS_CMD_LAST -f $WTMP_FILE -i >> $TS_OUTPUT 2>/dev/null + +ts_log "~~~ show ip last ~~~" +$TS_CMD_LAST -f $WTMP_FILE -i -a >> $TS_OUTPUT 2>/dev/null +ts_finalize_subtest + +rm -f $WTMP_FILE + +ts_finalize diff --git a/tests/ts/utmp/subsec b/tests/ts/utmp/subsec new file mode 100644 index 0000000..0fdff05 --- /dev/null +++ b/tests/ts/utmp/subsec @@ -0,0 +1,3 @@ +[7] [00010] [ipv6] [IPv6 ] [root ] [dns-server ] [2001:503:ba3e::2:30] [2013-08-28T20:30:40,123456+00:00] +[8] [00011] [ipv6] [IPv6 ] [root ] [dns-server ] [2001:503:ba3e::2:30] [2013-08-28T20:40:50,999999+00:00] +[0] [00000] [ts/0] [nonvalid] [foo ] [zero ] [0.0.0.0 ] [2013-08-28T12:00:00,123456789+00:00] diff --git a/tests/ts/utmp/txt-a b/tests/ts/utmp/txt-a new file mode 100644 index 0000000..47b6fc2 --- /dev/null +++ b/tests/ts/utmp/txt-a @@ -0,0 +1,19 @@ +[9] [00009] [ts/9] [accounting] [foo ] [nine ] [0.0.0.0 ] [2013-08-28T03:00:00,000000+00:00] +[8] [00008] [ts/8] [dead_process] [foo ] [eight ] [0.0.0.0 ] [2013-08-28T04:00:00,000000+00:00] +[7] [00007] [ts/7] [user_process] [foo ] [seven ] [0.0.0.0 ] [2013-08-28T05:00:00,000000+00:00] +[6] [00006] [ts/6] [login ] [foo ] [six ] [0.0.0.0 ] [2013-08-28T06:00:00,000000+00:00] +[5] [00005] [ts/5] [init ] [foo ] [five ] [0.0.0.0 ] [2013-08-28T07:00:00,000000+00:00] +[4] [00004] [ts/4] [oldtime ] [foo ] [four ] [0.0.0.0 ] [2013-08-28T08:00:00,000000+00:00] +[3] [00003] [ts/3] [newtime ] [foo ] [three ] [0.0.0.0 ] [2013-08-28T09:00:00,000000+00:00] +[2] [00002] [ts/2] [sysboot ] [foo ] [two ] [0.0.0.0 ] [2013-08-28T10:00:00,000000+00:00] +[1] [00001] [ts/1] [runlevel] [foo ] [one ] [0.0.0.0 ] [2013-08-28T11:00:00,000000+00:00] +[0] [00000] [ts/0] [nonvalid] [foo ] [zero ] [0.0.0.0 ] [2013-08-28T12:00:00,000000+00:00] +[7] [00010] [ipv4] [IPv4 ] [root ] [dns-server ] [198.41.0.4 ] [2013-08-28T13:00:00,000000+00:00] +[8] [00011] [ipv4] [IPv4 ] [root ] [dns-server ] [198.41.0.4 ] [2013-08-28T14:00:00,000000+00:00] +[1] [00012] [~~ ] [shutdown] [~ ] [system-name ] [0.0.0.0 ] [2013-08-28T15:00:00,000000+00:00] +[2] [00012] [~~ ] [reboot ] [~ ] [system-name ] [0.0.0.0 ] [2013-08-28T16:00:00,000000+00:00] +[1] [00012] [~~ ] [shutdown] [~ ] [system-name ] [0.0.0.0 ] [2013-08-28T17:00:00,000000+00:00] +[2] [00012] [~~ ] [reboot ] [~ ] [system-name ] [0.0.0.0 ] [2013-08-28T18:00:00,000000+00:00] +[7] [00013] [ts/1] [torvalds] [linux ] [hobby ] [128.214.205.14 ] [1991-08-26T00:57:08,000000+00:00] +[7] [00014] [long] [rick ] [long ] [never-gonna-logout ] [0.0.0.0 ] [1970-01-01T00:00:00,000000+00:00] +[8] [00014] [long] [rick ] [long ] [never-gonna-logout ] [0.0.0.0 ] [2038-01-19T03:14:07,000000+00:00] diff --git a/tests/ts/utmp/txt-a-old b/tests/ts/utmp/txt-a-old new file mode 100644 index 0000000..bc91d19 --- /dev/null +++ b/tests/ts/utmp/txt-a-old @@ -0,0 +1,19 @@ +[9] [00009] [ts/9] [accounting] [foo ] [nine ] [0.0.0.0 ] [Wed Aug 28 03:00:00 2013 GMT] +[8] [00008] [ts/8] [dead_process] [foo ] [eight ] [0.0.0.0 ] [Wed Aug 28 04:00:00 2013 GMT] +[7] [00007] [ts/7] [user_process] [foo ] [seven ] [0.0.0.0 ] [Wed Aug 28 05:00:00 2013 GMT] +[6] [00006] [ts/6] [login ] [foo ] [six ] [0.0.0.0 ] [Wed Aug 28 06:00:00 2013 GMT] +[5] [00005] [ts/5] [init ] [foo ] [five ] [0.0.0.0 ] [Wed Aug 28 07:00:00 2013 GMT] +[4] [00004] [ts/4] [oldtime ] [foo ] [four ] [0.0.0.0 ] [Wed Aug 28 08:00:00 2013 GMT] +[3] [00003] [ts/3] [newtime ] [foo ] [three ] [0.0.0.0 ] [Wed Aug 28 09:00:00 2013 GMT] +[2] [00002] [ts/2] [sysboot ] [foo ] [two ] [0.0.0.0 ] [Wed Aug 28 10:00:00 2013 GMT] +[1] [00001] [ts/1] [runlevel] [foo ] [one ] [0.0.0.0 ] [Wed Aug 28 11:00:00 2013 GMT] +[0] [00000] [ts/0] [nonvalid] [foo ] [zero ] [0.0.0.0 ] [Wed Aug 28 12:00:00 2013 GMT] +[7] [00010] [ipv4] [IPv4 ] [root ] [dns-server ] [198.41.0.4 ] [Wed Aug 28 13:00:00 2013 GMT] +[8] [00011] [ipv4] [IPv4 ] [root ] [dns-server ] [198.41.0.4 ] [Wed Aug 28 14:00:00 2013 GMT] +[1] [00012] [~~ ] [shutdown] [~ ] [system-name ] [0.0.0.0 ] [Wed Aug 28 15:00:00 2013 GMT] +[2] [00012] [~~ ] [reboot ] [~ ] [system-name ] [0.0.0.0 ] [Wed Aug 28 16:00:00 2013 GMT] +[1] [00012] [~~ ] [shutdown] [~ ] [system-name ] [0.0.0.0 ] [Wed Aug 28 17:00:00 2013 GMT] +[2] [00012] [~~ ] [reboot ] [~ ] [system-name ] [0.0.0.0 ] [Wed Aug 28 18:00:00 2013 GMT] +[7] [00013] [ts/1] [torvalds] [linux ] [hobby ] [128.214.205.14 ] [Mon Aug 26 00:57:08 1991 GMT] +[7] [00014] [long] [rick ] [long ] [never-gonna-logout ] [0.0.0.0 ] [ ] +[8] [00014] [long] [rick ] [long ] [never-gonna-logout ] [0.0.0.0 ] [Tue Jan 19 03:14:07 2038 GMT] diff --git a/tests/ts/utmp/txt-b b/tests/ts/utmp/txt-b new file mode 100644 index 0000000..f929273 --- /dev/null +++ b/tests/ts/utmp/txt-b @@ -0,0 +1,10 @@ +[7] [17058] [ts/1] [kerolasa] [pts/1 ] [:0.0 ] [0.0.0.0 ] [2013-01-16T23:44:09,000000+00:00] +[7] [22098] [ts/2] [kerolasa] [pts/2 ] [:0.0 ] [0.0.0.0 ] [2013-01-16T23:49:17,000000+00:00] +[7] [24915] [ts/3] [kerolasa] [pts/3 ] [:0.0 ] [0.0.0.0 ] [2013-01-17T12:23:33,000000+00:00] +[8] [24915] [ts/3] [kerolasa] [pts/3 ] [ ] [0.0.0.0 ] [2013-01-17T12:24:49,000000+00:00] +[7] [30629] [ts/3] [kerolasa] [pts/3 ] [:0.0 ] [0.0.0.0 ] [2013-01-17T13:12:39,000000+00:00] +[8] [30629] [ts/3] [kerolasa] [pts/3 ] [ ] [0.0.0.0 ] [2013-01-17T13:42:19,000000+00:00] +[8] [22098] [ts/2] [kerolasa] [pts/2 ] [ ] [0.0.0.0 ] [2013-01-17T13:42:48,000000+00:00] +[8] [17058] [ts/1] [kerolasa] [pts/1 ] [ ] [0.0.0.0 ] [2013-01-17T13:42:48,000000+00:00] +[7] [31545] [ts/1] [kerolasa] [pts/1 ] [:0.0 ] [0.0.0.0 ] [2013-01-17T20:17:21,000000+00:00] +[7] [28496] [ts/2] [kerolasa] [pts/2 ] [:0.0 ] [0.0.0.0 ] [2013-01-17T21:09:39,000000+00:00] diff --git a/tests/ts/utmp/txt-b-old b/tests/ts/utmp/txt-b-old new file mode 100644 index 0000000..02fb22d --- /dev/null +++ b/tests/ts/utmp/txt-b-old @@ -0,0 +1,10 @@ +[7] [17058] [ts/1] [kerolasa] [pts/1 ] [:0.0 ] [0.0.0.0 ] [Wed Jan 16 23:44:09 2013 GMT] +[7] [22098] [ts/2] [kerolasa] [pts/2 ] [:0.0 ] [0.0.0.0 ] [Wed Jan 16 23:49:17 2013 GMT] +[7] [24915] [ts/3] [kerolasa] [pts/3 ] [:0.0 ] [0.0.0.0 ] [Thu Jan 17 12:23:33 2013 GMT] +[8] [24915] [ts/3] [kerolasa] [pts/3 ] [ ] [0.0.0.0 ] [Thu Jan 17 12:24:49 2013 GMT] +[7] [30629] [ts/3] [kerolasa] [pts/3 ] [:0.0 ] [0.0.0.0 ] [Thu Jan 17 13:12:39 2013 GMT] +[8] [30629] [ts/3] [kerolasa] [pts/3 ] [ ] [0.0.0.0 ] [Thu Jan 17 13:42:19 2013 GMT] +[8] [22098] [ts/2] [kerolasa] [pts/2 ] [ ] [0.0.0.0 ] [Thu Jan 17 13:42:48 2013 GMT] +[8] [17058] [ts/1] [kerolasa] [pts/1 ] [ ] [0.0.0.0 ] [Thu Jan 17 13:42:48 2013 GMT] +[7] [31545] [ts/1] [kerolasa] [pts/1 ] [:0.0 ] [0.0.0.0 ] [Thu Jan 17 20:17:21 2013 GMT] +[7] [28496] [ts/2] [kerolasa] [pts/2 ] [:0.0 ] [0.0.0.0 ] [Thu Jan 17 21:09:39 2013 GMT] diff --git a/tests/ts/utmp/txt-ipv6 b/tests/ts/utmp/txt-ipv6 new file mode 100644 index 0000000..cceb411 --- /dev/null +++ b/tests/ts/utmp/txt-ipv6 @@ -0,0 +1,2 @@ +[7] [00010] [ipv6] [IPv6 ] [root ] [dns-server ] [2001:503:ba3e::2:30] [2013-08-28T20:30:40,000000+00:00] +[8] [00011] [ipv6] [IPv6 ] [root ] [dns-server ] [2001:503:ba3e::2:30] [2013-08-28T20:40:50,000000+00:00] diff --git a/tests/ts/utmp/txt-ipv6-old b/tests/ts/utmp/txt-ipv6-old new file mode 100644 index 0000000..5cce150 --- /dev/null +++ b/tests/ts/utmp/txt-ipv6-old @@ -0,0 +1,2 @@ +[7] [00010] [ipv6] [IPv6 ] [root ] [dns-server ] [2001:503:ba3e::2:30] [Wed Aug 28 20:30:40 2013 GMT] +[8] [00011] [ipv6] [IPv6 ] [root ] [dns-server ] [2001:503:ba3e::2:30] [Wed Aug 28 20:40:50 2013 GMT] diff --git a/tests/ts/utmp/utmp_functions.sh b/tests/ts/utmp/utmp_functions.sh new file mode 100644 index 0000000..74a100c --- /dev/null +++ b/tests/ts/utmp/utmp_functions.sh @@ -0,0 +1,18 @@ +ts_check_test_command "$TS_CMD_UTMPDUMP" +ts_check_test_command "$TS_HELPER_SYSINFO" + +function utmp_struct_size { + local size + # probably "utmpdump -r" could be improved regarding white spaces ... + local txt="[0] [00000] [ ] [ ] [ ] [ ] [0.0.0.0 ] [ ]" + + size=$(echo "$txt" | "$TS_CMD_UTMPDUMP" -r 2>/dev/null | wc -c \ + && exit ${PIPESTATUS[1]}) + ret=$? + [ $ret -eq 0 ] || size="0" + echo "$size" + return $ret +} + +BYTE_ORDER=$($TS_HELPER_SYSINFO byte-order) || ts_failed "byte-order failed" +SIZEOF_UTMP=$(utmp_struct_size) || ts_failed "utmp_struct_size failed" diff --git a/tests/ts/utmp/utmpdump-circle b/tests/ts/utmp/utmpdump-circle new file mode 100755 index 0000000..e8464b8 --- /dev/null +++ b/tests/ts/utmp/utmpdump-circle @@ -0,0 +1,48 @@ +#!/bin/bash + +# 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="circle" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +# this test is arch independent, no need for utmp_functions.sh +ts_check_test_command "$TS_CMD_UTMPDUMP" + +export LANG=C +export TZ=Asia/Tokyo +OUT_BIN1=${TS_OUTDIR}/${TS_TESTNAME}.bin1 +OUT_BIN2=${TS_OUTDIR}/${TS_TESTNAME}.bin2 +OUT_TXT=${TS_OUTDIR}/${TS_TESTNAME}.txt + +# Files with -old extension are using timestamp format before utmpdump +# started to use iso-8601 format. This check is testing nothing is lost +# when conversions performing following conversions. +# +# old text format -> binary -> new text format -> binary + +echo "no output expected" > $TS_OUTPUT +for f in txt-a txt-b txt-ipv6; do + $TS_CMD_UTMPDUMP -r $TS_SELF/$f-old > $OUT_BIN1 2>/dev/null && + $TS_CMD_UTMPDUMP $OUT_BIN1 > $OUT_TXT 2>/dev/null && + diff -u $TS_SELF/$f $OUT_TXT && + $TS_CMD_UTMPDUMP -r $OUT_TXT > $OUT_BIN2 2>/dev/null && + diff -q $OUT_BIN1 $OUT_BIN2 || + echo "circle failed for $f" +done >> $TS_OUTPUT 2>> $TS_ERRLOG + +rm -f "$OUT_BIN1" "$OUT_BIN2" "$OUT_TXT" + +ts_finalize diff --git a/tests/ts/utmp/utmpdump-subsecond b/tests/ts/utmp/utmpdump-subsecond new file mode 100755 index 0000000..d0d3289 --- /dev/null +++ b/tests/ts/utmp/utmpdump-subsecond @@ -0,0 +1,32 @@ +#!/bin/bash + +# 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="subsecond" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +# this test is arch independent, no need for utmp_functions.sh +ts_check_test_command "$TS_CMD_UTMPDUMP" + +OUT_BIN=${TS_OUTDIR}/${TS_TESTNAME}.bin + +echo "last 9 is expected to disappear in conversion" > $TS_OUTPUT +$TS_CMD_UTMPDUMP -r $TS_SELF/subsec > $OUT_BIN 2>/dev/null +$TS_CMD_UTMPDUMP $OUT_BIN >> $TS_OUTPUT 2>/dev/null + +rm -f "$OUT_BIN" + +ts_finalize diff --git a/tests/ts/utmp/utmpdump-tobin b/tests/ts/utmp/utmpdump-tobin new file mode 100755 index 0000000..556ad30 --- /dev/null +++ b/tests/ts/utmp/utmpdump-tobin @@ -0,0 +1,32 @@ +#!/bin/bash + +# 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="to binary" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +. "$TS_SELF/utmp_functions.sh" +[ $SIZEOF_UTMP -eq 384 ] || ts_skip "utmp struct size $SIZEOF_UTMP" + +export LANG=C +export TZ=Asia/Tokyo +OUTFILE=${TS_OUTDIR}/${TS_TESTNAME}.file +$TS_CMD_UTMPDUMP -r $TS_SELF/txt-b >| $OUTFILE 2>/dev/null +if diff -q $TS_SELF/wtmp-b.$BYTE_ORDER $OUTFILE; then + echo "no diff" +fi >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_finalize diff --git a/tests/ts/utmp/utmpdump-tobin-ipv6 b/tests/ts/utmp/utmpdump-tobin-ipv6 new file mode 100755 index 0000000..85254b7 --- /dev/null +++ b/tests/ts/utmp/utmpdump-tobin-ipv6 @@ -0,0 +1,32 @@ +#!/bin/bash + +# 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="IPv6 to binary" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +. "$TS_SELF/utmp_functions.sh" +[ $SIZEOF_UTMP -eq 384 ] || ts_skip "utmp struct size $SIZEOF_UTMP" + +export LANG=C +export TZ=Asia/Tokyo +OUTFILE=${TS_OUTDIR}/${TS_TESTNAME}.file +$TS_CMD_UTMPDUMP -r $TS_SELF/txt-ipv6 >| $OUTFILE 2>/dev/null +if diff -q $TS_SELF/wtmp-ipv6.$BYTE_ORDER $OUTFILE; then + echo "no diff" +fi >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_finalize diff --git a/tests/ts/utmp/utmpdump-totxt b/tests/ts/utmp/utmpdump-totxt new file mode 100755 index 0000000..7097fdd --- /dev/null +++ b/tests/ts/utmp/utmpdump-totxt @@ -0,0 +1,28 @@ +#!/bin/bash + +# 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="to text" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +. "$TS_SELF/utmp_functions.sh" +[ $SIZEOF_UTMP -eq 384 ] || ts_skip "utmp struct size $SIZEOF_UTMP" + +export LANG=C +export TZ=Asia/Tokyo +$TS_CMD_UTMPDUMP $TS_SELF/wtmp-b.$BYTE_ORDER >| $TS_OUTPUT 2>/dev/null + +ts_finalize diff --git a/tests/ts/utmp/utmpdump-totxt-ipv6 b/tests/ts/utmp/utmpdump-totxt-ipv6 new file mode 100755 index 0000000..84ab570 --- /dev/null +++ b/tests/ts/utmp/utmpdump-totxt-ipv6 @@ -0,0 +1,28 @@ +#!/bin/bash + +# 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="IPv6 to text" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +. "$TS_SELF/utmp_functions.sh" +[ $SIZEOF_UTMP -eq 384 ] || ts_skip "utmp struct size $SIZEOF_UTMP" + +export LANG=C +export TZ=Asia/Tokyo +$TS_CMD_UTMPDUMP $TS_SELF/wtmp-ipv6.$BYTE_ORDER >| $TS_OUTPUT 2>/dev/null + +ts_finalize diff --git a/tests/ts/utmp/wtmp-a.BE b/tests/ts/utmp/wtmp-a.BE new file mode 100644 index 0000000..5015f8e Binary files /dev/null and b/tests/ts/utmp/wtmp-a.BE differ diff --git a/tests/ts/utmp/wtmp-a.LE b/tests/ts/utmp/wtmp-a.LE new file mode 100644 index 0000000..f66bb20 Binary files /dev/null and b/tests/ts/utmp/wtmp-a.LE differ diff --git a/tests/ts/utmp/wtmp-b.BE b/tests/ts/utmp/wtmp-b.BE new file mode 100644 index 0000000..fb09a0c Binary files /dev/null and b/tests/ts/utmp/wtmp-b.BE differ diff --git a/tests/ts/utmp/wtmp-b.LE b/tests/ts/utmp/wtmp-b.LE new file mode 100644 index 0000000..45d35bb Binary files /dev/null and b/tests/ts/utmp/wtmp-b.LE differ diff --git a/tests/ts/utmp/wtmp-ipv6.BE b/tests/ts/utmp/wtmp-ipv6.BE new file mode 100644 index 0000000..8cf7d39 Binary files /dev/null and b/tests/ts/utmp/wtmp-ipv6.BE differ diff --git a/tests/ts/utmp/wtmp-ipv6.LE b/tests/ts/utmp/wtmp-ipv6.LE new file mode 100644 index 0000000..342553b Binary files /dev/null and b/tests/ts/utmp/wtmp-ipv6.LE differ diff --git a/tests/ts/uuid/namespace b/tests/ts/uuid/namespace new file mode 100755 index 0000000..7bfbe99 --- /dev/null +++ b/tests/ts/uuid/namespace @@ -0,0 +1,29 @@ +#!/bin/bash + +# +# Copyright (C) 2009 Karel Zak +# +# 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_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_UUID_NAMESPACE" + +$TS_HELPER_UUID_NAMESPACE > $TS_OUTPUT + +ts_finalize + + diff --git a/tests/ts/uuid/oids b/tests/ts/uuid/oids new file mode 100755 index 0000000..ec9c29d --- /dev/null +++ b/tests/ts/uuid/oids @@ -0,0 +1,33 @@ +#!/bin/bash + +# 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="oids" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +: . > $TS_OUTPUT + +ts_check_test_command "$TS_CMD_UUIDGEN" + +$TS_CMD_UUIDGEN --md5 --namespace @dns --name "www.widgets.com" >> $TS_OUTPUT + +$TS_CMD_UUIDGEN --md5 --namespace @dns --name "www.example.com" >> $TS_OUTPUT + +$TS_CMD_UUIDGEN --sha1 --namespace @dns --name "www.example.com" >> $TS_OUTPUT + +$TS_CMD_UUIDGEN --sha1 --namespace @oid --hex --name "525400fc0f5e" >> $TS_OUTPUT + +ts_finalize diff --git a/tests/ts/uuid/uuid_parser b/tests/ts/uuid/uuid_parser new file mode 100755 index 0000000..c286f6c --- /dev/null +++ b/tests/ts/uuid/uuid_parser @@ -0,0 +1,26 @@ +#!/bin/bash + +# 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="uuid_parser" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_UUID_PARSER" + +$TS_HELPER_UUID_PARSER >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "return value: $?" >> $TS_OUTPUT + +ts_finalize diff --git a/tests/ts/uuid/uuidd b/tests/ts/uuid/uuidd new file mode 100755 index 0000000..afc1121 --- /dev/null +++ b/tests/ts/uuid/uuidd @@ -0,0 +1,59 @@ +#!/bin/bash + +# 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="uuidd" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_UUID_PARSER" +ts_check_test_command "$TS_CMD_UUIDD" + +OUTPUT_FILE="$(mktemp "${TS_OUTDIR}/uuiddXXXXXXXXXXXXX")" +UUIDD_PID="$(mktemp -u "${TS_OUTDIR}/uuiddXXXXXXXXXXXXX")" +# socket path must be short (SIZEOF_SOCKADDR_UN_SUN_PATH 108) +UUIDD_SOCKET=$(mktemp "/tmp/ultest-$TS_COMPONENT-$TS_TESTNAME-socketXXXXXX") + +$TS_CMD_UUIDD -p "$UUIDD_PID" -s "$UUIDD_SOCKET" +if [ $? -ne 0 ]; then + ts_failed "daemon start" +fi + +test_flag() { + echo "options: $*" >> $TS_OUTPUT + $TS_CMD_UUIDD -s $UUIDD_SOCKET $* | + sed '/List of UUIDs:/d; s/^[[:space:]]*//' > "$OUTPUT_FILE" 2>>$TS_OUTPUT + $TS_HELPER_UUID_PARSER "$OUTPUT_FILE" >> $TS_OUTPUT 2>> $TS_ERRLOG + ret=$? + if [ $ret -ne 0 ]; then + echo "something wrong with $OUTPUT_FILE" >> $TS_OUTPUT + cat $OUTPUT_FILE >> $TS_OUTPUT 2>> $TS_ERRLOG + fi + echo "return value: $ret" >> $TS_OUTPUT +} + +test_flag -t +test_flag --time +test_flag -r +test_flag --random +test_flag -r -n 65 + +$TS_CMD_UUIDD -k -s "$UUIDD_SOCKET" >> $TS_OUTPUT 2>> $TS_ERRLOG + +sed -i 's/pid [0-9]*.$/pid ./' $TS_OUTPUT $TS_ERRLOG + +rm -f "$OUTPUT_FILE" "$UUIDD_PID" "$UUIDD_SOCKET" + +ts_finalize diff --git a/tests/ts/uuid/uuidgen b/tests/ts/uuid/uuidgen new file mode 100755 index 0000000..cbaaefa --- /dev/null +++ b/tests/ts/uuid/uuidgen @@ -0,0 +1,45 @@ +#!/bin/bash + +# 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="uuidgen" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_UUID_PARSER" +ts_check_test_command "$TS_CMD_UUIDGEN" + +OUTPUT_FILE="$(mktemp "${TS_OUTDIR}/uuidgenXXXXXXXXXXXXX")" + +test_flag() { + echo "option: $1" >> $TS_OUTPUT + $TS_CMD_UUIDGEN $1 > "$OUTPUT_FILE" 2>>$TS_OUTPUT + ret=$? + $TS_HELPER_UUID_PARSER "$OUTPUT_FILE" >> $TS_OUTPUT 2>> $TS_ERRLOG + if [ $? -ne 0 ] || [ $ret -ne 0 ]; then + echo "something wrong with $OUTPUT_FILE" >> $TS_OUTPUT + cat $OUTPUT_FILE >> $TS_OUTPUT 2>> $TS_ERRLOG + fi + echo "return values: $ret and $?" >> $TS_OUTPUT +} + +test_flag -r +test_flag -t +test_flag --random +test_flag --time + +rm -f "$OUTPUT_FILE" + +ts_finalize diff --git a/tests/ts/uuid/uuidparse b/tests/ts/uuid/uuidparse new file mode 100755 index 0000000..915886c --- /dev/null +++ b/tests/ts/uuid/uuidparse @@ -0,0 +1,61 @@ +#!/bin/bash + +# 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="uuidparse" +export TZ=GMT + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_UUIDPARSE" + +echo '00000000-0000-0000-0000-000000000000 + +00000000-0000-1000-0000-000000000000 +00000000-0000-2000-0000-000000000000 +00000000-0000-3000-0000-000000000000 +00000000-0000-4000-0000-000000000000 +00000000-0000-5000-0000-000000000000 +00000000-0000-6000-0000-000000000000 + +00000000-0000-0000-8000-000000000000 +00000000-0000-2000-8000-000000000000 +00000000-0000-3000-8000-000000000000 +00000000-0000-4000-8000-000000000000 +00000000-0000-5000-8000-000000000000 +00000000-0000-6000-8000-000000000000 + +00000000-0000-0000-d000-000000000000 +00000000-0000-1000-d000-000000000000 +00000000-0000-2000-d000-000000000000 +00000000-0000-3000-d000-000000000000 +00000000-0000-4000-d000-000000000000 +00000000-0000-5000-d000-000000000000 +00000000-0000-6000-d000-000000000000 + +00000000-0000-0000-f000-000000000000 +00000000-0000-1000-f000-000000000000 +00000000-0000-2000-f000-000000000000 +00000000-0000-3000-f000-000000000000 +00000000-0000-4000-f000-000000000000 +00000000-0000-5000-f000-000000000000 +00000000-0000-6000-f000-000000000000 + +9b274c46-544a-11e7-a972-00037f500001 + +invalid-input' | $TS_CMD_UUIDPARSE >> $TS_OUTPUT 2>> $TS_ERRLOG +echo "return value: $?" >> $TS_OUTPUT + +ts_finalize diff --git a/tests/ts/wipefs/wipefs b/tests/ts/wipefs/wipefs new file mode 100755 index 0000000..c79be0c --- /dev/null +++ b/tests/ts/wipefs/wipefs @@ -0,0 +1,33 @@ +#!/bin/bash + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="wipefs" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_WIPEFS" + +ts_skip_nonroot + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=50 num_parts=2 + +# remove old backups +rm -rf $HOME/wipefs-$(basename ${TS_DEVICE})-*.bak + +#remove the magic byte, back it up +$TS_CMD_WIPEFS --all --backup ${TS_DEVICE} &>/dev/null || ts_die "wipefs failed" + +#there should be just one magic string/backup file in this case +INFILE=$(ls $HOME/wipefs-$(basename ${TS_DEVICE})-*.bak) +OFFT=$(echo $INFILE | sed 's/^.*-\(.*\).bak$/\1/') +dd if=$INFILE of=$TS_DEVICE bs=1 conv=notrunc seek=$(($OFFT)) &>/dev/null + +#the bytes should be copied back, check if wipefs can recognize it +$TS_CMD_WIPEFS -a ${TS_DEVICE} > $TS_OUTDIR/out 2>/dev/null + +# check for output +[ -s $TS_OUTDIR/out ] && echo "OK" &> $TS_OUTPUT || exit 1 + +ts_finalize -- cgit v1.2.3