Subject: Re: [patch iproute2/net-next] devlink: fix JSON output of mon command

From: Petr Machata <[email-masked]>
Date: Mon, 06 Apr 2020 22:28:31 +0200

Jacob Keller <[email-masked]> writes:

> On 4/2/2020 2:56 AM, Jiri Pirko wrote:
>> From: Jiri Pirko <[email-masked]>
>>
>> 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.