summaryrefslogtreecommitdiffstats
path: root/tests/ts
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:33:34 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:33:34 +0000
commit1272be04be0cb803eec87f602edb2e3e6f111aea (patch)
treebce17f6478cdd9f3c4ec3d751135dc42786d6a56 /tests/ts
parentReleasing progress-linux version 2.39.3-11~progress7.99u1. (diff)
downloadutil-linux-1272be04be0cb803eec87f602edb2e3e6f111aea.tar.xz
util-linux-1272be04be0cb803eec87f602edb2e3e6f111aea.zip
Merging upstream version 2.40.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ts')
-rw-r--r--tests/ts/blkid/images-fs/swap-luks.img.xzbin0 -> 388 bytes
-rw-r--r--tests/ts/blkid/images-fs/vxfs-be.img.xzbin0 -> 128 bytes
-rw-r--r--tests/ts/blkid/images-fs/vxfs-le.img.xzbin0 -> 104 bytes
-rwxr-xr-xtests/ts/column/table7
-rw-r--r--tests/ts/dmesg/cid-input106
-rwxr-xr-xtests/ts/dmesg/cid-json28
-rwxr-xr-xtests/ts/dmesg/cid-kmsg-colors34
-rwxr-xr-xtests/ts/dmesg/cid-kmsg-console-levels49
-rwxr-xr-xtests/ts/dmesg/cid-kmsg-decode33
-rwxr-xr-xtests/ts/dmesg/cid-kmsg-delta33
-rwxr-xr-xtests/ts/dmesg/cid-kmsg-facilities36
-rwxr-xr-xtests/ts/dmesg/cid-kmsg-indentation45
-rw-r--r--tests/ts/dmesg/cid-kmsg-inputbin0 -> 5464 bytes
-rwxr-xr-xtests/ts/dmesg/cid-kmsg-json28
-rwxr-xr-xtests/ts/dmesg/cid-kmsg-limit34
-rw-r--r--tests/ts/dmesg/cid-kmsg-newlinesbin0 -> 152 bytes
-rw-r--r--tests/ts/dmesg/input1
-rwxr-xr-xtests/ts/dmesg/json28
-rwxr-xr-xtests/ts/dmesg/kmsg-file28
-rw-r--r--tests/ts/dmesg/kmsg-inputbin0 -> 3944 bytes
-rwxr-xr-xtests/ts/dmesg/timestamp-format42
-rwxr-xr-xtests/ts/eject/umount10
-rwxr-xr-xtests/ts/exch/exch40
-rwxr-xr-xtests/ts/fadvise/drop28
-rwxr-xr-xtests/ts/fdisk/resize66
-rwxr-xr-xtests/ts/fincore/count5
-rwxr-xr-xtests/ts/hexdump/format-strings4
-rwxr-xr-xtests/ts/lib/timeutils8
-rwxr-xr-xtests/ts/liblastlog2/dlopen23
-rwxr-xr-xtests/ts/liblastlog2/pam_lastlog2_output17
-rwxr-xr-xtests/ts/liblastlog2/remove_entry15
-rwxr-xr-xtests/ts/liblastlog2/rename_user15
-rwxr-xr-xtests/ts/liblastlog2/sqlite3_time15
-rwxr-xr-xtests/ts/liblastlog2/write_read_user15
-rwxr-xr-xtests/ts/liblastlog2/y2038_ll2_read_all15
-rwxr-xr-xtests/ts/libmount/optlist67
-rwxr-xr-xtests/ts/libmount/optstr8
-rwxr-xr-xtests/ts/libmount/update1
-rwxr-xr-xtests/ts/libmount/update-py1
-rwxr-xr-xtests/ts/libsmartcols/continuous-json28
-rw-r--r--tests/ts/libsmartcols/files/col-bool1
-rw-r--r--tests/ts/libsmartcols/files/col-float1
-rw-r--r--tests/ts/libsmartcols/files/col-hidden4
-rw-r--r--tests/ts/libsmartcols/files/col-id4
-rw-r--r--tests/ts/libsmartcols/files/col-name4
-rw-r--r--tests/ts/libsmartcols/files/col-noextremes4
-rw-r--r--tests/ts/libsmartcols/files/col-number4
-rw-r--r--tests/ts/libsmartcols/files/col-parent4
-rw-r--r--tests/ts/libsmartcols/files/col-strict4
-rw-r--r--tests/ts/libsmartcols/files/col-string4
-rw-r--r--tests/ts/libsmartcols/files/col-tree4
-rw-r--r--tests/ts/libsmartcols/files/col-trunc4
-rw-r--r--tests/ts/libsmartcols/files/col-wrap4
-rw-r--r--tests/ts/libsmartcols/files/col-wrapnl4
-rw-r--r--tests/ts/libsmartcols/files/col-wrapzero1
-rw-r--r--tests/ts/libsmartcols/files/data-bool10
-rw-r--r--tests/ts/libsmartcols/files/data-float10
-rw-r--r--tests/ts/libsmartcols/files/data-string-nl10
-rw-r--r--tests/ts/libsmartcols/files/data-string-zero10
-rwxr-xr-xtests/ts/libsmartcols/filter217
-rwxr-xr-xtests/ts/libsmartcols/fromfile26
-rw-r--r--tests/ts/lscpu/dumps/rv64-visionfive2.tar.gzbin0 -> 14329 bytes
-rwxr-xr-xtests/ts/lsfd/column-ainodeclass4
-rwxr-xr-xtests/ts/lsfd/column-deleted61
-rwxr-xr-xtests/ts/lsfd/column-kthread2
-rwxr-xr-xtests/ts/lsfd/column-name20
-rwxr-xr-xtests/ts/lsfd/column-source51
-rwxr-xr-xtests/ts/lsfd/column-source-with-root44
-rwxr-xr-xtests/ts/lsfd/column-type4
-rwxr-xr-xtests/ts/lsfd/column-xmode202
-rwxr-xr-xtests/ts/lsfd/filter-broken-exp (renamed from tests/ts/lsfd/option-filter-broken-exp)5
-rwxr-xr-xtests/ts/lsfd/filter-floating-point-nums90
-rw-r--r--tests/ts/lsfd/lsfd-functions.bash44
-rwxr-xr-xtests/ts/lsfd/mkfds-bpf-map49
-rwxr-xr-xtests/ts/lsfd/mkfds-bpf-prog49
-rwxr-xr-xtests/ts/lsfd/mkfds-cdev-tun65
-rwxr-xr-xtests/ts/lsfd/mkfds-directory2
-rwxr-xr-xtests/ts/lsfd/mkfds-eventfd104
-rwxr-xr-xtests/ts/lsfd/mkfds-eventpoll46
-rwxr-xr-xtests/ts/lsfd/mkfds-inotify74
-rwxr-xr-xtests/ts/lsfd/mkfds-inotify-btrfs91
-rwxr-xr-xtests/ts/lsfd/mkfds-mapped-packet-socket2
-rwxr-xr-xtests/ts/lsfd/mkfds-mqueue83
-rwxr-xr-xtests/ts/lsfd/mkfds-multiplexing70
-rwxr-xr-xtests/ts/lsfd/mkfds-netlink-groups2
-rwxr-xr-xtests/ts/lsfd/mkfds-netlink-protocol2
-rwxr-xr-xtests/ts/lsfd/mkfds-netns5
-rwxr-xr-xtests/ts/lsfd/mkfds-pidfd4
-rwxr-xr-xtests/ts/lsfd/mkfds-ping6
-rwxr-xr-xtests/ts/lsfd/mkfds-pipe-no-fork2
-rwxr-xr-xtests/ts/lsfd/mkfds-pty73
-rwxr-xr-xtests/ts/lsfd/mkfds-raw2
-rwxr-xr-xtests/ts/lsfd/mkfds-raw62
-rwxr-xr-xtests/ts/lsfd/mkfds-ro-block-device2
-rwxr-xr-xtests/ts/lsfd/mkfds-ro-regular-file2
-rwxr-xr-xtests/ts/lsfd/mkfds-rw-character-device2
-rwxr-xr-xtests/ts/lsfd/mkfds-signalfd64
-rwxr-xr-xtests/ts/lsfd/mkfds-socketpair95
-rwxr-xr-xtests/ts/lsfd/mkfds-symlink2
-rwxr-xr-xtests/ts/lsfd/mkfds-tcp6
-rwxr-xr-xtests/ts/lsfd/mkfds-tcp66
-rwxr-xr-xtests/ts/lsfd/mkfds-timerfd109
-rwxr-xr-xtests/ts/lsfd/mkfds-timerfd-alarm56
-rwxr-xr-xtests/ts/lsfd/mkfds-udp24
-rwxr-xr-xtests/ts/lsfd/mkfds-udp624
-rwxr-xr-xtests/ts/lsfd/mkfds-unix-dgram8
-rwxr-xr-xtests/ts/lsfd/mkfds-unix-in-netns4
-rwxr-xr-xtests/ts/lsfd/mkfds-unix-stream8
-rwxr-xr-xtests/ts/lsfd/mkfds-unix-stream-requiring-sockdiag58
-rwxr-xr-xtests/ts/lsfd/option-inet70
-rwxr-xr-xtests/ts/lsfd/option-pid2
-rwxr-xr-xtests/ts/lsfd/option-summary4
-rwxr-xr-xtests/ts/lslocks/lslocks117
-rwxr-xr-xtests/ts/misc/boilerplate39
-rwxr-xr-xtests/ts/misc/enosys58
-rwxr-xr-xtests/ts/misc/lsclocks70
-rwxr-xr-xtests/ts/misc/setpgid33
-rwxr-xr-xtests/ts/misc/time_t28
-rwxr-xr-xtests/ts/misc/waitpid4
-rwxr-xr-xtests/ts/mkswap/mkswap44
-rwxr-xr-xtests/ts/mount/fallback10
-rwxr-xr-xtests/ts/mount/fslists2
-rwxr-xr-xtests/ts/mount/fstab-all37
-rwxr-xr-xtests/ts/mount/fstab-bind2
-rwxr-xr-xtests/ts/mount/fstab-broken6
-rwxr-xr-xtests/ts/mount/fstab-btrfs8
-rwxr-xr-xtests/ts/mount/fstab-devname4
-rwxr-xr-xtests/ts/mount/fstab-devname2label2
-rwxr-xr-xtests/ts/mount/fstab-devname2uuid2
-rwxr-xr-xtests/ts/mount/fstab-label6
-rwxr-xr-xtests/ts/mount/fstab-label2devname4
-rwxr-xr-xtests/ts/mount/fstab-label2uuid4
-rwxr-xr-xtests/ts/mount/fstab-loop4
-rwxr-xr-xtests/ts/mount/fstab-none2
-rwxr-xr-xtests/ts/mount/fstab-symlink2
-rwxr-xr-xtests/ts/mount/fstab-uuid6
-rwxr-xr-xtests/ts/mount/fstab-uuid2devname4
-rwxr-xr-xtests/ts/mount/fstab-uuid2label4
-rwxr-xr-xtests/ts/mount/special43
-rwxr-xr-xtests/ts/mount/umount-recursive2
-rwxr-xr-xtests/ts/rename/basic4
-rwxr-xr-xtests/ts/schedutils/chrt11
-rwxr-xr-xtests/ts/setpriv/landlock64
-rwxr-xr-xtests/ts/swapon/devname4
-rw-r--r--tests/ts/wipefs/images/bcachefs.img.xzbin0 -> 5312 bytes
-rwxr-xr-xtests/ts/wipefs/signatures40
-rwxr-xr-xtests/ts/wipefs/wipefs18
147 files changed, 3499 insertions, 242 deletions
diff --git a/tests/ts/blkid/images-fs/swap-luks.img.xz b/tests/ts/blkid/images-fs/swap-luks.img.xz
new file mode 100644
index 0000000..9b5cb65
--- /dev/null
+++ b/tests/ts/blkid/images-fs/swap-luks.img.xz
Binary files differ
diff --git a/tests/ts/blkid/images-fs/vxfs-be.img.xz b/tests/ts/blkid/images-fs/vxfs-be.img.xz
new file mode 100644
index 0000000..61ff461
--- /dev/null
+++ b/tests/ts/blkid/images-fs/vxfs-be.img.xz
Binary files differ
diff --git a/tests/ts/blkid/images-fs/vxfs-le.img.xz b/tests/ts/blkid/images-fs/vxfs-le.img.xz
new file mode 100644
index 0000000..f4643a5
--- /dev/null
+++ b/tests/ts/blkid/images-fs/vxfs-le.img.xz
Binary files differ
diff --git a/tests/ts/column/table b/tests/ts/column/table
index 8b22d83..5d5e131 100755
--- a/tests/ts/column/table
+++ b/tests/ts/column/table
@@ -65,6 +65,13 @@ $TS_CMD_COLUMN --table $TS_SELF/files/mountinfo \
>> $TS_OUTPUT 2>> $TS_ERRLOG
ts_finalize_subtest
+ts_init_subtest "noheaders"
+$TS_CMD_COLUMN --table $TS_SELF/files/table \
+ --table-noheadings \
+ --table-columns VERYLONG,COLUMN,NAMES \
+ >> $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 \
diff --git a/tests/ts/dmesg/cid-input b/tests/ts/dmesg/cid-input
new file mode 100644
index 0000000..7dbd89d
--- /dev/null
+++ b/tests/ts/dmesg/cid-input
@@ -0,0 +1,106 @@
+<0>[ 0.000000] [ T0] example[0]
+<1>[ 1.000000] [ T1] example[1]
+<2>[ 8.000000] [ T2] example[2]
+<3>[ 27.000000] [ T3] example[3]
+<4>[ 64.000000] [ T4] example[4]
+<5>[ 125.000000] [ T5] example[5]
+<6>[ 216.000000] [ T6] example[6]
+<7>[ 343.000000] [ T7] example[7]
+<8>[ 512.000000] [ T8] example[8]
+<9>[ 729.000000] [ T9] example[9]
+<10>[ 1000.000000] [ T10] example[10]
+<11>[ 1331.000000] [ T11] example[11]
+<12>[ 1728.000000] [ T12] example[12]
+<13>[ 2197.000000] [ T13] example[13]
+<14>[ 2744.000000] [ T14] example[14]
+<15>[ 3375.000000] [ T15] example[15]
+<16>[ 4096.000000] [ T16] example[16]
+<17>[ 4913.000000] [ T17] example[17]
+<18>[ 5832.000000] [ T18] example[18]
+<19>[ 6859.000000] [ T19] example[19]
+<20>[ 8000.000000] [ T20] example[20]
+<21>[ 9261.000000] [ T21] example[21]
+<22>[10648.000000] [ T22] example[22]
+<23>[12167.000000] [ T23] example[23]
+<24>[13824.000000] [ T24] example[24]
+<25>[15625.000000] [ T25] example[25]
+<26>[17576.000000] [ T26] example[26]
+<27>[19683.000000] [ T27] example[27]
+<28>[21952.000000] [ T28] example[28]
+<29>[24389.000000] [ T29] example[29]
+<30>[27000.000000] [ T10] example[30]
+<31>[29791.000000] [ T31] example[31]
+<32>[32768.000000] [ T32] example[32]
+<33>[35937.000000] [ T33] example[33]
+<34>[39304.000000] [ T34] example[34]
+<35>[42875.000000] [ T35] example[35]
+<36>[46656.000000] [ T36] example[36]
+<37>[50653.000000] [ T37] example[37]
+<38>[54872.000000] [ T38] example[38]
+<39>[59319.000000] [ T39] example[39]
+<40>[64000.000000] [ T40] example[40]
+<41>[68921.000000] [ T41] example[41]
+<42>[74088.000000] [ T42] example[42]
+<43>[79507.000000] [ T43] example[43]
+<44>[85184.000000] [ T44] example[44]
+<45>[91125.000000] [ T45] example[45]
+<46>[97336.000000] [ T46] example[46]
+<47>[103823.000000] [ T47] example[47]
+<48>[110592.000000] [ T48] example[48]
+<49>[117649.000000] [ T49] example[49]
+<50>[125000.000000] [ T50] example[50]
+<51>[132651.000000] [ T51] example[51]
+<52>[140608.000000] [ T52] example[52]
+<53>[148877.000000] [ T53] example[53]
+<54>[157464.000000] [ T54] example[54]
+<55>[166375.000000] [ T55] example[55]
+<56>[175616.000000] [ T56] example[56]
+<57>[185193.000000] [ T57] example[57]
+<58>[195112.000000] [ T58] example[58]
+<59>[205379.000000] [ T59] example[59]
+<60>[216000.000000] [ T60] example[60]
+<61>[226981.000000] [ T61] example[61]
+<62>[238328.000000] [ T62] example[62]
+<63>[250047.000000] [ T63] example[63]
+<64>[262144.000000] [ T64] example[64]
+<65>[274625.000000] [ T65] example[65]
+<66>[287496.000000] [ T66] example[66]
+<67>[300763.000000] [ T67] example[67]
+<68>[314432.000000] [ T68] example[68]
+<69>[328509.000000] [ T69] example[69]
+<70>[343000.000000] [ T70] example[70]
+<71>[357911.000000] [ T71] example[71]
+<72>[373248.000000] [ T72] example[72]
+<73>[389017.000000] [ T73] example[73]
+<74>[405224.000000] [ T74] example[74]
+<75>[421875.000000] [ T75] example[75]
+<76>[438976.000000] [ T76] example[76]
+<77>[456533.000000] [ T77] example[77]
+<78>[474552.000000] [ T78] example[78]
+<79>[493039.000000] [ T79] example[79]
+<80>[512000.000000] [ T80] example[80]
+<81>[531441.000000] [ T81] example[81]
+<82>[551368.000000] [ T82] example[82]
+<83>[571787.000000] [ T83] example[83]
+<84>[592704.000000] [ T84] example[84]
+<85>[614125.000000] [ T85] example[85]
+<86>[636056.000000] [ T86] example[86]
+<87>[658503.000000] [ T87] example[87]
+<88>[681472.000000] [ T88] example[88]
+<89>[704969.000000] [ T89] example[89]
+<90>[729000.000000] [ T90] example[90]
+<91>[753571.000000] [ T91] example[91]
+<92>[778688.000000] [ T92] example[92]
+<93>[804357.000000] [ T93] example[93]
+<94>[830584.000000] [ T94] example[94]
+<95>[857375.000000] [ T95] example[95]
+<96>[884736.000000] [ T96] example[96]
+<97>[912673.000000] [ T97] example[97]
+<98>[941192.000000] [ T98] example[98]
+<99>[970299.000000] [ T99] example[99]
+<100>[1000000.000000] [ T100] example[100]
+<101>[1030301.000000] [ T101] example[101]
+<102>[1061208.000000] [ T102] example[102]
+<103>[1092727.000000] [ T103] example[103]
+<104>[1124864.000000] [ T104] example[104]
+<150>[4557523.000000] [ T105] example[105]
diff --git a/tests/ts/dmesg/cid-json b/tests/ts/dmesg/cid-json
new file mode 100755
index 0000000..7836379
--- /dev/null
+++ b/tests/ts/dmesg/cid-json
@@ -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="cid-json"
+
+. "$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 -J -F $TS_SELF/cid-input >> $TS_OUTPUT 2>/dev/null
+
+ts_finalize
diff --git a/tests/ts/dmesg/cid-kmsg-colors b/tests/ts/dmesg/cid-kmsg-colors
new file mode 100755
index 0000000..b94e8a9
--- /dev/null
+++ b/tests/ts/dmesg/cid-kmsg-colors
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="cid-kmsg-colors"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_HELPER_DMESG"
+ts_inhibit_custom_colorscheme
+
+export TZ="GMT"
+export DMESG_TEST_BOOTIME="1234567890.123456"
+
+$TS_HELPER_DMESG --color=always -K $TS_SELF/cid-kmsg-input -x >> $TS_OUTPUT 2>/dev/null
+
+# dmesg kmsg output can have varying number of caller_id padding spaces
+# normalize caller_id padding by removing leading spaces
+sed -i 's/\[ *T/\[T/g' $TS_OUTPUT
+sed -i 's/\[ *C/\[C/g' $TS_OUTPUT
+
+ts_finalize
diff --git a/tests/ts/dmesg/cid-kmsg-console-levels b/tests/ts/dmesg/cid-kmsg-console-levels
new file mode 100755
index 0000000..19d8004
--- /dev/null
+++ b/tests/ts/dmesg/cid-kmsg-console-levels
@@ -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="cid-kmsg-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
+ echo "Display console level: $I" >> $TS_OUTPUT
+ $TS_HELPER_DMESG -K $TS_SELF/cid-kmsg-input -l $I >> $TS_OUTPUT 2>/dev/null
+done
+
+echo "Display console level: err+" >> $TS_OUTPUT
+$TS_HELPER_DMESG -K $TS_SELF/cid-kmsg-input -l err+ >> $TS_OUTPUT 2>/dev/null
+echo "Display console level: emerg+" >> $TS_OUTPUT
+$TS_HELPER_DMESG -K $TS_SELF/cid-kmsg-input -l emerg+ >> $TS_OUTPUT 2>/dev/null
+echo "Display console level: +err" >> $TS_OUTPUT
+$TS_HELPER_DMESG -K $TS_SELF/cid-kmsg-input -l +err >> $TS_OUTPUT 2>/dev/null
+echo "Display console level: +debug" >> $TS_OUTPUT
+$TS_HELPER_DMESG -K $TS_SELF/cid-kmsg-input -l +debug >> $TS_OUTPUT 2>/dev/null
+echo "Display console level: debug" >> $TS_OUTPUT
+$TS_HELPER_DMESG -K $TS_SELF/cid-kmsg-input -l debug >> $TS_OUTPUT 2>/dev/null
+echo "Display console level: + (invalid)" >> $TS_OUTPUT
+$TS_HELPER_DMESG -K $TS_SELF/cid-kmsg-input -l + 2>> $TS_OUTPUT >/dev/null
+
+# dmesg kmsg output can have varying number of caller_id padding spaces
+# normalize caller_id padding by removing leading spaces
+sed -i 's/\[ *T/\[T/g' $TS_OUTPUT
+sed -i 's/\[ *C/\[C/g' $TS_OUTPUT
+
+ts_finalize
diff --git a/tests/ts/dmesg/cid-kmsg-decode b/tests/ts/dmesg/cid-kmsg-decode
new file mode 100755
index 0000000..b920997
--- /dev/null
+++ b/tests/ts/dmesg/cid-kmsg-decode
@@ -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="cid-kmsg-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 -K $TS_SELF/cid-kmsg-input >> $TS_OUTPUT 2>/dev/null
+
+# dmesg kmsg output can have varying number of caller_id padding spaces
+# normalize caller_id padding by removing leading spaces
+sed -i 's/\[ *T/\[T/g' $TS_OUTPUT
+sed -i 's/\[ *C/\[C/g' $TS_OUTPUT
+
+ts_finalize
diff --git a/tests/ts/dmesg/cid-kmsg-delta b/tests/ts/dmesg/cid-kmsg-delta
new file mode 100755
index 0000000..1b5f572
--- /dev/null
+++ b/tests/ts/dmesg/cid-kmsg-delta
@@ -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="cid-kmsg-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 -K $TS_SELF/cid-kmsg-input >> $TS_OUTPUT 2>/dev/null
+
+# dmesg kmsg output can have varying number of caller_id padding spaces
+# normalize caller_id padding by removing leading spaces
+sed -i 's/\[ *T/\[T/g' $TS_OUTPUT
+sed -i 's/\[ *C/\[C/g' $TS_OUTPUT
+
+ts_finalize
diff --git a/tests/ts/dmesg/cid-kmsg-facilities b/tests/ts/dmesg/cid-kmsg-facilities
new file mode 100755
index 0000000..38ca9c5
--- /dev/null
+++ b/tests/ts/dmesg/cid-kmsg-facilities
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="cid-kmsg-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
+ echo "Display facility list: $I" >> $TS_OUTPUT
+ $TS_HELPER_DMESG -K $TS_SELF/cid-kmsg-input -f $I -x >> $TS_OUTPUT 2>/dev/null
+done
+
+# dmesg kmsg output can have varying number of caller_id padding spaces
+# normalize caller_id padding by removing leading spaces
+sed -i 's/\[ *T/\[T/g' $TS_OUTPUT
+sed -i 's/\[ *C/\[C/g' $TS_OUTPUT
+
+ts_finalize
diff --git a/tests/ts/dmesg/cid-kmsg-indentation b/tests/ts/dmesg/cid-kmsg-indentation
new file mode 100755
index 0000000..c3f8e06
--- /dev/null
+++ b/tests/ts/dmesg/cid-kmsg-indentation
@@ -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="cid-kmsg-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 -K $TS_SELF/cid-kmsg-newlines >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+$TS_HELPER_DMESG -K $TS_SELF/cid-kmsg-newlines >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+$TS_HELPER_DMESG --time-format=delta --kmsg-file $TS_SELF/cid-kmsg-newlines >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+$TS_HELPER_DMESG --time-format=notime --kmsg-file $TS_SELF/cid-kmsg-newlines >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+$TS_HELPER_DMESG --time-format=reltime --kmsg-file $TS_SELF/cid-kmsg-newlines >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+$TS_HELPER_DMESG --time-format=ctime --kmsg-file $TS_SELF/cid-kmsg-newlines >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+$TS_HELPER_DMESG --time-format=iso --kmsg-file $TS_SELF/cid-kmsg-newlines >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+# dmesg kmsg output can have varying number of caller_id padding spaces
+# normalize caller_id padding by removing leading spaces
+sed -i 's/\[ *T/\[T/g' $TS_OUTPUT
+sed -i 's/\[ *C/\[C/g' $TS_OUTPUT
+
+ts_finalize
diff --git a/tests/ts/dmesg/cid-kmsg-input b/tests/ts/dmesg/cid-kmsg-input
new file mode 100644
index 0000000..2575be8
--- /dev/null
+++ b/tests/ts/dmesg/cid-kmsg-input
Binary files differ
diff --git a/tests/ts/dmesg/cid-kmsg-json b/tests/ts/dmesg/cid-kmsg-json
new file mode 100755
index 0000000..ad1e3e7
--- /dev/null
+++ b/tests/ts/dmesg/cid-kmsg-json
@@ -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="cid-kmsg-json"
+
+. "$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 -J -K $TS_SELF/cid-kmsg-input >> $TS_OUTPUT 2>/dev/null
+
+ts_finalize
diff --git a/tests/ts/dmesg/cid-kmsg-limit b/tests/ts/dmesg/cid-kmsg-limit
new file mode 100755
index 0000000..06f1c8b
--- /dev/null
+++ b/tests/ts/dmesg/cid-kmsg-limit
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="cid-kmsg-limit"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_HELPER_DMESG"
+
+export TZ="GMT"
+export DMESG_TEST_BOOTIME="1234567890.123456"
+
+$TS_HELPER_DMESG --since @1234567890.124 --until @1234567991 -K $TS_SELF/cid-kmsg-input \
+ >> $TS_OUTPUT 2> $TS_ERRLOG
+
+# dmesg kmsg output can have varying number of caller_id padding spaces
+# normalize caller_id padding by removing leading spaces
+sed -i 's/\[ *T/\[T/g' $TS_OUTPUT
+sed -i 's/\[ *C/\[C/g' $TS_OUTPUT
+
+ts_finalize
diff --git a/tests/ts/dmesg/cid-kmsg-newlines b/tests/ts/dmesg/cid-kmsg-newlines
new file mode 100644
index 0000000..574d217
--- /dev/null
+++ b/tests/ts/dmesg/cid-kmsg-newlines
Binary files differ
diff --git a/tests/ts/dmesg/input b/tests/ts/dmesg/input
index 98307df..bcec23e 100644
--- a/tests/ts/dmesg/input
+++ b/tests/ts/dmesg/input
@@ -103,3 +103,4 @@
<102>[1061208.000000] example[102]
<103>[1092727.000000] example[103]
<104>[1124864.000000] example[104]
+<150>[4557523.000000] example[105]
diff --git a/tests/ts/dmesg/json b/tests/ts/dmesg/json
new file mode 100755
index 0000000..09ed2b0
--- /dev/null
+++ b/tests/ts/dmesg/json
@@ -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="json"
+
+. "$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 -J -F $TS_SELF/input >> $TS_OUTPUT 2>/dev/null
+
+ts_finalize
diff --git a/tests/ts/dmesg/kmsg-file b/tests/ts/dmesg/kmsg-file
new file mode 100755
index 0000000..a90a91e
--- /dev/null
+++ b/tests/ts/dmesg/kmsg-file
@@ -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="kmsg-file"
+
+. "$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 -J -K $TS_SELF/kmsg-input >> $TS_OUTPUT 2>/dev/null
+
+ts_finalize
diff --git a/tests/ts/dmesg/kmsg-input b/tests/ts/dmesg/kmsg-input
new file mode 100644
index 0000000..c08331d
--- /dev/null
+++ b/tests/ts/dmesg/kmsg-input
Binary files differ
diff --git a/tests/ts/dmesg/timestamp-format b/tests/ts/dmesg/timestamp-format
new file mode 100755
index 0000000..feb1ad8
--- /dev/null
+++ b/tests/ts/dmesg/timestamp-format
@@ -0,0 +1,42 @@
+#!/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="timestamp-format"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_HELPER_DMESG"
+
+export TZ="GMT"
+export DMESG_TEST_BOOTIME="1234567890.123456"
+
+ts_init_subtest "multiple"
+$TS_HELPER_DMESG --time-format raw --time-format ctime --time-format iso -F $TS_SELF/input >> $TS_OUTPUT 2>/dev/null
+ts_finalize_subtest
+
+ts_init_subtest "delta"
+$TS_HELPER_DMESG --time-format iso --time-format delta -F $TS_SELF/input >> $TS_OUTPUT 2>/dev/null
+ts_finalize_subtest
+
+ts_init_subtest "delta-ctime"
+$TS_HELPER_DMESG --time-format reltime --time-format delta --time-format ctime -F $TS_SELF/input >> $TS_OUTPUT 2>/dev/null
+ts_finalize_subtest
+
+ts_init_subtest "delta-raw"
+$TS_HELPER_DMESG --time-format raw --time-format ctime --time-format delta -F $TS_SELF/input >> $TS_OUTPUT 2>/dev/null
+ts_finalize_subtest
+
+ts_finalize
diff --git a/tests/ts/eject/umount b/tests/ts/eject/umount
index 838ee9c..af5808f 100755
--- a/tests/ts/eject/umount
+++ b/tests/ts/eject/umount
@@ -83,7 +83,7 @@ init_device
mkfs.ext2 -q -F $TS_DEVICE
udevadm settle
mkdir -p $TS_MOUNTPOINT
-$TS_CMD_MOUNT $TS_DEVICE $TS_MOUNTPOINT
+$TS_CMD_MOUNT $TS_DEVICE $TS_MOUNTPOINT &> /dev/null
udevadm settle
$TS_CMD_EJECT --force $TS_DEVICE && ts_log "Success"
deinit_device
@@ -95,8 +95,8 @@ 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
+$TS_CMD_MOUNT ${TS_DEVICE}1 ${TS_MOUNTPOINT}1 &> /dev/null
+$TS_CMD_MOUNT ${TS_DEVICE}2 ${TS_MOUNTPOINT}2 &> /dev/null
udevadm settle
$TS_CMD_EJECT --force $TS_DEVICE && ts_log "Success"
deinit_device
@@ -116,8 +116,8 @@ 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
+$TS_CMD_MOUNT ${TS_DEVICE}1 ${TS_MOUNTPOINT}1 &> /dev/null
+$TS_CMD_MOUNT ${TS_DEVICE}2 ${TS_MOUNTPOINT}2 &> /dev/null
udevadm settle
$TS_CMD_EJECT --force ${TS_DEVICE}1 && ts_log "Success"
deinit_device
diff --git a/tests/ts/exch/exch b/tests/ts/exch/exch
new file mode 100755
index 0000000..1c6a28e
--- /dev/null
+++ b/tests/ts/exch/exch
@@ -0,0 +1,40 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 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="exch"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_EXCH"
+
+ts_cd "$TS_OUTDIR"
+
+{
+ echo A > a
+ echo B > b
+
+ cat a
+ cat b
+
+ "$TS_CMD_EXCH" a b
+
+ cat a
+ cat b
+} > "$TS_OUTPUT" 2>&1
+
+ts_finalize
diff --git a/tests/ts/fadvise/drop b/tests/ts/fadvise/drop
index 7c7eee5..45dcb91 100755
--- a/tests/ts/fadvise/drop
+++ b/tests/ts/fadvise/drop
@@ -16,7 +16,7 @@ ts_check_prog "sleep"
ts_cd "$TS_OUTDIR"
FILE="ddtest"
-BS=4k
+BS=65536
COUNT=8
FILE_FS="$("$TS_CMD_FINDMNT" -nr -o FSTYPE -T "$PWD")"
@@ -28,37 +28,41 @@ create_file() {
dd if=/dev/zero of="$FILE" bs=$BS count=$COUNT conv=fsync >& /dev/null
}
+do_fincore() {
+ "$TS_CMD_FINCORE" -o RES,SIZE,FILE "$FILE"
+}
+
{
create_file
- "$TS_CMD_FINCORE" "$FILE"
+ do_fincore
echo
create_file
echo "whole file"
"$TS_CMD_FADVISE" "$FILE"
echo status: $?
- "$TS_CMD_FINCORE" "$FILE"
+ do_fincore
echo
create_file
- echo "offset: 8192"
- "$TS_CMD_FADVISE" -o 8192 "$FILE"
+ echo "offset: $(( 2 * $BS ))"
+ "$TS_CMD_FADVISE" -o $(( 2 * $BS )) "$FILE"
echo status: $?
- "$TS_CMD_FINCORE" "$FILE"
+ do_fincore
echo
create_file
- echo "length: 16384"
- "$TS_CMD_FADVISE" -l 16384 "$FILE"
+ echo "length: $(( 4 * $BS ))"
+ "$TS_CMD_FADVISE" -l $(( 4 * $BS )) "$FILE"
echo status: $?
- "$TS_CMD_FINCORE" "$FILE"
+ do_fincore
echo
create_file
- echo "offset: 8192, length: 16384 fd: 42"
- "$TS_CMD_FADVISE" -o 8192 -l 16384 --fd 42 42<"$FILE"
+ echo "offset: $(( 2 * $BS )), length: $(( 4 * $BS )) fd: 42"
+ "$TS_CMD_FADVISE" -o $(( 2 * $BS )) -l $(( 4 * $BS )) --fd 42 42<"$FILE"
echo status: $?
- "$TS_CMD_FINCORE" "$FILE"
+ do_fincore
echo
rm "$FILE"
diff --git a/tests/ts/fdisk/resize b/tests/ts/fdisk/resize
new file mode 100755
index 0000000..9536cd7
--- /dev/null
+++ b/tests/ts/fdisk/resize
@@ -0,0 +1,66 @@
+#!/bin/bash
+#
+# This file is part of util-linux.
+#
+# Copyright (C) 2023 Thomas Weißschuh <thomas@t-8ch.de>
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the 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_FDISK"
+
+TEST_IMAGE_NAME=$(ts_image_init 10)
+
+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}"
+}
+
+function test_fdisk() {
+ "$TS_CMD_FDISK" --noauto-pt "${TEST_IMAGE_NAME}" &> /dev/null
+}
+
+ts_log "Create initial partitions"
+echo -e "g\nn\n\n\n+1M\nn\n\n8192\n+1M\nw\n" | test_fdisk
+
+print_layout
+
+ts_log "Grow first to max"
+echo -e "e\n1\n\nw\n" | test_fdisk
+
+print_layout
+
+ts_log "Grow second to max"
+echo -e "e\n2\n\nw\n" | test_fdisk
+
+print_layout
+
+ts_log "Resize first to 4096 bytes"
+echo -e "e\n1\n4K\nw\n" | test_fdisk
+
+print_layout
+
+ts_log "Resize second to 8 sectors"
+echo -e "e\n2\n8S\nw\n" | test_fdisk
+
+print_layout
+
+ts_finalize
diff --git a/tests/ts/fincore/count b/tests/ts/fincore/count
index ba5f6cd..caf9c3a 100755
--- a/tests/ts/fincore/count
+++ b/tests/ts/fincore/count
@@ -107,6 +107,7 @@ if test -f "$TS_EXPECTED.$PAGE_SIZE"; then
OUT_COLUMNS="PAGES,SIZE,FILE"
else
TS_EXPECTED+=".nosize"
+ TS_EXPECTED_ERR+=".nosize"
OUT_COLUMNS="PAGES,FILE"
fi
@@ -119,11 +120,11 @@ check_dd_fs_feat
INPUT=
input=
+ts_log_both "[ NO EXCITING FILE ]"
{
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
@@ -220,8 +221,8 @@ input=
"oflag=append seek=$hole_count"
} >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_log_both "[ MULTIPLE FILES ]"
{
- ts_log_both "[ MULTIPLE FILES ]"
$TS_CMD_FINCORE --output $OUT_COLUMNS --bytes $INPUT
footer "$?"
} >> $TS_OUTPUT 2>> $TS_ERRLOG
diff --git a/tests/ts/hexdump/format-strings b/tests/ts/hexdump/format-strings
index 9f055ba..b971538 100755
--- a/tests/ts/hexdump/format-strings
+++ b/tests/ts/hexdump/format-strings
@@ -43,6 +43,10 @@ ts_init_subtest "1b_octal"
$TS_CMD_HEXDUMP -b $FILES/ascii.in &> $TS_OUTPUT
ts_finalize_subtest
+ts_init_subtest "1b_hex"
+$TS_CMD_HEXDUMP -X $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
diff --git a/tests/ts/lib/timeutils b/tests/ts/lib/timeutils
index 13ec68b..043b0c0 100755
--- a/tests/ts/lib/timeutils
+++ b/tests/ts/lib/timeutils
@@ -16,9 +16,15 @@ ts_init "$*"
ts_check_test_command "$TS_HELPER_TIMEUTILS"
ts_init_subtest "timestamp"
+"$TS_HELPER_TIMEUTILS" --unittest-timestamp 2> "$TS_ERRLOG" || ts_die "test failed"
+ts_finalize_subtest
-"$TS_HELPER_TIMEUTILS" --unittest-timestamp 2> "$TS_ERRLOG"
+ts_init_subtest "format"
+"$TS_HELPER_TIMEUTILS" --unittest-format 2> "$TS_ERRLOG" || ts_die "test failed"
+ts_finalize_subtest
+ts_init_subtest "format-relative"
+"$TS_HELPER_TIMEUTILS" --unittest-format-relative 2> "$TS_ERRLOG" || ts_die "test failed"
ts_finalize_subtest
ts_finalize
diff --git a/tests/ts/liblastlog2/dlopen b/tests/ts/liblastlog2/dlopen
new file mode 100755
index 0000000..8ce4e17
--- /dev/null
+++ b/tests/ts/liblastlog2/dlopen
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="dlopen"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+# incorrect warning: top_builddir is referenced but not assigned.
+# shellcheck disable=SC2154
+if [ -e "$top_builddir/meson.conf" ]; then
+ #meson build
+ libpath=${top_builddir}/liblastlog2
+else
+ #automake/autoconf build
+ libpath=${top_builddir}/.libs
+fi
+
+ts_check_test_command $TS_HELPER_LIBLASTLOG2_DLOPEN
+
+$TS_HELPER_LIBLASTLOG2_DLOPEN ${libpath}/liblastlog2.so >/dev/null || ts_failed "returned an error"
+
+ts_finalize
diff --git a/tests/ts/liblastlog2/pam_lastlog2_output b/tests/ts/liblastlog2/pam_lastlog2_output
new file mode 100755
index 0000000..c9961f1
--- /dev/null
+++ b/tests/ts/liblastlog2/pam_lastlog2_output
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="pam_lastlog2_output"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command $TS_HELPER_LIBLASTLOG2_PAM_LASTLOG2_OUTPUT
+
+export TZ=UTC
+
+$TS_HELPER_LIBLASTLOG2_PAM_LASTLOG2_OUTPUT || ts_failed "returned an error"
+
+rm pam_lastlog2-output.db
+
+ts_finalize
diff --git a/tests/ts/liblastlog2/remove_entry b/tests/ts/liblastlog2/remove_entry
new file mode 100755
index 0000000..63503d9
--- /dev/null
+++ b/tests/ts/liblastlog2/remove_entry
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="remove_entry"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command $TS_HELPER_LIBLASTLOG2_REMOVE_ENTRY
+
+$TS_HELPER_LIBLASTLOG2_REMOVE_ENTRY || ts_failed "returned an error"
+
+rm tst-delete-user.db
+
+ts_finalize
diff --git a/tests/ts/liblastlog2/rename_user b/tests/ts/liblastlog2/rename_user
new file mode 100755
index 0000000..38f0763
--- /dev/null
+++ b/tests/ts/liblastlog2/rename_user
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="rename_user"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command $TS_HELPER_LIBLASTLOG2_RENAME_USER
+
+$TS_HELPER_LIBLASTLOG2_RENAME_USER || ts_failed "returned an error"
+
+rm tst-rename-user.db
+
+ts_finalize
diff --git a/tests/ts/liblastlog2/sqlite3_time b/tests/ts/liblastlog2/sqlite3_time
new file mode 100755
index 0000000..9ff27fe
--- /dev/null
+++ b/tests/ts/liblastlog2/sqlite3_time
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="sqlite3_time"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command $TS_HELPER_LIBLASTLOG2_Y2038_SQLITE2_TIME
+
+$TS_HELPER_LIBLASTLOG2_Y2038_SQLITE2_TIME >/dev/null || ts_failed "returned an error"
+
+rm y2038-sqlite3-time.db
+
+ts_finalize
diff --git a/tests/ts/liblastlog2/write_read_user b/tests/ts/liblastlog2/write_read_user
new file mode 100755
index 0000000..8a6028a
--- /dev/null
+++ b/tests/ts/liblastlog2/write_read_user
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="write_read_user"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command $TS_HELPER_LIBLASTLOG2_WRITE_READ_USER
+
+$TS_HELPER_LIBLASTLOG2_WRITE_READ_USER || ts_failed "returned an error"
+
+rm tst-write-read-user.db
+
+ts_finalize
diff --git a/tests/ts/liblastlog2/y2038_ll2_read_all b/tests/ts/liblastlog2/y2038_ll2_read_all
new file mode 100755
index 0000000..da779c2
--- /dev/null
+++ b/tests/ts/liblastlog2/y2038_ll2_read_all
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="y2038_ll2_read_all"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command $TS_HELPER_LIBLASTLOG2_Y2038_LL2_READ_ALL
+
+$TS_HELPER_LIBLASTLOG2_Y2038_LL2_READ_ALL >/dev/null || ts_failed "returned an error"
+
+rm y2038-ll2_read_all.db
+
+ts_finalize
diff --git a/tests/ts/libmount/optlist b/tests/ts/libmount/optlist
new file mode 100755
index 0000000..8499496
--- /dev/null
+++ b/tests/ts/libmount/optlist
@@ -0,0 +1,67 @@
+#!/bin/bash
+
+# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="options string"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command $TS_HELPER_LIBMOUNT_OPTLIST
+
+TESTPROG="$TS_HELPER_LIBMOUNT_OPTLIST"
+
+ts_init_subtest "append"
+ts_run $TESTPROG --append-str "aaa,bbb=BBB,context=\"foo,bar,gogo\",ccc" "ddd" &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "append-value"
+ts_run $TESTPROG --append-str "aaa,bbb=BBB,ccc" "ddd=DDD" &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "append-empty-value"
+ts_run $TESTPROG --append-str "aaa,bbb=BBB,ccc" "ddd=" &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "prepend"
+ts_run $TESTPROG --prepend-str "aaa,bbb=BBB,ccc" "ddd" &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "prepend-list"
+ts_run $TESTPROG --prepend-str "aaa,bbb=BBB,ccc" "ddd,eee=EEE,fff" &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "prepend-value"
+ts_run $TESTPROG --prepend-str "aaa,bbb=BBB,ccc" "ddd=DDD" &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "prepend-empty-value"
+ts_run $TESTPROG --prepend-str "aaa,bbb=BBB,ccc" "ddd=" &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "set"
+ts_run $TESTPROG --set-str "aaa,bbb=BBB,ccc" "new,data,for,list" &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "get-str"
+ts_run $TESTPROG --get-str "aaa,bbb=BBB,ccc,defaults" &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "get-str-linux"
+ts_run $TESTPROG --get-str "noexec,noauto,user,defaults" linux &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "get-str-user"
+ts_run $TESTPROG --get-str "noexec,noauto,user,defaults" user &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "get-flg-linux"
+ts_run $TESTPROG --get-flg "noexec,noauto,user,defaults" linux &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "get-flg-user"
+ts_run $TESTPROG --get-flg "noexec,noauto,user,defaults" user &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_finalize
diff --git a/tests/ts/libmount/optstr b/tests/ts/libmount/optstr
index 26d9b73..979517e 100755
--- a/tests/ts/libmount/optstr
+++ b/tests/ts/libmount/optstr
@@ -8,9 +8,9 @@ TS_DESC="options string"
. "$TS_TOPDIR"/functions.sh
ts_init "$*"
-TESTPROG="$TS_HELPER_LIBMOUNT_OPTSTR"
+ts_check_test_command $TS_HELPER_LIBMOUNT_OPTSTR
-[ -x $TESTPROG ] || ts_skip "test not compiled"
+TESTPROG="$TS_HELPER_LIBMOUNT_OPTSTR"
ts_init_subtest "append"
ts_run $TESTPROG --append "aaa,bbb=BBB,context=\"foo,bar,gogo\",ccc" "ddd" &> $TS_OUTPUT
@@ -28,6 +28,10 @@ ts_init_subtest "prepend"
ts_run $TESTPROG --prepend "aaa,bbb=BBB,ccc" "ddd" &> $TS_OUTPUT
ts_finalize_subtest
+ts_init_subtest "prepend-list"
+ts_run $TESTPROG --prepend "aaa,bbb=BBB,ccc" "ddd,eee=EEE,fff" &> $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
diff --git a/tests/ts/libmount/update b/tests/ts/libmount/update
index ba93e0b..b8f7488 100755
--- a/tests/ts/libmount/update
+++ b/tests/ts/libmount/update
@@ -7,7 +7,6 @@ TS_DESC="tab update"
. "$TS_TOPDIR"/functions.sh
ts_init "$*"
-ts_skip_nonroot
TESTPROG="$TS_HELPER_LIBMOUNT_UPDATE"
diff --git a/tests/ts/libmount/update-py b/tests/ts/libmount/update-py
index bfb8441..b4450c4 100755
--- a/tests/ts/libmount/update-py
+++ b/tests/ts/libmount/update-py
@@ -8,7 +8,6 @@ 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"
diff --git a/tests/ts/libsmartcols/continuous-json b/tests/ts/libsmartcols/continuous-json
new file mode 100755
index 0000000..8456d6b
--- /dev/null
+++ b/tests/ts/libsmartcols/continuous-json
@@ -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_CONTINUOUS_JSON"
+ts_check_test_command "$TESTPROG"
+
+ts_run $TESTPROG --width 80 >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+ts_finalize
diff --git a/tests/ts/libsmartcols/files/col-bool b/tests/ts/libsmartcols/files/col-bool
new file mode 100644
index 0000000..c3324e8
--- /dev/null
+++ b/tests/ts/libsmartcols/files/col-bool
@@ -0,0 +1 @@
+name=BOOL,right,type=boolean,json=boolean
diff --git a/tests/ts/libsmartcols/files/col-float b/tests/ts/libsmartcols/files/col-float
new file mode 100644
index 0000000..7069dc7
--- /dev/null
+++ b/tests/ts/libsmartcols/files/col-float
@@ -0,0 +1 @@
+name=NUM,right,type=float,json=float
diff --git a/tests/ts/libsmartcols/files/col-hidden b/tests/ts/libsmartcols/files/col-hidden
index 83182a8..9bbb15f 100644
--- a/tests/ts/libsmartcols/files/col-hidden
+++ b/tests/ts/libsmartcols/files/col-hidden
@@ -1,3 +1 @@
-FOO
-0
-hidden
+name=FOO,hidden
diff --git a/tests/ts/libsmartcols/files/col-id b/tests/ts/libsmartcols/files/col-id
index 0188f42..8a800fc 100644
--- a/tests/ts/libsmartcols/files/col-id
+++ b/tests/ts/libsmartcols/files/col-id
@@ -1,3 +1 @@
-ID
-0
-right
+name=ID,right,type=number,json=number
diff --git a/tests/ts/libsmartcols/files/col-name b/tests/ts/libsmartcols/files/col-name
index 0a98f29..4fed26f 100644
--- a/tests/ts/libsmartcols/files/col-name
+++ b/tests/ts/libsmartcols/files/col-name
@@ -1,3 +1 @@
-NAME
-0
-none
+name=NAME
diff --git a/tests/ts/libsmartcols/files/col-noextremes b/tests/ts/libsmartcols/files/col-noextremes
index 715edce..7df2e2f 100644
--- a/tests/ts/libsmartcols/files/col-noextremes
+++ b/tests/ts/libsmartcols/files/col-noextremes
@@ -1,3 +1 @@
-NOEXTREME
-0
-noextremes
+name=NOEXTREME,noextremes
diff --git a/tests/ts/libsmartcols/files/col-number b/tests/ts/libsmartcols/files/col-number
index 34a70e4..0f880ff 100644
--- a/tests/ts/libsmartcols/files/col-number
+++ b/tests/ts/libsmartcols/files/col-number
@@ -1,3 +1 @@
-NUM
-0
-right
+name=NUM,right,type=number,json=number
diff --git a/tests/ts/libsmartcols/files/col-parent b/tests/ts/libsmartcols/files/col-parent
index 86fe08c..be25a82 100644
--- a/tests/ts/libsmartcols/files/col-parent
+++ b/tests/ts/libsmartcols/files/col-parent
@@ -1,3 +1 @@
-PARENT
-0
-right
+name=PARENT,right,type=number
diff --git a/tests/ts/libsmartcols/files/col-strict b/tests/ts/libsmartcols/files/col-strict
index 62bb96b..8381f92 100644
--- a/tests/ts/libsmartcols/files/col-strict
+++ b/tests/ts/libsmartcols/files/col-strict
@@ -1,3 +1 @@
-STRICT
-20
-strictwidth,right
+name=STRICT,strictwidth,right,width=20
diff --git a/tests/ts/libsmartcols/files/col-string b/tests/ts/libsmartcols/files/col-string
index 7e2904b..e96c37f 100644
--- a/tests/ts/libsmartcols/files/col-string
+++ b/tests/ts/libsmartcols/files/col-string
@@ -1,3 +1 @@
-STRINGS
-0
-none
+name=STRINGS
diff --git a/tests/ts/libsmartcols/files/col-tree b/tests/ts/libsmartcols/files/col-tree
index 5076880..6c69ca0 100644
--- a/tests/ts/libsmartcols/files/col-tree
+++ b/tests/ts/libsmartcols/files/col-tree
@@ -1,3 +1 @@
-TREE
-0
-tree
+name=TREE,tree
diff --git a/tests/ts/libsmartcols/files/col-trunc b/tests/ts/libsmartcols/files/col-trunc
index 2887b43..55c9a70 100644
--- a/tests/ts/libsmartcols/files/col-trunc
+++ b/tests/ts/libsmartcols/files/col-trunc
@@ -1,3 +1 @@
-TRUNC
-0
-trunc
+name=TRUNC,trunc
diff --git a/tests/ts/libsmartcols/files/col-wrap b/tests/ts/libsmartcols/files/col-wrap
index dc4ca34..c8e622d 100644
--- a/tests/ts/libsmartcols/files/col-wrap
+++ b/tests/ts/libsmartcols/files/col-wrap
@@ -1,3 +1 @@
-WRAP
-0
-wrap
+name=WRAP,wrap
diff --git a/tests/ts/libsmartcols/files/col-wrapnl b/tests/ts/libsmartcols/files/col-wrapnl
index 0a18fd1..fcbc217 100644
--- a/tests/ts/libsmartcols/files/col-wrapnl
+++ b/tests/ts/libsmartcols/files/col-wrapnl
@@ -1,3 +1 @@
-WRAPNL
-0
-wrapnl
+name=WRAPNL,wrapnl
diff --git a/tests/ts/libsmartcols/files/col-wrapzero b/tests/ts/libsmartcols/files/col-wrapzero
new file mode 100644
index 0000000..b197014
--- /dev/null
+++ b/tests/ts/libsmartcols/files/col-wrapzero
@@ -0,0 +1 @@
+name=WRAPZERO,wrapzero
diff --git a/tests/ts/libsmartcols/files/data-bool b/tests/ts/libsmartcols/files/data-bool
new file mode 100644
index 0000000..d6bda92
--- /dev/null
+++ b/tests/ts/libsmartcols/files/data-bool
@@ -0,0 +1,10 @@
+0
+1
+
+0
+true
+false
+FALSE
+TRUE
+0
+1
diff --git a/tests/ts/libsmartcols/files/data-float b/tests/ts/libsmartcols/files/data-float
new file mode 100644
index 0000000..ead3d90
--- /dev/null
+++ b/tests/ts/libsmartcols/files/data-float
@@ -0,0 +1,10 @@
+0
+100
+100.5
+99.9
+411
+5111
+678993321
+7666666
+8000
+8000.5
diff --git a/tests/ts/libsmartcols/files/data-string-nl b/tests/ts/libsmartcols/files/data-string-nl
index 7822e57..ef16a72 100644
--- a/tests/ts/libsmartcols/files/data-string-nl
+++ b/tests/ts/libsmartcols/files/data-string-nl
@@ -1,10 +1,10 @@
aaa
bbbbb
-cccc\nCCCC
-dddddddd\nDDDD\nDD
-hello\nbaby
-aaa\nbbb\nccc\nddd
+cccc\x0ACCCC
+dddddddd\x0ADDDD\x0ADD
+hello\x0Ababy
+aaa\x0Abbb\x0Accc\x0Addd
eee
fffff
-g\nhhhhh
+g\x0Ahhhhh
ppppppppp
diff --git a/tests/ts/libsmartcols/files/data-string-zero b/tests/ts/libsmartcols/files/data-string-zero
new file mode 100644
index 0000000..5f936f1
--- /dev/null
+++ b/tests/ts/libsmartcols/files/data-string-zero
@@ -0,0 +1,10 @@
+aaa
+bbbbb
+cccc\x00CCCC
+dddddddd\x00DDDD\x00DD
+hello\x00baby
+aaa\x00bbb\x00ccc\x00ddd
+eee
+fffff
+g\x00hhhhh
+ppppppppp
diff --git a/tests/ts/libsmartcols/filter b/tests/ts/libsmartcols/filter
new file mode 100755
index 0000000..2025ef5
--- /dev/null
+++ b/tests/ts/libsmartcols/filter
@@ -0,0 +1,217 @@
+#!/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"
+
+### Number
+#
+prefix="number"
+declare -A FILTERS
+
+FILTERS["is"]='NUM'
+FILTERS["neg"]='!NUM'
+FILTERS["and"]='NUM && NAME'
+FILTERS["or"]='NUM || NAME'
+
+FILTERS["eq"]='NUM == 100'
+FILTERS["ne"]='NUM != 100'
+
+FILTERS["gt"]='NUM > 8000'
+FILTERS["ge"]='NUM >= 100'
+FILTERS["lt"]='NUM < 100'
+FILTERS["le"]='NUM <= 100'
+
+FILTERS["expr-and-expr"]='NUM > 10 && NUM < 8000'
+FILTERS["expr-or-expr"]='NUM == 3 || NUM == 100'
+FILTERS["and-or"]='(NUM >= 3 && NUM <= 100) || NUM == 0'
+
+FILTERS["as-string"]='NUM == "100"'
+
+printf '%s\n' "${!FILTERS[@]}" | sort | while read name; do
+ ts_init_subtest "$prefix-$name"
+ echo "expr: ${FILTERS[$name]}" >> $TS_OUTPUT
+ echo >> $TS_OUTPUT
+ ts_run $TESTPROG --nlines 10 --width 80 \
+ --filter "${FILTERS[$name]}" \
+ --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> /dev/null
+ ts_finalize_subtest
+done
+FILTERS=()
+
+
+### Float
+#
+prefix="float"
+declare -A FILTERS
+
+FILTERS["is"]='NUM'
+FILTERS["neg"]='!NUM'
+FILTERS["and"]='NUM && NAME'
+FILTERS["or"]='NUM || NAME'
+
+FILTERS["eq"]='NUM == 100'
+FILTERS["eq2"]='NUM == 100.5'
+
+FILTERS["ne"]='NUM != 100'
+FILTERS["ne2"]='NUM != 100.5'
+
+FILTERS["gt"]='NUM > 8000'
+FILTERS["gt2"]='NUM > 8000.5'
+
+FILTERS["ge"]='NUM >= 100'
+FILTERS["ge2"]='NUM >= 100.5'
+
+FILTERS["lt"]='NUM < 100'
+FILTERS["lt2"]='NUM < 100.5'
+
+FILTERS["le"]='NUM <= 100'
+FILTERS["le2"]='NUM <= 100.5'
+
+FILTERS["as-string"]='NUM == "100"'
+FILTERS["as-string2"]='NUM == "100.5"'
+
+printf '%s\n' "${!FILTERS[@]}" | sort | while read name; do
+ ts_init_subtest "$prefix-$name"
+ echo "expr: ${FILTERS[$name]}" >> $TS_OUTPUT
+ echo >> $TS_OUTPUT
+ ts_run $TESTPROG --nlines 10 --width 80 \
+ --filter "${FILTERS[$name]}" \
+ --column $TS_SELF/files/col-name \
+ --column $TS_SELF/files/col-float \
+ $TS_SELF/files/data-string \
+ $TS_SELF/files/data-float \
+ >> $TS_OUTPUT 2> /dev/null
+ ts_finalize_subtest
+done
+FILTERS=()
+
+### Boolean
+#
+prefix="bool"
+declare -A FILTERS
+
+FILTERS["is"]='BOOL'
+FILTERS["neg"]='!BOOL'
+FILTERS["and"]='BOOL && NAME'
+FILTERS["or"]='BOOL || NAME'
+
+FILTERS["eq-true"]='BOOL == TRUE'
+FILTERS["eq-true2"]='BOOL == true'
+FILTERS["eq-true3"]='BOOL == 1'
+
+FILTERS["eq-false"]='BOOL == FALSE'
+FILTERS["eq-false2"]='BOOL == false'
+FILTERS["eq-false3"]='BOOL == 0'
+
+FILTERS["ne"]='BOOL != false'
+FILTERS["ne2"]='BOOL != true'
+
+FILTERS["as-string"]='BOOL == "0"'
+FILTERS["as-string2"]='BOOL == "1"'
+
+printf '%s\n' "${!FILTERS[@]}" | sort | while read name; do
+ ts_init_subtest "$prefix-$name"
+ echo "expr: ${FILTERS[$name]}" >> $TS_OUTPUT
+ echo >> $TS_OUTPUT
+ ts_run $TESTPROG --nlines 10 --width 80 \
+ --filter "${FILTERS[$name]}" \
+ --column $TS_SELF/files/col-name \
+ --column $TS_SELF/files/col-bool \
+ $TS_SELF/files/data-string \
+ $TS_SELF/files/data-bool \
+ >> $TS_OUTPUT 2> /dev/null
+ ts_finalize_subtest
+done
+FILTERS=()
+
+
+### Strings
+#
+prefix="string"
+declare -A FILTERS
+
+FILTERS["is"]='NAME'
+FILTERS["neg"]='!NAME'
+
+FILTERS["eq"]='NAME == "bbb"'
+FILTERS["ne"]='NAME != "bbb"'
+
+FILTERS["gt"]='NAME > "bbb"'
+FILTERS["ge"]='NAME >= "bbb"'
+FILTERS["lt"]='NAME < "bbb"'
+FILTERS["le"]='NAME <= "bbb"'
+
+FILTERS["reg"]='NAME =~ "aaa.*"'
+FILTERS["nreg"]='NAME !~ "aaa.*"'
+
+printf '%s\n' "${!FILTERS[@]}" | sort | while read name; do
+ ts_init_subtest "$prefix-$name"
+ echo "expr: ${FILTERS[$name]}" >> $TS_OUTPUT
+ echo >> $TS_OUTPUT
+ ts_run $TESTPROG --nlines 10 --width 80 \
+ --filter "${FILTERS[$name]}" \
+ --column $TS_SELF/files/col-name \
+ $TS_SELF/files/data-string \
+ >> $TS_OUTPUT 2> /dev/null
+ ts_finalize_subtest
+done
+FILTERS=()
+
+
+### Broken
+#
+prefix="broken"
+declare -A FILTERS
+
+FILTERS["no-start"]='NUM == 100)'
+FILTERS["no-close"]='(NUM == 100'
+FILTERS["no-column"]=' == 100'
+FILTERS["no-param"]='NUM == '
+FILTERS["bad-oper"]='NUM ** 100'
+FILTERS["bad-oper2"]='NUM = 100'
+FILTERS["bad-column"]='XXX == 100'
+FILTERS["bad-number"]='NUM == 1y0'
+FILTERS["bad-float"]='NUM == 100 . 5'
+
+printf '%s\n' "${!FILTERS[@]}" | sort | while read name; do
+ ts_init_subtest "$prefix-$name"
+ echo "expr: ${FILTERS[$name]}" >> $TS_OUTPUT
+ echo >> $TS_OUTPUT
+ ts_run $TESTPROG --nlines 10 --width 80 \
+ --filter "${FILTERS[$name]}" \
+ --column $TS_SELF/files/col-number \
+ $TS_SELF/files/data-number \
+ 2>> $TS_OUTPUT 1> /dev/null
+
+ sed -i -e 's/syntax error.*/<bison syntax error message removed>/g' $TS_OUTPUT
+ ts_finalize_subtest
+done
+FILTERS=()
+
+
+ts_log "...done."
+ts_finalize
diff --git a/tests/ts/libsmartcols/fromfile b/tests/ts/libsmartcols/fromfile
index 45b8471..c11140c 100755
--- a/tests/ts/libsmartcols/fromfile
+++ b/tests/ts/libsmartcols/fromfile
@@ -249,6 +249,32 @@ ts_run $TESTPROG --nlines 10 \
>> $TS_OUTPUT 2>> $TS_ERRLOG
ts_finalize_subtest
+ts_init_subtest "wrapzero"
+ts_run $TESTPROG --nlines 10 \
+ --column $TS_SELF/files/col-name \
+ --column $TS_SELF/files/col-number \
+ --column $TS_SELF/files/col-wrapzero \
+ $TS_SELF/files/data-string \
+ $TS_SELF/files/data-number \
+ $TS_SELF/files/data-string-zero \
+ >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+ts_init_subtest "wrapzero-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-wrapzero \
+ $TS_SELF/files/data-string \
+ $TS_SELF/files/data-id \
+ $TS_SELF/files/data-parent \
+ $TS_SELF/files/data-string-zero \
+ >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
ts_init_subtest "raw"
ts_run $TESTPROG --nlines 10 --raw \
--column $TS_SELF/files/col-name \
diff --git a/tests/ts/lscpu/dumps/rv64-visionfive2.tar.gz b/tests/ts/lscpu/dumps/rv64-visionfive2.tar.gz
new file mode 100644
index 0000000..23666f1
--- /dev/null
+++ b/tests/ts/lscpu/dumps/rv64-visionfive2.tar.gz
Binary files differ
diff --git a/tests/ts/lsfd/column-ainodeclass b/tests/ts/lsfd/column-ainodeclass
index 6391c48..6829494 100755
--- a/tests/ts/lsfd/column-ainodeclass
+++ b/tests/ts/lsfd/column-ainodeclass
@@ -38,11 +38,11 @@ for C in pidfd inotify; do
${TS_CMD_LSFD} -n -o ASSOC,STTYPE,AINODECLASS -p "${PID}" -Q "${EXPR}"
echo "$C"':ASSOC,STTYPE,AINODECLASS': $?
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
} > "$TS_OUTPUT" 2>&1
- if [ "$C-$?" == "pidfd-$ENOSYS" ]; then
+ if [ "$C-$?" == "pidfd-$TS_EXIT_NOTSUPP" ]; then
ts_skip_subtest "pidfd_open(2) is not available"
continue
fi
diff --git a/tests/ts/lsfd/column-deleted b/tests/ts/lsfd/column-deleted
new file mode 100755
index 0000000..128cd0e
--- /dev/null
+++ b/tests/ts/lsfd/column-deleted
@@ -0,0 +1,61 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 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="DELETED column"
+
+. "$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=
+
+C=make-regular-file
+ts_init_subtest $C
+{
+ target=util-linux-lsfd-test-make-regular-file
+ coproc MKFDS { "$TS_HELPER_MKFDS" "$C" "$FD" file="$target" delete=1; }
+ if read -u ${MKFDS[0]} PID; then
+ EXPR='(FD == '"$FD"')'
+ ${TS_CMD_LSFD} -p "$PID" -n -o DELETED -Q "${EXPR}"
+ echo "$C: DELETED: " $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+} > "$TS_OUTPUT" 2>&1
+wait "${MKFDS_PID}"
+ts_finalize_subtest
+
+C=ro-regular-file
+ts_init_subtest $C
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" "$C" "$FD"; }
+ if read -u ${MKFDS[0]} PID; then
+ EXPR='(FD == '"$FD"')'
+ ${TS_CMD_LSFD} -p "$PID" -n -o DELETED -Q "${EXPR}"
+ echo "$C: DELETED: " $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+} > "$TS_OUTPUT" 2>&1
+wait "${MKFDS_PID}"
+ts_finalize_subtest
+
+ts_finalize
diff --git a/tests/ts/lsfd/column-kthread b/tests/ts/lsfd/column-kthread
index 0b093e9..2238ade 100755
--- a/tests/ts/lsfd/column-kthread
+++ b/tests/ts/lsfd/column-kthread
@@ -31,7 +31,7 @@ ts_check_prog "ps"
ts_cd "$TS_OUTDIR"
{
- "$TS_CMD_LSFD" -o COMMAND,PID,USER,MODE,TYPE,NAME,KTHREAD \
+ "$TS_CMD_LSFD" --threads -o COMMAND,PID,USER,MODE,TYPE,NAME,KTHREAD \
-Q '(PID < 3) and ((ASSOC == "cwd") or (ASSOC == "rtd"))'
echo $?
} > $TS_OUTPUT 2>&1
diff --git a/tests/ts/lsfd/column-name b/tests/ts/lsfd/column-name
index 5dc491a..8bf8f42 100755
--- a/tests/ts/lsfd/column-name
+++ b/tests/ts/lsfd/column-name
@@ -60,15 +60,31 @@ for C in ro-regular-file pidfd socketpair; do
}
echo "$C"':ASSOC,KNAME,NAME': ${PIPESTATUS[0]}
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
} > "$TS_OUTPUT" 2>&1
wait "${MKFDS_PID}"
- if [ "$C-$?" == "pidfd-$ENOSYS" ]; then
+ if [ "$C-$?" == "pidfd-$TS_EXIT_NOTSUPP" ]; then
ts_skip_subtest "pidfd_open(2) is not available"
continue
fi
ts_finalize_subtest
done
+C=make-regular-file
+ts_init_subtest deleted-file
+{
+ target=tmp-column-name
+ coproc MKFDS { "$TS_HELPER_MKFDS" $C $FD file=tmp-column-name delete=1; }
+ if read -r -u "${MKFDS[0]}" PID; then
+ ${TS_CMD_LSFD} -n -o DELETED,NAME -p "${PID}" -Q "${EXPR}" |
+ sed -e 's#.*/\([^/]\+\)#\1#'
+ echo "$C: DELETED,NAME: " ${PIPESTATUS[0]}
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+} > "$TS_OUTPUT" 2>&1
+wait "${MKFDS_PID}"
+ts_finalize_subtest
+
ts_finalize
diff --git a/tests/ts/lsfd/column-source b/tests/ts/lsfd/column-source
new file mode 100755
index 0000000..a74f9de
--- /dev/null
+++ b/tests/ts/lsfd/column-source
@@ -0,0 +1,51 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 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="SOURCE column"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+. "$TS_SELF/lsfd-functions.bash"
+ts_check_test_command "$TS_CMD_LSFD"
+
+ts_cd "$TS_OUTDIR"
+
+declare -a NAMESPACES=(
+ cgorup
+ ipc
+ mnt
+ net
+ pid
+ pid4c
+ # older kernel doesn't support time namespace.
+ # time
+ # time4c
+ user
+ uts
+)
+ts_init_subtest namespace-ASSOC
+{
+ EXPR="false"
+ for ns in "${NAMESPACES[@]}"; do
+ EXPR=${EXPR}' || (ASSOC == "'"$ns"'")'
+ done
+ ${TS_CMD_LSFD} -p $$ -n -o ASSOC,SOURCE -Q "$EXPR"
+} > "$TS_OUTPUT" 2>&1
+ts_finalize_subtest
+
+ts_finalize
diff --git a/tests/ts/lsfd/column-source-with-root b/tests/ts/lsfd/column-source-with-root
new file mode 100755
index 0000000..c00ee15
--- /dev/null
+++ b/tests/ts/lsfd/column-source-with-root
@@ -0,0 +1,44 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 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="SOURCE column (requiring the root privilege)"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+ts_skip_nonroot
+ts_skip_docker
+
+. "$TS_SELF/lsfd-functions.bash"
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_HELPER_MKFDS"
+
+ts_cd "$TS_OUTDIR"
+
+EXPR='(NAME =~ "/SYSV.*")'
+ts_init_subtest SysVIPC-shmem
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" sysvshm; }
+ if read -u ${MKFDS[0]} PID; then
+ ${TS_CMD_LSFD} -p "$PID" -n -o ASSOC,SOURCE -Q "${EXPR}"
+ echo 'ASSOC,SOURCE': $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait ${MKFDS_PID}
+} > "$TS_OUTPUT" 2>&1
+ts_finalize_subtest
+
+ts_finalize
diff --git a/tests/ts/lsfd/column-type b/tests/ts/lsfd/column-type
index cf6175e..77bc5c9 100755
--- a/tests/ts/lsfd/column-type
+++ b/tests/ts/lsfd/column-type
@@ -46,11 +46,11 @@ for C in ro-regular-file pidfd inotify socketpair; do
${TS_CMD_LSFD} -n -o ASSOC,STTYPE,TYPE -p "${PID}" -Q "${EXPR}"
echo "$C"':ASSOC,STTYPE,TYPE': $?
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
} > "$TS_OUTPUT" 2>&1
- if [ "$C-$?" == "pidfd-$ENOSYS" ]; then
+ if [ "$C-$?" == "pidfd-$TS_EXIT_NOTSUPP" ]; then
ts_skip_subtest "pidfd_open(2) is not available"
continue
fi
diff --git a/tests/ts/lsfd/column-xmode b/tests/ts/lsfd/column-xmode
new file mode 100755
index 0000000..1e719a4
--- /dev/null
+++ b/tests/ts/lsfd/column-xmode
@@ -0,0 +1,202 @@
+#!/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="MODE and XMODE columns"
+
+. "$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_cd "$TS_OUTDIR"
+
+INO=$(stat -c '%i' "$TS_HELPER_MKFDS")
+PID=
+FD=3
+
+
+EXPR="(FD == 3)"
+ts_init_subtest "MODE-r-bit"
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" ro-regular-file $FD; }
+ if read -r -u "${MKFDS[0]}" PID; then
+ "${TS_CMD_LSFD}" -n -o MODE -p "${PID}" -Q "${EXPR}"
+ echo "MODE(r-bit): " $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+} > "$TS_OUTPUT" 2>&1
+wait "${MKFDS_PID}"
+ts_finalize_subtest
+
+ts_init_subtest "XMODE-r-bit"
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" ro-regular-file $FD; }
+ if read -r -u "${MKFDS[0]}" PID; then
+ "${TS_CMD_LSFD}" -n -o XMODE -p "${PID}" -Q "${EXPR}"
+ echo "XMODE(r-bit): " $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+} > "$TS_OUTPUT" 2>&1
+wait "${MKFDS_PID}"
+ts_finalize_subtest
+
+EXPR="(FD == $((FD + 1)))"
+ts_init_subtest "MODE-w-bit"
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" pipe-no-fork $FD $((FD + 1)); }
+ if read -r -u "${MKFDS[0]}" PID; then
+ "${TS_CMD_LSFD}" -n -o MODE -p "${PID}" -Q "${EXPR}"
+ echo "MODE(w-bit): " $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+} > "$TS_OUTPUT" 2>&1
+wait "${MKFDS_PID}"
+ts_finalize_subtest
+
+ts_init_subtest "XMODE-w-bit"
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" pipe-no-fork $FD $((FD + 1)); }
+ if read -r -u "${MKFDS[0]}" PID; then
+ "${TS_CMD_LSFD}" -n -o XMODE -p "${PID}" -Q "${EXPR}"
+ echo "XMODE(w-bit): " $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+} > "$TS_OUTPUT" 2>&1
+wait "${MKFDS_PID}"
+ts_finalize_subtest
+
+EXPR='(ASSOC == "mem") and (INODE == '"$INO"') and (MODE != "r--") and (MODE != "rw-") and (MODE != "rwx")'
+ts_init_subtest "MODE-x-bit"
+if [ "$QEMU_USER" == "1" ]; then
+ ts_skip_subtest "running under qemu-user emulation"
+else
+ {
+ coproc MKFDS { "$TS_HELPER_MKFDS" ro-regular-file $FD; }
+ if read -r -u "${MKFDS[0]}" PID; then
+ "${TS_CMD_LSFD}" -n -o MODE -p "${PID}" -Q "${EXPR}"
+ echo "MODE(x-bit): " $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ } > "$TS_OUTPUT" 2>&1
+ wait "${MKFDS_PID}"
+ ts_finalize_subtest
+fi
+
+ts_init_subtest "XMODE-x-bit"
+if [ "$QEMU_USER" == "1" ]; then
+ ts_skip_subtest "running under qemu-user emulation"
+else
+ {
+ coproc MKFDS { "$TS_HELPER_MKFDS" ro-regular-file $FD; }
+ if read -r -u "${MKFDS[0]}" PID; then
+ "${TS_CMD_LSFD}" -n -o XMODE -p "${PID}" -Q "${EXPR}"
+ echo "XMODE(x-bit): " $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ } > "$TS_OUTPUT" 2>&1
+ wait "${MKFDS_PID}"
+ ts_finalize_subtest
+fi
+
+FILE=./test_mkfds_make_regular_file
+EXPR='(FD == '"$FD"')'
+ts_init_subtest "XMODE-D-bit"
+{
+ rm -f "${FILE}"
+ coproc MKFDS { "$TS_HELPER_MKFDS" make-regular-file $FD file="$FILE" delete=1; }
+ if read -r -u "${MKFDS[0]}" PID; then
+ "${TS_CMD_LSFD}" -n -o XMODE -p "${PID}" -Q "${EXPR}"
+ echo "XMODE(D-bit): " $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+} > "$TS_OUTPUT" 2>&1
+wait "${MKFDS_PID}"
+ts_finalize_subtest
+
+for m in flock-sh posix-r- ofd-r-; do
+ ts_init_subtest "XMODE-l-bit-$m"
+ {
+ rm -f "${FILE}"
+ coproc MKFDS { "$TS_HELPER_MKFDS" make-regular-file $FD file="$FILE" lock=$m; }
+ if read -r -u "${MKFDS[0]}" PID; then
+ "${TS_CMD_LSFD}" -n -o XMODE -p "${PID}" -Q "${EXPR}"
+ echo "XMODE(l-bit): " $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ } > "$TS_OUTPUT" 2>&1
+ wait "${MKFDS_PID}"
+ if [ "$?" == "$TS_EXIT_NOTSUPP" ]; then
+ ts_skip_subtest "$m lock is not available"
+ continue
+ fi
+ ts_finalize_subtest
+done
+
+ts_init_subtest "XMODE-l-bit-lease-r"
+f=ro-regular-file-read-lease
+touch "$f"
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" ro-regular-file $FD file=$f read-lease=1; }
+ if read -r -u "${MKFDS[0]}" PID; then
+ "${TS_CMD_LSFD}" -n -o XMODE -p "${PID}" -Q "${EXPR}"
+ echo "XMODE(l-bit): " $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+} > "$TS_OUTPUT" 2>&1
+wait "${MKFDS_PID}"
+rm -f "$f"
+ts_finalize_subtest
+
+for m in flock-ex posix--w posix-rw ofd--w ofd-rw lease-w; do
+ ts_init_subtest "XMODE-L-bit-$m"
+ {
+ rm -f "${FILE}"
+ coproc MKFDS { "$TS_HELPER_MKFDS" make-regular-file $FD file="$FILE" lock=$m; }
+ if read -r -u "${MKFDS[0]}" PID; then
+ "${TS_CMD_LSFD}" -n -o XMODE -p "${PID}" -Q "${EXPR}"
+ echo "XMODE(L-bit): " $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ } > "$TS_OUTPUT" 2>&1
+ wait "${MKFDS_PID}"
+ if [ "$?" == "$TS_EXIT_NOTSUPP" ]; then
+ ts_skip_subtest "$m lock is not available"
+ continue
+ fi
+ ts_finalize_subtest
+done
+
+M0=6
+M1=9
+EXPR="(FD == $M0) or (FD == $M1)"
+ts_init_subtest "XMODE-m-bit"
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" eventpoll $FD $M0 $M1; }
+ if read -r -u "${MKFDS[0]}" PID; then
+ "${TS_CMD_LSFD}" -n -o XMODE -p "${PID}" -Q "${EXPR}"
+ echo "XMODE(m-bit): " $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+} > "$TS_OUTPUT" 2>&1
+wait "${MKFDS_PID}"
+ts_finalize_subtest
+
+ts_finalize
diff --git a/tests/ts/lsfd/option-filter-broken-exp b/tests/ts/lsfd/filter-broken-exp
index bedf439..1854e50 100755
--- a/tests/ts/lsfd/option-filter-broken-exp
+++ b/tests/ts/lsfd/filter-broken-exp
@@ -25,12 +25,13 @@ 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
+sed -i -e 's/syntax error.*/<bison syntax error message removed>/g' \
+ $TS_OUTPUT $TS_ERRLOG
+
ts_finalize
diff --git a/tests/ts/lsfd/filter-floating-point-nums b/tests/ts/lsfd/filter-floating-point-nums
new file mode 100755
index 0000000..7f66dd5
--- /dev/null
+++ b/tests/ts/lsfd/filter-floating-point-nums
@@ -0,0 +1,90 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 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="timerfd"
+
+. "$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" timerfd $FD clockid=realtime remaining=0 interval=10 interval-nanofrac=000050000; }
+ if read -u ${MKFDS[0]} PID; then
+
+ PID_1=$((PID -1))
+ EXPR="(PID > ${PID_1}.9) and (PID < ${PID}.1) and (ASSOC == 'exe')"
+ PID_0=$(${TS_CMD_LSFD} -n -r -o PID -Q "$EXPR")
+ echo "pid in a range:" $?
+
+ if [[ "${PID_0}" == "${PID}" ]]; then
+ echo "coparing pids": $?
+ else
+ echo "coparing pids": $? "PID_0:${PID_0} == PID:${PID}"
+ fi
+
+ EXPR='(TIMERFD.INTERVAL < 10.000051) and (TIMERFD.INTERVAL > 10)'
+ ${TS_CMD_LSFD} -n -r -o FD,TIMERFD.INTERVAL -p "$PID" -Q "$EXPR"
+ echo "FD,TIMERFD.INTERVAL: $EXPR": $?
+
+ EXPR='(TIMERFD.INTERVAL <= 10) and (TIMERFD.INTERVAL > 9.99)'
+ ${TS_CMD_LSFD} -n -r -o FD,TIMERFD.INTERVAL -p "$PID" -Q "$EXPR"
+ echo "FD,TIMERFD.INTERVAL: $EXPR": $?
+
+ EXPR='(TIMERFD.INTERVAL >= 10)'
+ ${TS_CMD_LSFD} -n -r -o FD,TIMERFD.INTERVAL -p "$PID" -Q "$EXPR"
+ echo "FD,TIMERFD.INTERVAL: $EXPR": $?
+
+ EXPR='(TIMERFD.INTERVAL >= 10.0)'
+ ${TS_CMD_LSFD} -n -r -o FD,TIMERFD.INTERVAL -p "$PID" -Q "$EXPR"
+ echo "FD,TIMERFD.INTERVAL: $EXPR": $?
+
+
+ EXPR='(TIMERFD.INTERVAL < 10) and (0 < TIMERFD.INTERVAL)'
+ ${TS_CMD_LSFD} -n -r -o FD,TIMERFD.INTERVAL -p "$PID" -Q "$EXPR"
+ echo "FD,TIMERFD.INTERVAL: $EXPR": $?
+
+ EXPR='(TIMERFD.INTERVAL < 10) and (0.0 < TIMERFD.INTERVAL)'
+ ${TS_CMD_LSFD} -n -r -o FD,TIMERFD.INTERVAL -p "$PID" -Q "$EXPR"
+ echo "FD,TIMERFD.INTERVAL: $EXPR": $?
+
+ EXPR='(TIMERFD.INTERVAL > 11)'
+ ${TS_CMD_LSFD} -n -r -o FD,TIMERFD.INTERVAL -p "$PID" -Q "$EXPR"
+ echo "FD,TIMERFD.INTERVAL: $EXPR": $?
+
+ EXPR='(TIMERFD.INTERVAL == 10.00005)'
+ ${TS_CMD_LSFD} -n -r -o FD,TIMERFD.INTERVAL -p "$PID" -Q "$EXPR"
+ echo "FD,TIMERFD.INTERVAL: $EXPR": $?
+
+ EXPR='(TIMERFD.INTERVAL == 10.000051)'
+ ${TS_CMD_LSFD} -n -r -o FD,TIMERFD.INTERVAL -p "$PID" -Q "$EXPR"
+ echo "FD,TIMERFD.INTERVAL: $EXPR": $?
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+
+ wait "${MKFDS_PID}"
+} > "$TS_OUTPUT" 2>&1
+
+ts_finalize
diff --git a/tests/ts/lsfd/lsfd-functions.bash b/tests/ts/lsfd/lsfd-functions.bash
index d9a3595..3a3f58f 100644
--- a/tests/ts/lsfd/lsfd-functions.bash
+++ b/tests/ts/lsfd/lsfd-functions.bash
@@ -16,11 +16,11 @@
#
# The exit-status used in a test target.
-readonly ENOSYS=17
readonly EPERM=18
readonly ENOPROTOOPT=19
readonly EPROTONOSUPPORT=20
-readonly EACCESS=21
+readonly EACCES=21
+readonly ENOENT=22
function lsfd_wait_for_pausing {
ts_check_prog "sleep"
@@ -59,7 +59,7 @@ function lsfd_compare_dev {
fi
}
-lsfd_strip_type_stream()
+function lsfd_strip_type_stream
{
# lsfd changes the output of NAME column for a unix stream socket
# whether the kernel reports it is a "UNIX-STREAM" socket or a
@@ -68,7 +68,7 @@ lsfd_strip_type_stream()
sed -e 's/ type=stream//'
}
-lsfd_make_state_connected()
+function lsfd_make_state_connected
{
# Newer kernels report the states of unix dgram sockets created by
# sockerpair(2) are "connected" via /proc/net/unix though Older
@@ -83,3 +83,39 @@ lsfd_make_state_connected()
# to that on newer kernels.
sed -e 's/state=unconnected/state=connected/'
}
+
+function lsfd_check_mkfds_factory
+{
+ local FACTORY=$1
+
+ ts_check_test_command "$TS_HELPER_MKFDS"
+ if ! "$TS_HELPER_MKFDS" --is-available "$FACTORY"; then
+ ts_skip "test_mkfds has no factory for $FACTORY"
+ fi
+}
+
+function lsfd_check_sockdiag
+{
+ local family=$1
+
+ ts_check_test_command "$TS_HELPER_MKFDS"
+
+ local msg
+ local err
+
+ msg=$("$TS_HELPER_MKFDS" -c sockdiag 9 family=$family 2>&1)
+ err=$?
+
+ case $err in
+ 0)
+ return;;
+ $EPROTONOSUPPORT)
+ ts_skip "NETLINK_SOCK_DIAG protocol is not supported in socket(2)";;
+ $EACCES)
+ ts_skip "sending a msg via a sockdiag netlink socket is not permitted";;
+ $ENOENT)
+ ts_skip "sockdiag netlink socket is not available";;
+ *)
+ ts_failed "failed to create a sockdiag netlink socket $family ($err): $msg";;
+ esac
+}
diff --git a/tests/ts/lsfd/mkfds-bpf-map b/tests/ts/lsfd/mkfds-bpf-map
new file mode 100755
index 0000000..7821fe5
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-bpf-map
@@ -0,0 +1,49 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 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="bpf-map files"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+ts_skip_nonroot
+ts_skip_docker
+
+. "$TS_SELF/lsfd-functions.bash"
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_HELPER_MKFDS"
+
+ts_cd "$TS_OUTDIR"
+
+PID=
+FD=3
+NAME=mkfds_map
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" bpf-map "$FD" map-type-id=2 name="$NAME"; }
+ if read -r -u "${MKFDS[0]}" PID; then
+ "${TS_CMD_LSFD}" -r -n -oBPF-MAP.TYPE,BPF-MAP.TYPE.RAW,BPF.NAME -p "${PID}" -Q "(FD == $FD)"
+ echo "BPF-MAP.TYPE,BPF-MAP.TYPE.RAW,BPF.NAME": $?
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait "${MKFDS_PID}"
+} > "$TS_OUTPUT" 2>&1
+
+if [ "$?" == "$TS_EXIT_NOTSUPP" ]; then
+ ts_skip "bpf(2) is not available"
+fi
+
+ts_finalize
diff --git a/tests/ts/lsfd/mkfds-bpf-prog b/tests/ts/lsfd/mkfds-bpf-prog
new file mode 100755
index 0000000..b2a7275
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-bpf-prog
@@ -0,0 +1,49 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 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="bpf-prog files"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+ts_skip_nonroot
+ts_skip_docker
+
+. "$TS_SELF/lsfd-functions.bash"
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_HELPER_MKFDS"
+
+ts_cd "$TS_OUTDIR"
+
+PID=
+FD=3
+NAME=mkdfs_prog
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" bpf-prog "$FD" prog-type-id=2 name="$NAME"; }
+ if read -r -u "${MKFDS[0]}" PID; then
+ "${TS_CMD_LSFD}" -r -n -oBPF-PROG.TYPE,BPF-PROG.TYPE.RAW,BPF.NAME -p "${PID}" -Q "(FD == $FD)"
+ echo "BPF-PROG.TYPE,BPF-PROG.TYPE.RAW,BPF.NAME": $?
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait "${MKFDS_PID}"
+} > "$TS_OUTPUT" 2>&1
+
+if [ "$?" == "$TS_EXIT_NOTSUPP" ]; then
+ ts_skip "bpf(2) is not available"
+fi
+
+ts_finalize
diff --git a/tests/ts/lsfd/mkfds-cdev-tun b/tests/ts/lsfd/mkfds-cdev-tun
new file mode 100755
index 0000000..7354509
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-cdev-tun
@@ -0,0 +1,65 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 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="tun device and interface behind the device"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+ts_skip_nonroot
+
+[[ -e /dev/net/tun ]] || ts_skip "/dev/net/tun doest not exist"
+
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_HELPER_MKFDS"
+
+ts_cd "$TS_OUTDIR"
+
+PID=
+FD=3
+IFNAME=
+
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" cdev-tun $FD ; }
+ if read -u ${MKFDS[0]} PID IFNAME; then
+ EXPR='(FD == '"$FD"')'
+ ${TS_CMD_LSFD} -p "${PID}" -n -o ASSOC,MODE,TYPE,SOURCE -Q "${EXPR}"
+ echo 'ASSOC,MODE,TYPE,SOURCE': $?
+
+ output=$(${TS_CMD_LSFD} -p "${PID}" -n --raw -o NAME -Q "${EXPR}")
+ if [[ "$output" == "iface=$IFNAME" ]]; then
+ echo 'NAME': $?
+ else
+ echo 'NAME': $?
+ echo "expected NAME: iface=$IFNAME"
+ echo "output NAME: $output"
+ fi
+
+ output=$(${TS_CMD_LSFD} -p "${PID}" -n --raw -o TUN.IFACE -Q "${EXPR}")
+ if [[ "$output" == "$IFNAME" ]]; then
+ echo 'TUN.IFACE': $?
+ else
+ echo 'TUN.IFAEC': $?
+ echo "expected TUN.IFACE: $IFNAME"
+ echo "output TUN.IFACE: $output"
+ fi
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait ${MKFDS_PID}
+} > $TS_OUTPUT 2>&1
+
+ts_finalize
diff --git a/tests/ts/lsfd/mkfds-directory b/tests/ts/lsfd/mkfds-directory
index ef769c9..738cb86 100755
--- a/tests/ts/lsfd/mkfds-directory
+++ b/tests/ts/lsfd/mkfds-directory
@@ -101,7 +101,7 @@ esac
echo 'stat reports:' "$(stat -c %h /)"
fi
- kill -CONT ${PID}
+ echo DONE >&"${MKFDS[1]}"
fi
wait ${MKFDS_PID}
} > $TS_OUTPUT 2>&1
diff --git a/tests/ts/lsfd/mkfds-eventfd b/tests/ts/lsfd/mkfds-eventfd
new file mode 100755
index 0000000..02c86a6
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-eventfd
@@ -0,0 +1,104 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 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="eventfd with fork"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_HELPER_MKFDS"
+
+ts_cd "$TS_OUTDIR"
+
+PID0=
+PID1=
+FD0=3
+FD1=4
+EXPR=
+ID0=
+ID1=
+NAME0=
+NAME1=
+ENDPOINTS=
+
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" eventfd $FD0 $FD1 ; }
+ if read -u ${MKFDS[0]} PID0 PID1; then
+ EXPR='(FD == '"$FD0"') or (FD =='"$FD1"')'
+ ${TS_CMD_LSFD} -p "${PID0}" -n -o ASSOC,MODE,TYPE,SOURCE -Q "${EXPR}"
+ echo 'parent: ASSOC,MODE,TYPE,SOURCE': $?
+
+ NAME0=$(${TS_CMD_LSFD} -p "${PID0}" --raw -n -o NAME -Q "${EXPR}")
+ echo 'parent: NAME': $?
+
+ ID0=$(${TS_CMD_LSFD} -p "${PID0}" --raw -n -o EVENTFD.ID -Q "${EXPR}")
+ echo 'parent: ID': $?
+
+ EXPR='(FD == '"$FD0"') or (FD =='"$FD1"')'
+ ${TS_CMD_LSFD} -p "${PID1}" -n -o ASSOC,MODE,TYPE,SOURCE -Q "${EXPR}"
+ echo 'child: ASSOC,MODE,TYPE,SOURCE': $?
+
+ NAME1=$(${TS_CMD_LSFD} -p "${PID1}" --raw -n -o NAME -Q "${EXPR}")
+ echo 'child: NAME': $?
+
+ ID1=$(${TS_CMD_LSFD} -p "${PID1}" --raw -n -o EVENTFD.ID -Q "${EXPR}")
+ echo 'child: ID': $?
+
+ if [ "${NAME0}" == "${NAME1}" ]; then
+ echo 'NAME[STR]:' $?
+ else
+ echo 'NAME[STR]:' $?
+ echo NAME0: "${NAME0}"
+ echo NAME1: "${NAME1}"
+ fi
+
+ if [ "${ID0}" == "${ID1}" ]; then
+ echo 'ID[STR]:' $?
+ else
+ echo 'ID[STR]:' $?
+ echo ID0: "${ID0}"
+ echo ID0: "${ID1}"
+ fi
+
+ if [ "${NAME0}" == "id=${ID1}" ]; then
+ echo 'NAMExID[STR]:' $?
+ else
+ echo 'NAMExID[STR]:' $?
+ echo NAME0: "${NAME0}"
+ echo ID0: "${ID0}"
+ fi
+
+ EXPR='(EVENTFD.ID == '"${ID0}"')'
+ ENDPOINTS=$(${TS_CMD_LSFD} --raw -n -o PID,ASSOC,ENDPOINTS -Q "${EXPR}")
+ tmp=$(printf "%d %d %d,test_mkfds,%d\n%d %d %d,test_mkfds,%d" \
+ "$PID0" "$FD0" "$PID1" "$FD1" \
+ "$PID1" "$FD1" "$PID0" "$FD0")
+ if [ "$ENDPOINTS" == "$tmp" ]; then
+ echo 'ENDPOINTS[STR]:' $?
+ else
+ echo 'ENDPOINTS[STR]:' $?
+ echo 'ENDPOINTS:' "$ENDPOINTS"
+ echo 'lsfd:' "$tmp"
+ fi
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait ${MKFDS_PID}
+} > $TS_OUTPUT 2>&1
+
+ts_finalize
diff --git a/tests/ts/lsfd/mkfds-eventpoll b/tests/ts/lsfd/mkfds-eventpoll
new file mode 100755
index 0000000..230d6c4
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-eventpoll
@@ -0,0 +1,46 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 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="eventpoll targets"
+
+. "$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=
+FD0=3
+FD1=5
+FD2=7
+
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" eventpoll $FD0 $FD1 $FD2 ; }
+ if read -u ${MKFDS[0]} PID; then
+ EXPR='(FD == '"$FD0"')'
+ ${TS_CMD_LSFD} -p "${PID}" -n -o ASSOC,TYPE,NAME,EVENTPOLL.TFDS -Q "${EXPR}"
+ echo 'ASSOC,TYPE,NAME,EVENTPOLL.TFDS': $?
+ ${TS_CMD_LSFD} -J -p "${PID}" -n -o ASSOC,TYPE,NAME,EVENTPOLL.TFDS -Q "${EXPR}"
+ echo 'ASSOC,TYPE,NAME,EVENTPOLL.TFDS (JSON)': $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait ${MKFDS_PID}
+} > $TS_OUTPUT 2>&1
+
+ts_finalize
diff --git a/tests/ts/lsfd/mkfds-inotify b/tests/ts/lsfd/mkfds-inotify
new file mode 100755
index 0000000..a44fd77
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-inotify
@@ -0,0 +1,74 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 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="inotify"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_CMD_FINDMNT"
+ts_check_prog "stat"
+ts_check_prog "sed"
+
+ts_cd "$TS_OUTDIR"
+
+PID=
+FD=3
+dir=/proc
+file=/proc/cmdline
+PROC="$(stat -c %i $dir)"@"$($TS_CMD_FINDMNT --raw --noheadings -oMAJ:MIN --target $dir)"
+CMDLINE="$(stat -c %i $file)"@"$($TS_CMD_FINDMNT --raw --noheadings -oMAJ:MIN --target $file)"
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" inotify $FD dir=$dir file=$file ; }
+ if read -u ${MKFDS[0]} PID; then
+ EXPR='(PID == '"${PID}"') and (FD == '"$FD"')'
+ INODES_RAW=$(${TS_CMD_LSFD} --raw -n -o INOTIFY.INODES.RAW -Q "${EXPR}")
+ echo "INOTIFY.INODES.RAW": $?
+ if [[ "$INODES_RAW" == "${CMDLINE}"'\x0a'"${PROC}" ]]; then
+ echo "INOTIFY.INODES.RAW" == CMDLINE'\x0a'PROC
+ else
+ echo "INOTIFY.INODES.RAW": "$INODES_RAW"
+ echo "CMDLINE": "$CMDLINE"
+ echo "PROC": "$PROC"
+ fi
+ INODES_RAW_JSON=$(${TS_CMD_LSFD} -J --raw -n -o INOTIFY.INODES.RAW -Q "${EXPR}")
+ echo "INOTIFY.INODES.RAW (JSON)": $?
+ EXPECTED_JSON=$(cat<<EOF
+{
+ "lsfd": [
+ {
+ "inotify.inodes.raw": [
+ "$CMDLINE", "$PROC"
+ ]
+ }
+ ]
+}
+EOF
+ )
+ if [[ "$INODES_RAW_JSON" == "${EXPECTED_JSON}" ]]; then
+ echo "INOTIFY.INODES.RAW" == EXPECTED_JSON
+ else
+ echo "INOTIFY.INODES.RAW": "$INODES_RAW_JSON"
+ fi
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait "${MKFDS_PID}"
+} > "$TS_OUTPUT" 2>&1
+
+ts_finalize
diff --git a/tests/ts/lsfd/mkfds-inotify-btrfs b/tests/ts/lsfd/mkfds-inotify-btrfs
new file mode 100755
index 0000000..5dc8e97
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-inotify-btrfs
@@ -0,0 +1,91 @@
+#!/bin/bash
+#
+# Copyright (C) 2024 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="inotify on btrfs"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+ts_skip_nonroot
+
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_CMD_FINDMNT"
+ts_check_prog "stat"
+ts_check_prog "sed"
+ts_check_prog "mkfs.btrfs"
+ts_check_prog "dd"
+
+ts_cd "$TS_OUTDIR"
+
+IMG=img.btrfs
+MNTPNT=mntpnt
+mkdir -p $MNTPNT
+dd if=/dev/zero of=$IMG bs=114294784 count=1 status=none
+if ! mkfs.btrfs -q $IMG; then
+ ts_skip "failed to make a btrfs image: $IMG"
+fi
+if ! mount $IMG $MNTPNT; then
+ ts_skip "failed to mount a btrfs image, $IMG to $MNTPNT"
+fi
+trap "umount $MNTPNT; rm -f $IMG" EXIT
+
+if ! touch $MNTPNT/fstab; then
+ ts_skip "failed to touch a file on a btrfs filesystem: $MNTPNT/fstab"
+fi
+
+PID=
+FD=3
+ROOT="$(stat -c %i $MNTPNT)"@"$($TS_CMD_FINDMNT --raw --noheadings -oMAJ:MIN --target $MNTPNT)"
+FSTAB="$(stat -c %i $MNTPNT/fstab)"@"$($TS_CMD_FINDMNT --raw --noheadings -oMAJ:MIN --target $MNTPNT/fstab)"
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" inotify $FD dir=$MNTPNT file=$MNTPNT/fstab; }
+ if read -u ${MKFDS[0]} PID; then
+ EXPR='(PID == '"${PID}"') and (FD == '"$FD"')'
+ INODES_RAW=$(${TS_CMD_LSFD} --raw -n -o INOTIFY.INODES.RAW -Q "${EXPR}")
+ echo "INOTIFY.INODES.RAW": $?
+ if [[ "$INODES_RAW" == "${FSTAB}"'\x0a'"${ROOT}" ]]; then
+ echo "INOTIFY.INODES.RAW" == FSTAB'\x0a'ROOT
+ else
+ echo "INOTIFY.INODES.RAW": "$INODES_RAW"
+ echo "FSTAB": "$FSTAB"
+ echo "ROOT": "$ROOT"
+ fi
+ INODES_RAW_JSON=$(${TS_CMD_LSFD} -J --raw -n -o INOTIFY.INODES.RAW -Q "${EXPR}")
+ echo "INOTIFY.INODES.RAW (JSON)": $?
+ EXPECTED_JSON=$(cat<<EOF
+{
+ "lsfd": [
+ {
+ "inotify.inodes.raw": [
+ "$FSTAB", "$ROOT"
+ ]
+ }
+ ]
+}
+EOF
+ )
+ if [[ "$INODES_RAW_JSON" == "${EXPECTED_JSON}" ]]; then
+ echo "INOTIFY.INODES.RAW" == EXPECTED_JSON
+ else
+ echo "INOTIFY.INODES.RAW": "$INODES_RAW_JSON"
+ fi
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait "${MKFDS_PID}"
+} > "$TS_OUTPUT" 2>&1
+
+ts_finalize
diff --git a/tests/ts/lsfd/mkfds-mapped-packet-socket b/tests/ts/lsfd/mkfds-mapped-packet-socket
index a1fb68f..12c5ef6 100755
--- a/tests/ts/lsfd/mkfds-mapped-packet-socket
+++ b/tests/ts/lsfd/mkfds-mapped-packet-socket
@@ -49,7 +49,7 @@ for SOCKTYPE in RAW DGRAM; do
${TS_CMD_LSFD} -p "$PID" -n -o NAME,SOCK.TYPE,SOCK.PROTONAME,PACKET.IFACE,PACKET.PROTOCOL -Q "${EXPR}"
echo 'NAME,SOCK.TYPE,SOCK.PROTONAME,PACKET.IFACE,PACKET.PROTOCOL': $?
- kill -CONT ${PID}
+ echo DONE >&"${MKFDS[1]}"
fi
wait ${MKFDS_PID}
ERR=$?
diff --git a/tests/ts/lsfd/mkfds-mqueue b/tests/ts/lsfd/mkfds-mqueue
new file mode 100755
index 0000000..bd22132
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-mqueue
@@ -0,0 +1,83 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 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="mqueue with fork"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_HELPER_MKFDS"
+ts_check_native_byteorder
+
+ts_cd "$TS_OUTDIR"
+
+MQUEUE=/mkfds-mqueue
+PID0=
+PID1=
+FD0=3
+FD1=4
+EXPR=
+INODE0=
+INODE1=
+ENDPOINTS=
+
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" mqueue $FD0 $FD1 path=${MQUEUE}; }
+ if read -u ${MKFDS[0]} PID0 PID1; then
+ EXPR='(FD == '"$FD0"') or (FD =='"$FD1"')'
+ ${TS_CMD_LSFD} -p "${PID0}" -n -o ASSOC,MODE,TYPE,SOURCE,NAME -Q "${EXPR}"
+ echo 'parent: ASSOC,MODE,TYPE,SOURCE,NAME': $?
+
+ INODE0=$(${TS_CMD_LSFD} -p "${PID0}" --raw -n -o INODE -Q "${EXPR}")
+ echo 'parent: INODE': $?
+
+ EXPR='(FD == '"$FD0"') or (FD =='"$FD1"')'
+ ${TS_CMD_LSFD} -p "${PID1}" -n -o ASSOC,MODE,TYPE,SOURCE -Q "${EXPR}"
+ echo 'child: ASSOC,MODE,TYPE,SOURCE': $?
+
+ INODE1=$(${TS_CMD_LSFD} -p "${PID1}" --raw -n -o INODE -Q "${EXPR}")
+ echo 'child: INODE': $?
+
+ if [ "${INODE0}" == "${INODE1}" ]; then
+ echo 'INODE[STR]:' $?
+ else
+ echo 'INODE[STR]:' $?
+ echo INODE0: "${INODE0}"
+ echo INODE1: "${INODE1}"
+ fi
+
+ EXPR='(INODE == '"${INODE0}"') and (TYPE == "mqueue")'
+ ENDPOINTS=$(${TS_CMD_LSFD} --raw -n -o PID,ASSOC,ENDPOINTS -Q "${EXPR}")
+ tmp=$(printf "%d %d %d,test_mkfds,%d-w\n%d %d %d,test_mkfds,%dr-" \
+ "$PID0" "$FD0" "$PID1" "$FD1" \
+ "$PID1" "$FD1" "$PID0" "$FD0")
+ if [ "$ENDPOINTS" == "$tmp" ]; then
+ echo 'ENDPOINTS[STR]:' $?
+ else
+ echo 'ENDPOINTS[STR]:' $?
+ echo 'ENDPOINTS:' "$ENDPOINTS"
+ echo 'lsfd:' "$tmp"
+ grep mqueue /proc/self/mountinfo
+ fi
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait ${MKFDS_PID}
+} > $TS_OUTPUT 2>&1
+
+ts_finalize
diff --git a/tests/ts/lsfd/mkfds-multiplexing b/tests/ts/lsfd/mkfds-multiplexing
new file mode 100755
index 0000000..8cc7f31
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-multiplexing
@@ -0,0 +1,70 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 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="XMODE.m for classical system calls for multiplexing"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_HELPER_MKFDS"
+
+# /proc/${PID}/syscall is rendered in the host side byteorder.
+ts_skip_qemu_user
+
+ts_check_prog "grep"
+
+ts_cd "$TS_OUTDIR"
+
+PID=
+
+for multiplexer in pselect6 select poll ppoll; do
+ ts_init_subtest "${multiplexer}"
+ if ! "$TS_HELPER_MKFDS" -W | grep -q "^$multiplexer\$"; then
+ ts_skip_subtest "the multiplexer ${multiplexer} is not available"
+ continue
+ fi
+
+ {
+ coproc MKFDS { "$TS_HELPER_MKFDS" -w "$multiplexer" multiplexing {10..22}; }
+ } > "$TS_OUTPUT" 2>&1
+
+ if read -r -u "${MKFDS[0]}" PID; then
+ if ! cat /proc/"${PID}"/syscall > /dev/null 2>&1; then
+ kill -CONT "${PID}"
+ wait "${MKFDS_PID}"
+ ts_skip_subtest "cannot open /proc/${PID}/syscall"
+ continue
+ fi
+ {
+ "${TS_CMD_LSFD}" -n -o ASSOC,XMODE -p "${PID}" -Q '(FD >= 10) && (FD <= 22)'
+ echo "[$multiplexer] ASSOC,XMODE: $?"
+
+ # For debugging
+ if [[ $("${TS_CMD_LSFD}" -n -o XMODE -p "${PID}" -Q '(FD == 10)') != "r----m" ]]; then
+ cat /proc/"${PID}"/syscall
+ fi
+
+ echo DONE >&"${MKFDS[1]}"
+ } >> "$TS_OUTPUT" 2>&1
+ fi
+
+ wait "${MKFDS_PID}"
+ ts_finalize_subtest
+done
+
+ts_finalize
diff --git a/tests/ts/lsfd/mkfds-netlink-groups b/tests/ts/lsfd/mkfds-netlink-groups
index 896b50c..b7646c2 100755
--- a/tests/ts/lsfd/mkfds-netlink-groups
+++ b/tests/ts/lsfd/mkfds-netlink-groups
@@ -47,7 +47,7 @@ NETLINK_GROUPS=5
else
printf "LPORT: FAILED (PID: %d != NETLINK.LPORT: %d)\n" "${PID}" "${NETLINK_LPORT}"
fi
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
} > "$TS_OUTPUT" 2>&1
diff --git a/tests/ts/lsfd/mkfds-netlink-protocol b/tests/ts/lsfd/mkfds-netlink-protocol
index c1a5ffc..abf2eb2 100755
--- a/tests/ts/lsfd/mkfds-netlink-protocol
+++ b/tests/ts/lsfd/mkfds-netlink-protocol
@@ -46,7 +46,7 @@ NETLINK_GROUPS=5
else
printf "LPORT: FAILED (PID: %d != NETLINK.LPORT: %d)\n" "${PID}" "${NETLINK_LPORT}"
fi
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
} > "$TS_OUTPUT" 2>&1
diff --git a/tests/ts/lsfd/mkfds-netns b/tests/ts/lsfd/mkfds-netns
index cd110f6..0fbaec8 100755
--- a/tests/ts/lsfd/mkfds-netns
+++ b/tests/ts/lsfd/mkfds-netns
@@ -25,6 +25,7 @@ ts_skip_docker
. "$TS_SELF/lsfd-functions.bash"
ts_check_test_command "$TS_CMD_LSFD"
ts_check_test_command "$TS_HELPER_MKFDS"
+lsfd_check_mkfds_factory netns
ts_cd "$TS_OUTDIR"
@@ -61,11 +62,11 @@ INO_NS=
echo "NAME_FD: $NAME_FD" == "net:[INO_NS: $INO_NS]": $?
fi
- kill -CONT ${PID}
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
} > "$TS_OUTPUT" 2>&1
-if [ "$?" == "$ENOSYS" ]; then
+if [ "$?" == "$TS_EXIT_NOTSUPP" ]; then
ts_skip "ioctl(fd, SIOCGSKNS) is not available"
fi
diff --git a/tests/ts/lsfd/mkfds-pidfd b/tests/ts/lsfd/mkfds-pidfd
index aad693f..c0fae4f 100755
--- a/tests/ts/lsfd/mkfds-pidfd
+++ b/tests/ts/lsfd/mkfds-pidfd
@@ -40,11 +40,11 @@ EXPR="(PID != ${TARGET}) and (FD == 3) and (PIDFD.PID == ${TARGET})"
${TS_CMD_LSFD} -n -o ASSOC,STTYPE,SOURCE,NAME,PIDFD.COMM,PIDFD.PID -p "${PID}" -p ${TARGET} -Q "${EXPR}"
echo 'ASSOC,STTYPE,SOURCE,NAME,PIDFD.COMM,PIDFD.PID': $?
- kill -CONT ${PID}
+ echo DONE >&"${MKFDS[1]}"
fi
wait ${MKFDS_PID}
} > $TS_OUTPUT 2>&1
-if [ "$?" == "$ENOSYS" ]; then
+if [ "$?" == "$TS_EXIT_NOTSUPP" ]; then
ts_skip "pidfd_open(2) is not available"
fi
diff --git a/tests/ts/lsfd/mkfds-ping b/tests/ts/lsfd/mkfds-ping
index c2ca049..2baafde 100755
--- a/tests/ts/lsfd/mkfds-ping
+++ b/tests/ts/lsfd/mkfds-ping
@@ -90,7 +90,7 @@ ERRMSG=
for i in 0 1; do
ERRMSG=$("$TS_HELPER_MKFDS" -c -q "${FACTORY[$i]}" 3 id=$ID 2>&1)
ERR="$?"
- if [[ "$ERR" == "$EACCESS" ]]; then
+ if [[ "$ERR" == "$EACCES" ]]; then
case "$ERRMSG" in
*bind*)
MSG="making ${TYPE[$i]} socket with specifying id is not allowed (blocked by SELinux?)"
@@ -122,7 +122,7 @@ for i in 0 1; do
-o ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,${COLNS[$i]}.LADDR,${COLNS[$i]}.RADDR,PING.ID \
-p "${PID}" -Q "${EXPR[$i]}"
echo "ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,${COLNS[$i]}.LADDR,${COLNS[$i]}.RADDR,PING.ID": $?
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
@@ -132,7 +132,7 @@ for i in 0 1; do
-o ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,${COLNS[$i]}.LADDR,${COLNS[$i]}.RADDR,PING.ID \
-p "${PID}" -Q "${EXPR[$i]}"
echo "ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,${COLNS[$i]}.LADDR,${COLNS[$i]}.RADDR,PING.ID": $?
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
} > "$TS_OUTPUT" 2>&1
wait "${MKFDS_PID}"
diff --git a/tests/ts/lsfd/mkfds-pipe-no-fork b/tests/ts/lsfd/mkfds-pipe-no-fork
index e28aa9d..f2f950a 100755
--- a/tests/ts/lsfd/mkfds-pipe-no-fork
+++ b/tests/ts/lsfd/mkfds-pipe-no-fork
@@ -116,7 +116,7 @@ EOF
echo EXPECTED_LSFD_ENDPOINTS_JSON: "${EXPECTED_LSFD_ENDPOINTS_JSON}"
fi
- kill -CONT ${PID}
+ echo DONE >&"${MKFDS[1]}"
fi
wait ${MKFDS_PID}
} > $TS_OUTPUT 2>&1
diff --git a/tests/ts/lsfd/mkfds-pty b/tests/ts/lsfd/mkfds-pty
new file mode 100755
index 0000000..cc781eb
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-pty
@@ -0,0 +1,73 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 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="ptmx and associated pts"
+
+. "$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=
+FD0=5
+FD1=6
+INDEX=
+
+col_test()
+{
+ local col=$1
+ local expected=$2
+ local output
+
+ output=$(${TS_CMD_LSFD} -p "${PID}" -n --raw -o "$col" -Q "${EXPR}")
+ echo "$col": $?
+ if [[ "$output" != "$expected" ]]; then
+ echo "expected ${col} -Q ${EXPR}: ${expected}"
+ echo "output ${col} -Q ${EXPR}: ${output}"
+ fi
+}
+
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" pty $FD0 $FD1 ; }
+ if read -u ${MKFDS[0]} PID INDEX; then
+ EXPR='(FD == '$FD0')'
+ columns=ASSOC,MODE,TYPE,SOURCE
+ ${TS_CMD_LSFD} -p "${PID}" -n -r -o "$columns" -Q "${EXPR}"
+ echo "$columns": $?
+
+ col_test NAME "tty-index=${INDEX}"
+ col_test ENDPOINTS "${PID},test_mkfds,${FD1}r-"
+ col_test PTMX.TTY-INDEX "$INDEX"
+
+ EXPR='(FD == '$FD1')'
+ columns=ASSOC,MODE,TYPE
+ ${TS_CMD_LSFD} -p "${PID}" -n -r -o "$columns" -Q "${EXPR}"
+ echo "$columns": $?
+
+ col_test SOURCE "pts:${INDEX}"
+ col_test NAME "/dev/pts/${INDEX}"
+ col_test ENDPOINTS "${PID},test_mkfds,${FD0}rw"
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait ${MKFDS_PID}
+} > $TS_OUTPUT 2>&1
+
+ts_finalize
diff --git a/tests/ts/lsfd/mkfds-raw b/tests/ts/lsfd/mkfds-raw
index 0260ba1..5770340 100755
--- a/tests/ts/lsfd/mkfds-raw
+++ b/tests/ts/lsfd/mkfds-raw
@@ -40,7 +40,7 @@ PROTOCOL=5
-o ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,INET.LADDR,INET.RADDR,RAW.PROTOCOL \
-p "${PID}" -Q "${EXPR}"
echo 'ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,INET.LADDR,INET.RADDR,RAW.PROTOCOL': $?
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
diff --git a/tests/ts/lsfd/mkfds-raw6 b/tests/ts/lsfd/mkfds-raw6
index 0b82fff..1eddea2 100755
--- a/tests/ts/lsfd/mkfds-raw6
+++ b/tests/ts/lsfd/mkfds-raw6
@@ -41,7 +41,7 @@ PROTOCOL=5
-o ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,INET6.LADDR,INET6.RADDR,RAW.PROTOCOL \
-p "${PID}" -Q "${EXPR}"
echo 'ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,INET6.LADDR,INET6.RADDR,RAW.PROTOCOL': $?
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
diff --git a/tests/ts/lsfd/mkfds-ro-block-device b/tests/ts/lsfd/mkfds-ro-block-device
index ad5a492..7b14630 100755
--- a/tests/ts/lsfd/mkfds-ro-block-device
+++ b/tests/ts/lsfd/mkfds-ro-block-device
@@ -72,7 +72,7 @@ EXPR=
lsfd_compare_dev "${TS_CMD_LSFD}" "${LSFD_LOOP_BDEV}" "${EXPR}"
- kill -CONT ${PID}
+ echo DONE >&"${MKFDS[1]}"
fi
wait ${MKFDS_PID}
} > $TS_OUTPUT 2>&1
diff --git a/tests/ts/lsfd/mkfds-ro-regular-file b/tests/ts/lsfd/mkfds-ro-regular-file
index a2c4c26..367a07d 100755
--- a/tests/ts/lsfd/mkfds-ro-regular-file
+++ b/tests/ts/lsfd/mkfds-ro-regular-file
@@ -70,7 +70,7 @@ EXPR=
lsfd_compare_dev "${TS_CMD_LSFD}" $target "${EXPR}"
- kill -CONT ${PID}
+ echo DONE >&"${MKFDS[1]}"
fi
wait ${MKFDS_PID}
} > $TS_OUTPUT 2>&1
diff --git a/tests/ts/lsfd/mkfds-rw-character-device b/tests/ts/lsfd/mkfds-rw-character-device
index 85dd29c..3df2944 100755
--- a/tests/ts/lsfd/mkfds-rw-character-device
+++ b/tests/ts/lsfd/mkfds-rw-character-device
@@ -42,7 +42,7 @@ EXPR=
lsfd_compare_dev "${TS_CMD_LSFD}" $target "${EXPR}"
- kill -CONT ${PID}
+ echo DONE >&"${MKFDS[1]}"
fi
wait ${MKFDS_PID}
} > $TS_OUTPUT 2>&1
diff --git a/tests/ts/lsfd/mkfds-signalfd b/tests/ts/lsfd/mkfds-signalfd
new file mode 100755
index 0000000..ecc7379
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-signalfd
@@ -0,0 +1,64 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 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="signalfd"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+# s390x and riscv64 reported the same error:
+#
+# lsfd: signalfd ...
+# diff-{{{
+# --- /home/runner/work/util-linux/util-linux/tests/expected/lsfd/mkfds-signalfd 2023-06-08 10:20:13.520555037 +0000
+# +++ /home/runner/work/util-linux/util-linux/tests/output/lsfd/mkfds-signalfd 2023-06-08 11:12:21.150054369 +0000
+# @@ -1,2 +1,2 @@
+# - 3 signalfd mask=FPE,USR1,42 FPE,USR1,42
+# + 3 signalfd mask=FPE,USR1,44 FPE,USR1,44
+# ASSOC,TYPE,NAME,SIGNALFD.MASK: 0
+# }}}-diff
+#
+# FAILED (lsfd/mkfds-signalfd)
+#
+# The error is nothing to do with endianness; the endian s390x is
+# big-endian. riscv64 is little-endian.
+#
+# So Qemu's user emulation is suspicious.
+ts_skip_qemu_user
+
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_HELPER_MKFDS"
+
+ts_cd "$TS_OUTDIR"
+
+PID=
+FD=3
+
+COL=ASSOC,TYPE,NAME,SIGNALFD.MASK
+EXPR='(FD == '"$FD"')'
+
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" signalfd $FD; }
+ if read -u ${MKFDS[0]} PID; then
+ ${TS_CMD_LSFD} -p "${PID}" -n -o "${COL}" -Q "${EXPR}"
+ echo "${COL}": $?
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait "${MKFDS_PID}"
+} > "$TS_OUTPUT" 2>&1
+
+ts_finalize
diff --git a/tests/ts/lsfd/mkfds-socketpair b/tests/ts/lsfd/mkfds-socketpair
index 3ffd088..3ef60c7 100755
--- a/tests/ts/lsfd/mkfds-socketpair
+++ b/tests/ts/lsfd/mkfds-socketpair
@@ -20,6 +20,7 @@ TS_DESC="AF_UNIX socket pair created with socketpair(2)"
. "$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"
@@ -28,11 +29,14 @@ ts_check_prog "sed"
ts_cd "$TS_OUTDIR"
+lsfd_check_sockdiag "unix"
+
PID=
FD0=3
FD1=4
EXPR=
+ts_init_subtest "DGRAM"
{
coproc MKFDS { "$TS_HELPER_MKFDS" socketpair $FD0 $FD1 socktype=DGRAM; }
if read -u ${MKFDS[0]} PID; then
@@ -40,9 +44,96 @@ EXPR=
${TS_CMD_LSFD} -n -o ASSOC,MODE,STTYPE,SOURCE,SOCK.PROTONAME -Q "${EXPR}" | sed -e 's/UNIX-DGRAM/UNIX/'
echo 'ASSOC,MODE,STTYPE,SOURCE,SOCK.PROTONAME': ${PIPESTATUS[0]}
- kill -CONT ${PID}
+ echo DONE >&"${MKFDS[1]}"
+ fi
+} > "$TS_OUTPUT" 2>&1
+
+wait ${MKFDS_PID}
+ts_finalize_subtest
+
+ts_init_subtest "STREAM"
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" socketpair $FD0 $FD1 socktype=STREAM; }
+ if read -u ${MKFDS[0]} PID; then
+ EXPR='(PID == '"${PID}"') and ((FD == '"$FD0"') or (FD == '"$FD1"'))'
+ ${TS_CMD_LSFD} -n -o ASSOC,MODE,STTYPE,SOURCE,SOCK.PROTONAME -Q "${EXPR}" | sed -e 's/UNIX-STREAM/UNIX/'
+ echo 'ASSOC,MODE,STTYPE,SOURCE,SOCK.PROTONAME': ${PIPESTATUS[0]}
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+} > "$TS_OUTPUT" 2>&1
+
+wait ${MKFDS_PID}
+ts_finalize_subtest
+
+mkfds_socketpair_stream_endpoint()
+{
+ ts_init_subtest "STREAM-ENDPOINT"
+ if [ "$QEMU_USER" == "1" ]; then
+ ts_skip_subtest "running under qemu-user emulation"
+ return
+ fi
+ {
+ coproc MKFDS { "$TS_HELPER_MKFDS" socketpair $FD0 $FD1 socktype=STREAM; }
+ if read -u ${MKFDS[0]} PID; then
+ EXPR='(FD == '"$FD0"') or (FD == '"$FD1"')'
+ ${TS_CMD_LSFD} -p "${PID}" -n -o ASSOC,MODE,STTYPE,SOURCE,ENDPOINTS -Q "${EXPR}" | sed -e "s/${PID}/1/g"
+ echo 'ASSOC,MODE,STTYPE,SOURCE,ENDPOINTS': ${PIPESTATUS[0]}
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ } > "$TS_OUTPUT" 2>&1
+
+ wait ${MKFDS_PID}
+ ts_finalize_subtest
+}
+
+mkfds_socketpair_stream_shutdown_state()
+{
+ ts_init_subtest "STREAM-SHUTDOWN-STATE"
+ if [ "$QEMU_USER" == "1" ]; then
+ ts_skip_subtest "running under qemu-user emulation"
+ return
+ fi
+ {
+ coproc MKFDS { "$TS_HELPER_MKFDS" socketpair $FD0 $FD1 socktype=STREAM halfclose=1; }
+ if read -u ${MKFDS[0]} PID; then
+ EXPR='(FD == '"$FD0"') or (FD == '"$FD1"')'
+ ${TS_CMD_LSFD} -p "${PID}" -n -o ASSOC,MODE,STTYPE,SOURCE,SOCK.SHUTDOWN -Q "${EXPR}"
+ echo 'ASSOC,MODE,STTYPE,SOURCE,SOCK.SHUTDOWN': ${PIPESTATUS[0]}
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ } > "$TS_OUTPUT" 2>&1
+
+ wait ${MKFDS_PID}
+ ts_finalize_subtest
+}
+
+mkfds_socketpair_stream_endpoint_halfclose()
+{
+ ts_init_subtest "STREAM-ENDPOINT-halfclose"
+ if [ "$QEMU_USER" == "1" ]; then
+ ts_skip_subtest "running under qemu-user emulation"
+ return
fi
+ {
+ coproc MKFDS { "$TS_HELPER_MKFDS" socketpair $FD0 $FD1 socktype=STREAM halfclose=1; }
+ if read -u ${MKFDS[0]} PID; then
+ EXPR='(FD == '"$FD0"') or (FD == '"$FD1"')'
+ ${TS_CMD_LSFD} -p "${PID}" -n -o ASSOC,MODE,STTYPE,SOURCE,ENDPOINTS -Q "${EXPR}" | sed -e "s/${PID}/1/g"
+ echo 'ASSOC,MODE,STTYPE,SOURCE,ENDPOINTS': ${PIPESTATUS[0]}
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ } > "$TS_OUTPUT" 2>&1
+
wait ${MKFDS_PID}
-} > $TS_OUTPUT 2>&1
+ ts_finalize_subtest
+}
+
+mkfds_socketpair_stream_endpoint
+mkfds_socketpair_stream_shutdown_state
+mkfds_socketpair_stream_endpoint_halfclose
ts_finalize
diff --git a/tests/ts/lsfd/mkfds-symlink b/tests/ts/lsfd/mkfds-symlink
index 4825645..56eccca 100755
--- a/tests/ts/lsfd/mkfds-symlink
+++ b/tests/ts/lsfd/mkfds-symlink
@@ -37,7 +37,7 @@ EXPR=
${TS_CMD_LSFD} -n -o ASSOC,MODE,TYPE,NAME,FLAGS -Q "${EXPR}"
echo 'ASSOC,MODE,TYPE,NAME,FLAGS': $?
- kill -CONT ${PID}
+ echo DONE >&"${MKFDS[1]}"
fi
wait ${MKFDS_PID}
} > $TS_OUTPUT 2>&1
diff --git a/tests/ts/lsfd/mkfds-tcp b/tests/ts/lsfd/mkfds-tcp
index e531a7b..666cf6a 100755
--- a/tests/ts/lsfd/mkfds-tcp
+++ b/tests/ts/lsfd/mkfds-tcp
@@ -34,15 +34,15 @@ EXPR='(TYPE == "TCP") and (FD >= 3) and (FD <= 5)'
{
coproc MKFDS { "$TS_HELPER_MKFDS" tcp $FDS $FDC $FDA \
- server-port=34567 \
- client-port=23456 ; }
+ server-port=56789 \
+ client-port=45678 ; }
if read -r -u "${MKFDS[0]}" PID; then
${TS_CMD_LSFD} -n \
-o ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET.LADDR,INET.RADDR,TCP.LADDR,TCP.LPORT,TCP.RADDR,TCP.RPORT \
-p "${PID}" -Q "${EXPR}"
echo 'ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET.LADDR,INET.RADDR,TCP.LADDR,TCP.LPORT,TCP.RADDR,TCP.RPORT': $?
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
} > "$TS_OUTPUT" 2>&1
diff --git a/tests/ts/lsfd/mkfds-tcp6 b/tests/ts/lsfd/mkfds-tcp6
index 7368bfa..bffa630 100755
--- a/tests/ts/lsfd/mkfds-tcp6
+++ b/tests/ts/lsfd/mkfds-tcp6
@@ -35,15 +35,15 @@ EXPR='(TYPE == "TCPv6") and (FD >= 3) and (FD <= 5)'
{
coproc MKFDS { "$TS_HELPER_MKFDS" tcp6 $FDS $FDC $FDA \
- server-port=34567 \
- client-port=23456 ; }
+ server-port=56789 \
+ client-port=45678 ; }
if read -r -u "${MKFDS[0]}" PID; then
${TS_CMD_LSFD} -n \
-o ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET6.LADDR,INET6.RADDR,TCP.LADDR,TCP.LPORT,TCP.RADDR,TCP.RPORT \
-p "${PID}" -Q "${EXPR}"
echo 'ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET6.LADDR,INET6.RADDR,TCP.LADDR,TCP.LPORT,TCP.RADDR,TCP.RPORT': $?
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
} > "$TS_OUTPUT" 2>&1
diff --git a/tests/ts/lsfd/mkfds-timerfd b/tests/ts/lsfd/mkfds-timerfd
new file mode 100755
index 0000000..d2e0b8a
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-timerfd
@@ -0,0 +1,109 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 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="timerfd"
+
+. "$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=
+FD=3
+EXPR='(FD == '"$FD"')'
+
+ts_init_subtest "realtime-remaining-and-interval"
+{
+ clock=realtime
+ coproc MKFDS { "$TS_HELPER_MKFDS" timerfd $FD clockid=$clock remaining=99 interval=5 interval-nanofrac=123456789; }
+ if read -u ${MKFDS[0]} PID; then
+ ${TS_CMD_LSFD} -p "${PID}" -n -o ASSOC,TYPE,NAME -Q "${EXPR}" | \
+ sed -e 's/remaining=[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/remaining=100.987654321/'
+ echo 'ASSOC,TYPE,NAME': ${PIPESTATUS[0]}
+
+ ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.CLOCKID -Q "${EXPR}"
+ echo 'CLOCKID': $?
+
+ ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.REMAINING -Q "${EXPR}" | \
+ sed -e 's/^ *[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$/100.987654321/'
+ echo 'TIMERFD.REMAINING': ${PIPESTATUS[0]}
+
+ ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.INTERVAL -Q "${EXPR}"
+ echo 'TIMERFD.INTERVAL': $?
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait "${MKFDS_PID}"
+} > "$TS_OUTPUT" 2>&1
+ts_finalize_subtest
+
+ts_init_subtest "monotonic-remaining-only"
+{
+ clock=monotonic
+ coproc MKFDS { "$TS_HELPER_MKFDS" timerfd $FD clockid=$clock remaining=99 interval=0 interval-nanofrac=0; }
+ if read -u ${MKFDS[0]} PID; then
+ EXPR='(FD == '"$FD"')'
+ ${TS_CMD_LSFD} -p "${PID}" -n -o ASSOC,TYPE,NAME -Q "${EXPR}" | \
+ sed -e 's/remaining=[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/remaining=100.987654321/'
+ echo 'ASSOC,TYPE,NAME': ${PIPESTATUS[0]}
+
+ ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.CLOCKID -Q "${EXPR}"
+ echo 'CLOCKID': $?
+
+ ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.REMAINING -Q "${EXPR}" | \
+ sed -e 's/^ *[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$/100.987654321/'
+ echo 'TIMERFD.REMAINING': ${PIPESTATUS[0]}
+
+ ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.INTERVAL -Q "${EXPR}"
+ echo 'TIMERFD.INTERVAL': $?
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait "${MKFDS_PID}"
+} > "$TS_OUTPUT" 2>&1
+ts_finalize_subtest
+
+ts_init_subtest "boottime-interval-only"
+{
+ clock=boottime
+ coproc MKFDS { "$TS_HELPER_MKFDS" timerfd $FD clockid=$clock remaining=0 interval=10 interval-nanofrac=123456789; }
+ if read -u ${MKFDS[0]} PID; then
+ EXPR='(FD == '"$FD"')'
+ ${TS_CMD_LSFD} -p "${PID}" -n -o ASSOC,TYPE,NAME -Q "${EXPR}"
+ echo 'ASSOC,TYPE,NAME': $?
+
+ ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.CLOCKID -Q "${EXPR}"
+ echo 'CLOCKID': $?
+
+ ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.REMAINING -Q "${EXPR}"
+ echo 'TIMERFD.REMAINING': $?
+
+ ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.INTERVAL -Q "${EXPR}"
+ echo 'TIMERFD.INTERVAL': $?
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait "${MKFDS_PID}"
+} > "$TS_OUTPUT" 2>&1
+ts_finalize_subtest
+
+ts_finalize
diff --git a/tests/ts/lsfd/mkfds-timerfd-alarm b/tests/ts/lsfd/mkfds-timerfd-alarm
new file mode 100755
index 0000000..c7e6650
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-timerfd-alarm
@@ -0,0 +1,56 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 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="timerfd associating alarm"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_skip_capability WAKE_ALARM
+
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_HELPER_MKFDS"
+
+ts_cd "$TS_OUTDIR"
+
+PID=
+FD=3
+EXPR='(FD == '"$FD"')'
+
+{
+ for clock in realtime-alarm boottime-alarm; do
+ coproc MKFDS { "$TS_HELPER_MKFDS" timerfd $FD clockid=$clock remaining=0 interval=0 interval-nanofrac=0; }
+ if read -u ${MKFDS[0]} PID; then
+ ${TS_CMD_LSFD} -p "${PID}" -n -o ASSOC,TYPE,NAME -Q "${EXPR}"
+ echo 'ASSOC,TYPE,NAME': $?
+
+ ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.CLOCKID -Q "${EXPR}"
+ echo 'CLOCKID': $?
+
+ ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.REMAINING -Q "${EXPR}"
+ echo 'TIMERFD.REMAINING': $?
+
+ ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.INTERVAL -Q "${EXPR}"
+ echo 'TIMERFD.INTERVAL': $?
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait "${MKFDS_PID}"
+ done
+} > "$TS_OUTPUT" 2>&1
+
+ts_finalize
diff --git a/tests/ts/lsfd/mkfds-udp b/tests/ts/lsfd/mkfds-udp
index e6e1f1c..3d1b272 100755
--- a/tests/ts/lsfd/mkfds-udp
+++ b/tests/ts/lsfd/mkfds-udp
@@ -51,8 +51,8 @@ LPORT=
for lite in 0 1; do
coproc MKFDS { "$TS_HELPER_MKFDS" udp $FDS $FDC \
- server-port=34567 \
- client-port=23456 \
+ server-port=56789 \
+ client-port=45678 \
lite=$lite; }
if read -r -u "${MKFDS[0]}" PID; then
${TS_CMD_LSFD} -n \
@@ -60,13 +60,13 @@ for lite in 0 1; do
-p "${PID}" -Q "${EXPR[$lite]}"
echo "ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET.LADDR,INET.RADDR,${COLNS[$lite]}.LADDR,${COLNS[$lite]}.LPORT,${COLNS[$lite]}.RADDR,${COLNS[$lite]}.RPORT": $?
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
coproc MKFDS { "$TS_HELPER_MKFDS" udp $FDS $FDC \
- server-port=34567 \
- client-port=23456 \
+ server-port=56789 \
+ client-port=45678 \
server-do-bind=no \
lite=$lite; }
if read -r -u "${MKFDS[0]}" PID; then
@@ -85,13 +85,13 @@ for lite in 0 1; do
echo "NAME pattern match: FAILED (NAME=$NAME)"
fi
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
coproc MKFDS { "$TS_HELPER_MKFDS" udp $FDS $FDC \
- server-port=34567 \
- client-port=23456 \
+ server-port=56789 \
+ client-port=45678 \
client-do-bind=no \
lite=$lite; }
if read -r -u "${MKFDS[0]}" PID; then
@@ -115,13 +115,13 @@ for lite in 0 1; do
echo "LADDR/LPORT pattern match: FAILED (LADDR=$LADDR, LPORT=$LPORT)"
fi
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
coproc MKFDS { "$TS_HELPER_MKFDS" udp $FDS $FDC \
- server-port=34567 \
- client-port=23456 \
+ server-port=56789 \
+ client-port=45678 \
client-do-connect=no \
lite=$lite; }
if read -r -u "${MKFDS[0]}" PID; then
@@ -130,7 +130,7 @@ for lite in 0 1; do
-p "${PID}" -Q "${EXPR[$lite]}"
echo 'ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET.LADDR,INET.RADDR,UDP.LADDR,UDP.LPORT,UDP.RADDR,UDP.RPORT': $?
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
done > "$TS_OUTPUT" 2>&1
diff --git a/tests/ts/lsfd/mkfds-udp6 b/tests/ts/lsfd/mkfds-udp6
index 75381ba..26bdacd 100755
--- a/tests/ts/lsfd/mkfds-udp6
+++ b/tests/ts/lsfd/mkfds-udp6
@@ -52,8 +52,8 @@ LPORT=
for lite in 0 1; do
coproc MKFDS { "$TS_HELPER_MKFDS" udp6 $FDS $FDC \
- server-port=34567 \
- client-port=23456 \
+ server-port=56789 \
+ client-port=45678 \
lite=$lite; }
if read -r -u "${MKFDS[0]}" PID; then
${TS_CMD_LSFD} -n \
@@ -61,13 +61,13 @@ for lite in 0 1; do
-p "${PID}" -Q "${EXPR[$lite]}"
echo "ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET6.LADDR,INET6.RADDR,${COLNS[$lite]}.LADDR,${COLNS[$lite]}.LPORT,${COLNS[$lite]}.RADDR,${COLNS[$lite]}.RPORT": $?
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
coproc MKFDS { "$TS_HELPER_MKFDS" udp6 $FDS $FDC \
- server-port=34567 \
- client-port=23456 \
+ server-port=56789 \
+ client-port=45678 \
server-do-bind=no \
lite=$lite; }
if read -r -u "${MKFDS[0]}" PID; then
@@ -86,13 +86,13 @@ for lite in 0 1; do
echo "NAME pattern match: FAILED (NAME=$NAME)"
fi
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
coproc MKFDS { "$TS_HELPER_MKFDS" udp6 $FDS $FDC \
- server-port=34567 \
- client-port=23456 \
+ server-port=56789 \
+ client-port=45678 \
client-do-bind=no \
lite=$lite; }
if read -r -u "${MKFDS[0]}" PID; then
@@ -116,13 +116,13 @@ for lite in 0 1; do
echo "LADDR/LPORT pattern match: FAILED (LADDR=$LADDR, LPORT=$LPORT)"
fi
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
coproc MKFDS { "$TS_HELPER_MKFDS" udp6 $FDS $FDC \
- server-port=34567 \
- client-port=23456 \
+ server-port=56789 \
+ client-port=45678 \
client-do-connect=no \
lite=$lite; }
if read -r -u "${MKFDS[0]}" PID; then
@@ -131,7 +131,7 @@ for lite in 0 1; do
-p "${PID}" -Q "${EXPR[$lite]}"
echo "ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET6.LADDR,INET6.RADDR,${COLNS[$lite]}.LADDR,${COLNS[$lite]}.LPORT,${COLNS[$lite]}.RADDR,${COLNS[$lite]}.RPORT": $?
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
done > "$TS_OUTPUT" 2>&1
diff --git a/tests/ts/lsfd/mkfds-unix-dgram b/tests/ts/lsfd/mkfds-unix-dgram
index c8b40eb..45a0b2d 100755
--- a/tests/ts/lsfd/mkfds-unix-dgram
+++ b/tests/ts/lsfd/mkfds-unix-dgram
@@ -35,7 +35,7 @@ make_state_connected()
{
# The first one is for rewriting NAME column.
# The second one is for rewriting STATE column.
- lsfd_make_state_connected | sed -e 's/unconnected/ connected/'
+ lsfd_make_state_connected | sed -e 's/unconnected/connected/'
}
{
@@ -43,11 +43,12 @@ make_state_connected()
path=test_mkfds-unix-dgram ; }
if read -r -u "${MKFDS[0]}" PID; then
${TS_CMD_LSFD} -n \
+ -r \
-o ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH \
-p "${PID}" -Q "${EXPR}" | make_state_connected
echo 'ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH': ${PIPESTATUS[0]}
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
@@ -56,11 +57,12 @@ make_state_connected()
abstract=true ; }
if read -r -u "${MKFDS[0]}" PID; then
${TS_CMD_LSFD} -n \
+ -r \
-o ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH \
-p "${PID}" -Q "${EXPR}" | make_state_connected
echo 'ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH': $?
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
} > "$TS_OUTPUT" 2>&1
diff --git a/tests/ts/lsfd/mkfds-unix-in-netns b/tests/ts/lsfd/mkfds-unix-in-netns
index cfca087..9ed4567 100755
--- a/tests/ts/lsfd/mkfds-unix-in-netns
+++ b/tests/ts/lsfd/mkfds-unix-in-netns
@@ -78,7 +78,7 @@ for t in stream dgram seqpacket; do
compare_net_namespaces "$t" "${PID}"
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
@@ -94,7 +94,7 @@ for t in stream dgram seqpacket; do
compare_net_namespaces "abstract $t" "${PID}"
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
} > "$TS_OUTPUT" 2>&1
diff --git a/tests/ts/lsfd/mkfds-unix-stream b/tests/ts/lsfd/mkfds-unix-stream
index fe08e72..3c31443 100755
--- a/tests/ts/lsfd/mkfds-unix-stream
+++ b/tests/ts/lsfd/mkfds-unix-stream
@@ -46,7 +46,7 @@ EXPR='(((TYPE == "UNIX-STREAM") or (TYPE == "UNIX")) and (FD >= 3) and (FD <= 5)
-p "${PID}" -Q "${EXPR}" | lsfd_strip_type_stream
echo 'ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH': ${PIPESTATUS[0]}
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
@@ -59,7 +59,7 @@ EXPR='(((TYPE == "UNIX-STREAM") or (TYPE == "UNIX")) and (FD >= 3) and (FD <= 5)
-p "${PID}" -Q "${EXPR}" | lsfd_strip_type_stream
echo '(abs) ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH': ${PIPESTATUS[0]}
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
@@ -75,7 +75,7 @@ EXPR='(((TYPE == "UNIX-STREAM") or (TYPE == "UNIX")) and (FD >= 3) and (FD <= 5)
echo '(shutdown) ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH': ${PIPESTATUS[0]}
# Surprisingly, the socket status doesn't change at all.
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
@@ -88,7 +88,7 @@ EXPR='(((TYPE == "UNIX-STREAM") or (TYPE == "UNIX")) and (FD >= 3) and (FD <= 5)
-p "${PID}" -Q "${EXPR}" | lsfd_strip_type_stream
echo 'ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH': ${PIPESTATUS[0]}
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
diff --git a/tests/ts/lsfd/mkfds-unix-stream-requiring-sockdiag b/tests/ts/lsfd/mkfds-unix-stream-requiring-sockdiag
new file mode 100755
index 0000000..6189d0d
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-unix-stream-requiring-sockdiag
@@ -0,0 +1,58 @@
+#!/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="UNIX stream sockets"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+ts_skip_qemu_user
+
+. "$TS_SELF/lsfd-functions.bash"
+
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_HELPER_MKFDS"
+
+ts_cd "$TS_OUTDIR"
+
+lsfd_check_sockdiag "unix"
+
+PID=
+FDS=3
+FDC=4
+FDA=5
+EXPR='(((TYPE == "UNIX-STREAM") or (TYPE == "UNIX")) and (FD >= 3) and (FD <= 5))'
+
+{
+ for t in stream seqpacket; do
+
+ coproc MKFDS { "$TS_HELPER_MKFDS" unix-stream $FDS $FDC $FDA \
+ path="test_mkfds-unix with newline ${t} $(printf 'a\nb\nc')" \
+ type=$t ; }
+ if read -r -u "${MKFDS[0]}" PID; then
+ ${TS_CMD_LSFD} -n \
+ -o ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH \
+ -p "${PID}" -Q "${EXPR}" | lsfd_strip_type_stream
+ echo 'ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH': ${PIPESTATUS[0]}
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait "${MKFDS_PID}"
+
+ done
+} > "$TS_OUTPUT" 2>&1
+
+ts_finalize
diff --git a/tests/ts/lsfd/option-inet b/tests/ts/lsfd/option-inet
index 011a9b3..7ca8837 100755
--- a/tests/ts/lsfd/option-inet
+++ b/tests/ts/lsfd/option-inet
@@ -25,23 +25,54 @@ ts_skip_docker
ts_check_test_command "$TS_CMD_LSFD"
ts_check_test_command "$TS_HELPER_MKFDS"
+ts_check_prog "mkfifo"
+
ts_cd "$TS_OUTDIR"
+FIFO=./test_mkfds-option-inet.fifo
{
- "$TS_HELPER_MKFDS" -q tcp 3 4 5 server-port=34567 client-port=23456 &
- PID0=$!
-
- "$TS_HELPER_MKFDS" -q tcp6 3 4 5 server-port=34567 client-port=23456 &
- PID1=$!
-
- "$TS_HELPER_MKFDS" -q ro-regular-file 3 file=/etc/passwd &
- PID2=$!
-
- "$TS_HELPER_MKFDS" -q udp 3 4 server-port=34567 client-port=23456 server-do-bind=1 client-do-bind=1 client-do-connect=1&
- PID3=$!
-
- "$TS_HELPER_MKFDS" -q udp6 3 4 lite=1 server-port=34567 client-port=23456 server-do-bind=1 client-do-bind=1 client-do-connect=1&
- PID4=$!
+ rm -f "${FIFO}"
+ if ! mkfifo "${FIFO}"; then
+ ts_finalize "failed in creating a fifo"
+ fi
+
+ "$TS_HELPER_MKFDS" -X tcp 3 4 5 server-port=34567 client-port=23456 > "${FIFO}" &
+ if ! read PID0 < "${FIFO}"; then
+ rm "${FIFO}"
+ ts_finalize "$TS_HELPER_MKFDS tcp...doesn't report its pid"
+ fi
+
+ "$TS_HELPER_MKFDS" -X tcp6 3 4 5 server-port=34567 client-port=23456 > "${FIFO}" &
+ if ! read PID1 < "${FIFO}"; then
+ kill -CONT "${PID0}"
+ wait "${PID0}"
+ rm "${FIFO}"
+ ts_finalize "$TS_HELPER_MKFDS tcp6...doesn't report its pid"
+ fi
+
+ "$TS_HELPER_MKFDS" -X ro-regular-file 3 file=/etc/passwd > "${FIFO}" &
+ if ! read PID2 < "${FIFO}"; then
+ kill -CONT "${PID0}" "${PID1}"
+ wait "${PID0}" "${PID1}"
+ rm "${FIFO}"
+ ts_finalize "$TS_HELPER_MKFDS ro-regular-file...doesn't report its pid"
+ fi
+
+ "$TS_HELPER_MKFDS" -X udp 3 4 server-port=34567 client-port=23456 server-do-bind=1 client-do-bind=1 client-do-connect=1 > "${FIFO}" &
+ if ! read PID3 < "${FIFO}"; then
+ kill -CONT "${PID0}" "${PID1}" "${PID2}"
+ wait "${PID0}" "${PID1}" "${PID2}"
+ rm "${FIFO}"
+ ts_finalize "$TS_HELPER_MKFDS udp...doesn't report its pid"
+ fi
+
+ "$TS_HELPER_MKFDS" -X udp6 3 4 lite=1 server-port=34567 client-port=23456 server-do-bind=1 client-do-bind=1 client-do-connect=1 > "${FIFO}" &
+ if ! read PID4 < "${FIFO}"; then
+ kill -CONT "${PID0}" "${PID1}" "${PID2}" "${PID3}"
+ wait "${PID0}" "${PID1}" "${PID2}" "${PID3}"
+ rm "${FIFO}"
+ ts_finalize "$TS_HELPER_MKFDS udp6 lite=1...doesn't report its pid"
+ fi
OPT='--inet'
echo "# $OPT"
@@ -85,14 +116,9 @@ ts_cd "$TS_OUTDIR"
-o ASSOC,TYPE,NAME \
-Q "(PID == $PID0) or (PID == $PID1) or (PID == $PID2) or (PID == $PID3) or (PID == $PID4)"
- kill -CONT "${PID0}"
- wait "${PID0}"
-
- kill -CONT "${PID1}"
- wait "${PID1}"
-
- kill -CONT "${PID2}"
- wait "${PID2}"
+ kill -CONT "${PID0}" "${PID1}" "${PID2}" "${PID3}" "${PID4}"
+ wait "${PID0}" "${PID1}" "${PID2}" "${PID3}" "${PID4}"
+ rm "${FIFO}"
} > "$TS_OUTPUT" 2>&1
ts_finalize
diff --git a/tests/ts/lsfd/option-pid b/tests/ts/lsfd/option-pid
index 0ea4353..003b624 100755
--- a/tests/ts/lsfd/option-pid
+++ b/tests/ts/lsfd/option-pid
@@ -72,7 +72,7 @@ POUT=
[ "${QOUT}" = "${POUT}" ]
echo "EQ[-p PID --pid=1]:" $?
- kill -CONT ${PID}
+ echo DONE >&"${MKFDS[1]}"
fi
wait ${MKFDS_PID}
} > $TS_OUTPUT 2>&1
diff --git a/tests/ts/lsfd/option-summary b/tests/ts/lsfd/option-summary
index 64bf54b..9813901 100755
--- a/tests/ts/lsfd/option-summary
+++ b/tests/ts/lsfd/option-summary
@@ -35,14 +35,14 @@ PIDS=
PID=
for i in {1..10}; do
- "$TS_HELPER_MKFDS" -q ro-regular-file $FD file=$F_GROUP &
+ "$TS_HELPER_MKFDS" -X -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 &
+ "$TS_HELPER_MKFDS" -X -q ro-regular-file $FD file=$F_PASSWD &
PID=$!
PIDS="${PIDS} ${PID} "
lsfd_wait_for_pausing "${PID}"
diff --git a/tests/ts/lslocks/lslocks b/tests/ts/lslocks/lslocks
new file mode 100755
index 0000000..912fac8
--- /dev/null
+++ b/tests/ts/lslocks/lslocks
@@ -0,0 +1,117 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 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="flock"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_LSLOCKS"
+ts_check_test_command "$TS_HELPER_MKFDS"
+ts_check_prog "sed"
+
+ts_cd "$TS_OUTDIR"
+
+FILE0=util-linux-lslocks-target-file
+FILE=${FILE0}--$$
+FD=17
+DFD=18
+COLS=COMMAND,TYPE,SIZE,MODE,START,END
+OPTS="--raw --noheadings"
+METHODS=(
+ flock-sh
+ flock-ex
+ posix-r-
+ posix--w
+ posix-rw
+ ofd-r-
+ ofd--w
+ ofd-rw
+ lease-w
+)
+
+OFD_METHODS=(
+ flock-sh
+ flock-ex
+ ofd-r-
+ ofd--w
+ ofd-rw
+ lease-w
+)
+
+SLEEP()
+{
+ # It appears that there is a time lag between locking and its
+ # visibility in /proc/locks. See the unstbale results of errors I
+ # observed in https://github.com/util-linux/util-linux/pull/2629.
+ sleep 1
+}
+
+DFD=18
+COLS_WITH_HOLDERS=COMMAND,TYPE,SIZE,MODE,START,END,HOLDERS
+run_lslocks()
+{
+ local m=$1
+
+ {
+ rm -f "${FILE}"
+ coproc MKFDS { "$TS_HELPER_MKFDS" make-regular-file $FD file="$FILE" lock=$m; }
+ if read -r -u "${MKFDS[0]}" PID; then
+ SLEEP
+
+ "$TS_CMD_LSLOCKS" ${OPTS} --pid "${PID}" -o "${COLS}"
+ echo "# $m + ${COLS} + ${OPTS}": $?
+ "$TS_CMD_LSLOCKS" ${OPTS} --pid "${PID}" -o PATH | sed -e 's#.*\('"$FILE0"'\)--[0-9]\+ *$#\1#'
+ echo "# $m + PATH + ${OPTS}": ${PIPESTATUS[0]}
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ } > "$TS_OUTPUT" 2>&1
+
+ wait "${MKFDS_PID}"
+}
+
+run_lslocks_with_co_holders()
+{
+ local m=$1
+
+ {
+ rm -f "${FILE}"
+ coproc MKFDS { "$TS_HELPER_MKFDS" make-regular-file $FD file="$FILE" lock=$m dupfd=$DFD; }
+ SLEEP
+ if read -r -u "${MKFDS[0]}" PID; then
+ "$TS_CMD_LSLOCKS" ${OPTS} --pid "${PID}" -o "${COLS_WITH_HOLDERS}" | sed -e "s/${PID},/1,/g"
+ echo "# $m + ${COLS_WITH_HOLDERS} + ${OPTS}": ${PIPESTATUS[0]}
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ } > "$TS_OUTPUT" 2>&1
+
+ wait "${MKFDS_PID}"
+}
+
+for m in "${METHODS[@]}"; do
+ ts_init_subtest "$m"
+ run_lslocks "$m"
+ ts_finalize_subtest
+done
+
+for m in "${OFD_METHODS[@]}"; do
+ ts_init_subtest "$m+HOLDERS"
+ run_lslocks_with_co_holders "$m"
+ ts_finalize_subtest
+done
+
+ts_finalize
diff --git a/tests/ts/misc/boilerplate b/tests/ts/misc/boilerplate
new file mode 100755
index 0000000..d795ec2
--- /dev/null
+++ b/tests/ts/misc/boilerplate
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+# Copyright (C) 2023 Thomas Weißschuh <thomas@t-8ch.de>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="Documentation/boilerplate"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_HELPER_BOILERPLATE"
+
+ts_init_subtest exec
+
+"$TS_HELPER_BOILERPLATE" >> "$TS_OUTPUT" 2>> "$TS_ERRLOG"
+echo "ret=$?" >> "$TS_OUTPUT"
+
+ts_finalize_subtest
+
+ts_init_subtest help
+
+"$TS_HELPER_BOILERPLATE" --help >> "$TS_OUTPUT" 2>> "$TS_ERRLOG"
+echo "ret=$?" >> "$TS_OUTPUT"
+
+ts_finalize_subtest
+
+ts_finalize
diff --git a/tests/ts/misc/enosys b/tests/ts/misc/enosys
new file mode 100755
index 0000000..ae93c63
--- /dev/null
+++ b/tests/ts/misc/enosys
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+# Copyright (C) 2022 Thomas Weißschuh <thomas@t-8ch.de>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="enosys"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_HELPER_ENOSYS"
+ts_check_enosys_syscalls fallocate fsopen execve
+
+ts_init_subtest basic
+
+FALLOCATE_TEST="$TS_HELPER_ENOSYS fallocate"
+
+$FALLOCATE_TEST > /dev/null 2>> "$TS_OUTPUT"
+"$TS_CMD_ENOSYS" -s fallocate $FALLOCATE_TEST > /dev/null 2>> "$TS_OUTPUT"
+"$TS_CMD_ENOSYS" -s fsopen -s fallocate $FALLOCATE_TEST > /dev/null 2>> "$TS_OUTPUT"
+"$TS_CMD_ENOSYS" -s fallocate -s fsopen $FALLOCATE_TEST > /dev/null 2>> "$TS_OUTPUT"
+
+ts_finalize_subtest
+
+ts_init_subtest exec
+
+FALLOCATE_TEST="$TS_HELPER_ENOSYS exec"
+
+$FALLOCATE_TEST > /dev/null 2>> "$TS_OUTPUT"
+"$TS_CMD_ENOSYS" -s execve $FALLOCATE_TEST > /dev/null 2>> "$TS_OUTPUT"
+
+ts_finalize_subtest
+
+ts_init_subtest ioctl
+
+FALLOCATE_TEST="$TS_HELPER_ENOSYS ioctl"
+
+$FALLOCATE_TEST > /dev/null 2>> "$TS_OUTPUT"
+"$TS_CMD_ENOSYS" -s ioctl $FALLOCATE_TEST > /dev/null 2>> "$TS_OUTPUT"
+"$TS_CMD_ENOSYS" -i FIOCLEX $FALLOCATE_TEST > /dev/null 2>> "$TS_OUTPUT"
+"$TS_CMD_ENOSYS" -i "$("$TS_CMD_ENOSYS" -m | grep FIOCLEX | awk '{ print $1 }')" $FALLOCATE_TEST > /dev/null 2>> "$TS_OUTPUT"
+"$TS_CMD_ENOSYS" -s ioctl -i FIOCLEX $FALLOCATE_TEST > /dev/null 2>> "$TS_OUTPUT"
+
+ts_finalize_subtest
+
+ts_finalize
diff --git a/tests/ts/misc/lsclocks b/tests/ts/misc/lsclocks
new file mode 100755
index 0000000..71fefaa
--- /dev/null
+++ b/tests/ts/misc/lsclocks
@@ -0,0 +1,70 @@
+#!/bin/bash
+
+# Copyright (C) 2023 Thomas Weißschuh <thomas@t-8ch.de>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="lsclocks"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_LSCLOCKS"
+ts_check_prog sed
+
+mask_timestamps() {
+ sed 's/[0-9]\+\.[0-9]\+/X.X/g'
+}
+
+NO_DISCOVER="--no-discover-dynamic --no-discover-rtc"
+
+ts_init_subtest basic
+
+"$TS_CMD_LSCLOCKS" $NO_DISCOVER -o TYPE,ID,CLOCK,NAME > "$TS_OUTPUT" 2>> "$TS_ERRLOG"
+
+ts_finalize_subtest
+
+ts_init_subtest time
+
+"$TS_CMD_LSCLOCKS" --time monotonic | mask_timestamps > "$TS_OUTPUT" 2>> "$TS_ERRLOG"
+
+ts_finalize_subtest
+
+ts_init_subtest dynamic
+
+if [ -c /dev/ptp0 ] && [ -r /dev/ptp0 ]; then
+ "$TS_CMD_LSCLOCKS" $NO_DISCOVER --dynamic-clock /dev/ptp0 --output TYPE,ID,CLOCK,NAME \
+ | tail -1 > "$TS_OUTPUT" 2>> "$TS_ERRLOG"
+ ts_finalize_subtest
+else
+ ts_skip_subtest "/dev/ptp0 not usable"
+fi
+
+ts_init_subtest rtc
+
+if [ -c /dev/rtc0 ] && [ -r /dev/rtc0 ]; then
+ "$TS_CMD_LSCLOCKS" $NO_DISCOVER --rtc /dev/rtc0 --output TYPE,ID,CLOCK,NAME \
+ | tail -1 > "$TS_OUTPUT" 2>> "$TS_ERRLOG"
+ ts_finalize_subtest
+else
+ ts_skip_subtest "/dev/rtc0 not usable"
+fi
+
+ts_init_subtest cpu
+
+"$TS_CMD_LSCLOCKS" --cpu 1 --output TYPE,ID,NAME | tail -1 > "$TS_OUTPUT" 2>> "$TS_ERRLOG"
+
+ts_finalize_subtest
+
+ts_finalize
diff --git a/tests/ts/misc/setpgid b/tests/ts/misc/setpgid
new file mode 100755
index 0000000..40c4754
--- /dev/null
+++ b/tests/ts/misc/setpgid
@@ -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="setpgid"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_SETPGID"
+
+$TS_CMD_SETPGID echo "success" >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+# qemu-user always reports '0' for the pgid field which prevents the test from
+# working so we skip it.
+ts_skip_qemu_user
+
+PGID1="$(awk '{print $5}' /proc/self/stat)"
+PGID2="$($TS_CMD_SETPGID awk '{print $5}' /proc/self/stat)"
+test ! "$PGID1" = "$PGID2" && echo "not equal" >> $TS_OUTPUT
+
+ts_finalize
diff --git a/tests/ts/misc/time_t b/tests/ts/misc/time_t
new file mode 100755
index 0000000..b0ced51
--- /dev/null
+++ b/tests/ts/misc/time_t
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+# Copyright (C) 2023 Thomas Weißschuh <thomas@t-8ch.de>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="time_t size"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_HELPER_SYSINFO"
+[ -n "$UL_ALLOW_32BIT_TIME" ] && ts_skip "32bit time allowed"
+
+"$TS_HELPER_SYSINFO" 'sz(time_t)' >> "$TS_OUTPUT"
+
+ts_finalize
diff --git a/tests/ts/misc/waitpid b/tests/ts/misc/waitpid
index ae5ab6f..904222c 100755
--- a/tests/ts/misc/waitpid
+++ b/tests/ts/misc/waitpid
@@ -24,7 +24,7 @@ ts_check_test_command "$TS_CMD_WAITPID"
ts_init_subtest normal
-(sleep 0.2; echo 1 >> "$TS_OUTPUT") &
+(sleep 0.5; echo 1 >> "$TS_OUTPUT") &
BG1="$!"
(sleep 0.1; echo 2 >> "$TS_OUTPUT") &
@@ -44,7 +44,7 @@ echo $? >> "$TS_OUTPUT"
ts_finalize_subtest
ts_init_subtest exited
-"$TS_CMD_WAITPID" -e 2147483647 >> "$TS_OUTPUT" 2>> "$TS_ERRLOG"
+"$TS_CMD_WAITPID" -v -e 2147483647 >> "$TS_OUTPUT" 2>> "$TS_ERRLOG"
echo $? >> "$TS_ERRLOG"
ts_finalize_subtest
diff --git a/tests/ts/mkswap/mkswap b/tests/ts/mkswap/mkswap
index fa4856b..39b8723 100755
--- a/tests/ts/mkswap/mkswap
+++ b/tests/ts/mkswap/mkswap
@@ -27,6 +27,7 @@ ts_check_test_command "$TS_CMD_MKSWAP"
ts_check_test_command "$TS_HELPER_SYSINFO"
ts_check_prog "xz"
ts_check_prog "cmp"
+ts_check_prog "truncate"
UUID=4c08e1cd-3c82-46bf-a55b-0c3270d6dfeb
@@ -49,17 +50,54 @@ for PAGESIZE in 4096 8192; do
ts_init_subtest $name
rm -f "$outimg"
- truncate -s $(( PAGESIZE * 10 )) "$outimg" > $TS_ERRLOG 2>&1
+ truncate -s $(( PAGESIZE * 10 )) "$outimg" >> $TS_ERRLOG 2>&1
"$TS_CMD_MKSWAP" -q -L label -U "$UUID" -e "$ENDIANNESS" -p "$PAGESIZE" "$outimg" \
- > "$TS_OUTPUT" 2>/dev/null \
+ >> "$TS_OUTPUT" 2>/dev/null \
|| ts_log "mkswap failed"
xz -dc "$TS_SELF/${BYTE_ORDER}-${PAGESIZE}.img.xz" > "$origimg"
- cmp "$origimg" "$outimg" > "$TS_ERRLOG" 2>&1
+ cmp "$origimg" "$outimg" >> "$TS_ERRLOG" 2>&1
+
+ ts_finalize_subtest
+
+ ts_init_subtest "$name-file"
+
+ rm -f "$outimg"
+
+ "$TS_CMD_MKSWAP" -q -L label -U "$UUID" -e "$ENDIANNESS" -p "$PAGESIZE" -F -s $(( PAGESIZE * 10 )) "$outimg" \
+ >> "$TS_OUTPUT" 2>/dev/null \
+ || ts_log "mkswap failed"
+ xz -dc "$TS_SELF/${BYTE_ORDER}-${PAGESIZE}.img.xz" > "$origimg"
+
+ cmp "$origimg" "$outimg" >> "$TS_ERRLOG" 2>&1
ts_finalize_subtest
done
done
+ts_init_subtest offset
+
+offset=10000
+outimg="$TS_OUTDIR/offset.img"
+
+rm -f "$outimg"
+truncate -s $(( 4096 * 10 )) "$outimg" > $TS_ERRLOG 2>&1
+
+rm -f "$outimg.offset"
+truncate -s $(( 4096 * 10 + $offset )) "$outimg.offset" > $TS_ERRLOG 2>&1
+
+"$TS_CMD_MKSWAP" -q -U "$UUID" -p 4096 "$outimg" \
+ >> "$TS_OUTPUT" 2>/dev/null \
+ || ts_log "mkswap failed"
+
+"$TS_CMD_MKSWAP" -q -U "$UUID" -p 4096 -o "$offset" "$outimg.offset" \
+ >> "$TS_OUTPUT" 2>/dev/null \
+ || ts_log "mkswap -o failed"
+
+cmp -n "$offset" "$outimg.offset" /dev/zero >> "$TS_ERRLOG" 2>&1
+cmp "$outimg" "$outimg.offset" 0 "$offset" >> "$TS_ERRLOG" 2>&1
+
+ts_finalize_subtest
+
ts_finalize
diff --git a/tests/ts/mount/fallback b/tests/ts/mount/fallback
index e2a1de7..cbdf449 100755
--- a/tests/ts/mount/fallback
+++ b/tests/ts/mount/fallback
@@ -22,7 +22,7 @@ test_mount_fallback() {
mkdir -p "$MY_SOURCE"
mkdir -p "$TS_MOUNTPOINT"
- "$TS_HELPER_ENOSYS" $2 -- "$TS_CMD_MOUNT" --bind "$MY_SOURCE" "$TS_MOUNTPOINT" \
+ "$TS_CMD_ENOSYS" $2 -- "$TS_CMD_MOUNT" --bind "$MY_SOURCE" "$TS_MOUNTPOINT" \
>> "$TS_OUTPUT" 2>> "$TS_ERRLOG"
[ "$?" = "0" ] || ts_log "error: mount $TS_MOUNTPOINT"
@@ -49,7 +49,7 @@ mkdir -p "$MOUNTPOINT"
ts_init_subtest "later-fsopen"
-$TS_HELPER_ENOSYS -s fsopen -- "$TS_CMD_MOUNT" -t foo,bar,ext2 "$DEVICE" "$MOUNTPOINT" \
+$TS_CMD_ENOSYS -s fsopen -- "$TS_CMD_MOUNT" -t foo,bar,ext2 "$DEVICE" "$MOUNTPOINT" \
>> $TS_OUTPUT 2>> $TS_ERRLOG
ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
mkdir -p ${MOUNTPOINT}/subdir
@@ -58,7 +58,7 @@ ts_finalize_subtest
ts_init_subtest "subdir"
-$TS_HELPER_ENOSYS -s fsopen -s open_tree -- \
+$TS_CMD_ENOSYS -s fsopen -s open_tree -- \
"$TS_CMD_MOUNT" -o X-mount.subdir=subdir "$DEVICE" "$MOUNTPOINT" \
>> $TS_OUTPUT 2>> $TS_ERRLOG
ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
@@ -69,12 +69,12 @@ ts_finalize_subtest
ts_init_subtest "mount_setattr"
"$TS_CMD_MOUNT" "$DEVICE" "$MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG
ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
-$TS_HELPER_ENOSYS -s mount_setattr -- \
+$TS_CMD_ENOSYS -s mount_setattr -- \
"$TS_CMD_MOUNT" -o remount,ro "$MOUNTPOINT" \
>> $TS_OUTPUT 2>> $TS_ERRLOG
$TS_CMD_FINDMNT --kernel --mountpoint "$MOUNTPOINT" --options "ro" &> /dev/null
[ "$?" == "0" ] || ts_die "Cannot find read-only in $MOUNTPOINT in /proc/self/mountinfo"
-$TS_HELPER_ENOSYS -s mount_setattr -- \
+$TS_CMD_ENOSYS -s mount_setattr -- \
"$TS_CMD_MOUNT" --make-slave "$MOUNTPOINT" \
>> $TS_OUTPUT 2>> $TS_ERRLOG
$TS_CMD_FINDMNT -n --kernel --mountpoint "$MOUNTPOINT" -o PROPAGATION >> $TS_OUTPUT
diff --git a/tests/ts/mount/fslists b/tests/ts/mount/fslists
index 230186a..6ac72c3 100755
--- a/tests/ts/mount/fslists
+++ b/tests/ts/mount/fslists
@@ -61,7 +61,7 @@ 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_CMD_MOUNT -T "$TS_FSTAB" $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
diff --git a/tests/ts/mount/fstab-all b/tests/ts/mount/fstab-all
index 83e1b63..ad9a7d0 100755
--- a/tests/ts/mount/fstab-all
+++ b/tests/ts/mount/fstab-all
@@ -68,16 +68,15 @@ MOUNTPOINT=$TS_MOUNTPOINT
[ -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
+rm -rf "${TS_FSTAB}"
+echo "${TS_DEVICE}1 ${MOUNTPOINT}A ext2 rw,defaults 0 0" >> "${TS_FSTAB}"
+echo "${TS_DEVICE}2 ${MOUNTPOINT}B ext2 rw,defaults 0 0" >> "${TS_FSTAB}"
+echo "${TS_DEVICE}3 ${MOUNTPOINT}C ext2 ro,defaults 0 0" >> "${TS_FSTAB}"
+echo "${TS_DEVICE}4 ${MOUNTPOINT}D ext4 rw,defaults 0 0" >> "${TS_FSTAB}"
ts_init_subtest "basic"
-$TS_CMD_MOUNT --all --fstab $MY_FSTAB >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_MOUNT --all --fstab "${TS_FSTAB}" >> $TS_OUTPUT 2>> $TS_ERRLOG
[ $? == 0 ] || ts_log "mount failed"
udevadm settle
$TS_CMD_UMOUNT ${MOUNTPOINT}{A,B,C,D}
@@ -86,7 +85,7 @@ ts_finalize_subtest
ts_init_subtest "filter-type"
-$TS_CMD_MOUNT --all --fstab $MY_FSTAB -t ext4 >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_MOUNT --all --fstab "${TS_FSTAB}" -t ext4 >> $TS_OUTPUT 2>> $TS_ERRLOG
[ $? == 0 ] || ts_log "mount failed"
udevadm settle
$TS_CMD_UMOUNT ${MOUNTPOINT}D
@@ -95,7 +94,7 @@ ts_finalize_subtest
ts_init_subtest "filter-notype"
-$TS_CMD_MOUNT --all --fstab $MY_FSTAB -t noext4 >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_MOUNT --all --fstab "${TS_FSTAB}" -t noext4 >> $TS_OUTPUT 2>> $TS_ERRLOG
[ $? == 0 ] || ts_log "mount failed"
udevadm settle
$TS_CMD_UMOUNT ${MOUNTPOINT}{A,B,C}
@@ -104,7 +103,7 @@ ts_finalize_subtest
ts_init_subtest "filter-option"
-$TS_CMD_MOUNT --all --fstab $MY_FSTAB -O ro >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_MOUNT --all --fstab "${TS_FSTAB}" -O ro >> $TS_OUTPUT 2>> $TS_ERRLOG
[ $? == 0 ] || ts_log "mount failed"
udevadm settle
$TS_CMD_UMOUNT ${MOUNTPOINT}C
@@ -113,7 +112,7 @@ ts_finalize_subtest
ts_init_subtest "override-option"
-$TS_CMD_MOUNT --all --fstab $MY_FSTAB -o ro >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_MOUNT --all --fstab "${TS_FSTAB}" -o ro >> $TS_OUTPUT 2>> $TS_ERRLOG
[ $? == 0 ] || ts_log "mount failed"
udevadm settle
$TS_CMD_UMOUNT ${MOUNTPOINT}{A,B,C,D}
@@ -123,7 +122,7 @@ ts_finalize_subtest
ts_init_subtest "relative-path"
cd "$TS_OUTDIR" > /dev/null
-$TS_CMD_MOUNT --all --fstab $(basename "$MY_FSTAB") >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_MOUNT --all --fstab $(basename "${TS_FSTAB}") >> $TS_OUTPUT 2>> $TS_ERRLOG
[ $? == 0 ] || ts_log "mount failed"
udevadm settle
$TS_CMD_UMOUNT ${MOUNTPOINT}{A,B,C,D}
@@ -135,16 +134,14 @@ 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
+rm -rf "${TS_FSTAB}"
+echo "${TS_DEVICE}1 /foo/A ext2 rw,defaults 0 0" >> "${TS_FSTAB}"
+echo "${TS_DEVICE}2 /foo/B ext2 rw,defaults 0 0" >> "${TS_FSTAB}"
+echo "${TS_DEVICE}3 /foo/C ext2 rw,defaults 0 0" >> "${TS_FSTAB}"
+echo "${TS_DEVICE}4 /foo/D ext4 rw,defaults 0 0" >> "${TS_FSTAB}"
# mount all to prefix
$TS_CMD_MOUNT --all \
- --fstab $MY_FSTAB \
+ --fstab "${TS_FSTAB}" \
--target-prefix $MY_ROOT \
-o X-mount.mkdir >> $TS_OUTPUT 2>> $TS_ERRLOG
[ $? == 0 ] || ts_log "mount failed"
diff --git a/tests/ts/mount/fstab-bind b/tests/ts/mount/fstab-bind
index 2c799df..cae016d 100755
--- a/tests/ts/mount/fstab-bind
+++ b/tests/ts/mount/fstab-bind
@@ -20,7 +20,7 @@ ts_fstab_add $MY_SOURCE "$TS_MOUNTPOINT" "none" "bind,default,noauto"
mkdir -p $MY_SOURCE
mkdir -p $TS_MOUNTPOINT
-$TS_CMD_MOUNT $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_MOUNT -T "$TS_FSTAB" $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
[ "$?" = "0" ] || ts_log "error: mount $TS_MOUNTPOINT"
$TS_CMD_FINDMNT --mountpoint "$TS_MOUNTPOINT" &> /dev/null
diff --git a/tests/ts/mount/fstab-broken b/tests/ts/mount/fstab-broken
index 19edc5f..ec4c342 100755
--- a/tests/ts/mount/fstab-broken
+++ b/tests/ts/mount/fstab-broken
@@ -34,11 +34,11 @@ mkdir -p $MNT
ts_fstab_lock
ts_fstab_open
-echo "tmpd $MNT tmpfs" >> /etc/fstab
+echo "tmpd $MNT tmpfs" >> "$TS_FSTAB"
ts_fstab_close
ts_init_subtest "mount"
-$TS_CMD_MOUNT $MNT &> /dev/null
+$TS_CMD_MOUNT -T "$TS_FSTAB" $MNT &> /dev/null
[ "$?" = "0" ] || ts_log "error: mount $MNT"
$TS_CMD_FINDMNT --kernel --mountpoint "$MNT" &> /dev/null
if [ "$?" != "0" ]; then
@@ -57,7 +57,7 @@ ts_finalize_subtest
ts_init_subtest "mount-all"
-$TS_CMD_MOUNT -a &> /dev/null
+$TS_CMD_MOUNT -T "$TS_FSTAB" -a &> /dev/null
[ "$?" = "0" ] || ts_log "error: mount -a"
$TS_CMD_FINDMNT --kernel --mountpoint "$MNT" &> /dev/null
if [ "$?" != "0" ]; then
diff --git a/tests/ts/mount/fstab-btrfs b/tests/ts/mount/fstab-btrfs
index a1003ab..8e76dbb 100755
--- a/tests/ts/mount/fstab-btrfs
+++ b/tests/ts/mount/fstab-btrfs
@@ -94,8 +94,8 @@ ts_fstab_addline "$DEVICE" "$TS_MOUNTPOINT_SUBVOLID" "btrfs" "subvolid=$NON_DEFA
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_MOUNT -T "$TS_FSTAB" -a >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_MOUNT -T "$TS_FSTAB" -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
@@ -124,8 +124,8 @@ ts_fstab_addline "$DEVICE" "$TS_MOUNTPOINT_SUBVOLID" "auto" "subvolid=$NON_DEFAU
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_MOUNT -T "$TS_FSTAB" -a >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_MOUNT -T "$TS_FSTAB" -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
diff --git a/tests/ts/mount/fstab-devname b/tests/ts/mount/fstab-devname
index 5b64a32..6ac03b5 100755
--- a/tests/ts/mount/fstab-devname
+++ b/tests/ts/mount/fstab-devname
@@ -42,13 +42,13 @@ MOUNTPOINT=$TS_MOUNTPOINT
ts_fstab_add $DEVICE
ts_init_subtest "mountpoint"
-$TS_CMD_MOUNT $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_MOUNT -T "$TS_FSTAB" $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_CMD_MOUNT -T "$TS_FSTAB" $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
diff --git a/tests/ts/mount/fstab-devname2label b/tests/ts/mount/fstab-devname2label
index 1d85621..44066e1 100755
--- a/tests/ts/mount/fstab-devname2label
+++ b/tests/ts/mount/fstab-devname2label
@@ -41,7 +41,7 @@ ts_device_has "LABEL" $LABEL $DEVICE \
ts_fstab_add "LABEL=$LABEL"
ts_udevadm_settle "$DEVICE" "LABEL"
-$TS_CMD_MOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_MOUNT -T "$TS_FSTAB" $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"
diff --git a/tests/ts/mount/fstab-devname2uuid b/tests/ts/mount/fstab-devname2uuid
index 8105fa0..5039591 100755
--- a/tests/ts/mount/fstab-devname2uuid
+++ b/tests/ts/mount/fstab-devname2uuid
@@ -39,7 +39,7 @@ UUID=$(ts_uuid_by_devname "$DEVICE") || ts_die "Cannot find UUID on $DEVICE"
ts_fstab_add "UUID=$UUID"
ts_udevadm_settle "$DEVICE" "UUID"
-$TS_CMD_MOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_MOUNT -T "$TS_FSTAB" $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"
diff --git a/tests/ts/mount/fstab-label b/tests/ts/mount/fstab-label
index 4b23e7f..a3cc06d 100755
--- a/tests/ts/mount/fstab-label
+++ b/tests/ts/mount/fstab-label
@@ -42,19 +42,19 @@ 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_CMD_MOUNT -T "$TS_FSTAB" $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_CMD_MOUNT -T "$TS_FSTAB" -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_CMD_MOUNT -T "$TS_FSTAB" 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
diff --git a/tests/ts/mount/fstab-label2devname b/tests/ts/mount/fstab-label2devname
index 75ca05e..fddbfa0 100755
--- a/tests/ts/mount/fstab-label2devname
+++ b/tests/ts/mount/fstab-label2devname
@@ -44,13 +44,13 @@ ts_udevadm_settle "$DEVICE" "LABEL"
[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
ts_init_subtest "L-option"
-$TS_CMD_MOUNT -L $LABEL >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_MOUNT -T "$TS_FSTAB" -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_CMD_MOUNT -T "$TS_FSTAB" "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
diff --git a/tests/ts/mount/fstab-label2uuid b/tests/ts/mount/fstab-label2uuid
index 4bfcae4..927cde9 100755
--- a/tests/ts/mount/fstab-label2uuid
+++ b/tests/ts/mount/fstab-label2uuid
@@ -46,13 +46,13 @@ ts_udevadm_settle "$DEVICE" "LABEL" "UUID"
[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
ts_init_subtest "L-option"
-$TS_CMD_MOUNT -L $LABEL >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_MOUNT -T "$TS_FSTAB" -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_CMD_MOUNT -T "$TS_FSTAB" "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
diff --git a/tests/ts/mount/fstab-loop b/tests/ts/mount/fstab-loop
index 7cc589f..0541e3a 100755
--- a/tests/ts/mount/fstab-loop
+++ b/tests/ts/mount/fstab-loop
@@ -39,10 +39,10 @@ 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_CMD_MOUNT -T "$TS_FSTAB" -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_CMD_MOUNT -T "$TS_FSTAB" -a >> $TS_OUTPUT 2>> $TS_ERRLOG
ts_fstab_close
diff --git a/tests/ts/mount/fstab-none b/tests/ts/mount/fstab-none
index 6a4d05b..95daa6c 100755
--- a/tests/ts/mount/fstab-none
+++ b/tests/ts/mount/fstab-none
@@ -17,7 +17,7 @@ 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
+$TS_CMD_MOUNT -T "$TS_FSTAB" $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
[ "$?" = "0" ] || ts_log "error: mount $TS_MOUNTPOINT"
$TS_CMD_FINDMNT --mountpoint "$TS_MOUNTPOINT" &> /dev/null
diff --git a/tests/ts/mount/fstab-symlink b/tests/ts/mount/fstab-symlink
index 4d3e37b..6d419f9 100755
--- a/tests/ts/mount/fstab-symlink
+++ b/tests/ts/mount/fstab-symlink
@@ -46,7 +46,7 @@ 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_CMD_MOUNT -T "$TS_FSTAB" $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"
diff --git a/tests/ts/mount/fstab-uuid b/tests/ts/mount/fstab-uuid
index 03917b7..f51bb29 100755
--- a/tests/ts/mount/fstab-uuid
+++ b/tests/ts/mount/fstab-uuid
@@ -42,19 +42,19 @@ 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_CMD_MOUNT -T "$TS_FSTAB" $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_CMD_MOUNT -T "$TS_FSTAB" -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_CMD_MOUNT -T "$TS_FSTAB" 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
diff --git a/tests/ts/mount/fstab-uuid2devname b/tests/ts/mount/fstab-uuid2devname
index 9bf165e..2b338ac 100755
--- a/tests/ts/mount/fstab-uuid2devname
+++ b/tests/ts/mount/fstab-uuid2devname
@@ -42,13 +42,13 @@ ts_udevadm_settle "$DEVICE" "UUID"
[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
ts_init_subtest "U-option"
-$TS_CMD_MOUNT -U $UUID >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_MOUNT -T "$TS_FSTAB" -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_CMD_MOUNT -T "$TS_FSTAB" "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
diff --git a/tests/ts/mount/fstab-uuid2label b/tests/ts/mount/fstab-uuid2label
index de10ff0..02eb6b9 100755
--- a/tests/ts/mount/fstab-uuid2label
+++ b/tests/ts/mount/fstab-uuid2label
@@ -45,13 +45,13 @@ ts_udevadm_settle "$DEVICE" "LABEL" "UUID"
[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
ts_init_subtest "U-option"
-$TS_CMD_MOUNT -U $UUID >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_MOUNT -T "$TS_FSTAB" -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_CMD_MOUNT -T "$TS_FSTAB" "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
diff --git a/tests/ts/mount/special b/tests/ts/mount/special
index 359d8aa..1771f5a 100755
--- a/tests/ts/mount/special
+++ b/tests/ts/mount/special
@@ -23,6 +23,7 @@ MOUNTER="/sbin/mount.mytest"
ts_init "$*"
ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
ts_skip_nonroot
@@ -55,7 +56,45 @@ ts_init_subtest "username"
$TS_CMD_MOUNT -t mytest -ouser=name,abc /foo /bar &> $TS_OUTPUT
ts_finalize_subtest
-rm -f $MOUNTER
-ts_finalize
+ts_init_subtest "missing-options"
+grep -q 'nodev[[:space:]]*tmpfs' /proc/filesystems
+if [ "$?" == "0" ]; then
+cat > $MOUNTER <<EOF
+#!/bin/bash
+# This util-linux regression test component
+# It's safe to remove me...
+#
+exec $TS_CMD_MOUNT -t tmpfs -i "\$1" "\$2" -o x-foo=123
+EOF
+ chmod +x $MOUNTER
+
+ mountpoint="$TS_OUTDIR/mnt"
+ mkdir -p "$mountpoint"
+ export LIBMOUNT_UTAB=$TS_OUTDIR/utab
+ rm -f $LIBMOUNT_UTAB
+ echo -n "" > $LIBMOUNT_UTAB
+
+ $TS_CMD_MOUNT -t mytest -o x-bar=BAR /foo "$mountpoint" &> $TS_OUTPUT
+ udevadm settle
+
+ grep -q "$mountpoint" /proc/mounts
+ if [ "$?" == "0" ]; then
+ cat "$LIBMOUNT_UTAB" \
+ | grep "$mountpoint" \
+ | sed -e "s|$mountpoint|/mountpoint|g" \
+ -e 's/ID=[[:digit:]]* //g' \
+ &> $TS_OUTPUT
+ $TS_CMD_UMOUNT "$mountpoint"
+ unset LIBMOUNT_UTAB
+ rm -f $MOUNTER
+ ts_finalize_subtest
+ else
+ ts_skip_subtest "tmpfs not mounted"
+ fi
+else
+ ts_skip_subtest "tmpfs unsupported"
+fi
+
+ts_finalize
diff --git a/tests/ts/mount/umount-recursive b/tests/ts/mount/umount-recursive
index 8b1fd47..94e3680 100755
--- a/tests/ts/mount/umount-recursive
+++ b/tests/ts/mount/umount-recursive
@@ -86,7 +86,7 @@ $TS_CMD_MOUNT ${TS_DEVICE}4 $TS_MOUNTPOINT/mntB/mntD >> $TS_OUTPUT 2>> $TS_ERRLO
ts_log "E) Mount child-bind"
mkdir -p $TS_MOUNTPOINT/bindC
-$TS_CMD_MOUNT --bind $TS_MOUNTPOINT/mntB/mntC $TS_MOUNTPOINT/bindC &> /dev/nul
+$TS_CMD_MOUNT --bind $TS_MOUNTPOINT/mntB/mntC $TS_MOUNTPOINT/bindC &> /dev/null
ts_log "F) Mount mountpoint-bind"
$TS_CMD_MOUNT --bind $TS_MOUNTPOINT $TS_MOUNTPOINT &> /dev/null
diff --git a/tests/ts/rename/basic b/tests/ts/rename/basic
index 786b092..28d1a57 100755
--- a/tests/ts/rename/basic
+++ b/tests/ts/rename/basic
@@ -72,4 +72,8 @@ touch rename_all_empty
$TS_CMD_RENAME -v -a '' _ rename_all_empty >> $TS_OUTPUT 2>> $TS_ERRLOG
rm -f _r_e_n_a_m_e___a_l_l___e_m_p_t_y_
+mkdir rename_dir
+$TS_CMD_RENAME -v dir new_dir rename_dir/ >> $TS_OUTPUT 2>> $TS_ERRLOG
+rmdir rename_new_dir
+
ts_finalize
diff --git a/tests/ts/schedutils/chrt b/tests/ts/schedutils/chrt
index aca735f..fd5f7af 100755
--- a/tests/ts/schedutils/chrt
+++ b/tests/ts/schedutils/chrt
@@ -21,9 +21,8 @@ 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"
+ts_skip_docker
+ts_skip_qemu_user
function do_chrt {
$TS_CMD_CHRT $* $TS_CMD_CHRT --pid 0 | sed 's/.* policy: //; s/.* priority: //' >> $TS_OUTPUT 2>> $TS_ERRLOG
@@ -93,9 +92,9 @@ 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
+ do_chrt --deadline --sched-period 130000 0
+ do_chrt --deadline --sched-period 130000 --sched-deadline 120000 0
+ do_chrt --deadline --sched-period 130000 --sched-deadline 120000 --sched-runtime 100000 0
cleanup_output
ts_finalize_subtest
fi
diff --git a/tests/ts/setpriv/landlock b/tests/ts/setpriv/landlock
new file mode 100755
index 0000000..d4ce5d1
--- /dev/null
+++ b/tests/ts/setpriv/landlock
@@ -0,0 +1,64 @@
+#!/bin/bash
+
+# Copyright (C) 2023 Thomas Weißschuh <thomas@t-8ch.de>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="setpriv landlock"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+[[ "$COVERAGE" = yes ]] && ts_skip "does not work with coverage"
+
+ts_check_test_command "$TS_CMD_SETPRIV"
+
+"$TS_CMD_SETPRIV" --landlock-access fs \
+ --landlock-rule path-beneath:execute:/ \
+ --landlock-rule path-beneath:read-file:/ \
+ true \
+ || ts_skip "no landlock support in setpriv"
+
+ts_init_subtest "nothing-allowed"
+"$TS_CMD_SETPRIV" --landlock-access fs true &> "$TS_OUTPUT"
+ts_finalize_subtest
+
+ts_init_subtest "partial-access-fail"
+"$TS_CMD_SETPRIV" --landlock-access \
+ fs:write cp /dev/null /dev/zero \
+ &> "$TS_OUTPUT"
+ts_finalize_subtest
+
+ts_init_subtest "partial-access-success"
+"$TS_CMD_SETPRIV" \
+ --landlock-access fs:write --landlock-rule path-beneath:write:/dev/zero \
+ cp /dev/null /dev/zero \
+ &> "$TS_OUTPUT"
+ts_finalize_subtest
+
+ts_init_subtest "combined-access"
+"$TS_CMD_SETPRIV" --landlock-access fs:execute,read-file \
+ --landlock-rule path-beneath:execute,read-file:/ \
+ true \
+ &> "$TS_OUTPUT"
+ts_finalize_subtest
+
+ts_init_subtest "wildcard-access"
+"$TS_CMD_SETPRIV" --landlock-access fs \
+ --landlock-rule path-beneath::/ \
+ true \
+ &> "$TS_OUTPUT"
+ts_finalize_subtest
+
+ts_finalize
diff --git a/tests/ts/swapon/devname b/tests/ts/swapon/devname
index d62b9d9..f4f9c16 100755
--- a/tests/ts/swapon/devname
+++ b/tests/ts/swapon/devname
@@ -36,11 +36,11 @@ $TS_CMD_MKSWAP $DEVICE > /dev/null 2>> $TS_OUTPUT \
ts_device_has "TYPE" "swap" $DEVICE || ts_die "Cannot find swap on $DEVICE"
-$TS_CMD_SWAPON $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_SWAPON $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG || ts_die "Swapon failed"
grep -q "^$DEVICE\b" /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps"
-$TS_CMD_SWAPOFF $DEVICE
+$TS_CMD_SWAPOFF $DEVICE || ts_die "Swapoff failed"
# swapon/mkswap warns if system sets different permissions for loop devices
sed --in-place '/insecure permissions .*, 0660 suggested/d' $TS_OUTPUT
diff --git a/tests/ts/wipefs/images/bcachefs.img.xz b/tests/ts/wipefs/images/bcachefs.img.xz
new file mode 100644
index 0000000..2c74b96
--- /dev/null
+++ b/tests/ts/wipefs/images/bcachefs.img.xz
Binary files differ
diff --git a/tests/ts/wipefs/signatures b/tests/ts/wipefs/signatures
new file mode 100755
index 0000000..7749588
--- /dev/null
+++ b/tests/ts/wipefs/signatures
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2023 Thomas Weißschuh <thomas@t-8ch.de>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="signatures"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_WIPEFS"
+ts_check_prog "xz"
+
+mkdir -p "${TS_OUTDIR}/images"
+
+for img in $(ls "${TS_SELF}"/images/*.img.xz | sort); do
+ name="$(basename "$img" .img.xz)"
+ outimg="${TS_OUTDIR}/images/${name}.img"
+
+ xz -dc "$img" > "$outimg"
+
+ ts_init_subtest "$name"
+ "$TS_CMD_WIPEFS" --parsable --no-act "$outimg" 2> "$TS_ERRLOG" > "$TS_OUTPUT"
+ ts_finalize_subtest
+done
+
+ts_finalize
diff --git a/tests/ts/wipefs/wipefs b/tests/ts/wipefs/wipefs
index c79be0c..0f0f8d8 100755
--- a/tests/ts/wipefs/wipefs
+++ b/tests/ts/wipefs/wipefs
@@ -7,25 +7,27 @@ TS_DESC="wipefs"
ts_init "$*"
ts_check_test_command "$TS_CMD_WIPEFS"
+ts_check_test_command "$TS_CMD_MKMINIX"
-ts_skip_nonroot
+img="$(ts_image_init 50)"
+backups="$TS_OUTDIR/backups"
-# set global variable TS_DEVICE
-ts_scsi_debug_init dev_size_mb=50 num_parts=2
+"$TS_CMD_MKMINIX" "$img" &>/dev/null
# remove old backups
-rm -rf $HOME/wipefs-$(basename ${TS_DEVICE})-*.bak
+rm -rf "$backups"
+mkdir -p "$backups"
#remove the magic byte, back it up
-$TS_CMD_WIPEFS --all --backup ${TS_DEVICE} &>/dev/null || ts_die "wipefs failed"
+$TS_CMD_WIPEFS --all --backup="${backups}" ${img} &>/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)
+INFILE=$(ls $backups/wipefs-$(basename ${img})-*.bak)
OFFT=$(echo $INFILE | sed 's/^.*-\(.*\).bak$/\1/')
-dd if=$INFILE of=$TS_DEVICE bs=1 conv=notrunc seek=$(($OFFT)) &>/dev/null
+dd if=$INFILE of=$img 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
+$TS_CMD_WIPEFS -a ${img} > $TS_OUTDIR/out 2>/dev/null
# check for output
[ -s $TS_OUTDIR/out ] && echo "OK" &> $TS_OUTPUT || exit 1