Re: [PATCH nft v7 2/2]tests:py: add netns feature

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

 



On Mon, Jun 17, 2019 at 7:00 PM Jones Desougi
<jones.desougi+netfilter@xxxxxxxxx> wrote:
>
>
>
> On Fri, Jun 14, 2019 at 4:41 PM Shekhar Sharma <shekhar250198@xxxxxxxxx> wrote:
>>
>> This patch adds the netns feature to the 'nft-test.py' file.
>>
>>
>> Signed-off-by: Shekhar Sharma <shekhar250198@xxxxxxxxx>
>> ---
>> The version history of the patch is :
>> v1: add the netns feature
>> v2: use format() method to simplify print statements.
>> v3: updated the shebang
>> v4: resent the same with small changes
>> v5&v6: resent with small changes
>> v7: netns commands changed for passing the netns name via netns argument.
>>
>>  tests/py/nft-test.py | 141 +++++++++++++++++++++++++++++++------------
>>  1 file changed, 102 insertions(+), 39 deletions(-)
>>
>> diff --git a/tests/py/nft-test.py b/tests/py/nft-test.py
>> index 09d00dba..6ec27267 100755
>> --- a/tests/py/nft-test.py
>> +++ b/tests/py/nft-test.py
>
> [...]
>>
>> @@ -280,6 +291,9 @@ def chain_create(chain, table, filename):
>>          return -1
>>
>>      cmd = "add chain %s %s" % (table, chain)
>> +    if netns:
>> +        cmd = "ip netns exec " + "{} {}".format(cmd)
>
>
> This looks broken. The netns is missing in the format call.
>
oops!, missed the netns argument. Will correct it.

>>
>> +
>
>
> Here an extra empty line also starts appearing after the new netns conditional.
>
Will remove it.

>>
>>      if chain.config:
>>          cmd += " { %s; }" % chain.config
>>
> [...]
>>
>> @@ -1319,13 +1376,15 @@ def run_test_file(filename, force_all_family_option, specific_file):
>>
>>      if specific_file:
>>          if force_all_family_option:
>> -            print print_result_all(filename, tests, total_warning, total_error,
>> -                                   total_unit_run)
>> +            print(print_result_all(filename, tests, total_warning, total_error,
>> +                                   total_unit_run))
>>          else:
>> -            print print_result(filename, tests, total_warning, total_error)
>> +            print(print_result(filename, tests, total_warning, total_error))
>>      else:
>>          if tests == passed and tests > 0:
>> -            print filename + ": " + Colors.GREEN + "OK" + Colors.ENDC
>> +            print(filename + ": " + Colors.GREEN + "OK" + Colors.ENDC)
>> +        if netns:
>> +            execute_cmd("ip netns del " + netns, filename, 0)
>
>
> Hmm, looks like this is in the else branch of "if specific_file:", should it be?
>
>>
>>
>>      f.close()
>>      del table_list[:]
>
Not sure. It is in the else branch of 'if specific_file', it can be
nested inside the
'if tests==passed....' statement and written after f.close() as well.
Not sure which one
to choose.

> [...]
Thanks!

Shekhar



[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux