Re: [PATCH V2] tests: json: Add test cases for json format

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

 



On 24 August 2017 at 10:49, Shyam Saini <mayhs11saini@xxxxxxxxx> wrote:
> These test cases can be used to test upcoming "import json" command.
>
> Here is the short description of the files:
> all_ruleset_list   ->    contains list of all the individual rules

Wait. You are generating the JSON files from this ruleset, right?

Then, why not simplify the tests by:

 * load a ruleset model (your all_ruleset_list file)
 * export it in JSON format (nft export json)
 * import it again in JSON format (nft import)
 * comparte resulting ruleset (nft list ruleset) with the original
file (all_ruleset_list file)

This way we test in the same run all the JSON code paths.

You will need a simple testcase, like this:

=== 8< ===
#!/bin/bash
set -e
TMP=$(mktmp)
RULESET="table ip { ... } "
echo $RULESET > $TMP
$NFT -f $TMP
$NFT export json > $TMP
cat $TMP | $NFT import json)
RESULT=$($NFT list ruleset)
# compare result and initial ruleset, if fail show diff
=== 8< ===

That was quick and dirty code for you to get the idea.
Please follow the example of other testcases [0] to compare ruleset,
create tempfiles and so on.

Please, if possible, try to add a testcase that is [OK]. Not sure what
is wrong with the dup statement.

thanks Shyam!

[0] http://git.netfilter.org/nftables/tree/tests/shell/testcases/netns/0001nft-f_0
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux