From e760d200a4b9cd31928b68a1f2f882157344351e Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Tue, 10 Apr 2018 19:00:24 +0200 Subject: tests/py: Use libnftables instead of calling nft binary This adds a simple nftables Python class in py/nftables.py which gives access to libnftables API via ctypes module. nft-test.py is extended to make use of the above class instead of calling nft binary. Since command line formatting had to be touched anyway, this patch also streamlines things a bit by introducing __str__ methods to classes Table and Chain and making extensive use of format strings instead of onerously adding all string parts together. Since the called commands don't see a shell anymore, all shell meta character escaping done in testcases is removed. The visible effects of this change are: * Four new warnings in ip/flowtable.t due to changing objref IDs (will be addressed later in a patch to libnftnl). * Reported command line in warning and error messages changed slightly for obvious reasons. * Reduction of a full test run's runtime by a factor of four. Status diff after running with 'time': < 83 test files, 77 files passed, 1724 unit tests, 0 error, 33 warning < 87.23user 696.13system 15:11.82elapsed 85%CPU (0avgtext+0avgdata 9604maxresident)k < 8inputs+36800outputs (0major+35171235minor)pagefaults 0swaps > 83 test files, 77 files passed, 1724 unit tests, 4 error, 33 warning > 6.80user 30.18system 3:45.86elapsed 16%CPU (0avgtext+0avgdata 14064maxresident)k > 0inputs+35808outputs (0major+2874minor)pagefaults 0swaps Signed-off-by: Phil Sutter Signed-off-by: Pablo Neira Ayuso --- tests/py/ip/objects.t | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/py/ip/objects.t') diff --git a/tests/py/ip/objects.t b/tests/py/ip/objects.t index 76b802ac..5e8c7631 100644 --- a/tests/py/ip/objects.t +++ b/tests/py/ip/objects.t @@ -19,8 +19,8 @@ ip saddr 192.168.1.3 quota name "qt3";fail quota name tcp dport map {443 : "qt1", 80 : "qt2", 22 : "qt1"};ok # ct helper -%cthelp1 type ct helper { type \"ftp\" protocol tcp\; };ok -%cthelp2 type ct helper { type \"ftp\" protocol tcp\; l3proto ip6\; };fail +%cthelp1 type ct helper { type "ftp" protocol tcp; };ok +%cthelp2 type ct helper { type "ftp" protocol tcp; l3proto ip6; };fail ct helper set "cthelp1";ok ct helper set tcp dport map {21 : "cthelp1", 2121 : "cthelp1" };ok -- cgit v1.2.3