netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [nft PATCH v4 2/8] tests: py: Enable JSON and JSON schema by default
Date: Thu, 4 Sep 2025 20:33:50 +0200	[thread overview]
Message-ID: <aLnbjSgT5GuY0SHX@orbyte.nwl.cc> (raw)
In-Reply-To: <aLnEqJBm6tNK4IrQ@calendula>

On Thu, Sep 04, 2025 at 06:56:08PM +0200, Pablo Neira Ayuso wrote:
> On Thu, Sep 04, 2025 at 06:13:06PM +0200, Phil Sutter wrote:
> > On Thu, Sep 04, 2025 at 05:29:54PM +0200, Pablo Neira Ayuso wrote:
> > > On Thu, Sep 04, 2025 at 05:24:48PM +0200, Phil Sutter wrote:
> > > > Introduce -J/--disable-json and -S/--no-schema to explicitly disable
> > > > them if desired.
> > > > 
> > > > Signed-off-by: Phil Sutter <phil@nwl.cc>
> > > > ---
> > > >  tests/py/nft-test.py | 16 ++++++++++++----
> > > >  1 file changed, 12 insertions(+), 4 deletions(-)
> > > > 
> > > > diff --git a/tests/py/nft-test.py b/tests/py/nft-test.py
> > > > index 984f2b937a077..12c6174b01257 100755
> > > > --- a/tests/py/nft-test.py
> > > > +++ b/tests/py/nft-test.py
> > > > @@ -1488,7 +1488,11 @@ def set_delete_elements(set_element, set_name, table, filename=None,
> > > >  
> > > >      parser.add_argument('-j', '--enable-json', action='store_true',
> > > >                          dest='enable_json',
> > > > -                        help='test JSON functionality as well')
> > > > +                        help='test JSON functionality as well (default)')
> > > > +
> > > > +    parser.add_argument('-J', '--disable-json', action='store_true',
> > > > +                        dest='disable_json',
> > > > +                        help='Do not test JSON functionality as well')
> > > 
> > > Would it be possible to have common options to the different tests?
> > > 
> > > 1/8 uses -s and -j.
> > > 
> > > I am not sure we have to worry about breaking backward for test
> > > syntax, we only run this.
> > 
> > It's a bit of a mess with nft-test.py as it always performs standard
> > syntax testing and JSON syntax is an add-on one may enable (or not). So
> > to test JSON only, I'd have to refactor the ~300 lines long rule_add()
> > function. Not the worst thing to do, but much more work than "just"
> > having --enable-json being the default.
> 
> Oh, I see, so this is:
> 
> * no -j, then only standard is tested.
> * -j, both standard and json are tested.
> 
> Maybe more simple is to reverse this logic, ie.
> 
> * no -j, then both standard and json syntax are tested.
> * -s, only standard is tested.

So basically rename -J to -s in my patch? ;)
Note that -s clashes with --schema (although one could drop it as my
patch enables it by default, as well).

> Does this help?

Let me suggest an alternative: I promise to refactor that famous italian
pasta style function into smaller chunks like:

- Gather test data from files
- Instantiate a rule object with methods:
  - apply()
  - json_apply()
  - validate_payload()
  - validate_listing()
- Perform checks as per user choice (-j, -s, both/none)

And we live with the inconsistent UI for now?

Cheers, Phil

  reply	other threads:[~2025-09-04 18:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-04 15:24 [nft PATCH v4 0/8] Run all test suites via 'make check' Phil Sutter
2025-09-04 15:24 ` [nft PATCH v4 1/8] tests: monitor: Excercise all syntaxes and variants by default Phil Sutter
2025-09-04 15:24 ` [nft PATCH v4 2/8] tests: py: Enable JSON and JSON schema " Phil Sutter
2025-09-04 15:29   ` Pablo Neira Ayuso
2025-09-04 16:13     ` Phil Sutter
2025-09-04 16:56       ` Pablo Neira Ayuso
2025-09-04 18:33         ` Phil Sutter [this message]
2025-09-04 15:24 ` [nft PATCH v4 3/8] tests: Prepare exit codes for automake Phil Sutter
2025-09-04 15:24 ` [nft PATCH v4 4/8] tests: json_echo: Skip if run as non-root Phil Sutter
2025-09-04 15:24 ` [nft PATCH v4 5/8] tests: shell: Skip packetpath/nat_ftp in fake root env Phil Sutter
2025-09-04 15:24 ` [nft PATCH v4 6/8] tests: build: Do not assume caller's CWD Phil Sutter
2025-09-04 15:24 ` [nft PATCH v4 7/8] tests: build: Avoid a recursive 'make check' run Phil Sutter
2025-09-04 15:24 ` [nft PATCH v4 8/8] Makefile: Enable support for 'make check' Phil Sutter
2025-09-11 16:14 ` [nft PATCH v4 0/8] Run all test suites via " Phil Sutter

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=aLnbjSgT5GuY0SHX@orbyte.nwl.cc \
    --to=phil@nwl.cc \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).