summaryrefslogtreecommitdiffstats
path: root/tests/ts
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 14:30:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 14:30:35 +0000
commit378c18e5f024ac5a8aef4cb40d7c9aa9633d144c (patch)
tree44dfb6ca500d32cabd450649b322a42e70a30683 /tests/ts
parentInitial commit. (diff)
downloadutil-linux-378c18e5f024ac5a8aef4cb40d7c9aa9633d144c.tar.xz
util-linux-378c18e5f024ac5a8aef4cb40d7c9aa9633d144c.zip
Adding upstream version 2.38.1.upstream/2.38.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-xtests/ts/bitops/swapbytes29
-rwxr-xr-xtests/ts/blkdiscard/offsets101
-rwxr-xr-xtests/ts/blkid/dm-err52
-rw-r--r--tests/ts/blkid/images-fs/adaptec-raid.img.xzbin0 -> 672 bytes
-rw-r--r--tests/ts/blkid/images-fs/bcache-B.img.xzbin0 -> 180 bytes
-rw-r--r--tests/ts/blkid/images-fs/bcache-C.img.xzbin0 -> 9976 bytes
-rw-r--r--tests/ts/blkid/images-fs/befs.img.xzbin0 -> 28584 bytes
-rw-r--r--tests/ts/blkid/images-fs/bfs.img.xzbin0 -> 492 bytes
-rw-r--r--tests/ts/blkid/images-fs/bluestore.img.xzbin0 -> 412 bytes
-rw-r--r--tests/ts/blkid/images-fs/cramfs.img.xzbin0 -> 144 bytes
-rw-r--r--tests/ts/blkid/images-fs/ddf-raid.img.xzbin0 -> 8140 bytes
-rw-r--r--tests/ts/blkid/images-fs/drbd-v08.img.xzbin0 -> 448 bytes
-rw-r--r--tests/ts/blkid/images-fs/drbd-v09.img.xzbin0 -> 460 bytes
-rw-r--r--tests/ts/blkid/images-fs/drbdmanage-control-volume.img.xzbin0 -> 2520 bytes
-rw-r--r--tests/ts/blkid/images-fs/erofs.img.xzbin0 -> 200 bytes
-rw-r--r--tests/ts/blkid/images-fs/exfat.img.xzbin0 -> 4620 bytes
-rw-r--r--tests/ts/blkid/images-fs/ext2.img.xzbin0 -> 384 bytes
-rw-r--r--tests/ts/blkid/images-fs/ext3.img.xzbin0 -> 1612 bytes
-rw-r--r--tests/ts/blkid/images-fs/f2fs.img.xzbin0 -> 22188 bytes
-rw-r--r--tests/ts/blkid/images-fs/fat.img.xzbin0 -> 488 bytes
-rw-r--r--tests/ts/blkid/images-fs/fat16_noheads.img.xzbin0 -> 16300 bytes
-rw-r--r--tests/ts/blkid/images-fs/fat32_cp850_O_tilde.img.xzbin0 -> 5400 bytes
-rw-r--r--tests/ts/blkid/images-fs/fat32_label_64MB.img.xzbin0 -> 10428 bytes
-rw-r--r--tests/ts/blkid/images-fs/fat32_mkdosfs_label1.img.xzbin0 -> 5400 bytes
-rw-r--r--tests/ts/blkid/images-fs/fat32_mkdosfs_label1_dosfslabel_NO_NAME.img.xzbin0 -> 5404 bytes
-rw-r--r--tests/ts/blkid/images-fs/fat32_mkdosfs_label1_dosfslabel_empty.img.xzbin0 -> 5396 bytes
-rw-r--r--tests/ts/blkid/images-fs/fat32_mkdosfs_label1_dosfslabel_label2.img.xzbin0 -> 5400 bytes
-rw-r--r--tests/ts/blkid/images-fs/fat32_mkdosfs_label1_mlabel_NO_NAME.img.xzbin0 -> 5412 bytes
-rw-r--r--tests/ts/blkid/images-fs/fat32_mkdosfs_label1_mlabel_erase.img.xzbin0 -> 5412 bytes
-rw-r--r--tests/ts/blkid/images-fs/fat32_mkdosfs_label1_xp_erase.img.xzbin0 -> 5400 bytes
-rw-r--r--tests/ts/blkid/images-fs/fat32_mkdosfs_label1_xp_label2.img.xzbin0 -> 5404 bytes
-rw-r--r--tests/ts/blkid/images-fs/fat32_mkdosfs_none.img.xzbin0 -> 5376 bytes
-rw-r--r--tests/ts/blkid/images-fs/fat32_mkdosfs_none_dosfslabel_NO_NAME.img.xzbin0 -> 5384 bytes
-rw-r--r--tests/ts/blkid/images-fs/fat32_mkdosfs_none_dosfslabel_label1.img.xzbin0 -> 5380 bytes
-rw-r--r--tests/ts/blkid/images-fs/fat32_mkdosfs_none_dosfslabel_label1_xp_label2.img.xzbin0 -> 5404 bytes
-rw-r--r--tests/ts/blkid/images-fs/fat32_mkdosfs_none_xp_label1.img.xzbin0 -> 5400 bytes
-rw-r--r--tests/ts/blkid/images-fs/fat32_mkdosfs_none_xp_label1_dosfslabel_label2.img.xzbin0 -> 5396 bytes
-rw-r--r--tests/ts/blkid/images-fs/fat32_xp_label1.img.xzbin0 -> 5936 bytes
-rw-r--r--tests/ts/blkid/images-fs/fat32_xp_none.img.xzbin0 -> 5908 bytes
-rw-r--r--tests/ts/blkid/images-fs/fat32_xp_none_dosfslabel_label1.img.xzbin0 -> 5908 bytes
-rw-r--r--tests/ts/blkid/images-fs/fat32_xp_none_mlabel_label1.img.xzbin0 -> 5660 bytes
-rw-r--r--tests/ts/blkid/images-fs/gfs2.img.xzbin0 -> 5092 bytes
-rw-r--r--tests/ts/blkid/images-fs/hfs.img.xzbin0 -> 1876 bytes
-rw-r--r--tests/ts/blkid/images-fs/hfsplus.img.xzbin0 -> 1940 bytes
-rw-r--r--tests/ts/blkid/images-fs/hpfs.img.xzbin0 -> 2172 bytes
-rw-r--r--tests/ts/blkid/images-fs/hpt37x-raid.img.xzbin0 -> 400 bytes
-rw-r--r--tests/ts/blkid/images-fs/hpt45x-raid.img.xzbin0 -> 424 bytes
-rw-r--r--tests/ts/blkid/images-fs/iso-different-iso-joliet-label.img.xzbin0 -> 712 bytes
-rw-r--r--tests/ts/blkid/images-fs/iso-joliet.img.xzbin0 -> 21884 bytes
-rw-r--r--tests/ts/blkid/images-fs/iso-multi-0-174-348-genisoimage.img.xzbin0 -> 656 bytes
-rw-r--r--tests/ts/blkid/images-fs/iso-rr-joliet.img.xzbin0 -> 22144 bytes
-rw-r--r--tests/ts/blkid/images-fs/iso-unicode-long-label.img.xzbin0 -> 616 bytes
-rw-r--r--tests/ts/blkid/images-fs/iso.img.xzbin0 -> 21656 bytes
-rw-r--r--tests/ts/blkid/images-fs/isw-raid.img.xzbin0 -> 528 bytes
-rw-r--r--tests/ts/blkid/images-fs/jbd.img.xzbin0 -> 688 bytes
-rw-r--r--tests/ts/blkid/images-fs/jfs.img.xzbin0 -> 4768 bytes
-rw-r--r--tests/ts/blkid/images-fs/jmicron-raid.img.xzbin0 -> 480 bytes
-rw-r--r--tests/ts/blkid/images-fs/lsi-raid.img.xzbin0 -> 436 bytes
-rw-r--r--tests/ts/blkid/images-fs/luks1.img.xzbin0 -> 300 bytes
-rw-r--r--tests/ts/blkid/images-fs/luks2.img.xzbin0 -> 276 bytes
-rw-r--r--tests/ts/blkid/images-fs/lvm2.img.xzbin0 -> 512 bytes
-rw-r--r--tests/ts/blkid/images-fs/mdraid.img.xzbin0 -> 1752 bytes
-rw-r--r--tests/ts/blkid/images-fs/minix-BE.img.xzbin0 -> 220 bytes
-rw-r--r--tests/ts/blkid/images-fs/minix-LE.img.xzbin0 -> 224 bytes
-rw-r--r--tests/ts/blkid/images-fs/mpool.img.xzbin0 -> 544 bytes
-rw-r--r--tests/ts/blkid/images-fs/netware.img.xzbin0 -> 244 bytes
-rw-r--r--tests/ts/blkid/images-fs/nilfs2.img.xzbin0 -> 25072 bytes
-rw-r--r--tests/ts/blkid/images-fs/ntfs.img.xzbin0 -> 89576 bytes
-rw-r--r--tests/ts/blkid/images-fs/nvidia-raid.img.xzbin0 -> 572 bytes
-rw-r--r--tests/ts/blkid/images-fs/ocfs2.img.xzbin0 -> 18644 bytes
-rw-r--r--tests/ts/blkid/images-fs/promise-raid.img.xzbin0 -> 740 bytes
-rw-r--r--tests/ts/blkid/images-fs/reiser3.img.xzbin0 -> 936 bytes
-rw-r--r--tests/ts/blkid/images-fs/reiser4.img.xzbin0 -> 904 bytes
-rw-r--r--tests/ts/blkid/images-fs/romfs.img.xzbin0 -> 384 bytes
-rw-r--r--tests/ts/blkid/images-fs/silicon-raid.img.xzbin0 -> 588 bytes
-rw-r--r--tests/ts/blkid/images-fs/small-fat32.img.xzbin0 -> 576 bytes
-rw-r--r--tests/ts/blkid/images-fs/swap0.img.xzbin0 -> 496 bytes
-rw-r--r--tests/ts/blkid/images-fs/swap1.img.xzbin0 -> 524 bytes
-rw-r--r--tests/ts/blkid/images-fs/tuxonice.img.xzbin0 -> 37032 bytes
-rw-r--r--tests/ts/blkid/images-fs/ubi.img.xzbin0 -> 380 bytes
-rw-r--r--tests/ts/blkid/images-fs/ubifs.img.xzbin0 -> 1128 bytes
-rw-r--r--tests/ts/blkid/images-fs/udf-bdr-2.60-nero.img.xzbin0 -> 1956 bytes
-rw-r--r--tests/ts/blkid/images-fs/udf-cd-mkudfiso-20100208.img.xzbin0 -> 756 bytes
-rw-r--r--tests/ts/blkid/images-fs/udf-cd-nero-6.img.xzbin0 -> 2168 bytes
-rw-r--r--tests/ts/blkid/images-fs/udf-hdd-macosx-2.60-4096.img.xzbin0 -> 2604 bytes
-rw-r--r--tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.0.0-1.img.xzbin0 -> 2728 bytes
-rw-r--r--tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.0.0-2.img.xzbin0 -> 2772 bytes
-rw-r--r--tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-1.img.xzbin0 -> 2364 bytes
-rw-r--r--tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-2.img.xzbin0 -> 2380 bytes
-rw-r--r--tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-3.img.xzbin0 -> 2376 bytes
-rw-r--r--tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-4.img.xzbin0 -> 2380 bytes
-rw-r--r--tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-5.img.xzbin0 -> 2396 bytes
-rw-r--r--tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-6.img.xzbin0 -> 2360 bytes
-rw-r--r--tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-7.img.xzbin0 -> 2720 bytes
-rw-r--r--tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-8.img.xzbin0 -> 2328 bytes
-rw-r--r--tests/ts/blkid/images-fs/udf-hdd-mkudffs-2.2.img.xzbin0 -> 2396 bytes
-rw-r--r--tests/ts/blkid/images-fs/udf-hdd-udfclient-0.7.5.img.xzbin0 -> 2292 bytes
-rw-r--r--tests/ts/blkid/images-fs/udf-hdd-udfclient-0.7.7.img.xzbin0 -> 2296 bytes
-rw-r--r--tests/ts/blkid/images-fs/udf-hdd-win7.img.xzbin0 -> 2624 bytes
-rw-r--r--tests/ts/blkid/images-fs/udf-multi-0-320-640-mkudffs.img.xzbin0 -> 1720 bytes
-rw-r--r--tests/ts/blkid/images-fs/udf-multi-0-417-834-genisoimage.img.xzbin0 -> 3176 bytes
-rw-r--r--tests/ts/blkid/images-fs/udf.img.xzbin0 -> 1884 bytes
-rw-r--r--tests/ts/blkid/images-fs/ufs.img.xzbin0 -> 1296 bytes
-rw-r--r--tests/ts/blkid/images-fs/vdo.img.xzbin0 -> 140 bytes
-rw-r--r--tests/ts/blkid/images-fs/via-raid.img.xzbin0 -> 528 bytes
-rw-r--r--tests/ts/blkid/images-fs/vmfs.img.xzbin0 -> 512 bytes
-rw-r--r--tests/ts/blkid/images-fs/vmfs_volume.img.xzbin0 -> 680 bytes
-rw-r--r--tests/ts/blkid/images-fs/xfs-log.img.xzbin0 -> 1720 bytes
-rw-r--r--tests/ts/blkid/images-fs/xfs-v5.img.xzbin0 -> 4040 bytes
-rw-r--r--tests/ts/blkid/images-fs/xfs.img.xzbin0 -> 2892 bytes
-rw-r--r--tests/ts/blkid/images-fs/zfs.img.xzbin0 -> 19904 bytes
-rw-r--r--tests/ts/blkid/images-fs/zonefs.img.xzbin0 -> 784 bytes
-rw-r--r--tests/ts/blkid/images-pt/atari-primary.img.xzbin0 -> 932 bytes
-rw-r--r--tests/ts/blkid/images-pt/atari-xgm.img.xzbin0 -> 956 bytes
-rw-r--r--tests/ts/blkid/images-pt/bsd.img.xzbin0 -> 840 bytes
-rw-r--r--tests/ts/blkid/images-pt/dos+bsd.img.xzbin0 -> 2620 bytes
-rw-r--r--tests/ts/blkid/images-pt/gpt.img.xzbin0 -> 2140 bytes
-rw-r--r--tests/ts/blkid/images-pt/sgi.img.xzbin0 -> 1724 bytes
-rw-r--r--tests/ts/blkid/images-pt/sun.img.xzbin0 -> 1748 bytes
-rwxr-xr-xtests/ts/blkid/low-probe66
-rwxr-xr-xtests/ts/blkid/lowprobe-pt44
-rwxr-xr-xtests/ts/blkid/md-raid0-whole99
-rwxr-xr-xtests/ts/blkid/md-raid1-part99
-rwxr-xr-xtests/ts/blkid/md-raid1-whole103
-rwxr-xr-xtests/ts/build-sys/config70
-rwxr-xr-xtests/ts/cal/bigyear83
-rwxr-xr-xtests/ts/cal/color80
-rwxr-xr-xtests/ts/cal/colorw79
-rwxr-xr-xtests/ts/cal/jan175345
-rwxr-xr-xtests/ts/cal/month72
-rwxr-xr-xtests/ts/cal/sep175286
-rwxr-xr-xtests/ts/cal/vertical72
-rwxr-xr-xtests/ts/cal/weekarg98
-rwxr-xr-xtests/ts/cal/weeknum57
-rwxr-xr-xtests/ts/cal/year54
-rwxr-xr-xtests/ts/chfn/gecos36
-rwxr-xr-xtests/ts/col/io86
-rwxr-xr-xtests/ts/col/multibyte40
-rw-r--r--tests/ts/col/multibyte.data1
-rwxr-xr-xtests/ts/col/newlines46
-rwxr-xr-xtests/ts/col/options43
-rw-r--r--tests/ts/colcrt/crash1bin0 -> 314 bytes
-rw-r--r--tests/ts/colcrt/crash2bin0 -> 776 bytes
-rwxr-xr-xtests/ts/colcrt/functional50
-rw-r--r--tests/ts/colcrt/hang11
-rw-r--r--tests/ts/colcrt/nasty-inputbin0 -> 545 bytes
-rwxr-xr-xtests/ts/colcrt/regressions37
-rw-r--r--tests/ts/colcrt/underlines23
-rwxr-xr-xtests/ts/colrm/rm2-228
-rwxr-xr-xtests/ts/column/columnate52
-rw-r--r--tests/ts/column/files/fivecols10
-rw-r--r--tests/ts/column/files/mountinfo41
-rw-r--r--tests/ts/column/files/onecolumn9
-rw-r--r--tests/ts/column/files/table6
-rw-r--r--tests/ts/column/files/table-empty-lines6
-rw-r--r--tests/ts/column/files/table-sep6
-rw-r--r--tests/ts/column/files/table-sep-space6
-rwxr-xr-xtests/ts/column/invalid-multibyte30
-rwxr-xr-xtests/ts/column/multi-file34
-rwxr-xr-xtests/ts/column/table127
-rw-r--r--tests/ts/cramfs/cramfs-big.imgbin0 -> 4096 bytes
-rw-r--r--tests/ts/cramfs/cramfs-little.imgbin0 -> 4096 bytes
-rwxr-xr-xtests/ts/cramfs/doubles62
-rwxr-xr-xtests/ts/cramfs/fsck-bad-header102
-rwxr-xr-xtests/ts/cramfs/fsck-endianness58
-rwxr-xr-xtests/ts/cramfs/mkfs125
-rwxr-xr-xtests/ts/cramfs/mkfs-endianness63
-rw-r--r--tests/ts/cramfs/mkfs-endianness_testdata_a8
-rw-r--r--tests/ts/cramfs/mkfs-endianness_testdata_b217
-rwxr-xr-xtests/ts/dmesg/colors28
-rwxr-xr-xtests/ts/dmesg/console-levels30
-rwxr-xr-xtests/ts/dmesg/decode28
-rwxr-xr-xtests/ts/dmesg/delta28
-rwxr-xr-xtests/ts/dmesg/facilities30
-rwxr-xr-xtests/ts/dmesg/indentation40
-rw-r--r--tests/ts/dmesg/input105
-rw-r--r--tests/ts/dmesg/newlines5
-rwxr-xr-xtests/ts/eject/umount127
-rwxr-xr-xtests/ts/fdisk/align-512-4K79
-rwxr-xr-xtests/ts/fdisk/align-512-4K-6380
-rwxr-xr-xtests/ts/fdisk/align-512-4K-md104
-rwxr-xr-xtests/ts/fdisk/align-512-51273
-rwxr-xr-xtests/ts/fdisk/align-512-512-topology79
-rwxr-xr-xtests/ts/fdisk/bsd141
-rwxr-xr-xtests/ts/fdisk/gpt107
-rwxr-xr-xtests/ts/fdisk/gpt-resize63
-rwxr-xr-xtests/ts/fdisk/id56
-rwxr-xr-xtests/ts/fdisk/mbr-dos-mode145
-rwxr-xr-xtests/ts/fdisk/mbr-nondos-mode190
-rwxr-xr-xtests/ts/fdisk/mbr-sort83
-rwxr-xr-xtests/ts/fdisk/oddinput53
-rwxr-xr-xtests/ts/fdisk/sunlabel104
-rwxr-xr-xtests/ts/fincore/count227
-rw-r--r--tests/ts/findmnt/files/mountinfo32
-rw-r--r--tests/ts/findmnt/files/mountinfo-messy29
-rw-r--r--tests/ts/findmnt/files/mountinfo-nonroot31
-rwxr-xr-xtests/ts/findmnt/filter79
-rwxr-xr-xtests/ts/findmnt/outputs49
-rwxr-xr-xtests/ts/findmnt/target35
-rwxr-xr-xtests/ts/fsck/ismounted49
-rwxr-xr-xtests/ts/fuzzers/test_fdisk_script_fuzz29
-rw-r--r--tests/ts/fuzzers/test_fdisk_script_fuzz_files/crash-8ae1c667bed4b4b864f62e78cded81d5083177eb1
-rw-r--r--tests/ts/fuzzers/test_fdisk_script_fuzz_files/crash-d216dfd17039a189c3858d78fbcf588695439b3b1
-rw-r--r--tests/ts/fuzzers/test_fdisk_script_fuzz_files/github-1015-1bin0 -> 12 bytes
-rw-r--r--tests/ts/fuzzers/test_fdisk_script_fuzz_files/github-1015-22
-rw-r--r--tests/ts/fuzzers/test_fdisk_script_fuzz_files/oss-fuzz-245892
-rw-r--r--tests/ts/fuzzers/test_fdisk_script_fuzz_files/oss-fuzz-248611
-rw-r--r--tests/ts/fuzzers/test_fdisk_script_fuzz_files/parse_line_valcommas-use-of-uninitialized-value1
-rwxr-xr-xtests/ts/fuzzers/test_last_fuzz29
-rw-r--r--tests/ts/fuzzers/test_last_fuzz_files/github-1097bin0 -> 384 bytes
-rwxr-xr-xtests/ts/fuzzers/test_mount_fuzz29
-rw-r--r--tests/ts/fuzzers/test_mount_fuzz_files/oss-fuzz-23722bin0 -> 4 bytes
-rwxr-xr-xtests/ts/getopt/basic49
-rwxr-xr-xtests/ts/getopt/options231
-rwxr-xr-xtests/ts/hardlink/options98
-rw-r--r--tests/ts/hardlink/testdir1.tar.xzbin0 -> 26468 bytes
-rw-r--r--tests/ts/hexdump/files/ascii.inbin0 -> 640 bytes
-rwxr-xr-xtests/ts/hexdump/format-strings69
-rwxr-xr-xtests/ts/hexdump/highlighting267
-rwxr-xr-xtests/ts/hwclock/systohc103
-rw-r--r--tests/ts/ipcs/functions.sh114
-rwxr-xr-xtests/ts/ipcs/headers60
-rwxr-xr-xtests/ts/ipcs/limits54
-rwxr-xr-xtests/ts/ipcs/limits237
-rwxr-xr-xtests/ts/ipcs/mk-rm-msg44
-rwxr-xr-xtests/ts/ipcs/mk-rm-sem44
-rwxr-xr-xtests/ts/ipcs/mk-rm-shm44
-rwxr-xr-xtests/ts/isosize/print-size37
-rw-r--r--tests/ts/isosize/sample.iso.gzbin0 -> 632 bytes
-rwxr-xr-xtests/ts/kill/all_processes66
-rw-r--r--tests/ts/kill/kill_functions.sh29
-rwxr-xr-xtests/ts/kill/name_to_number72
-rwxr-xr-xtests/ts/kill/options68
-rwxr-xr-xtests/ts/kill/print_pid63
-rwxr-xr-xtests/ts/kill/queue58
-rwxr-xr-xtests/ts/libfdisk/gpt65
-rwxr-xr-xtests/ts/libfdisk/mkpart66
-rwxr-xr-xtests/ts/libfdisk/mkpart-full225
-rwxr-xr-xtests/ts/libmount/context176
-rwxr-xr-xtests/ts/libmount/context-py166
-rwxr-xr-xtests/ts/libmount/context-utab133
-rwxr-xr-xtests/ts/libmount/context-utab-py138
-rwxr-xr-xtests/ts/libmount/debug30
-rw-r--r--tests/ts/libmount/files/fstab14
-rw-r--r--tests/ts/libmount/files/fstab.broken14
-rw-r--r--tests/ts/libmount/files/fstab.comment22
-rw-r--r--tests/ts/libmount/files/kernel_cmdline1
-rw-r--r--tests/ts/libmount/files/mountinfo33
-rw-r--r--tests/ts/libmount/files/mountinfo_mv32
-rw-r--r--tests/ts/libmount/files/mountinfo_nosrc7
-rw-r--r--tests/ts/libmount/files/mountinfo_re32
-rw-r--r--tests/ts/libmount/files/mountinfo_u31
-rw-r--r--tests/ts/libmount/files/mtab12
-rw-r--r--tests/ts/libmount/files/swaps4
-rwxr-xr-xtests/ts/libmount/lock41
-rwxr-xr-xtests/ts/libmount/loop143
-rwxr-xr-xtests/ts/libmount/loop-overlay65
-rwxr-xr-xtests/ts/libmount/optstr148
-rwxr-xr-xtests/ts/libmount/tabdiff31
-rwxr-xr-xtests/ts/libmount/tabfiles85
-rwxr-xr-xtests/ts/libmount/tabfiles-py75
-rwxr-xr-xtests/ts/libmount/tabfiles-tags86
-rwxr-xr-xtests/ts/libmount/tabfiles-tags-py90
-rwxr-xr-xtests/ts/libmount/update112
-rwxr-xr-xtests/ts/libmount/update-py32
-rwxr-xr-xtests/ts/libmount/utils84
-rw-r--r--tests/ts/libsmartcols/files/col-hidden3
-rw-r--r--tests/ts/libsmartcols/files/col-id3
-rw-r--r--tests/ts/libsmartcols/files/col-name3
-rw-r--r--tests/ts/libsmartcols/files/col-noextremes3
-rw-r--r--tests/ts/libsmartcols/files/col-number3
-rw-r--r--tests/ts/libsmartcols/files/col-parent3
-rw-r--r--tests/ts/libsmartcols/files/col-strict3
-rw-r--r--tests/ts/libsmartcols/files/col-string3
-rw-r--r--tests/ts/libsmartcols/files/col-tree3
-rw-r--r--tests/ts/libsmartcols/files/col-trunc3
-rw-r--r--tests/ts/libsmartcols/files/col-wrap3
-rw-r--r--tests/ts/libsmartcols/files/col-wrapnl3
-rw-r--r--tests/ts/libsmartcols/files/data-id10
-rw-r--r--tests/ts/libsmartcols/files/data-number10
-rw-r--r--tests/ts/libsmartcols/files/data-number-tiny10
-rw-r--r--tests/ts/libsmartcols/files/data-parent10
-rw-r--r--tests/ts/libsmartcols/files/data-string10
-rw-r--r--tests/ts/libsmartcols/files/data-string-empty10
-rw-r--r--tests/ts/libsmartcols/files/data-string-extreme10
-rw-r--r--tests/ts/libsmartcols/files/data-string-long10
-rw-r--r--tests/ts/libsmartcols/files/data-string-nl10
-rwxr-xr-xtests/ts/libsmartcols/fromfile286
-rwxr-xr-xtests/ts/libsmartcols/title28
-rwxr-xr-xtests/ts/logger/errors116
-rwxr-xr-xtests/ts/logger/formats85
-rwxr-xr-xtests/ts/logger/journald35
-rwxr-xr-xtests/ts/logger/options82
-rwxr-xr-xtests/ts/login/islocal29
-rw-r--r--tests/ts/login/islocal.data10
-rwxr-xr-xtests/ts/login/logindefs26
-rw-r--r--tests/ts/login/logindefs.data16
-rwxr-xr-xtests/ts/look/separator41
-rw-r--r--tests/ts/look/words3
-rwxr-xr-xtests/ts/losetup/losetup86
-rwxr-xr-xtests/ts/losetup/losetup-blkdev81
-rwxr-xr-xtests/ts/losetup/losetup-loop247
-rw-r--r--tests/ts/losetup/losetup_functions.sh7
-rw-r--r--tests/ts/lsblk/README19
-rw-r--r--tests/ts/lsblk/dumps/simple-lvm.tar.xzbin0 -> 14216 bytes
-rw-r--r--tests/ts/lsblk/dumps/simple-nvme.tar.xzbin0 -> 10292 bytes
-rwxr-xr-xtests/ts/lsblk/lsblk56
-rw-r--r--tests/ts/lsblk/mk-input.sh124
-rw-r--r--tests/ts/lscpu/dumps/armv7.tar.gzbin0 -> 3163 bytes
-rw-r--r--tests/ts/lscpu/dumps/ppc-qemu.tar.gzbin0 -> 2014 bytes
-rw-r--r--tests/ts/lscpu/dumps/ppc64-POWER7-64cpu.tar.gzbin0 -> 56867 bytes
-rw-r--r--tests/ts/lscpu/dumps/ppc64-POWER7.tar.gzbin0 -> 14350 bytes
-rw-r--r--tests/ts/lscpu/dumps/rv64-linux.tar.gzbin0 -> 4215 bytes
-rw-r--r--tests/ts/lscpu/dumps/s390-kvm.tar.gzbin0 -> 2275 bytes
-rw-r--r--tests/ts/lscpu/dumps/s390-lpar-drawer.tar.gzbin0 -> 18131 bytes
-rw-r--r--tests/ts/lscpu/dumps/s390-lpar.tar.gzbin0 -> 6611 bytes
-rw-r--r--tests/ts/lscpu/dumps/s390-nested-virt.tar.gzbin0 -> 7199 bytes
-rw-r--r--tests/ts/lscpu/dumps/s390-zvm.tar.gzbin0 -> 2582 bytes
-rw-r--r--tests/ts/lscpu/dumps/sparc64.tar.gzbin0 -> 2756 bytes
-rw-r--r--tests/ts/lscpu/dumps/vbox-win.tar.gzbin0 -> 15769 bytes
-rw-r--r--tests/ts/lscpu/dumps/vmware_fpe.tar.gzbin0 -> 59743 bytes
-rw-r--r--tests/ts/lscpu/dumps/x86_64-64cpu.tar.gzbin0 -> 153140 bytes
-rw-r--r--tests/ts/lscpu/dumps/x86_64-dell_e4310.tar.gzbin0 -> 12933 bytes
-rw-r--r--tests/ts/lscpu/dumps/x86_64-epyc_7451.tar.gzbin0 -> 361027 bytes
-rwxr-xr-xtests/ts/lscpu/lscpu59
-rw-r--r--tests/ts/lscpu/mk-input.sh43
-rwxr-xr-xtests/ts/lsfd/column-kthread41
-rw-r--r--tests/ts/lsfd/lsfd-functions.bash53
-rwxr-xr-xtests/ts/lsfd/mkfds-directory87
-rwxr-xr-xtests/ts/lsfd/mkfds-pipe-no-fork73
-rwxr-xr-xtests/ts/lsfd/mkfds-ro-block-device75
-rwxr-xr-xtests/ts/lsfd/mkfds-ro-regular-file78
-rwxr-xr-xtests/ts/lsfd/mkfds-rw-character-device50
-rwxr-xr-xtests/ts/lsfd/mkfds-socketpair48
-rwxr-xr-xtests/ts/lsfd/mkfds-symlink45
-rwxr-xr-xtests/ts/lsfd/option-filter-broken-exp36
-rwxr-xr-xtests/ts/lsfd/option-pid80
-rwxr-xr-xtests/ts/lsfd/option-summary62
-rw-r--r--tests/ts/lsmem/dumps/s390-zvm-6g.tar.bz2bin0 -> 2459 bytes
-rw-r--r--tests/ts/lsmem/dumps/x86_64-16g.tar.bz2bin0 -> 8660 bytes
-rwxr-xr-xtests/ts/lsmem/lsmem60
-rwxr-xr-xtests/ts/lsmem/mk-input.sh22
-rwxr-xr-xtests/ts/lsns/ioctl_ns113
-rwxr-xr-xtests/ts/lsns/netnsid96
-rwxr-xr-xtests/ts/lsns/nsfs94
-rw-r--r--tests/ts/md5/data7
-rwxr-xr-xtests/ts/md5/md531
-rw-r--r--tests/ts/minix/broken-rootbin0 -> 5120 bytes
-rw-r--r--tests/ts/minix/debian.bug.773892bin0 -> 16384 bytes
-rwxr-xr-xtests/ts/minix/fsck56
-rwxr-xr-xtests/ts/minix/fsck-images90
-rwxr-xr-xtests/ts/minix/mkfs57
-rwxr-xr-xtests/ts/misc/fallocate39
-rwxr-xr-xtests/ts/misc/flock106
-rwxr-xr-xtests/ts/misc/ionice30
-rwxr-xr-xtests/ts/misc/line65
-rwxr-xr-xtests/ts/misc/mbsencode85
-rwxr-xr-xtests/ts/misc/mcookie28
-rwxr-xr-xtests/ts/misc/mountpoint36
-rwxr-xr-xtests/ts/misc/rev31
-rwxr-xr-xtests/ts/misc/setarch92
-rwxr-xr-xtests/ts/misc/setsid25
-rwxr-xr-xtests/ts/misc/strtosize62
-rwxr-xr-xtests/ts/misc/swaplabel69
-rwxr-xr-xtests/ts/misc/whereis50
-rwxr-xr-xtests/ts/more/regexp27
-rwxr-xr-xtests/ts/more/squeeze26
-rwxr-xr-xtests/ts/mount/devname61
-rwxr-xr-xtests/ts/mount/dm-verity72
-rwxr-xr-xtests/ts/mount/fslists90
-rwxr-xr-xtests/ts/mount/fstab-all145
-rwxr-xr-xtests/ts/mount/fstab-broken80
-rwxr-xr-xtests/ts/mount/fstab-btrfs141
-rwxr-xr-xtests/ts/mount/fstab-devname58
-rwxr-xr-xtests/ts/mount/fstab-devname2label52
-rwxr-xr-xtests/ts/mount/fstab-devname2uuid50
-rwxr-xr-xtests/ts/mount/fstab-label63
-rwxr-xr-xtests/ts/mount/fstab-label2devname60
-rwxr-xr-xtests/ts/mount/fstab-label2uuid63
-rwxr-xr-xtests/ts/mount/fstab-loop56
-rwxr-xr-xtests/ts/mount/fstab-none37
-rwxr-xr-xtests/ts/mount/fstab-symlink71
-rwxr-xr-xtests/ts/mount/fstab-uuid64
-rwxr-xr-xtests/ts/mount/fstab-uuid2devname59
-rwxr-xr-xtests/ts/mount/fstab-uuid2label61
-rwxr-xr-xtests/ts/mount/label56
-rwxr-xr-xtests/ts/mount/move94
-rwxr-xr-xtests/ts/mount/regfile41
-rwxr-xr-xtests/ts/mount/remount62
-rwxr-xr-xtests/ts/mount/rlimit93
-rwxr-xr-xtests/ts/mount/shared-subtree87
-rwxr-xr-xtests/ts/mount/special43
-rwxr-xr-xtests/ts/mount/umount-alltargets125
-rwxr-xr-xtests/ts/mount/umount-recursive97
-rwxr-xr-xtests/ts/mount/uuid53
-rwxr-xr-xtests/ts/namei/logic35
-rwxr-xr-xtests/ts/partx/partx186
-rwxr-xr-xtests/ts/partx/partx-image43
-rwxr-xr-xtests/ts/paths/built-in32
-rwxr-xr-xtests/ts/rename/basic71
-rwxr-xr-xtests/ts/rename/exit_codes42
-rwxr-xr-xtests/ts/rename/overwrite31
-rwxr-xr-xtests/ts/rename/subdir68
-rwxr-xr-xtests/ts/rename/symlink57
-rwxr-xr-xtests/ts/schedutils/chrt110
-rwxr-xr-xtests/ts/schedutils/chrt-non-root61
-rwxr-xr-xtests/ts/schedutils/cpuset59
-rwxr-xr-xtests/ts/script/buffering-race27
-rwxr-xr-xtests/ts/script/options66
-rwxr-xr-xtests/ts/script/race48
-rwxr-xr-xtests/ts/script/replay98
-rwxr-xr-xtests/ts/sfdisk/dos276
-rwxr-xr-xtests/ts/sfdisk/dump87
-rw-r--r--tests/ts/sfdisk/files/dump-gaps7
-rw-r--r--tests/ts/sfdisk/files/dump-old7
-rwxr-xr-xtests/ts/sfdisk/gpt206
-rwxr-xr-xtests/ts/sfdisk/movedata75
-rwxr-xr-xtests/ts/sfdisk/resize154
-rwxr-xr-xtests/ts/sfdisk/script157
-rwxr-xr-xtests/ts/sfdisk/wipe104
-rw-r--r--tests/ts/sha1/data7
-rwxr-xr-xtests/ts/sha1/sha131
-rwxr-xr-xtests/ts/swapon/devname50
-rwxr-xr-xtests/ts/swapon/fixpgsz49
-rwxr-xr-xtests/ts/swapon/fixsig53
-rwxr-xr-xtests/ts/swapon/label52
-rwxr-xr-xtests/ts/swapon/uuid50
-rwxr-xr-xtests/ts/ul/basic42
-rw-r--r--tests/ts/ul/basic.input95
-rw-r--r--tests/ts/ul/filter.input9
-rwxr-xr-xtests/ts/ul/ul29
-rwxr-xr-xtests/ts/utmp/last93
-rwxr-xr-xtests/ts/utmp/last-ipv666
-rw-r--r--tests/ts/utmp/subsec3
-rw-r--r--tests/ts/utmp/txt-a19
-rw-r--r--tests/ts/utmp/txt-a-old19
-rw-r--r--tests/ts/utmp/txt-b10
-rw-r--r--tests/ts/utmp/txt-b-old10
-rw-r--r--tests/ts/utmp/txt-ipv62
-rw-r--r--tests/ts/utmp/txt-ipv6-old2
-rw-r--r--tests/ts/utmp/utmp_functions.sh18
-rwxr-xr-xtests/ts/utmp/utmpdump-circle48
-rwxr-xr-xtests/ts/utmp/utmpdump-subsecond32
-rwxr-xr-xtests/ts/utmp/utmpdump-tobin32
-rwxr-xr-xtests/ts/utmp/utmpdump-tobin-ipv632
-rwxr-xr-xtests/ts/utmp/utmpdump-totxt28
-rwxr-xr-xtests/ts/utmp/utmpdump-totxt-ipv628
-rw-r--r--tests/ts/utmp/wtmp-a.BEbin0 -> 7296 bytes
-rw-r--r--tests/ts/utmp/wtmp-a.LEbin0 -> 7296 bytes
-rw-r--r--tests/ts/utmp/wtmp-b.BEbin0 -> 3840 bytes
-rw-r--r--tests/ts/utmp/wtmp-b.LEbin0 -> 3840 bytes
-rw-r--r--tests/ts/utmp/wtmp-ipv6.BEbin0 -> 768 bytes
-rw-r--r--tests/ts/utmp/wtmp-ipv6.LEbin0 -> 768 bytes
-rwxr-xr-xtests/ts/uuid/namespace29
-rwxr-xr-xtests/ts/uuid/oids33
-rwxr-xr-xtests/ts/uuid/uuid_parser26
-rwxr-xr-xtests/ts/uuid/uuidd59
-rwxr-xr-xtests/ts/uuid/uuidgen45
-rwxr-xr-xtests/ts/uuid/uuidparse61
-rwxr-xr-xtests/ts/wipefs/wipefs33
460 files changed, 18012 insertions, 0 deletions
diff --git a/tests/ts/bitops/swapbytes b/tests/ts/bitops/swapbytes
new file mode 100755
index 0000000..798ad53
--- /dev/null
+++ b/tests/ts/bitops/swapbytes
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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..5e724d5
--- /dev/null
+++ b/tests/ts/blkdiscard/offsets
@@ -0,0 +1,101 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2014 Federico Simoncelli <fsimonce@redhat.com>
+#
+# 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/dm-err b/tests/ts/blkid/dm-err
new file mode 100755
index 0000000..fb6c179
--- /dev/null
+++ b/tests/ts/blkid/dm-err
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2016 Karel Zak <kzak@redhat.com>
+#
+# 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/adaptec-raid.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/bcache-B.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/bcache-C.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/befs.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/bfs.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/bluestore.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/cramfs.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/ddf-raid.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/drbd-v08.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/drbd-v09.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/drbdmanage-control-volume.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/erofs.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/exfat.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/ext2.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/ext3.img.xz
Binary files 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..f7f9dde
--- /dev/null
+++ b/tests/ts/blkid/images-fs/f2fs.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/fat.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/fat16_noheads.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/fat32_cp850_O_tilde.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/fat32_label_64MB.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/fat32_mkdosfs_label1.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/fat32_mkdosfs_label1_dosfslabel_NO_NAME.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/fat32_mkdosfs_label1_dosfslabel_empty.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/fat32_mkdosfs_label1_dosfslabel_label2.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/fat32_mkdosfs_label1_mlabel_NO_NAME.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/fat32_mkdosfs_label1_mlabel_erase.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/fat32_mkdosfs_label1_xp_erase.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/fat32_mkdosfs_label1_xp_label2.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/fat32_mkdosfs_none.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/fat32_mkdosfs_none_dosfslabel_NO_NAME.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/fat32_mkdosfs_none_dosfslabel_label1.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/fat32_mkdosfs_none_dosfslabel_label1_xp_label2.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/fat32_mkdosfs_none_xp_label1.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/fat32_mkdosfs_none_xp_label1_dosfslabel_label2.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/fat32_xp_label1.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/fat32_xp_none.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/fat32_xp_none_dosfslabel_label1.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/fat32_xp_none_mlabel_label1.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/gfs2.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/hfs.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/hfsplus.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/hpfs.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/hpt37x-raid.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/hpt45x-raid.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/iso-different-iso-joliet-label.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/iso-joliet.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/iso-multi-0-174-348-genisoimage.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/iso-rr-joliet.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/iso-unicode-long-label.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/iso.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/isw-raid.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/jbd.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/jfs.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/jmicron-raid.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/lsi-raid.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/luks1.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/luks2.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/lvm2.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/mdraid.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/minix-BE.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/minix-LE.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/mpool.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/netware.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/nilfs2.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/ntfs.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/nvidia-raid.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/ocfs2.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/promise-raid.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/reiser3.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/reiser4.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/romfs.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/silicon-raid.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/small-fat32.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/swap0.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/swap1.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/tuxonice.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/ubi.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/ubifs.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/udf-bdr-2.60-nero.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/udf-cd-mkudfiso-20100208.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/udf-cd-nero-6.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/udf-hdd-macosx-2.60-4096.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.0.0-1.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.0.0-2.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-1.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-2.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-3.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-4.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-5.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-6.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-7.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-8.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-2.2.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/udf-hdd-udfclient-0.7.5.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/udf-hdd-udfclient-0.7.7.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/udf-hdd-win7.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/udf-multi-0-320-640-mkudffs.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/udf-multi-0-417-834-genisoimage.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/udf.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/ufs.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/vdo.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/via-raid.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/vmfs.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/vmfs_volume.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/xfs-log.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/xfs-v5.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/xfs.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/zfs.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-fs/zonefs.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-pt/atari-primary.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-pt/atari-xgm.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-pt/bsd.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-pt/dos+bsd.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-pt/gpt.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-pt/sgi.img.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/blkid/images-pt/sun.img.xz
Binary files differ
diff --git a/tests/ts/blkid/low-probe b/tests/ts/blkid/low-probe
new file mode 100755
index 0000000..3847653
--- /dev/null
+++ b/tests/ts/blkid/low-probe
@@ -0,0 +1,66 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2009 Karel Zak <kzak@redhat.com>
+#
+# 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
+ # -<numbers>- 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..2177de9
--- /dev/null
+++ b/tests/ts/blkid/lowprobe-pt
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2009 Karel Zak <kzak@redhat.com>
+#
+# 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..c37f1d6
--- /dev/null
+++ b/tests/ts/blkid/md-raid0-whole
@@ -0,0 +1,99 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+#
+# 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 <<EOF
+o
+w
+q
+EOF
+
+ts_log "Create partitions on RAID device"
+$TS_CMD_FDISK ${MD_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF
+n
+p
+1
+
++10M
+n
+p
+2
+
+
+p
+w
+q
+EOF
+
+udevadm settle
+
+ts_log "Probe first RAID member"
+$TS_CMD_BLKID -p -o udev $DEVICE1 2>> $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..ea61519
--- /dev/null
+++ b/tests/ts/blkid/md-raid1-part
@@ -0,0 +1,99 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+#
+# 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 <<EOF
+o
+n
+p
+1
+
++25M
+n
+p
+2
+
+
+p
+w
+q
+EOF
+
+# replace generated ID with something stable
+$TS_CMD_FDISK ${TS_DEVICE} &> /dev/null <<EOF
+x
+i
+0x1
+r
+w
+q
+EOF
+
+udevadm settle
+MD_DEVNAME=md8
+MD_DEVICE=/dev/${MD_DEVNAME}
+
+ts_lock "md"
+
+ts_log "Create RAID1 device"
+mdadm -q -S ${MD_DEVICE} &> /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..d121354
--- /dev/null
+++ b/tests/ts/blkid/md-raid1-whole
@@ -0,0 +1,103 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+#
+# 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 <<EOF
+o
+w
+q
+EOF
+
+ts_log "Create partitions on RAID device"
+$TS_CMD_FDISK ${MD_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF
+n
+p
+1
+
++10M
+n
+p
+2
+
++10M
+p
+w
+q
+EOF
+
+udevadm settle
+
+ts_log "Probe first RAID member"
+$TS_CMD_BLKID -p -o udev $DEVICE1 2>> $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<removed>@' $TS_OUTPUT
+# remove generated UUIDs
+sed -i -e 's/ID_FS_UUID.*//g' $TS_OUTPUT
+
+ts_finalize
diff --git a/tests/ts/build-sys/config b/tests/ts/build-sys/config
new file mode 100755
index 0000000..1adefd3
--- /dev/null
+++ b/tests/ts/build-sys/config
@@ -0,0 +1,70 @@
+#!/bin/bash
+
+# Copyright (C) 2011 Karel Zak <kzak@redhat.com>
+
+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
+
+for conf in $config_gen_dir/config-gen.d/*.conf; do
+ 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
+done
+
+ts_finalize
diff --git a/tests/ts/cal/bigyear b/tests/ts/cal/bigyear
new file mode 100755
index 0000000..34139fd
--- /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..2e89412
--- /dev/null
+++ b/tests/ts/cal/color
@@ -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"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_CAL"
+
+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_finalize
diff --git a/tests/ts/cal/colorw b/tests/ts/cal/colorw
new file mode 100755
index 0000000..9be3998
--- /dev/null
+++ b/tests/ts/cal/colorw
@@ -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="color with week numbers"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_CAL"
+
+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/jan1753 b/tests/ts/cal/jan1753
new file mode 100755
index 0000000..1be3db3
--- /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..62fd1f9
--- /dev/null
+++ b/tests/ts/cal/month
@@ -0,0 +1,72 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007-2018 Karel Zak <kzak@redhat.com>
+#
+# 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..41c30d4
--- /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..f92f042
--- /dev/null
+++ b/tests/ts/cal/vertical
@@ -0,0 +1,72 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007-2018 Karel Zak <kzak@redhat.com>
+#
+# 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..f51644a
--- /dev/null
+++ b/tests/ts/cal/weekarg
@@ -0,0 +1,98 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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"
+
+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..f2aec94
--- /dev/null
+++ b/tests/ts/cal/weeknum
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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..6a8c42e
--- /dev/null
+++ b/tests/ts/cal/year
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007-2018 Karel Zak <kzak@redhat.com>
+#
+# 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..aad27d4
--- /dev/null
+++ b/tests/ts/chfn/gecos
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2019 Radka Skvarilova <rskvaril@redhat.com>
+#
+# 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 "$*"
+
+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..c7e0d09
--- /dev/null
+++ b/tests/ts/col/io
@@ -0,0 +1,86 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2020 Sami Kerola <kerolasa@iki.fi>
+#
+# 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 "<B\x10\x0E\t\v\x100" | ts_run $TS_CMD_COL >> $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..543608c
--- /dev/null
+++ b/tests/ts/col/multibyte
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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..209de0b
--- /dev/null
+++ b/tests/ts/col/newlines
@@ -0,0 +1,46 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2020 Sami Kerola <kerolasa@iki.fi>
+#
+# 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..5031220
--- /dev/null
+++ b/tests/ts/col/options
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2020 Sami Kerola <kerolasa@iki.fi>
+#
+# 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
--- /dev/null
+++ b/tests/ts/colcrt/crash1
Binary files differ
diff --git a/tests/ts/colcrt/crash2 b/tests/ts/colcrt/crash2
new file mode 100644
index 0000000..0843cb6
--- /dev/null
+++ b/tests/ts/colcrt/crash2
Binary files differ
diff --git a/tests/ts/colcrt/functional b/tests/ts/colcrt/functional
new file mode 100755
index 0000000..3e8cc38
--- /dev/null
+++ b/tests/ts/colcrt/functional
@@ -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="functional"
+
+export LC_CTYPE='C'
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+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
--- /dev/null
+++ b/tests/ts/colcrt/nasty-input
Binary files differ
diff --git a/tests/ts/colcrt/regressions b/tests/ts/colcrt/regressions
new file mode 100755
index 0000000..130ad9a
--- /dev/null
+++ b/tests/ts/colcrt/regressions
@@ -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="regressions"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+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..061f5b8
--- /dev/null
+++ b/tests/ts/colrm/rm2-2
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2011 Sami Kerola <kerolasa@iki.fi>
+#
+# 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..ebeb0c4
--- /dev/null
+++ b/tests/ts/column/columnate
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2011 Sami Kerola <kerolasa@iki.fi>
+#
+# 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..f3d643e
--- /dev/null
+++ b/tests/ts/column/invalid-multibyte
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2014 Sami Kerola <kerolasa@iki.fi>
+#
+# 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..fa2b2cb
--- /dev/null
+++ b/tests/ts/column/multi-file
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2011 Sami Kerola <kerolasa@iki.fi>
+# 2011 Karel Zak <kzak@redhat.com>
+#
+# 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..0ef5388
--- /dev/null
+++ b/tests/ts/column/table
@@ -0,0 +1,127 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2011 Sami Kerola <kerolasa@iki.fi>
+#
+# 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_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_finalize
diff --git a/tests/ts/cramfs/cramfs-big.img b/tests/ts/cramfs/cramfs-big.img
new file mode 100644
index 0000000..2ea516e
--- /dev/null
+++ b/tests/ts/cramfs/cramfs-big.img
Binary files differ
diff --git a/tests/ts/cramfs/cramfs-little.img b/tests/ts/cramfs/cramfs-little.img
new file mode 100644
index 0000000..a1dfab5
--- /dev/null
+++ b/tests/ts/cramfs/cramfs-little.img
Binary files differ
diff --git a/tests/ts/cramfs/doubles b/tests/ts/cramfs/doubles
new file mode 100755
index 0000000..eb2c7fa
--- /dev/null
+++ b/tests/ts/cramfs/doubles
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2011 Karel Zak <kzak@redhat.com>
+#
+# 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..95d8274
--- /dev/null
+++ b/tests/ts/cramfs/fsck-bad-header
@@ -0,0 +1,102 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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..bcfb46c
--- /dev/null
+++ b/tests/ts/cramfs/fsck-endianness
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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..90630eb
--- /dev/null
+++ b/tests/ts/cramfs/mkfs
@@ -0,0 +1,125 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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..91d4765
--- /dev/null
+++ b/tests/ts/cramfs/mkfs-endianness
@@ -0,0 +1,63 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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..156cb1e
--- /dev/null
+++ b/tests/ts/dmesg/colors
@@ -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="colors"
+
+. $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 --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..f6a64e3
--- /dev/null
+++ b/tests/ts/dmesg/console-levels
@@ -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="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_finalize
diff --git a/tests/ts/dmesg/decode b/tests/ts/dmesg/decode
new file mode 100755
index 0000000..ada2eac
--- /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..a0983cc
--- /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..d004a4f
--- /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..0e026d0
--- /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/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..a6d1f25
--- /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 <<EOF
+o
+n
+p
+1
+
++50M
+n
+p
+2
+
+
+p
+w
+EOF
+ udevadm settle
+ mkfs.ext2 -q ${dev}1
+ mkfs.ext2 -q ${dev}2
+ udevadm settle
+}
+
+function deinit_device {
+ ts_scsi_debug_rmmod
+}
+
+if [ "$TS_USE_SYSTEM_COMMANDS" != "yes" ]; then
+ # As the eject binary execl()s an uninstrumented /bin/umount binary, we need
+ # to explicitly $LD_PRELOAD the ASan's runtime DSO, otherwise ASan will complain.
+ # Since all three utilities used by this test (eject, fdisk, mount) are just
+ # libtool wrappers, let's check the kill binary instead, which should have
+ # the needed DSO information.
+ ASAN_RT_PATH="$(ts_get_asan_rt_path "$TS_CMD_KILL")"
+ [ -n "$ASAN_RT_PATH" ] && export LD_PRELOAD="$ASAN_RT_PATH:$LD_PRELOAD"
+fi
+
+ts_init_subtest "by-disk"
+init_device
+$TS_CMD_EJECT --force $TS_DEVICE && ts_log "Success"
+deinit_device
+ts_finalize_subtest
+
+
+ts_init_subtest "by-disk-mounted"
+init_device
+mkfs.ext2 -q -F $TS_DEVICE
+udevadm settle
+mkdir -p $TS_MOUNTPOINT
+$TS_CMD_MOUNT $TS_DEVICE $TS_MOUNTPOINT
+udevadm settle
+$TS_CMD_EJECT --force $TS_DEVICE && ts_log "Success"
+deinit_device
+ts_finalize_subtest
+
+
+ts_init_subtest "by-disk-mounted-partition"
+init_device
+init_partitions $TS_DEVICE
+mkdir -p ${TS_MOUNTPOINT}1
+mkdir -p ${TS_MOUNTPOINT}2
+$TS_CMD_MOUNT ${TS_DEVICE}1 ${TS_MOUNTPOINT}1
+$TS_CMD_MOUNT ${TS_DEVICE}2 ${TS_MOUNTPOINT}2
+udevadm settle
+$TS_CMD_EJECT --force $TS_DEVICE && ts_log "Success"
+deinit_device
+ts_finalize_subtest
+
+
+ts_init_subtest "by-partition"
+init_device
+init_partitions $TS_DEVICE
+$TS_CMD_EJECT --force ${TS_DEVICE}1 && ts_log "Success"
+deinit_device
+ts_finalize_subtest
+
+
+ts_init_subtest "by-partition-mounted"
+init_device
+init_partitions $TS_DEVICE
+mkdir -p ${TS_MOUNTPOINT}1
+mkdir -p ${TS_MOUNTPOINT}2
+$TS_CMD_MOUNT ${TS_DEVICE}1 ${TS_MOUNTPOINT}1
+$TS_CMD_MOUNT ${TS_DEVICE}2 ${TS_MOUNTPOINT}2
+udevadm settle
+$TS_CMD_EJECT --force ${TS_DEVICE}1 && ts_log "Success"
+deinit_device
+ts_finalize_subtest
+
+
+ts_finalize
diff --git a/tests/ts/fdisk/align-512-4K b/tests/ts/fdisk/align-512-4K
new file mode 100755
index 0000000..88e99cb
--- /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 <<EOF
+o
+n
+p
+1
+
++10M
+n
+p
+2
+
++10M
+n
+p
+3
+
++10M
+n
+e
+
+
+n
+
++5M
+n
+
++5M
+n
+
+
+p
+w
+q
+EOF
+
+udevadm settle
+ts_log "Alignment offsets:"
+cat /sys/block/${DEVNAME}/${DEVNAME}{1,2,3,4,5,6,7}/alignment_offset >> $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..325a5d4
--- /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 <<EOF
+o
+n
+p
+1
+
++10M
+n
+p
+2
+
++10M
+n
+p
+3
+
++10M
+n
+e
+
+
+n
+
++5M
+n
+
++5M
+n
+
+
+p
+w
+q
+EOF
+
+udevadm settle
+ts_log "Alignment offsets:"
+cat /sys/block/${DEVNAME}/${DEVNAME}{1,2,3,4,5,6,7}/alignment_offset >> $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..0f40405
--- /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 <<EOF
+o
+n
+p
+1
+
++49150
+n
+p
+2
+
++49150
+p
+w
+q
+EOF
+
+udevadm settle
+ts_log "Alignment offsets:"
+cat /sys/block/${DEVNAME}/${DEVNAME}{1,2}/alignment_offset >> $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 <<EOF
+n
+p
+1
+
++10M
+n
+p
+2
+
++10M
+p
+w
+q
+EOF
+
+udevadm settle
+ts_log "Alignment offsets (MD):"
+cat /sys/block/${MD_DEVNAME}/${MD_DEVNAME}p{1,2}/alignment_offset >> $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..cda1321
--- /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 <<EOF
+o
+n
+p
+1
+
++10M
+n
+p
+2
+
++10M
+n
+p
+3
+
++10M
+n
+e
+
+
+n
+
++5M
+n
+
++5M
+n
+
+
+p
+q
+EOF
+
+ts_fdisk_clean $DEVICE
+
+ts_finalize
diff --git a/tests/ts/fdisk/align-512-512-topology b/tests/ts/fdisk/align-512-512-topology
new file mode 100755
index 0000000..3ccb1a9
--- /dev/null
+++ b/tests/ts/fdisk/align-512-512-topology
@@ -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/512 +topology"
+
+. $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
+DEVNAME=$(basename $TS_DEVICE)
+
+ts_log "Create partitions"
+$TS_CMD_FDISK --noauto-pt ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF
+o
+n
+p
+1
+
++10M
+n
+p
+2
+
++10M
+n
+p
+3
+
++10M
+n
+e
+
+
+n
+
++5M
+n
+
++5M
+n
+
+
+p
+w
+q
+EOF
+
+udevadm settle
+ts_log "Alignment offsets:"
+cat /sys/block/${DEVNAME}/${DEVNAME}{1,2,3,4,5,6,7}/alignment_offset >> $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..9ce2723
--- /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 <kzak@redhat.com>
+#
+# 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..18e4fab
--- /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 <kzak@redhat.com>
+#
+# 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..a5d248a
--- /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..c52e44b
--- /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..cc27429
--- /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..d366f28
--- /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..6a6d3b8
--- /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..8c23abb
--- /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..4c0d375
--- /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..fb35b0f
--- /dev/null
+++ b/tests/ts/fincore/count
@@ -0,0 +1,227 @@
+#!/bin/bash
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="count file contents in core"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_HELPER_SYSINFO"
+
+# Send patch if you know how to keep it portable and robust. Thanks.
+TS_KNOWN_FAIL="yes"
+
+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..b92768a
--- /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..3a4422b
--- /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..ada7a2e
--- /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..ffe1a1d
--- /dev/null
+++ b/tests/ts/fsck/ismounted
@@ -0,0 +1,49 @@
+#!/bin/bash
+#
+# Copyright (C) 2009 Karel Zak <kzak@redhat.com>
+#
+# 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_fdisk_script_fuzz b/tests/ts/fuzzers/test_fdisk_script_fuzz
new file mode 100755
index 0000000..708d372
--- /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
--- /dev/null
+++ b/tests/ts/fuzzers/test_fdisk_script_fuzz_files/github-1015-1
Binary files 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..5d92d0d
--- /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
--- /dev/null
+++ b/tests/ts/fuzzers/test_last_fuzz_files/github-1097
Binary files differ
diff --git a/tests/ts/fuzzers/test_mount_fuzz b/tests/ts/fuzzers/test_mount_fuzz
new file mode 100755
index 0000000..c934907
--- /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
--- /dev/null
+++ b/tests/ts/fuzzers/test_mount_fuzz_files/oss-fuzz-23722
Binary files differ
diff --git a/tests/ts/getopt/basic b/tests/ts/getopt/basic
new file mode 100755
index 0000000..5bd1f50
--- /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..eedcbbc
--- /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..fc1a0d6
--- /dev/null
+++ b/tests/ts/hardlink/options
@@ -0,0 +1,98 @@
+#!/bin/bash
+#
+# Copyright (C) 2018 Ruediger Meier <ruediger.meier@ga-group.nl>
+#
+# 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
+}
+
+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" | \
+ sed 's/^Duration:.*/Duration: [Redacted]/' >> $TS_OUTPUT 2>> $TS_ERRLOG
+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" | \
+ sed 's/^Duration:.*/Duration: [Redacted]/' >> $TS_OUTPUT 2>> $TS_ERRLOG
+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
--- /dev/null
+++ b/tests/ts/hardlink/testdir1.tar.xz
Binary files differ
diff --git a/tests/ts/hexdump/files/ascii.in b/tests/ts/hexdump/files/ascii.in
new file mode 100644
index 0000000..4c2598b
--- /dev/null
+++ b/tests/ts/hexdump/files/ascii.in
Binary files differ
diff --git a/tests/ts/hexdump/format-strings b/tests/ts/hexdump/format-strings
new file mode 100755
index 0000000..3901b36
--- /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..e577579
--- /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/systohc b/tests/ts/hwclock/systohc
new file mode 100755
index 0000000..228ef7c
--- /dev/null
+++ b/tests/ts/hwclock/systohc
@@ -0,0 +1,103 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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 <kzak@redhat.com>
+#
+# 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="<was_number>"
+ }
+ print $0 >> text
+ }'
+}
diff --git a/tests/ts/ipcs/headers b/tests/ts/ipcs/headers
new file mode 100755
index 0000000..1ee13a9
--- /dev/null
+++ b/tests/ts/ipcs/headers
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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..671f23c
--- /dev/null
+++ b/tests/ts/ipcs/limits
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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..77ad70f
--- /dev/null
+++ b/tests/ts/ipcs/limits2
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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..a9e2ca9
--- /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..ec59c08
--- /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..eb85ad6
--- /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..dcd585b
--- /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
--- /dev/null
+++ b/tests/ts/isosize/sample.iso.gz
Binary files 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..8a7f4be
--- /dev/null
+++ b/tests/ts/kill/name_to_number
@@ -0,0 +1,72 @@
+#!/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"
+
+. "$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/libfdisk/gpt b/tests/ts/libfdisk/gpt
new file mode 100755
index 0000000..3578cd1
--- /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 <<EOF
+label: gpt
+label-id: b181c399-4711-4c52-8b65-9e764541218d
+
+size=5M, attrs="RequiredPartition,48"
+attrs="52,53,62"
+EOF
+ts_fdisk_clean ${TEST_IMAGE_NAME}
+ts_finalize_subtest
+
+TEST_IMAGE_NAME=$(ts_image_init 10)
+
+ts_init_subtest "all-defaults-with-typo"
+$TS_CMD_SFDISK --unit S ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF
+label: gpt
+label-id: b181c399-4711-4c52-8b65-9e764541218d
+
+size=5M, attrs="RequiredPartiton,48"
+attrs="52,53,62"
+EOF
+ts_fdisk_clean ${TEST_IMAGE_NAME}
+ts_finalize_subtest
+
+ts_init_subtest "getattr"
+ts_run $TESTPROG --getattr ${TEST_IMAGE_NAME} 1 >> $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..44029a6
--- /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..05b2b47
--- /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..70c779c
--- /dev/null
+++ b/tests/ts/libmount/context
@@ -0,0 +1,176 @@
+#!/bin/bash
+
+# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+
+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)
+
+MOUNTINFO_ONLY=yes
+has_mtab=$( ts_has_mtab_support )
+if [ "$has_mtab" == "yes" ]; then
+ MOUNTINFO_ONLY=no
+fi
+
+ts_log "Create partitions"
+$TS_CMD_FDISK --noauto-pt ${TS_DEVICE} &> /dev/null <<EOF
+o
+n
+p
+1
+
+
+w
+q
+EOF
+
+DEVICE="${TS_DEVICE}1"
+
+udevadm settle
+
+grep -q " $DEVNAME\$" /proc/partitions
+if [ $? -ne 0 ]; then
+ ts_skip "no partition!"
+fi
+
+ts_log "Create filesystem"
+mkfs.ext4 -L "$LABEL" -U "$UUID" $DEVICE &> /dev/null
+
+ts_log "Do tests..."
+
+export LIBMOUNT_MTAB=$TS_OUTPUT.mtab
+> $LIBMOUNT_MTAB
+
+# check local mtab of system mountinfo
+function is_mounted {
+ if [ "$MOUNTINFO_ONLY" = "yes" ]; then
+ ts_is_mounted "$1"
+ return $?
+ fi
+ grep -q "$1" $LIBMOUNT_MTAB && return 0
+ return 1
+}
+
+
+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
+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..a6a0816
--- /dev/null
+++ b/tests/ts/libmount/context-py
@@ -0,0 +1,166 @@
+#!/bin/bash
+
+# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+
+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)
+
+MOUNTINFO_ONLY=yes
+has_mtab=$( ts_has_mtab_support )
+if [ "$has_mtab" == "yes" ]; then
+ MOUNTINFO_ONLY=no
+fi
+
+ts_log "Create partitions"
+$TS_CMD_FDISK --noauto-pt ${TS_DEVICE} &> /dev/null <<EOF
+o
+n
+p
+1
+
+
+w
+q
+EOF
+
+DEVICE="${TS_DEVICE}1"
+
+udevadm settle
+
+grep -q " $DEVNAME\$" /proc/partitions
+if [ $? -ne 0 ]; then
+ ts_skip "no partition!"
+fi
+
+ts_log "Create filesystem"
+mkfs.ext4 -L "$LABEL" -U "$UUID" $DEVICE &> /dev/null
+
+ts_log "Do tests..."
+
+export LIBMOUNT_MTAB=$TS_OUTPUT.mtab
+> $LIBMOUNT_MTAB
+
+# check local mtab of system mountinfo
+function is_mounted {
+ if [ "$MOUNTINFO_ONLY" = "yes" ]; then
+ ts_is_mounted "$1"
+ return $?
+ fi
+ grep -q "\(^\| \)$1 " $LIBMOUNT_MTAB && return 0
+ return 1
+}
+
+
+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..47a6769
--- /dev/null
+++ b/tests/ts/libmount/context-utab
@@ -0,0 +1,133 @@
+#!/bin/bash
+
+# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+
+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 <<EOF
+o
+n
+p
+1
+
+
+w
+q
+EOF
+
+DEVICE="${TS_DEVICE}1"
+
+udevadm settle
+
+grep -q " $DEVNAME\$" /proc/partitions
+if [ $? -ne 0 ]; then
+ ts_skip "no partition!"
+fi
+
+ts_log "Create filesystem"
+mkfs.ext4 -L "$LABEL" -U "$UUID" $DEVICE &> /dev/null
+
+ts_log "Do tests..."
+
+export LIBMOUNT_MTAB=$TS_OUTPUT.mtab
+rm -f $LIBMOUNT_MTAB
+ln -s /proc/mounts $LIBMOUNT_MTAB
+
+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..94c9e5b
--- /dev/null
+++ b/tests/ts/libmount/context-utab-py
@@ -0,0 +1,138 @@
+#!/bin/bash
+
+# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+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 <<EOF
+o
+n
+p
+1
+
+
+w
+q
+EOF
+
+DEVICE="${TS_DEVICE}1"
+
+udevadm settle
+
+grep -q " $DEVNAME\$" /proc/partitions
+if [ $? -ne 0 ]; then
+ ts_skip "no partition!"
+fi
+
+ts_log "Create filesystem"
+mkfs.ext4 -L "$LABEL" -U "$UUID" $DEVICE &> /dev/null
+
+ts_log "Do tests..."
+
+export LIBMOUNT_MTAB=$TS_OUTPUT.mtab
+rm -f $LIBMOUNT_MTAB
+ln -s /proc/mounts $LIBMOUNT_MTAB
+
+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..5507d54
--- /dev/null
+++ b/tests/ts/libmount/debug
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+# Copyright (C) 2014 Ondrej Oprala <ooprala@redhat.com
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="debugging"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+TESTPROG="$TS_HELPER_LIBMOUNT_DEBUG"
+
+[ -x $TESTPROG ] || ts_skip "test not compiled"
+
+# CACHE | LOCKS
+ts_init_subtest "set-from-code"
+ts_run $TESTPROG 20 2>&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..7ba678b
--- /dev/null
+++ b/tests/ts/libmount/lock
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+
+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..6de00ee
--- /dev/null
+++ b/tests/ts/libmount/loop
@@ -0,0 +1,143 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2016 Stanislav Brabec <sbrabec@suse.cz>
+#
+# 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/:.*:/: <target>/; s/for .*/for <source>/' > $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/:.*:/: <target>/; s/for .*/for <source>/' > $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/:.*:/: <target>/; s/for .*/for <source>/' > $TS_OUTPUT
+$TS_CMD_LOSETUP --detach $LODEV >> $TS_OUTPUT 2>> $TS_ERRLOG
+rm "$BACKFILE"-2
+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..62874a1
--- /dev/null
+++ b/tests/ts/libmount/loop-overlay
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2016 Stanislav Brabec <sbrabec@suse.cz>
+#
+# 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/:.*:/: <target>/; s/for .*/for <source>/' >> $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/:.*:/: <target>/; s/for .*/for <source>/' >> $TS_OUTPUT
+$TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" 2>&1 \
+ | sed 's/:.*:/: <target>/; s/for .*/for <source>/' >> $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..03a1635
--- /dev/null
+++ b/tests/ts/libmount/optstr
@@ -0,0 +1,148 @@
+#!/bin/bash
+
+# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+
+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 "fix"
+ts_run $TESTPROG --fix "uid=root,gid=root" &> $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_finalize
diff --git a/tests/ts/libmount/tabdiff b/tests/ts/libmount/tabdiff
new file mode 100755
index 0000000..344daae
--- /dev/null
+++ b/tests/ts/libmount/tabdiff
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+# Copyright (C) 2011 Karel Zak <kzak@redhat.com>
+
+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..716fed8
--- /dev/null
+++ b/tests/ts/libmount/tabfiles
@@ -0,0 +1,85 @@
+#!/bin/bash
+
+# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+
+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..9754afe
--- /dev/null
+++ b/tests/ts/libmount/tabfiles-py
@@ -0,0 +1,75 @@
+#!/bin/bash
+
+# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+
+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..c5452cf
--- /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..171f189
--- /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..abc1547
--- /dev/null
+++ b/tests/ts/libmount/update
@@ -0,0 +1,112 @@
+#!/bin/bash
+
+# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+
+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.{mtab,mountinfo}
+
+export LIBMOUNT_MTAB=$TS_OUTPUT.mtab
+rm -f $LIBMOUNT_MTAB
+> $LIBMOUNT_MTAB
+
+
+#
+# Traditional /etc/mtab
+#
+has_mtab=$( ts_has_mtab_support )
+if [ "$has_mtab" == "yes" ]; then
+
+ ts_init_subtest "mtab-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 "gg=G,ffff=f,ro,noatime"
+ ts_run $TESTPROG --add /dev/sda2 /mnt/bar ext3 "rw,noatime"
+ ts_run $TESTPROG --add /dev/sda1 /mnt/gogo ext3 "rw,noatime,nosuid"
+ ts_run $TESTPROG --add none /proc proc defaults
+ cp $LIBMOUNT_MTAB $TS_OUTPUT # save the mtab aside
+ ts_finalize_subtest # checks the mtab
+
+ ts_init_subtest "mtab-move"
+ ts_run $TESTPROG --move /mnt/foo /mnt/newfoo
+ ts_run $TESTPROG --move /mnt/bar /mnt/newbar
+ cp $LIBMOUNT_MTAB $TS_OUTPUT # save the mtab aside
+ ts_finalize_subtest # checks the mtab
+
+ ts_init_subtest "mtab-remount"
+ ts_run $TESTPROG --remount /mnt/newfoo "ro,noatime"
+ ts_run $TESTPROG --remount /mnt/bar "rw,atime,nosuid"
+ cp $LIBMOUNT_MTAB $TS_OUTPUT # save the mtab aside
+ ts_finalize_subtest # checks the mtab
+
+ ts_init_subtest "mtab-umount"
+ ts_run $TESTPROG --remove /mnt/bar
+ ts_run $TESTPROG --remove /mnt/gogo
+ ts_run $TESTPROG --remove /proc
+ cp $LIBMOUNT_MTAB $TS_OUTPUT # save the mtab aside
+ ts_finalize_subtest # checks the mtab
+fi
+
+#
+# utab
+#
+rm -f $LIBMOUNT_MTAB
+ln -s /proc/mounts $LIBMOUNT_MTAB
+
+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 mtab aside
+ts_finalize_subtest # checks the mtab
+
+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 mtab aside
+ts_finalize_subtest # checks the mtab
+
+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 mtab aside
+ts_finalize_subtest # checks the mtab
+
+ts_init_subtest "utab-umount"
+ts_run $TESTPROG --remove /mnt/newbar
+ts_run $TESTPROG --remove /proc
+cp $LIBMOUNT_UTAB $TS_OUTPUT # save the mtab aside
+ts_finalize_subtest # checks the mtab
+
+#
+# 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..e4bba9c
--- /dev/null
+++ b/tests/ts/libmount/update-py
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+
+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..ad25e8f
--- /dev/null
+++ b/tests/ts/libmount/utils
@@ -0,0 +1,84 @@
+#!/bin/bash
+
+# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+
+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..d87f2cc
--- /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..77c2797
--- /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..f808099
--- /dev/null
+++ b/tests/ts/logger/errors
@@ -0,0 +1,116 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2015 Sami Kerola <kerolasa@iki.fi>
+#
+# 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..82716c8
--- /dev/null
+++ b/tests/ts/logger/formats
@@ -0,0 +1,85 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2015 Sami Kerola <kerolasa@iki.fi>
+#
+# 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..9ed87ad
--- /dev/null
+++ b/tests/ts/logger/journald
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2015 Sami Kerola <kerolasa@iki.fi>
+#
+# 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..30daea5
--- /dev/null
+++ b/tests/ts/logger/options
@@ -0,0 +1,82 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2015 Sami Kerola <kerolasa@iki.fi>
+#
+# 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..bb37270
--- /dev/null
+++ b/tests/ts/login/islocal
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2008 James Youngman <jay@gnu.org>
+#
+# 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..2db3f89
--- /dev/null
+++ b/tests/ts/login/logindefs
@@ -0,0 +1,26 @@
+#!/bin/bash
+#
+# Copyright (C) 2011 Karel Zak <kzak@redhat.com>
+#
+# 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..c6028e3
--- /dev/null
+++ b/tests/ts/look/separator
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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 | egrep --invert-match "'s$" | \
+# egrep "^[[: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..1fec0dd
--- /dev/null
+++ b/tests/ts/losetup/losetup
@@ -0,0 +1,86 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2013 Karel Zak <kzak@redhat.com>
+#
+# 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..54693be
--- /dev/null
+++ b/tests/ts/losetup/losetup-blkdev
@@ -0,0 +1,81 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2013 Karel Zak <kzak@redhat.com>
+#
+# 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..037e5c7
--- /dev/null
+++ b/tests/ts/losetup/losetup-loop
@@ -0,0 +1,247 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2016 Stanislav Brabec <sbrabec@suse.cz>
+#
+# 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 <testname>
+
+* 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
--- /dev/null
+++ b/tests/ts/lsblk/dumps/simple-lvm.tar.xz
Binary files 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
--- /dev/null
+++ b/tests/ts/lsblk/dumps/simple-nvme.tar.xz
Binary files differ
diff --git a/tests/ts/lsblk/lsblk b/tests/ts/lsblk/lsblk
new file mode 100755
index 0000000..b790f75
--- /dev/null
+++ b/tests/ts/lsblk/lsblk
@@ -0,0 +1,56 @@
+#!/bin/bash
+#
+# Copyright (C) 2018 Karel Zak <kzak@redhat.com>
+#
+# 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 <http://www.gnu.org/licenses/>.
+#
+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 100644
index 0000000..2bbd9e3
--- /dev/null
+++ b/tests/ts/lsblk/mk-input.sh
@@ -0,0 +1,124 @@
+#!/bin/bash
+#
+# Copyright (C) 2018 Karel Zak <kzak@redhat.com>
+#
+# 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 <testname>\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
--- /dev/null
+++ b/tests/ts/lscpu/dumps/armv7.tar.gz
Binary files 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
--- /dev/null
+++ b/tests/ts/lscpu/dumps/ppc-qemu.tar.gz
Binary files 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
--- /dev/null
+++ b/tests/ts/lscpu/dumps/ppc64-POWER7-64cpu.tar.gz
Binary files 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
--- /dev/null
+++ b/tests/ts/lscpu/dumps/ppc64-POWER7.tar.gz
Binary files 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
--- /dev/null
+++ b/tests/ts/lscpu/dumps/rv64-linux.tar.gz
Binary files 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
--- /dev/null
+++ b/tests/ts/lscpu/dumps/s390-kvm.tar.gz
Binary files 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
--- /dev/null
+++ b/tests/ts/lscpu/dumps/s390-lpar-drawer.tar.gz
Binary files 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
--- /dev/null
+++ b/tests/ts/lscpu/dumps/s390-lpar.tar.gz
Binary files 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
--- /dev/null
+++ b/tests/ts/lscpu/dumps/s390-nested-virt.tar.gz
Binary files 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
--- /dev/null
+++ b/tests/ts/lscpu/dumps/s390-zvm.tar.gz
Binary files 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
--- /dev/null
+++ b/tests/ts/lscpu/dumps/sparc64.tar.gz
Binary files 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
--- /dev/null
+++ b/tests/ts/lscpu/dumps/vbox-win.tar.gz
Binary files 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
--- /dev/null
+++ b/tests/ts/lscpu/dumps/vmware_fpe.tar.gz
Binary files 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
--- /dev/null
+++ b/tests/ts/lscpu/dumps/x86_64-64cpu.tar.gz
Binary files 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
--- /dev/null
+++ b/tests/ts/lscpu/dumps/x86_64-dell_e4310.tar.gz
Binary files 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
--- /dev/null
+++ b/tests/ts/lscpu/dumps/x86_64-epyc_7451.tar.gz
Binary files differ
diff --git a/tests/ts/lscpu/lscpu b/tests/ts/lscpu/lscpu
new file mode 100755
index 0000000..d224007
--- /dev/null
+++ b/tests/ts/lscpu/lscpu
@@ -0,0 +1,59 @@
+#!/bin/bash
+#
+# Copyright (C) 2008 Cai Qian <qcai@redhat.com>
+#
+# 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 <http://www.gnu.org/licenses/>.
+#
+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
+
+ # LE/BE depends on binary
+ sed -i -e '/Byte Order:.*/d' $TS_OUTPUT
+
+ 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 100644
index 0000000..65e3d20
--- /dev/null
+++ b/tests/ts/lscpu/mk-input.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+#
+# Copyright (C) 2008-2009 Karel Zak <kzak@redhat.com>
+#
+# 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 <testname>\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
+
+tar zcvf $TS_NAME.tar.gz $TS_DUMP
+rm -rf $TS_DUMP
+
+
diff --git a/tests/ts/lsfd/column-kthread b/tests/ts/lsfd/column-kthread
new file mode 100755
index 0000000..9fd10bf
--- /dev/null
+++ b/tests/ts/lsfd/column-kthread
@@ -0,0 +1,41 @@
+#!/bin/bash
+#
+# Copyright (C) 2021 Masatake YAMATO <yamato@redhat.com>
+#
+# 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/lsfd-functions.bash b/tests/ts/lsfd/lsfd-functions.bash
new file mode 100644
index 0000000..b57ba11
--- /dev/null
+++ b/tests/ts/lsfd/lsfd-functions.bash
@@ -0,0 +1,53 @@
+#!/bin/bash
+#
+# Copyright (C) 2021 Masatake YAMATO <yamato@redhat.com>
+#
+# 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.
+#
+
+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
+}
diff --git a/tests/ts/lsfd/mkfds-directory b/tests/ts/lsfd/mkfds-directory
new file mode 100755
index 0000000..cae5f2a
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-directory
@@ -0,0 +1,87 @@
+#!/bin/bash
+#
+# Copyright (C) 2021 Masatake YAMATO <yamato@redhat.com>
+#
+# 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_HELPER_MKFDS"
+
+ts_check_prog "stat"
+ts_check_prog "id"
+ts_check_prog "sed"
+
+ts_cd "$TS_OUTDIR"
+
+PID=
+FD=3
+EXPR=
+
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" directory $FD; }
+ 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//'
+ }
+ 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}
+ wait ${MKFDS_PID}
+ fi
+} > $TS_OUTPUT 2>&1
+
+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..171b3b8
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-pipe-no-fork
@@ -0,0 +1,73 @@
+#!/bin/bash
+#
+# Copyright (C) 2021 Masatake YAMATO <yamato@redhat.com>
+#
+# 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; }
+ 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]:' $?
+
+ kill -CONT ${PID}
+ wait ${MKFDS_PID}
+ fi
+} > $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..86c1ba8
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-ro-block-device
@@ -0,0 +1,75 @@
+#!/bin/bash
+#
+# Copyright (C) 2021 Masatake YAMATO <yamato@redhat.com>
+#
+# 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_SELF/lsfd-functions.bash
+
+ts_check_test_command "$TS_CMD_LSFD"
+
+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}
+ wait ${MKFDS_PID}
+ fi
+} > $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..9441a4e
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-ro-regular-file
@@ -0,0 +1,78 @@
+#!/bin/bash
+#
+# Copyright (C) 2021 Masatake YAMATO <yamato@redhat.com>
+#
+# 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}
+ wait ${MKFDS_PID}
+ fi
+} > $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..4f368f6
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-rw-character-device
@@ -0,0 +1,50 @@
+#!/bin/bash
+#
+# Copyright (C) 2021 Masatake YAMATO <yamato@redhat.com>
+#
+# 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}
+ wait ${MKFDS_PID}
+ fi
+} > $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..7c0ef7d
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-socketpair
@@ -0,0 +1,48 @@
+#!/bin/bash
+#
+# Copyright (C) 2021 Masatake YAMATO <yamato@redhat.com>
+#
+# 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,TYPE,SOURCE,PROTONAME -Q "${EXPR}" | sed -e 's/UNIX-DGRAM/UNIX/'
+ echo 'ASSOC,MODE,TYPE,SOURCE,PROTONAME': $?
+
+ kill -CONT ${PID}
+ wait ${MKFDS_PID}
+ fi
+} > $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..e4513d9
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-symlink
@@ -0,0 +1,45 @@
+#!/bin/bash
+#
+# Copyright (C) 2021 Masatake YAMATO <yamato@redhat.com>
+#
+# 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}
+ wait ${MKFDS_PID}
+ fi
+} > $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..58b48e1
--- /dev/null
+++ b/tests/ts/lsfd/option-filter-broken-exp
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+# Copyright (C) 2022 Masatake YAMATO <yamato@redhat.com>
+#
+# 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-pid b/tests/ts/lsfd/option-pid
new file mode 100755
index 0000000..65365bf
--- /dev/null
+++ b/tests/ts/lsfd/option-pid
@@ -0,0 +1,80 @@
+#!/bin/bash
+#
+# Copyright (C) 2021 Masatake YAMATO <yamato@redhat.com>
+#
+# 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}
+ wait ${MKFDS_PID}
+ fi
+} > $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..e27122a
--- /dev/null
+++ b/tests/ts/lsfd/option-summary
@@ -0,0 +1,62 @@
+#!/bin/bash
+#
+# Copyright (C) 2021 Masatake YAMATO <yamato@redhat.com>
+#
+# 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
--- /dev/null
+++ b/tests/ts/lsmem/dumps/s390-zvm-6g.tar.bz2
Binary files 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
--- /dev/null
+++ b/tests/ts/lsmem/dumps/x86_64-16g.tar.bz2
Binary files differ
diff --git a/tests/ts/lsmem/lsmem b/tests/ts/lsmem/lsmem
new file mode 100755
index 0000000..9c431b5
--- /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 <http://www.gnu.org/licenses/>.
+#
+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 <testname>\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..fa626bf
--- /dev/null
+++ b/tests/ts/lsns/ioctl_ns
@@ -0,0 +1,113 @@
+#!/bin/bash
+#
+# Copyright (C) 2021 Masatake YAMATO <yamato@redhat.com>
+#
+# 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_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..9d04f28
--- /dev/null
+++ b/tests/ts/lsns/netnsid
@@ -0,0 +1,96 @@
+#!/bin/bash
+#
+# Copyright (C) 2017 Masatake YAMATO <yamato@redhat.com>
+#
+# 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; 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..70cab2b
--- /dev/null
+++ b/tests/ts/lsns/nsfs
@@ -0,0 +1,94 @@
+#!/bin/bash
+#
+# Copyright (C) 2017 Masatake YAMATO <yamato@redhat.com>
+#
+# 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_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..57c4d52
--- /dev/null
+++ b/tests/ts/md5/md5
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2009 Karel Zak <kzak@redhat.com>
+#
+# 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
--- /dev/null
+++ b/tests/ts/minix/broken-root
Binary files differ
diff --git a/tests/ts/minix/debian.bug.773892 b/tests/ts/minix/debian.bug.773892
new file mode 100644
index 0000000..db97848
--- /dev/null
+++ b/tests/ts/minix/debian.bug.773892
Binary files differ
diff --git a/tests/ts/minix/fsck b/tests/ts/minix/fsck
new file mode 100755
index 0000000..0ca86df
--- /dev/null
+++ b/tests/ts/minix/fsck
@@ -0,0 +1,56 @@
+#!/bin/bash
+#
+# Copyright (C) 2009 Karel Zak <kzak@redhat.com>
+#
+# 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
+
+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..4c20422
--- /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..27ed957
--- /dev/null
+++ b/tests/ts/minix/mkfs
@@ -0,0 +1,57 @@
+#!/bin/bash
+#
+# Copyright (C) 2009 Karel Zak <kzak@redhat.com>
+#
+# 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..ec3d2d2
--- /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..6b8edfa
--- /dev/null
+++ b/tests/ts/misc/flock
@@ -0,0 +1,106 @@
+#!/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 "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..81cc0f8
--- /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..8424fc7
--- /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 </dev/null) |
+ $TS_CMD_LINE >> $TS_OUTPUT 2>> $TS_ERRLOG
+echo "ret: $?" >> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest 'empty-input-wait-for-eof'
+$TS_CMD_LINE </dev/null >> $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..cc3a540
--- /dev/null
+++ b/tests/ts/misc/mbsencode
@@ -0,0 +1,85 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2018 Vaclav Dolezal <vdolezal@redhat.com>
+#
+# 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..9931216
--- /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..e52ccb2
--- /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/rev b/tests/ts/misc/rev
new file mode 100755
index 0000000..0b3b64c
--- /dev/null
+++ b/tests/ts/misc/rev
@@ -0,0 +1,31 @@
+#!/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
+
+ts_finalize
diff --git a/tests/ts/misc/setarch b/tests/ts/misc/setarch
new file mode 100755
index 0000000..ab2f6c0
--- /dev/null
+++ b/tests/ts/misc/setarch
@@ -0,0 +1,92 @@
+#!/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"
+
+ARCH=$(uname -m)
+
+ts_init_subtest options
+test -e /.dockerenv && ts_skip "unsupported in docker environment"
+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_finalize
diff --git a/tests/ts/misc/setsid b/tests/ts/misc/setsid
new file mode 100755
index 0000000..dc4a329
--- /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..7d78c35
--- /dev/null
+++ b/tests/ts/misc/strtosize
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+#
+# 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..8b1abb5
--- /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:<swapfile>:g" \
+ -e "s/insecure permissions [0-9]*/insecure permissions <perm>/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:<swapfile>:g" \
+ -e "s/insecure permissions [0-9]*/insecure permissions <perm>/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/whereis b/tests/ts/misc/whereis
new file mode 100755
index 0000000..44643ae
--- /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/more/regexp b/tests/ts/more/regexp
new file mode 100755
index 0000000..869d712
--- /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..3b17ddb
--- /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/devname b/tests/ts/mount/devname
new file mode 100755
index 0000000..f4ebc6d
--- /dev/null
+++ b/tests/ts/mount/devname
@@ -0,0 +1,61 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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"
+has_mtab=$( ts_has_mtab_support )
+if [ "$has_mtab" == "yes" ]; then
+ MTAB_FILE="/etc/mtab"
+fi
+
+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..4babbbf
--- /dev/null
+++ b/tests/ts/mount/dm-verity
@@ -0,0 +1,72 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2021 Vojtech Eichler <veichler@redhat.com>
+#
+# 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/fslists b/tests/ts/mount/fslists
new file mode 100755
index 0000000..74a87f6
--- /dev/null
+++ b/tests/ts/mount/fslists
@@ -0,0 +1,90 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2014 Karel Zak <kzak@redhat.com>
+#
+# 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..6b70188
--- /dev/null
+++ b/tests/ts/mount/fstab-all
@@ -0,0 +1,145 @@
+#!/bin/bash
+
+# Copyright (C) 2019 Karel Zak <kzak@redhat.com>
+
+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 <<EOF
+o
+n
+p
+1
+
++10M
+n
+p
+2
+
++10M
+n
+p
+3
+
++10M
+n
+p
+
++10M
+w
+q
+EOF
+
+udevadm settle
+
+ts_log "Create filesystem A"
+mkfs.ext2 ${TS_DEVICE}1 &> /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 "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-broken b/tests/ts/mount/fstab-broken
new file mode 100755
index 0000000..947e3af
--- /dev/null
+++ b/tests/ts/mount/fstab-broken
@@ -0,0 +1,80 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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
+
+# 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..0003b5d
--- /dev/null
+++ b/tests/ts/mount/fstab-btrfs
@@ -0,0 +1,141 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2016 Stanislav Brabec <sbrabec@suse.cz>
+#
+# 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_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"
+
+$TS_CMD_MOUNT -o loop "$DEVICE" "$TS_MOUNTPOINT_CREATE"
+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..660c5e7
--- /dev/null
+++ b/tests/ts/mount/fstab-devname
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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..7257fbc
--- /dev/null
+++ b/tests/ts/mount/fstab-devname2label
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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..02b3ee1
--- /dev/null
+++ b/tests/ts/mount/fstab-devname2uuid
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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..6ec0641
--- /dev/null
+++ b/tests/ts/mount/fstab-label
@@ -0,0 +1,63 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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..5b184ed
--- /dev/null
+++ b/tests/ts/mount/fstab-label2devname
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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..b0ef960
--- /dev/null
+++ b/tests/ts/mount/fstab-label2uuid
@@ -0,0 +1,63 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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..7d4fbff
--- /dev/null
+++ b/tests/ts/mount/fstab-loop
@@ -0,0 +1,56 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2016 Stanislav Brabec <sbrabec@suse.cz>
+#
+# 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..e2ed0af
--- /dev/null
+++ b/tests/ts/mount/fstab-none
@@ -0,0 +1,37 @@
+#!/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_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..9f63a5a
--- /dev/null
+++ b/tests/ts/mount/fstab-symlink
@@ -0,0 +1,71 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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..f1cb4bd
--- /dev/null
+++ b/tests/ts/mount/fstab-uuid
@@ -0,0 +1,64 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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..cd51a2f
--- /dev/null
+++ b/tests/ts/mount/fstab-uuid2devname
@@ -0,0 +1,59 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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..e7d4db0
--- /dev/null
+++ b/tests/ts/mount/fstab-uuid2label
@@ -0,0 +1,61 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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..cd17784
--- /dev/null
+++ b/tests/ts/mount/label
@@ -0,0 +1,56 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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..9d2723a
--- /dev/null
+++ b/tests/ts/mount/move
@@ -0,0 +1,94 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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
+
+function mount_and_check {
+ # last arg must be an existing or to-be-mounted mountpoint
+ local mountpoint="${@: -1}"
+
+ $TS_CMD_MOUNT "$@" \
+ || 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..d56f507
--- /dev/null
+++ b/tests/ts/mount/regfile
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+# Copyright (C) 2011 Karel Zak <kzak@redhat.com>
+# 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..38db9bf
--- /dev/null
+++ b/tests/ts/mount/remount
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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"
+has_mtab=$( ts_has_mtab_support )
+if [ "$has_mtab" == "yes" ]; then
+ MTAB_FILE="/etc/mtab"
+fi
+
+mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE"
+
+# mount read-write
+$TS_CMD_MOUNT $DEVICE $TS_MOUNTPOINT || ts_die "Cannot mount $TS_MOUNTPOINT"
+
+# check the mount
+egrep -q "^$DEVICE $TS_MOUNTPOINT" $MTAB_FILE \
+ || ts_die "Cannot find $TS_MOUNTPOINT in $MTAB_FILE"
+
+# remount
+$TS_CMD_MOUNT -o remount,ro $TS_MOUNTPOINT \
+ || 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/rlimit b/tests/ts/mount/rlimit
new file mode 100755
index 0000000..50d9153
--- /dev/null
+++ b/tests/ts/mount/rlimit
@@ -0,0 +1,93 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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 /etc/mtab file should not be modified if RLIMIT_FSIZE (ulimit -f)
+# is too low, otherwise the file could be corrupted (incomplete write).
+# The [u]mount(8) has to block SIGXFSZ and check if all writes and fflush
+# calls are successful.
+#
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="rlimit-fsize"
+
+. $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_MD5"
+
+ts_skip_nonroot
+ts_check_losetup
+ts_check_prog "mkfs.ext2"
+
+has_mtab=$( ts_has_mtab_support )
+[ "$has_mtab" == "yes" ] || ts_skip "mtab unsupported"
+
+[ -L /etc/mtab ] && ts_skip "mtab is symlink"
+[ "$(stat --format '%s' /etc/mtab)" -gt "1024" ] || ts_skip "mtab is too small"
+
+function mtab_checksum()
+{
+ "$TS_HELPER_MD5" < /etc/mtab
+}
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE"
+
+
+ts_init_subtest "mount"
+OLD_SUM=$(mtab_checksum)
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+(
+ ulimit -f 1
+ $TS_CMD_MOUNT $DEVICE $TS_MOUNTPOINT
+) &> /dev/null
+NEW_SUM=$(mtab_checksum)
+[ $NEW_SUM = $OLD_SUM ] && echo "OK: mtab unmodified by mount" >> $TS_OUTPUT
+ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $TS_MOUNTPOINT &> /dev/null
+ts_is_mounted $DEVICE && ts_die "$DEVICE is still mounted"
+ts_finalize_subtest
+
+
+ts_init_subtest "umount"
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+$TS_CMD_MOUNT $DEVICE $TS_MOUNTPOINT &> /dev/null
+ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts"
+OLD_SUM=$(mtab_checksum)
+(
+ ulimit -f 1
+ $TS_CMD_UMOUNT $TS_MOUNTPOINT &> /dev/null
+) &> /dev/null
+NEW_SUM=$(mtab_checksum)
+[ $NEW_SUM = $OLD_SUM ] && echo "OK: mtab unmodified by umount" >> $TS_OUTPUT
+if ts_is_mounted $DEVICE; then
+ echo "FAIL: $DEVICE is still mounted" >> $TS_OUTPUT
+ $TS_CMD_UMOUNT $TS_MOUNTPOINT &> /dev/null
+else
+ # repair /etc/mtab
+ $TS_CMD_UMOUNT --fake $TS_MOUNTPOINT &> /dev/null
+fi
+ts_finalize_subtest
+
+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..44b460b
--- /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
+[ "$?" = "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..21edd65
--- /dev/null
+++ b/tests/ts/mount/special
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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.<type>"
+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_CMD_MOUNT -t mytest /foo /bar &> $TS_OUTPUT
+
+rm -f $MOUNTER
+
+ts_finalize
+
diff --git a/tests/ts/mount/umount-alltargets b/tests/ts/mount/umount-alltargets
new file mode 100755
index 0000000..37a163d
--- /dev/null
+++ b/tests/ts/mount/umount-alltargets
@@ -0,0 +1,125 @@
+#!/bin/bash
+
+# Copyright (C) 2013 Karel Zak <kzak@redhat.com>
+
+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"
+
+has_mtab=$( ts_has_mtab_support )
+if [ "$has_mtab" == "yes" ]; then
+ [ -L /etc/mtab ] || ts_skip "regular mtab"
+fi
+
+# 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 <<EOF
+o
+n
+p
+1
+
++10M
+n
+p
+2
+
++10M
+n
+p
+3
+
++10M
+n
+p
+
++10M
+w
+q
+EOF
+
+udevadm settle
+
+ts_log "Create filesystem A"
+mkfs.ext2 ${TS_DEVICE}1 &> /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
+[ -d "${MOUNTPOINT}1/subA/subAB" ] || mkdir -p ${MOUNTPOINT}1/subA/subAB
+$TS_CMD_MOUNT ${TS_DEVICE}3 ${MOUNTPOINT}1/subA/subAB
+[ -d "${MOUNTPOINT}1/subB" ] || mkdir -p ${MOUNTPOINT}1/subB
+$TS_CMD_MOUNT ${TS_DEVICE}4 ${MOUNTPOINT}1/subB
+$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..700c58c
--- /dev/null
+++ b/tests/ts/mount/umount-recursive
@@ -0,0 +1,97 @@
+#!/bin/bash
+
+# Copyright (C) 2012 Karel Zak <kzak@redhat.com>
+
+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 <<EOF
+o
+n
+p
+1
+
++10M
+n
+p
+2
+
++10M
+n
+p
+3
+
++10M
+n
+p
+
++10M
+w
+q
+EOF
+
+udevadm settle
+
+ts_log "Create filesystem A"
+mkfs.ext2 ${TS_DEVICE}1 &> /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
+
+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
+
+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..db03766
--- /dev/null
+++ b/tests/ts/mount/uuid
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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..d602949
--- /dev/null
+++ b/tests/ts/namei/logic
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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..3925d1b
--- /dev/null
+++ b/tests/ts/partx/partx
@@ -0,0 +1,186 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2010 Davidlohr Bueso <dave@gnu.org>
+#
+# 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 <<EOF
+label: dos
+label-id: 0x1ddc8a79
+32,33760,,
+33792,33792,,
+67584,34816,,
+EOF
+udevadm settle
+
+
+ts_init_subtest "detect-parts"
+{
+ $TS_CMD_PARTX --show $TS_DEVICE &&
+ echo OK ||
+ echo "Unable to list partitions"
+ check_partition_count $PARTS
+} >> $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..c7f471e
--- /dev/null
+++ b/tests/ts/partx/partx-image
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2010 Davidlohr Bueso <dave@gnu.org>
+#
+# 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..bf55c10
--- /dev/null
+++ b/tests/ts/paths/built-in
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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..fb20b49
--- /dev/null
+++ b/tests/ts/rename/basic
@@ -0,0 +1,71 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2014 Sami Kerola <kerolasa@iki.fi>
+#
+# 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
+
+ts_finalize
diff --git a/tests/ts/rename/exit_codes b/tests/ts/rename/exit_codes
new file mode 100755
index 0000000..a9d9095
--- /dev/null
+++ b/tests/ts/rename/exit_codes
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2014 Sami Kerola <kerolasa@iki.fi>
+#
+# 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..b6a633a
--- /dev/null
+++ b/tests/ts/rename/overwrite
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2017 Sami Kerola <kerolasa@iki.fi>
+#
+# 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..192c2ff
--- /dev/null
+++ b/tests/ts/rename/subdir
@@ -0,0 +1,68 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2014 Sami Kerola <kerolasa@iki.fi>
+#
+# 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
+
+ts_finalize
diff --git a/tests/ts/rename/symlink b/tests/ts/rename/symlink
new file mode 100755
index 0000000..91a0539
--- /dev/null
+++ b/tests/ts/rename/symlink
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2014 Sami Kerola <kerolasa@iki.fi>
+#
+# 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..b16adbd
--- /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]*/<removed>/' $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..e542fc3
--- /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]*/<removed>/' $TS_OUTPUT
+ sed -i -e 's/[0-9]* (process/<removed> (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..afd0fd5
--- /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..b720383
--- /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 </dev/null >$TS_OUTPUT
+
+ts_finalize
+
diff --git a/tests/ts/script/options b/tests/ts/script/options
new file mode 100755
index 0000000..9b5f9d5
--- /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 >/dev/null 2>&1
+$TS_HELPER_SCRIPT --append -c "echo append2" $TS_OUTPUT </dev/null >/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 >/dev/null 2>> $TS_OUTPUT
+echo $? >> $TS_OUTPUT
+$TS_HELPER_SCRIPT -a --force --command "echo with force" </dev/null >/dev/null
+echo $? >> $TS_OUTPUT
+rm -f typescript
+ln -s $TS_OUTPUT tpircsepyt
+$TS_HELPER_SCRIPT -a --command "echo not typescript" tpircsepyt </dev/null >/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 >/dev/null 2>&1
+$TS_HELPER_SCRIPT -a -q --command "echo quiet2" $TS_OUTPUT </dev/null >/dev/null 2>&1
+ts_finalize_subtest
+
+ts_init_subtest "return"
+$TS_HELPER_SCRIPT --command "exit 1" $TS_OUTPUT </dev/null >/dev/null 2>&1
+echo $? >> $TS_OUTPUT
+$TS_HELPER_SCRIPT -a --command "exit 0" $TS_OUTPUT </dev/null >/dev/null 2>&1
+echo $? >> $TS_OUTPUT
+$TS_HELPER_SCRIPT -e --append -c "exit 42" $TS_OUTPUT </dev/null >/dev/null 2>&1
+echo $? >> $TS_OUTPUT
+$TS_HELPER_SCRIPT --return --append -c "exit 127" $TS_OUTPUT </dev/null >/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 >/dev/null 2>&1
+$TS_HELPER_SCRIPT -a -o 9 --command "echo 2:1234567890" $TS_OUTPUT </dev/null >/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..6ef5309
--- /dev/null
+++ b/tests/ts/script/race
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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..4aa155c
--- /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 <<EOF
+ 2048,6144,L
+8192, 6144,S
+14336 , 6144 ,
+20480,,E
+,6144 ,
+,,
+EOF
+ts_fdisk_clean $TS_DEVICE
+udevadm settle
+ts_finalize_subtest
+
+
+ts_init_subtest "activate"
+$TS_CMD_SFDISK --activate ${TS_DEVICE} 1 >> $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 <<EOF
+ 2048 6144 L
+8192 6144 S
+,,
+EOF
+ts_fdisk_clean $TS_DEVICE
+udevadm settle
+ts_finalize_subtest
+
+
+ts_init_subtest "read-dump-case"
+$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null
+udevadm settle
+$TS_CMD_SFDISK --unit S ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF
+unit: sectors
+label-id: 0x1ddc8a79
+
+${TS_DEVICE}1 : stArt= 2048, sIZe= 6144, id=83, bootAble
+EOF
+ts_fdisk_clean $TS_DEVICE
+udevadm settle
+ts_finalize_subtest
+
+
+ts_init_subtest "read-dump"
+$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null
+udevadm settle
+$TS_CMD_SFDISK --unit S ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF
+unit: sectors
+label-id: 0x1ddc8a79
+
+${TS_DEVICE}1 : start= 2048, size= 6144, Id=83, bootable
+${TS_DEVICE}2 : start= 8192, size= 6144, Id=82
+${TS_DEVICE}3 : start= 14336, size= 6144, Id=83
+${TS_DEVICE}4 : start= 20480, size= 81920, Id= 5
+${TS_DEVICE}5 : start= 20481, size= 6144, Id=83
+${TS_DEVICE}6 : start= 26626, size= 75774, Id=83
+EOF
+ts_fdisk_clean $TS_DEVICE
+udevadm settle
+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
+
+
+#
+# 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 <<EOF
+label: dos
+1, 1000, L
+1001, 1000, S
+2001, 1000
+3001,,E
+3002,1000,L
+4003,1000,L
+5004,,L
+EOF
+ts_fdisk_clean $TS_DEVICE
+udevadm settle
+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 <<EOF
+label: dos
+,10M,S,*
+EOF
+udevadm settle
+echo ',+' | $TS_CMD_SFDISK --no-reread -N1 ${TS_DEVICE} >> $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 <<EOF
+label: dos
+,1M
+,2M,E
+EOF
+udevadm settle
+echo ',+' | $TS_CMD_SFDISK --no-reread -N2 ${TS_DEVICE} >> $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 <<EOF
+label: dos
+,1M
+,5M,E
+EOF
+udevadm settle
+echo ',-2M' | $TS_CMD_SFDISK --no-reread -N2 ${TS_DEVICE} >> $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 <<EOF
+label: dos
+,1M
+,1M
+,1M
+,5M,E
+,1M
+,1M
+EOF
+udevadm settle
+echo ',+' | $TS_CMD_SFDISK --no-reread -N4 ${TS_DEVICE} >> $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 <<EOF
+label: dos
+,1M
+,1M
+,1M
+,10M,E
+,1M
+,1M
+EOF
+udevadm settle
+echo ',+' | $TS_CMD_SFDISK --no-reread -N6 ${TS_DEVICE} >> $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 <<EOF
+3MiB 5MiB L
+- 6MiB L
+EOF
+ts_fdisk_clean $TS_DEVICE
+udevadm settle
+ts_finalize_subtest
+
+
+ts_init_subtest "default-vs-gap2"
+$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null
+udevadm settle
+$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF
+4MiB 3MiB L
+13MiB 5MiB L
+- 4MiB L
+- 2MiB L
+- - L
+EOF
+ts_fdisk_clean $TS_DEVICE
+udevadm settle
+ts_finalize_subtest
+
+
+ts_init_subtest "sizes-vs-gaps"
+$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null
+udevadm settle
+$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF
+2048 1023 L -
+4096 4095 L -
+8192 8191 L -
+EOF
+ts_fdisk_clean $TS_DEVICE
+udevadm settle
+ts_finalize_subtest
+
+
+ts_finalize
diff --git a/tests/ts/sfdisk/dump b/tests/ts/sfdisk/dump
new file mode 100755
index 0000000..09a1267
--- /dev/null
+++ b/tests/ts/sfdisk/dump
@@ -0,0 +1,87 @@
+#!/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=100 sector_size=512 physblk_exp=3
+
+ts_init_subtest "v2.32"
+$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null
+udevadm settle
+$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF
+label: gpt
+label-id: 613005F9-1C8C-E141-8AEB-F32E8E296C75
+device: ${TS_DEVICE}
+unit: sectors
+first-lba: 2048
+last-lba: 204766
+
+${TS_DEVICE}1 : start= 2048, size= 20480, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=28A432A3-8D63-3142-B9F5-68A2BF2BC60B
+${TS_DEVICE}2 : start= 22528, size= 22528, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=6A7D17FC-7252-564A-9B68-5E2107999BF1
+${TS_DEVICE}3 : start= 45056, size= 24576, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=26C303E4-0321-3346-B9EF-BDD39BEA1166
+${TS_DEVICE}4 : start= 69632, size= 135135, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=AF79D434-C8B3-2445-80FB-317AB157447C
+EOF
+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_init_subtest "v2.35"
+$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null
+udevadm settle
+$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF
+label: gpt
+label-id: 613005F9-1C8C-E141-8AEB-F32E8E296C75
+device: ${TS_DEVICE}
+unit: sectors
+first-lba: 2048
+last-lba: 204766
+sector-size: 512
+
+${TS_DEVICE}1 : start= 2048, size= 20480, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=28A432A3-8D63-3142-B9F5-68A2BF2BC60B
+${TS_DEVICE}2 : start= 22528, size= 22528, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=6A7D17FC-7252-564A-9B68-5E2107999BF1
+${TS_DEVICE}3 : start= 45056, size= 24576, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=26C303E4-0321-3346-B9EF-BDD39BEA1166
+${TS_DEVICE}4 : start= 69632, size= 135135, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=AF79D434-C8B3-2445-80FB-317AB157447C
+EOF
+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_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..0726433
--- /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 <<EOF
+label: gpt
+label-id: b181c399-4711-4c52-8b65-9e764541218d
+
+,5M
+, 5M, L
+, 5M,S
+, 5M, 4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709
+, ,
+EOF
+ts_fdisk_clean $TS_DEVICE
+udevadm settle
+ts_finalize_subtest
+
+
+ts_init_subtest "uuid"
+$TS_CMD_SFDISK --part-uuid ${TS_DEVICE} 1 91dc657b-d7b4-4653-a367-663194ffd432 &> /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 <<EOF
+unit: sectors
+label: gpt
+label-id: 3b8559db-33af-43e9-befc-c331d829b539
+
+${TS_DEVICE}1 : start=2048, size=6144, type=44479540-F297-41B2-9AF7-D131D5F0458A, uuid=4dd6948a-44f8-4e6c-8bdc-064f740704f8
+${TS_DEVICE}2 : start=8192, size=6144, uuid=44b51def-5f04-465a-91aa-2889a62d8e49
+${TS_DEVICE}3 : start=14336, size=6144, uuid=643e1d0d-bc02-4ced-b83b-86121062858f
+${TS_DEVICE}4 : start=20480, size=81887,uuid=d2a29b0a-fdee-40c3-9bae-b9fa782c986c, name="GPT is the best"
+EOF
+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_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 <<EOF
+label: gpt
+,10M,S,*
+EOF
+udevadm settle
+echo ',+' | $TS_CMD_SFDISK --no-reread -N1 ${TS_DEVICE} >> $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 <<EOF
+unit: sectors
+label: gpt
+label-id: 3b8559db-33af-43e9-befc-c331d829b539
+
+${TS_DEVICE}1 : start=8192, size=6144
+${TS_DEVICE}2 : start=2048, size=6144
+${TS_DEVICE}3 : start=20480, size=81887
+${TS_DEVICE}4 : start=14336, size=6144
+EOF
+udevadm settle
+# why --reorder does not re-read?
+$TS_CMD_SFDISK --reorder ${TS_DEVICE} >> $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..239c828
--- /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..fa11373
--- /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 <<EOF
+label: dos
+label-id: 0xda2e45ac
+device: ${TS_DEVICE}
+unit: sectors
+
+${TS_DEVICE}1 : start= 2048, size= 2048, type=83
+${TS_DEVICE}2 : start= 4096, size= 2048, type=83
+${TS_DEVICE}3 : start= 6144, size= 102400, type=5
+${TS_DEVICE}4 : start= 108544, size= 2048, type=83
+${TS_DEVICE}5 : start= 8192, size= 2048, type=83
+${TS_DEVICE}6 : start= 12288, size= 96256, type=83
+EOF
+udevadm settle
+# enlarge to use all space behind partition #4
+echo ',+,' | $TS_CMD_SFDISK --no-reread -N 4 ${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/script b/tests/ts/sfdisk/script
new file mode 100755
index 0000000..501fce1
--- /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 <<EOF
+unit: sectors
+label: gpt
+label-id: 3b8559db-33af-43e9-befc-c331d829b539
+
+${TS_DEVICE}1 : start=2048, size=6144, Id=44479540-F297-41B2-9AF7-D131D5F0458A, uuid=4dd6948a-44f8-4e6c-8bdc-064f740704f8
+${TS_DEVICE}2 : start=8192, size=6144, id=44479540-F297-41B2-9AF7-D131D5F0458A, uuid=44b51def-5f04-465a-91aa-2889a62d8e49
+${TS_DEVICE}3 : start=14336, size=6144, type=44479540-F297-41B2-9AF7-D131D5F0458A, uuid=643e1d0d-bc02-4ced-b83b-86121062858f
+${TS_DEVICE}4 : start=20480, size=81887,Type=44479540-F297-41B2-9AF7-D131D5F0458A, uuid=d2a29b0a-fdee-40c3-9bae-b9fa782c986c
+EOF
+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_init_subtest "separator"
+$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null
+udevadm settle
+$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF
+unit: sectors
+label: gpt
+label-id: 3b8559db-33af-43e9-befc-c331d829b539
+
+${TS_DEVICE}1 : start=2048 size=6144 uuid=4dd6948a-44f8-4e6c-8bdc-064f740704f8
+${TS_DEVICE}2 : start=8192,size=6144, uuid=44b51def-5f04-465a-91aa-2889a62d8e49 ,type=44479540-F297-41B2-9AF7-D131D5F0458A
+${TS_DEVICE}3 : start=14336 , size=6144 ,uuid=643e1d0d-bc02-4ced-b83b-86121062858f
+${TS_DEVICE}4 : start=20480; size=81887 ; uuid=d2a29b0a-fdee-40c3-9bae-b9fa782c986c
+EOF
+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_init_subtest "quotes"
+$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null
+udevadm settle
+$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF
+unit: sectors
+label: gpt
+label-id: 3b8559db-33af-43e9-befc-c331d829b539
+
+${TS_DEVICE}1 : start=2048 uuid="4dd6948a-44f8-4e6c-8bdc-064f740704f8" size=6144
+${TS_DEVICE}2 : start= 8192 uuid="44b51def-5f04-465a-91aa-2889a62d8e49" , size=6144
+${TS_DEVICE}3: start=14336 uuid="643e1d0d-bc02-4ced-b83b-86121062858f",size=6144
+${TS_DEVICE}4 : start=20480 uuid="d2a29b0a-fdee-40c3-9bae-b9fa782c986c", size=6144
+EOF
+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_init_subtest "broken-1"
+$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null
+udevadm settle
+$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF
+unit: sectors
+label: gpt
+label-id: 3b8559db-33af-43e9-befc-c331d829b539
+
+${TS_DEVICE}1 : start =2048 uuid="4dd6948a-44f8-4e6c-8bdc-064f740704f8" size=6144
+EOF
+ts_fdisk_clean $TS_DEVICE
+ts_finalize_subtest
+
+
+ts_init_subtest "broken-2"
+$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null
+udevadm settle
+$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF
+unit: sectors
+label: gpt
+label-id: 3b8559db-33af-43e9-befc-c331d829b539
+
+${TS_DEVICE}1 : start=2048uuid="4dd6948a-44f8-4e6c-8bdc-064f740704f8" size=6144
+EOF
+ts_fdisk_clean $TS_DEVICE
+ts_finalize_subtest
+
+
+ts_init_subtest "broken-3"
+$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null
+udevadm settle
+$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF
+unit: sectors
+label: gpt
+label-id: 3b8559db-33af-43e9-befc-c331d829b539
+
+${TS_DEVICE}1 : start=2048 uuid=,"4dd6948a-44f8-4e6c-8bdc-064f740704f8" size=6144
+EOF
+ts_fdisk_clean $TS_DEVICE
+ts_finalize_subtest
+
+
+ts_init_subtest "broken-4"
+$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null
+udevadm settle
+$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF
+unit: sectors
+label: gpt
+label-id: 3b8559db-33af-43e9-befc-c331d829b539
+
+${TS_DEVICE}1 : start=2048 uuid="4dd6948a-44f8-4e6c-8bdc-064f740704f8 size=6144
+EOF
+ts_fdisk_clean $TS_DEVICE
+ts_finalize_subtest
+
+
+ts_init_subtest "broken-5"
+$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null
+udevadm settle
+$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF
+unit: sectors
+label: gpt
+label-id: 3b8559db-33af-43e9-befc-c331d829b539
+
+${TS_DEVICE}1 : start=2048 uuid=4dd6948a-44f8-4e6c-8bdc-064f740704f8" size=6144
+EOF
+ts_fdisk_clean $TS_DEVICE
+ts_finalize_subtest
+
+ts_finalize
diff --git a/tests/ts/sfdisk/wipe b/tests/ts/sfdisk/wipe
new file mode 100755
index 0000000..2c930fd
--- /dev/null
+++ b/tests/ts/sfdisk/wipe
@@ -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="wipe"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_SFDISK"
+ts_check_test_command "$TS_CMD_WIPEFS"
+ts_check_test_command "$TS_CMD_MKSWAP"
+
+ts_skip_nonroot
+
+SFDISK_OPTS="--no-tell-kernel --no-reread"
+
+# set global variable TS_DEVICE
+ts_scsi_debug_init dev_size_mb=50 sector_size=512 physblk_exp=3
+
+
+ts_init_subtest "gpt-to-dos"
+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 --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..055d690
--- /dev/null
+++ b/tests/ts/sha1/sha1
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2009 Karel Zak <kzak@redhat.com>
+#
+# 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..9972f6c
--- /dev/null
+++ b/tests/ts/swapon/devname
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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..4479cd8
--- /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..c3104a2
--- /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..1a4c638
--- /dev/null
+++ b/tests/ts/swapon/label
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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..7e3d1dc
--- /dev/null
+++ b/tests/ts/swapon/uuid
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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..883c8de
--- /dev/null
+++ b/tests/ts/ul/basic
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2020 Sami Kerola <kerolasa@iki.fi>
+#
+# 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..c707658
--- /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..9683103
--- /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..d4a9645
--- /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..f171eae
--- /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..f9ee11e
--- /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..33a8dc4
--- /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..aab396a
--- /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..099533c
--- /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..bc9704e
--- /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
--- /dev/null
+++ b/tests/ts/utmp/wtmp-a.BE
Binary files differ
diff --git a/tests/ts/utmp/wtmp-a.LE b/tests/ts/utmp/wtmp-a.LE
new file mode 100644
index 0000000..f66bb20
--- /dev/null
+++ b/tests/ts/utmp/wtmp-a.LE
Binary files differ
diff --git a/tests/ts/utmp/wtmp-b.BE b/tests/ts/utmp/wtmp-b.BE
new file mode 100644
index 0000000..fb09a0c
--- /dev/null
+++ b/tests/ts/utmp/wtmp-b.BE
Binary files differ
diff --git a/tests/ts/utmp/wtmp-b.LE b/tests/ts/utmp/wtmp-b.LE
new file mode 100644
index 0000000..45d35bb
--- /dev/null
+++ b/tests/ts/utmp/wtmp-b.LE
Binary files differ
diff --git a/tests/ts/utmp/wtmp-ipv6.BE b/tests/ts/utmp/wtmp-ipv6.BE
new file mode 100644
index 0000000..8cf7d39
--- /dev/null
+++ b/tests/ts/utmp/wtmp-ipv6.BE
Binary files differ
diff --git a/tests/ts/utmp/wtmp-ipv6.LE b/tests/ts/utmp/wtmp-ipv6.LE
new file mode 100644
index 0000000..342553b
--- /dev/null
+++ b/tests/ts/utmp/wtmp-ipv6.LE
Binary files differ
diff --git a/tests/ts/uuid/namespace b/tests/ts/uuid/namespace
new file mode 100755
index 0000000..bec2c9d
--- /dev/null
+++ b/tests/ts/uuid/namespace
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2009 Karel Zak <kzak@redhat.com>
+#
+# 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..77e010c
--- /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..6c085b7
--- /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..a38996c
--- /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 <num>./' $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..f34b06c
--- /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..1ec371e
--- /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..6916362
--- /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