#!/bin/sh
#
# Check decoding of ip:port pairs associated with socket descriptors
#
# Copyright (c) 2014-2016 Dmitry V. Levin <ldv@strace.io>
# Copyright (c) 2016-2024 The strace developers.
# All rights reserved.
#
# SPDX-License-Identifier: GPL-2.0-or-later

. "${srcdir=.}/init.sh"

check_prog sed

run_prog ../netlink_inet_diag
run_prog > /dev/null
run_strace -a22 -yy -eclose,network $args > "$EXP"

# Filter out close() calls made by ld.so and libc.
#
# Filter out listen() call as we cannot easily predict the kernel
# behaviour because there is no easy way to tell whether the Linux kernel
# contains commit v6.8-rc1~131^2~223.
sed -n '/^listen/d;/^socket/,$p' < "$LOG" > "$OUT"
match_diff "$OUT" "$EXP"
