netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Petr Machata <petrm@mellanox.com>
Cc: Jacob Keller <jacob.e.keller@intel.com>,
	Jiri Pirko <jiri@resnulli.us>,
	netdev@vger.kernel.org, dsahern@gmail.com, davem@davemloft.net,
	kuba@kernel.org, mlxsw@mellanox.com
Subject: Re: [patch iproute2/net-next] devlink: fix JSON output of mon command
Date: Mon, 6 Apr 2020 15:48:43 -0700	[thread overview]
Message-ID: <20200406154843.6b31b0b1@hermes.lan> (raw)
In-Reply-To: <87imice4uo.fsf@mellanox.com>

On Mon, 06 Apr 2020 22:28:31 +0200
Petr Machata <petrm@mellanox.com> wrote:

> Jacob Keller <jacob.e.keller@intel.com> writes:
> 
> > On 4/2/2020 2:56 AM, Jiri Pirko wrote:  
> >> From: Jiri Pirko <jiri@mellanox.com>
> >>
> >> The current JSON output of mon command is broken. Fix it and make sure
> >> that the output is a valid JSON. Also, handle SIGINT gracefully to allow
> >> to end the JSON properly.
> >>  
> >
> > I wonder if there is an easy way we could get "make check" or something
> > to add a test to help verify this is valid JSON?  
> 
> Simply piping to jq is an easy way to figure out if it's at least valid
> JSON. In principle it would be possible to write more detailed checks as
> TDC (tc-testing) selftests in the kernel.
> 
> Something like this:
> 
>     {
>         "id": "a520",
>         "name": "JSON",
>         "category": [
>             "qdisc",
>             "fifo"
>         ],
>         "setup": [
>             "$IP link add dev $DUMMY type dummy || /bin/true",
> 	    "$TC qdisc add dev $DUMMY handle 1: root bfifo"
>         ],
>         "cmdUnderTest": "/bin/true",
>         "expExitCode": "0",
>         "verifyCmd": "$TC -j qdisc show dev $DUMMY | jq '.[].kind'",
>         "matchPattern": "bfifo",
>         "matchCount": "1",
>         "teardown": [
>             "$TC qdisc del dev $DUMMY handle 1: root bfifo",
>             "$IP link del dev $DUMMY type dummy"
>         ]
>     }
> 
> Kinda verbose for this level of detail though.

I just use python -m json.tool which is easy (always available)
and picky

  reply	other threads:[~2020-04-06 22:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-02  9:56 [patch iproute2/net-next] devlink: fix JSON output of mon command Jiri Pirko
2020-04-06 18:43 ` Jacob Keller
2020-04-06 20:28   ` Petr Machata
2020-04-06 22:48     ` Stephen Hemminger [this message]
2020-04-07  9:09 ` Jiri Pirko
2020-04-09 14:43 ` David Ahern
2020-04-09 18:28   ` Jiri Pirko

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=20200406154843.6b31b0b1@hermes.lan \
    --to=stephen@networkplumber.org \
    --cc=davem@davemloft.net \
    --cc=dsahern@gmail.com \
    --cc=jacob.e.keller@intel.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=mlxsw@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=petrm@mellanox.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 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).