Re: [PATCH net-next 3/6] selftests: net: print report check location in python tests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jakub Kicinski <kuba@xxxxxxxxxx> writes:

> Developing Python tests is a bit annoying because when test fails
> we only print the fail message and no info about which exact check
> led to it. Print the location (the first line of this example is new):
>
>   # At /root/ksft-net-drv/./net/nl_netdev.py line 38:
>   # Check failed 0 != 10
>   not ok 3 nl_netdev.page_pool_check
>
> Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx>

Reviewed-by: Petr Machata <petrm@xxxxxxxxxx>

> +def _fail(*args):
> +    global KSFT_RESULT
> +    KSFT_RESULT = False
> +
> +    frame = inspect.stack()[2]
> +    ksft_pr("At " + frame.filename + " line " + str(frame.lineno) + ":")
> +    ksft_pr(" ".join([str(a) for a in args]))

I think this could have just been ksft_pr(*args) like before, but
whatever.

> +
>  def ksft_eq(a, b, comment=""):
>      global KSFT_RESULT
>      if a != b:
> -        KSFT_RESULT = False
> -        ksft_pr("Check failed", a, "!=", b, comment)
> +        _fail("Check failed", a, "!=", b, comment)




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux