From: Florian Westphal <fw@strlen.de>
To: Yi Chen <yiche@redhat.com>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH] tests: shell: Add a test case to verify the limit statement.
Date: Thu, 19 Jun 2025 00:46:36 +0200 [thread overview]
Message-ID: <aFNBzJOssxBN-ck4@strlen.de> (raw)
In-Reply-To: <20250617104128.27188-1-yiche@redhat.com>
Yi Chen <yiche@redhat.com> wrote:
> Signed-off-by: Yi Chen <yiche@redhat.com>
> ---
> tests/shell/features/ncat.sh | 4 +
> tests/shell/testcases/packetpath/rate_limit | 154 ++++++++++++++++++++
> 2 files changed, 158 insertions(+)
> create mode 100755 tests/shell/features/ncat.sh
> create mode 100755 tests/shell/testcases/packetpath/rate_limit
>
> diff --git a/tests/shell/features/ncat.sh b/tests/shell/features/ncat.sh
> new file mode 100755
> index 00000000..eb1581ce
> --- /dev/null
> +++ b/tests/shell/features/ncat.sh
> @@ -0,0 +1,4 @@
> +#!/bin/sh
> +
> +# check whether ncat is installed
> +ncat -h >/dev/null 2>&1
Could you convert the test to use socat, which is already
used by many other tests?
> +assert_pass()
> +{
> + local ret=$?
> + if [ $ret != 0 ]; then
> + echo "FAIL: ${@}"
> + exit 1
> + else
> + echo "PASS: ${@}"
> + fi
> +}
This is now the 3rd copy of this helper.
Maybe its time to add a library/utility file that has these
functions?
test-wrapper.sh could export an environment variable pointing to it, e.g.
export NFT_TEST_LIBRARY_FILE="$NFT_TEST_BASEDIR/helpers/lib.sh"
or whatever. Then tests can do
. $NFT_TEST_LIBRARY_FILE
and gain these helpers in case they need them.
> +# tcp test
> +ip netns exec $S ncat -lk 80 > /dev/null & sleep 1
I guess sleep 1 is fine. But maybe its time to add a central
helper for this wait.
You could submit a patch that adds the helpers/lib.sh file and
then lifts the "wait_local_port_listen" helper function from
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/diff/tools/testing/selftests/net/lib.sh?id=d9d836bfa5e6e255c411733b4b1ce7a1f8346c54
Other than that I think the test looks good, thanks Yi!
next prev parent reply other threads:[~2025-06-18 22:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-17 10:41 [PATCH] tests: shell: Add a test case to verify the limit statement Yi Chen
2025-06-18 22:46 ` Florian Westphal [this message]
[not found] ` <CAJsUoE0etJbdwHsHFHDnY1CkdmAXLJy7PunwQg9Me4n-AMPWmQ@mail.gmail.com>
2025-06-20 9:31 ` Florian Westphal
[not found] ` <CAJsUoE1ZChx7VcbZLnBpwbbkhGmfVVzomHUu7GP8xQCs00gZrw@mail.gmail.com>
2025-06-20 12:30 ` Yi Chen
2025-06-20 16:40 ` [PATCH] tests: shell: Verify limit statement with new test case Yi Chen
2025-06-20 16:47 ` [PATCH v2] " Yi Chen
2025-06-21 11:37 ` Florian Westphal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aFNBzJOssxBN-ck4@strlen.de \
--to=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=yiche@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.