PID=
FD=3
EXPR="(FD == 3)"
+RC=
for C in pidfd inotify; do
+ RC=
ts_init_subtest $C
{
coproc MKFDS { "$TS_HELPER_MKFDS" $C $FD ; }
echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
+ RC=$?
} > "$TS_OUTPUT" 2>&1
- if [ "$C-$?" == "pidfd-$TS_EXIT_NOTSUPP" ]; then
+ if [ "$C-$RC" == "pidfd-$TS_EXIT_NOTSUPP" ]; then
ts_skip_subtest "pidfd_open(2) is not available"
continue
fi
PID=
FD=3
EXPR="(FD == 3)"
+RC=
make_state_connected()
{
}
for C in ro-regular-file pidfd socketpair; do
+ RC=
ts_init_subtest $C
{
coproc MKFDS {
fi
} > "$TS_OUTPUT" 2>&1
wait "${MKFDS_PID}"
+ RC=$?
- if [ "$C-$?" == "pidfd-$TS_EXIT_NOTSUPP" ]; then
+ if [ "$C-$RC" == "pidfd-$TS_EXIT_NOTSUPP" ]; then
ts_skip_subtest "pidfd_open(2) is not available"
continue
fi
PID=
FD=3
EXPR="(FD == 3)"
+RC=
for C in ro-regular-file pidfd inotify socketpair; do
+ RC=
ts_init_subtest $C
{
coproc MKFDS {
echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
+ RC=$?
} > "$TS_OUTPUT" 2>&1
- if [ "$C-$?" == "pidfd-$TS_EXIT_NOTSUPP" ]; then
+ if [ "$C-$RC" == "pidfd-$TS_EXIT_NOTSUPP" ]; then
ts_skip_subtest "pidfd_open(2) is not available"
continue
fi
wait "${MKFDS_PID}"
ts_finalize_subtest
+RC=
for m in flock-sh posix-r- ofd-r-; do
ts_init_subtest "XMODE-l-bit-$m"
{
fi
} > "$TS_OUTPUT" 2>&1
wait "${MKFDS_PID}"
- if [ "$?" == "$TS_EXIT_NOTSUPP" ]; then
+ RC=$?
+ if [ "$RC" == "$TS_EXIT_NOTSUPP" ]; then
ts_skip_subtest "$m lock is not available"
continue
fi
rm -f "$f"
ts_finalize_subtest
+RC=
for m in flock-ex posix--w posix-rw ofd--w ofd-rw lease-w; do
ts_init_subtest "XMODE-L-bit-$m"
{
fi
} > "$TS_OUTPUT" 2>&1
wait "${MKFDS_PID}"
- if [ "$?" == "$TS_EXIT_NOTSUPP" ]; then
+ RC=$?
+ if [ "$RC" == "$TS_EXIT_NOTSUPP" ]; then
ts_skip_subtest "$m lock is not available"
continue
fi
echo "pid in a range:" $?
if [[ "${PID_0}" == "${PID}" ]]; then
- echo "coparing pids": $?
+ echo "coparing pids": 0
else
- echo "coparing pids": $? "PID_0:${PID_0} == PID:${PID}"
+ echo "coparing pids": 1 "PID_0:${PID_0} == PID:${PID}"
fi
EXPR='(TIMERFD.INTERVAL < 10.000051) and (TIMERFD.INTERVAL > 10)'
PID=
FD=3
NAME=mkfds_map
+RC=
+
{
coproc MKFDS { "$TS_HELPER_MKFDS" bpf-map "$FD" map-type-id=2 name="$NAME"; }
if read -r -u "${MKFDS[0]}" PID; then
echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
+ RC=$?
} > "$TS_OUTPUT" 2>&1
-if [ "$?" == "$TS_EXIT_NOTSUPP" ]; then
+if [ "$RC" == "$TS_EXIT_NOTSUPP" ]; then
ts_skip "bpf(2) is not available"
fi
TAG=
FD=3
NAME=mkdfs_prog
+RC=
+
{
coproc MKFDS { "$TS_HELPER_MKFDS" bpf-prog "$FD" prog-type-id=2 name="$NAME"; }
if read -r -u "${MKFDS[0]}" PID ID TAG; then
echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
+ RC=$?
} > "$TS_OUTPUT" 2>&1
-if [ "$?" == "$TS_EXIT_NOTSUPP" ]; then
+if [ "$RC" == "$TS_EXIT_NOTSUPP" ]; then
ts_skip "bpf(2) is not available"
fi
output=$(${TS_CMD_LSFD} -p "${PID}" -n --raw -o NAME -Q "${EXPR}")
if [[ "$output" =~ "iface=$IFNAME"(\\x20devnetns=$netns)? ]]; then
- echo 'NAME': $?
+ echo 'NAME': 0
if [[ -n "${BASH_REMATCH[1]}" ]]; then
devnetns_available=yes
fi
else
- echo 'NAME': $?
+ echo 'NAME': 1
echo "expected NAME: iface=$IFNAME"
echo "output NAME: $output"
echo "netns: $netns"
output=$(${TS_CMD_LSFD} -p "${PID}" -n --raw -o TUN.IFACE -Q "${EXPR}")
if [[ "$output" == "$IFNAME" ]]; then
- echo 'TUN.IFACE': $?
+ echo 'TUN.IFACE': 0
else
- echo 'TUN.IFACE': $?
+ echo 'TUN.IFACE': 1
echo "expected TUN.IFACE: $IFNAME"
echo "output TUN.IFACE: $output"
fi
{
output=$(${TS_CMD_LSFD} -p "${PID}" -n --raw -o TUN.DEVNETNS -Q "${EXPR}")
if [[ "$output" == "$netns" ]]; then
- echo 'TUN.DEVNETNS': $?
+ echo 'TUN.DEVNETNS': 0
else
- echo 'TUN.DEVNETNS': $?
+ echo 'TUN.DEVNETNS': 1
echo "expected TUN.DEVNETNS: $netns"
echo "output TUN.DEVNETNS: $output"
fi
cat
fi
}
- echo 'ASSOC,MODE,TYPE,FLAGS,NAME': $?
+ echo 'ASSOC,MODE,TYPE,FLAGS,NAME': ${PIPESTATUS[0]}
LSFD_PID=$(${TS_CMD_LSFD} --raw -n -o PID -Q "${EXPR}")
echo 'PID[RUN]:' $?
echo 'child: ID': $?
if [ "${NAME0}" == "${NAME1}" ]; then
- echo 'NAME[STR]:' $?
+ echo 'NAME[STR]:' 0
else
- echo 'NAME[STR]:' $?
+ echo 'NAME[STR]:' 1
echo NAME0: "${NAME0}"
echo NAME1: "${NAME1}"
fi
if [ "${ID0}" == "${ID1}" ]; then
- echo 'ID[STR]:' $?
+ echo 'ID[STR]:' 0
else
- echo 'ID[STR]:' $?
+ echo 'ID[STR]:' 1
echo ID0: "${ID0}"
echo ID0: "${ID1}"
fi
if [ "${NAME0}" == "id=${ID1}" ]; then
- echo 'NAMExID[STR]:' $?
+ echo 'NAMExID[STR]:' 0
else
- echo 'NAMExID[STR]:' $?
+ echo 'NAMExID[STR]:' 1
echo NAME0: "${NAME0}"
echo ID0: "${ID0}"
fi
"$PID0" "$FD0" "$PID1" "$FD1" \
"$PID1" "$FD1" "$PID0" "$FD0")
if [ "$ENDPOINTS" == "$tmp" ]; then
- echo 'ENDPOINTS[STR]:' $?
+ echo 'ENDPOINTS[STR]:' 0
else
- echo 'ENDPOINTS[STR]:' $?
+ echo 'ENDPOINTS[STR]:' 1
echo 'ENDPOINTS:' "$ENDPOINTS"
echo 'lsfd:' "$tmp"
fi
NETNS=
FD0=3
FD1=4
+RC=
{
coproc MKFDS { "$TS_HELPER_MKFDS" foreign-sockets $FD0 $FD1 ; }
echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
+ RC=$?
} > "$TS_OUTPUT" 2>&1
-if [[ "$?" == "$EPERM" ]]; then
+if [[ "$RC" == "$EPERM" ]]; then
ts_skip "unshare(2) is not permitted on this platform"
fi
NETLINK_PROTOCOL=4
NETLINK_LPORT=
NETLINK_GROUPS=5
+RC=
{
coproc MKFDS { "$TS_HELPER_MKFDS" netlink $FD protocol=$NETLINK_PROTOCOL groups=$NETLINK_GROUPS; }
echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
+ RC=$?
} > "$TS_OUTPUT" 2>&1
-if [[ $? == "$EPROTONOSUPPORT" ]]; then
+if [[ $RC == "$EPROTONOSUPPORT" ]]; then
ts_skip "It seems that this platform doesn't support making a netlink socket"
fi
NETLINK_PROTOCOL=4
NETLINK_LPORT=
NETLINK_GROUPS=5
+RC=
{
coproc MKFDS { "$TS_HELPER_MKFDS" netlink $FD protocol=$NETLINK_PROTOCOL; }
echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
+ RC=$?
} > "$TS_OUTPUT" 2>&1
-if [[ $? == "$EPROTONOSUPPORT" ]]; then
+if [[ $RC == "$EPROTONOSUPPORT" ]]; then
ts_skip "It seems that this platform doesn't support making a netlink socket"
fi
NAME_NS=
INO_FD=
INO_NS=
+RC=
{
coproc MKFDS { "$TS_HELPER_MKFDS" netns "$FD"; }
if read -r -u "${MKFDS[0]}" PID; then
INO_NS=$( "${TS_CMD_LSFD}" -n -oINODE -p "${PID}" -Q '(ASSOC == "net")')
if [[ "$NAME_FD" = "$NAME_NS" ]]; then
- echo "NAME_FD" == "NAME_NS": $?
+ echo "NAME_FD" == "NAME_NS": 0
else
- echo "NAME_FD: $NAME_FD" == "NAME_NS: $NAME_NS": $?
+ echo "NAME_FD: $NAME_FD" == "NAME_NS: $NAME_NS": 1
fi
if [[ "$NAME_FD" = "net:[$INO_FD]" ]]; then
- echo "NAME_FD" == "net:[INO_FD]": $?
+ echo "NAME_FD" == "net:[INO_FD]": 0
else
- echo "NAME_FD: $NAME_FD" == "net:[INO_FD: $INO_FD]": $?
+ echo "NAME_FD: $NAME_FD" == "net:[INO_FD: $INO_FD]": 1
fi
if [[ "$NAME_FD" = "net:[$INO_NS]" ]]; then
- echo "NAME_FD" == "net:[INO_NS]": $?
+ echo "NAME_FD" == "net:[INO_NS]": 0
else
- echo "NAME_FD: $NAME_FD" == "net:[INO_NS: $INO_NS]": $?
+ echo "NAME_FD: $NAME_FD" == "net:[INO_NS: $INO_NS]": 1
fi
echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
+ RC=$?
} > "$TS_OUTPUT" 2>&1
-if [ "$?" == "$TS_EXIT_NOTSUPP" ]; then
+if [ "$RC" == "$TS_EXIT_NOTSUPP" ]; then
ts_skip "ioctl(fd, SIOCGSKNS) is not available"
fi
FD=3
TARGET=1
EXPR="(PID != ${TARGET}) and (FD == 3) and (PIDFD.PID == ${TARGET})"
+RC=
{
coproc MKFDS { "$TS_HELPER_MKFDS" pidfd $FD target-pid=${TARGET} ; }
echo DONE >&"${MKFDS[1]}"
fi
wait ${MKFDS_PID}
+ RC=$?
} > $TS_OUTPUT 2>&1
-if [ "$?" == "$TS_EXIT_NOTSUPP" ]; then
+if [ "$RC" == "$TS_EXIT_NOTSUPP" ]; then
ts_skip "pidfd_open(2) is not available"
fi
expected=$(printf '%s\n%s' "${line0}" "${line1}")
if [ "${LSFD_ENDPOINTS}" == "${expected}" ]; then
- echo 'ENDPOINTS[STR]:' $?
+ echo 'ENDPOINTS[STR]:' 0
else
echo "lsfd output:"
echo "${LSFD_ENDPOINTS}"
FDSOCK=5
EXPR='((TYPE == "UNIX") or (TYPE == "UNIX-STREAM")) and (FD == 5)'
+RC=
compare_net_namespaces()
{
}
for t in stream dgram seqpacket; do
+ RC=
ts_init_subtest "$t"
{
coproc MKFDS { "$TS_HELPER_MKFDS" unix-in-netns $FDSELFNS $FDALTNS $FDSOCK \
echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
+ RC=$?
} > "$TS_OUTPUT" 2>&1
- if [ "$?" == "$EPERM" ]; then
+ if [ "$RC" == "$EPERM" ]; then
ts_skip_subtest "unshare(2) is not permitted on this platform"
continue
fi