summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-14 19:23:00 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-14 19:23:00 +0000
commit803b3a091c225d48395508a8f9ffa6e08cbddc5b (patch)
treea3168c9e7da8991c423b5978aacf90c3c2b135c1 /tests
parentReleasing progress-linux version 2.40-8~progress7.99u1. (diff)
downloadutil-linux-803b3a091c225d48395508a8f9ffa6e08cbddc5b.tar.xz
util-linux-803b3a091c225d48395508a8f9ffa6e08cbddc5b.zip
Merging upstream version 2.40.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/expected/findmnt/df-options4
-rw-r--r--tests/expected/lsns/ioctl_ns.err0
-rw-r--r--tests/helpers/test_mkfds.c29
-rwxr-xr-xtests/ts/findmnt/df-options62
-rwxr-xr-xtests/ts/lsfd/mkfds-multiplexing16
-rwxr-xr-xtests/ts/lslocks/lslocks11
-rwxr-xr-xtests/ts/lsns/ioctl_ns6
7 files changed, 115 insertions, 13 deletions
diff --git a/tests/expected/findmnt/df-options b/tests/expected/findmnt/df-options
new file mode 100644
index 0000000..3f0f509
--- /dev/null
+++ b/tests/expected/findmnt/df-options
@@ -0,0 +1,4 @@
+-D: OK
+-I: OK
+--df: OK
+--dfi: OK
diff --git a/tests/expected/lsns/ioctl_ns.err b/tests/expected/lsns/ioctl_ns.err
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/expected/lsns/ioctl_ns.err
diff --git a/tests/helpers/test_mkfds.c b/tests/helpers/test_mkfds.c
index 39427ba..4b138c2 100644
--- a/tests/helpers/test_mkfds.c
+++ b/tests/helpers/test_mkfds.c
@@ -3200,6 +3200,25 @@ static int send_diag_request(int diagsd, void *req, size_t req_size)
return 0;
}
+static int recv_diag_request(int diagsd)
+{
+ __attribute__((aligned(sizeof(void *)))) uint8_t buf[8192];
+ const struct nlmsghdr *h;
+ int r = recvfrom(diagsd, buf, sizeof(buf), 0, NULL, NULL);;
+ if (r < 0)
+ return errno;
+
+ h = (void *)buf;
+ if (!NLMSG_OK(h, (size_t)r))
+ return -1;
+
+ if (h->nlmsg_type == NLMSG_ERROR) {
+ struct nlmsgerr *e = (struct nlmsgerr *)NLMSG_DATA(h);
+ return - e->error;
+ }
+ return 0;
+}
+
static void *make_sockdiag(const struct factory *factory, struct fdesc fdescs[],
int argc, char ** argv)
{
@@ -3243,6 +3262,16 @@ static void *make_sockdiag(const struct factory *factory, struct fdesc fdescs[],
err(EXIT_FAILURE, "failed in sendmsg()");
}
+ e = recv_diag_request(diagsd);
+ if (e != 0) {
+ close (diagsd);
+ if (e == ENOENT)
+ err(EXIT_ENOENT, "failed in recvfrom()");
+ if (e > 0)
+ err(EXIT_FAILURE, "failed in recvfrom()");
+ if (e < 0)
+ errx(EXIT_FAILURE, "failed in recvfrom() => -1");
+ }
if (diagsd != fdescs[0].fd) {
if (dup2(diagsd, fdescs[0].fd) < 0) {
diff --git a/tests/ts/findmnt/df-options b/tests/ts/findmnt/df-options
new file mode 100755
index 0000000..58208b9
--- /dev/null
+++ b/tests/ts/findmnt/df-options
@@ -0,0 +1,62 @@
+#!/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="the columns enabled with -D and -I options"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_FINDMNT"
+ts_check_prog "head"
+
+ts_cd "$TS_OUTDIR"
+
+D_expectation="SOURCE FSTYPE SIZE USED AVAIL USE% TARGET"
+I_expectation="SOURCE FSTYPE INO.TOTAL INO.USED INO.AVAIL INO.USE% TARGET"
+{
+ if [[ $($TS_CMD_FINDMNT --raw -D | head -1) == "$D_expectation" ]]; then
+ echo "-D: OK"
+ else
+ echo "-D: ERROR"
+ $TS_CMD_FINDMNT --raw -D
+ echo $?
+ fi
+
+ if [[ $($TS_CMD_FINDMNT --raw -I | head -1) == "$I_expectation" ]]; then
+ echo "-I: OK"
+ else
+ echo "-I: ERROR"
+ $TS_CMD_FINDMNT --raw -I
+ echo $?
+ fi
+
+ if [[ $($TS_CMD_FINDMNT --raw --df | head -1) == "$D_expectation" ]]; then
+ echo "--df: OK"
+ else
+ echo "--df: ERROR"
+ $TS_CMD_FINDMNT --raw --df
+ echo $?
+ fi
+
+ if [[ $($TS_CMD_FINDMNT --raw --dfi | head -1) == "$I_expectation" ]]; then
+ echo "--dfi: OK"
+ else
+ echo "--dfi: ERROR"
+ $TS_CMD_FINDMNT --raw --dfi
+ echo $?
+ fi
+} >> "$TS_OUTPUT" 2>> "$TS_ERRLOG"
+
+ts_finalize
diff --git a/tests/ts/lsfd/mkfds-multiplexing b/tests/ts/lsfd/mkfds-multiplexing
index 8cc7f31..a53f6eb 100755
--- a/tests/ts/lsfd/mkfds-multiplexing
+++ b/tests/ts/lsfd/mkfds-multiplexing
@@ -26,6 +26,8 @@ ts_check_test_command "$TS_HELPER_MKFDS"
# /proc/${PID}/syscall is rendered in the host side byteorder.
ts_skip_qemu_user
+ts_check_prog "cat"
+ts_check_prog "cut"
ts_check_prog "grep"
ts_cd "$TS_OUTDIR"
@@ -44,12 +46,24 @@ for multiplexer in pselect6 select poll ppoll; do
} > "$TS_OUTPUT" 2>&1
if read -r -u "${MKFDS[0]}" PID; then
- if ! cat /proc/"${PID}"/syscall > /dev/null 2>&1; then
+ syscall_line=$(cat /proc/"${PID}"/syscall 2>> "$TS_OUTPUT")
+ syscall_status=$?
+ if [[ "$syscall_status" != 0 ]]; then
kill -CONT "${PID}"
wait "${MKFDS_PID}"
ts_skip_subtest "cannot open /proc/${PID}/syscall"
continue
fi
+ syscall_n=$(cut -f1 -d' ' <<< "$syscall_line")
+ # We assume the syscall number for the $multiplexer is not zero
+ # on any platforms.
+ if [[ "$syscall_n" == 0 ]]; then
+ kill -CONT "${PID}"
+ wait "${MKFDS_PID}"
+ ts_skip_subtest "incorrect syscall number in /proc/${PID}/syscall"
+ continue
+ fi
+
{
"${TS_CMD_LSFD}" -n -o ASSOC,XMODE -p "${PID}" -Q '(FD >= 10) && (FD <= 22)'
echo "[$multiplexer] ASSOC,XMODE: $?"
diff --git a/tests/ts/lslocks/lslocks b/tests/ts/lslocks/lslocks
index 912fac8..a9ef69a 100755
--- a/tests/ts/lslocks/lslocks
+++ b/tests/ts/lslocks/lslocks
@@ -53,14 +53,6 @@ OFD_METHODS=(
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()
@@ -71,8 +63,6 @@ run_lslocks()
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#'
@@ -91,7 +81,6 @@ run_lslocks_with_co_holders()
{
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]}
diff --git a/tests/ts/lsns/ioctl_ns b/tests/ts/lsns/ioctl_ns
index 6f306d5..7ab192b 100755
--- a/tests/ts/lsns/ioctl_ns
+++ b/tests/ts/lsns/ioctl_ns
@@ -80,6 +80,8 @@ init
echo
echo userns expected: "$expected"
echo userns actual: "$actual"
+ echo "$TS_CMD_LSNS":
+ LSNS_DEBUG=all "$TS_CMD_LSNS"
cleanup
exit $RESULT
fi
@@ -92,10 +94,12 @@ init
echo
echo pidns expected: "$expected"
echo pidns actual: "$actual"
+ echo "$TS_CMD_LSNS":
+ LSNS_DEBUG=all "$TS_CMD_LSNS"
cleanup
fi
exit $RESULT
-) &
+) >> $TS_ERRLOG 2>&1 &
mainpid=$!
(
exec 4< $FIFO_WAIT