summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2018-10-09 00:03:28 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2018-10-15 14:04:27 +0200
commit80077787f8f21da1efd8dc27a4c5767ab47a1df6 (patch)
tree01d9b399a1aad23d7ea1d1e1daa0ad98bec69e0a /tests
parentaaf20ad0dc22d2ebcad1b2c43288e984f0efe2c3 (diff)
src: remove json support
We have better json support in libnftables these days. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am9
-rw-r--r--tests/jsonfiles/01-table.json1
-rw-r--r--tests/jsonfiles/02-table.json1
-rw-r--r--tests/jsonfiles/11-chain.json1
-rw-r--r--tests/jsonfiles/12-chain.json1
-rw-r--r--tests/jsonfiles/13-chain.json1
-rw-r--r--tests/jsonfiles/14-chain.json1
-rw-r--r--tests/jsonfiles/20-rule-bitwise.json1
-rw-r--r--tests/jsonfiles/21-rule-byteorder.json1
-rw-r--r--tests/jsonfiles/22-rule-cmp.json1
-rw-r--r--tests/jsonfiles/23-rule-counter.json1
-rw-r--r--tests/jsonfiles/24-rule-ct.json1
-rw-r--r--tests/jsonfiles/25-rule-exthdr.json1
-rw-r--r--tests/jsonfiles/26-rule-immediate.json1
-rw-r--r--tests/jsonfiles/27-rule-limit.json1
-rw-r--r--tests/jsonfiles/28-rule-log.json1
-rw-r--r--tests/jsonfiles/29-rule-match.json1
-rw-r--r--tests/jsonfiles/30-rule-lookup.json1
-rw-r--r--tests/jsonfiles/31-rule-meta.json1
-rw-r--r--tests/jsonfiles/32-rule-nat4.json1
-rw-r--r--tests/jsonfiles/33-rule-nat6.json1
-rw-r--r--tests/jsonfiles/34-rule-payload.json1
-rw-r--r--tests/jsonfiles/35-rule-target.json1
-rw-r--r--tests/jsonfiles/36-rule-real.json1
-rw-r--r--tests/jsonfiles/37-rule-real.json1
-rw-r--r--tests/jsonfiles/38-rule-real.json1
-rw-r--r--tests/jsonfiles/39-rule-real.json1
-rw-r--r--tests/jsonfiles/40-rule-real.json1
-rw-r--r--tests/jsonfiles/41-rule-real.json1
-rw-r--r--tests/jsonfiles/42-rule-real.json1
-rw-r--r--tests/jsonfiles/43-rule-real.json1
-rw-r--r--tests/jsonfiles/44-rule-real.json1
-rw-r--r--tests/jsonfiles/45-rule-real.json1
-rw-r--r--tests/jsonfiles/46-rule-real.json1
-rw-r--r--tests/jsonfiles/47-rule-real.json1
-rw-r--r--tests/jsonfiles/48-rule-real.json1
-rw-r--r--tests/jsonfiles/49-rule-real.json1
-rw-r--r--tests/jsonfiles/50-rule-real.json1
-rw-r--r--tests/jsonfiles/51-rule-real.json1
-rw-r--r--tests/jsonfiles/52-rule-real.json1
-rw-r--r--tests/jsonfiles/53-rule-real.json1
-rw-r--r--tests/jsonfiles/54-rule-real.json1
-rw-r--r--tests/jsonfiles/55-rule-real.json1
-rw-r--r--tests/jsonfiles/56-rule-real.json1
-rw-r--r--tests/jsonfiles/57-rule-real.json1
-rw-r--r--tests/jsonfiles/58-rule-real.json1
-rw-r--r--tests/jsonfiles/59-rule-real.json1
-rw-r--r--tests/jsonfiles/60-rule-real.json1
-rw-r--r--tests/jsonfiles/61-rule-real.json1
-rw-r--r--tests/jsonfiles/62-set.json1
-rw-r--r--tests/jsonfiles/63-set.json1
-rw-r--r--tests/jsonfiles/64-ruleset.json1
-rw-r--r--tests/jsonfiles/65-rule-meta-target.json1
-rw-r--r--tests/jsonfiles/66-rule-queue.json1
-rw-r--r--tests/jsonfiles/67-rule-queue.json1
-rw-r--r--tests/jsonfiles/68-rule-masq.json1
-rw-r--r--tests/jsonfiles/69-rule-redir.json1
-rw-r--r--tests/jsonfiles/70-rule-real.json1
-rw-r--r--tests/nft-parsing-test.c283
-rwxr-xr-xtests/test-script.sh1
60 files changed, 2 insertions, 348 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5872bb1..556575f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,10 +1,8 @@
include $(top_srcdir)/Make_global.am
-EXTRA_DIST = test-script.sh \
- jsonfiles
+EXTRA_DIST = test-script.sh
-check_PROGRAMS = nft-parsing-test \
- nft-table-test \
+check_PROGRAMS = nft-table-test \
nft-chain-test \
nft-object-test \
nft-rule-test \
@@ -37,9 +35,6 @@ check_PROGRAMS = nft-parsing-test \
nft-expr_target-test \
nft-expr_hash-test
-nft_parsing_test_SOURCES = nft-parsing-test.c
-nft_parsing_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} ${LIBJSON_LIBS}
-
nft_table_test_SOURCES = nft-table-test.c
nft_table_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
diff --git a/tests/jsonfiles/01-table.json b/tests/jsonfiles/01-table.json
deleted file mode 100644
index 20754f1..0000000
--- a/tests/jsonfiles/01-table.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"table":{"name":"filter","family":"ip","flags":0,"use":0}}]}]}
diff --git a/tests/jsonfiles/02-table.json b/tests/jsonfiles/02-table.json
deleted file mode 100644
index 797a00d..0000000
--- a/tests/jsonfiles/02-table.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"table":{"name":"filter2","family":"ip6","flags":0,"use":0}}]}]}
diff --git a/tests/jsonfiles/11-chain.json b/tests/jsonfiles/11-chain.json
deleted file mode 100644
index 5808819..0000000
--- a/tests/jsonfiles/11-chain.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"chain":{"name":"input","handle":1,"bytes":1375696,"packets":4136,"table":"filter","family":"ip","use":0,"type":"filter","hooknum":"input","prio":0,"policy":"accept"}}]}]}
diff --git a/tests/jsonfiles/12-chain.json b/tests/jsonfiles/12-chain.json
deleted file mode 100644
index c1c823c..0000000
--- a/tests/jsonfiles/12-chain.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"chain":{"name":"forward","handle":2,"bytes":0,"packets":0,"table":"filter","family":"ip","use":0,"type":"filter","hooknum":"forward","prio":0,"policy":"accept"}}]}]}
diff --git a/tests/jsonfiles/13-chain.json b/tests/jsonfiles/13-chain.json
deleted file mode 100644
index 22940f9..0000000
--- a/tests/jsonfiles/13-chain.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"chain":{"name":"output","handle":3,"bytes":454786,"packets":2681,"table":"filter","family":"ip","use":0,"type":"filter","hooknum":"output","prio":0,"policy":"accept"}}]}]}
diff --git a/tests/jsonfiles/14-chain.json b/tests/jsonfiles/14-chain.json
deleted file mode 100644
index 0fb1948..0000000
--- a/tests/jsonfiles/14-chain.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"chain":{"name":"chain1","handle":4,"bytes":0,"packets":0,"table":"filter","family":"ip","use":0}}]}]}
diff --git a/tests/jsonfiles/20-rule-bitwise.json b/tests/jsonfiles/20-rule-bitwise.json
deleted file mode 100644
index 0e2e5c6..0000000
--- a/tests/jsonfiles/20-rule-bitwise.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"input","handle":20,"expr":[{"type":"bitwise","sreg":1,"dreg":1,"len":4,"mask":{"reg":{"type":"value","len":4,"data0":"0x0000000a"}},"xor":{"reg":{"type":"value","len":4,"data0":"0x00000000"}}}]}}]}]}
diff --git a/tests/jsonfiles/21-rule-byteorder.json b/tests/jsonfiles/21-rule-byteorder.json
deleted file mode 100644
index 18a33f2..0000000
--- a/tests/jsonfiles/21-rule-byteorder.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"input","handle":21,"expr":[{"type":"byteorder","sreg":3,"dreg":4,"op":"hton","len":4,"size":4}]}}]}]}
diff --git a/tests/jsonfiles/22-rule-cmp.json b/tests/jsonfiles/22-rule-cmp.json
deleted file mode 100644
index c8f91ec..0000000
--- a/tests/jsonfiles/22-rule-cmp.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"forward","handle":22,"expr":[{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":16,"data0":"0x00000000","data1":"0x6e6f6200","data2":"0x2e303164","data3":"0x00393331"}}}]}}]}]}
diff --git a/tests/jsonfiles/23-rule-counter.json b/tests/jsonfiles/23-rule-counter.json
deleted file mode 100644
index 30d7a06..0000000
--- a/tests/jsonfiles/23-rule-counter.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":23,"expr":[{"type":"counter","pkts":135,"bytes":21655}]}}]}]}
diff --git a/tests/jsonfiles/24-rule-ct.json b/tests/jsonfiles/24-rule-ct.json
deleted file mode 100644
index 71783e8..0000000
--- a/tests/jsonfiles/24-rule-ct.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"input","handle":24,"expr":[{"type":"ct","dreg":1,"key":"state"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":4,"data0":"0x00000008"}}}]}}]}]}
diff --git a/tests/jsonfiles/25-rule-exthdr.json b/tests/jsonfiles/25-rule-exthdr.json
deleted file mode 100644
index 0f6988c..0000000
--- a/tests/jsonfiles/25-rule-exthdr.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"input","handle":25,"expr":[{"type":"exthdr","dreg":1,"exthdr_type":"mh","offset":2,"len":16}]}}]}]}
diff --git a/tests/jsonfiles/26-rule-immediate.json b/tests/jsonfiles/26-rule-immediate.json
deleted file mode 100644
index 89cd360..0000000
--- a/tests/jsonfiles/26-rule-immediate.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"input","handle":26,"expr":[{"type":"immediate","dreg":0,"data":{"reg":{"type":"verdict","verdict":"accept"}}}]}}]}]}
diff --git a/tests/jsonfiles/27-rule-limit.json b/tests/jsonfiles/27-rule-limit.json
deleted file mode 100644
index fdd5358..0000000
--- a/tests/jsonfiles/27-rule-limit.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"input","handle":27,"expr":[{"type":"limit","rate":321321,"unit":0}]}}]}]}
diff --git a/tests/jsonfiles/28-rule-log.json b/tests/jsonfiles/28-rule-log.json
deleted file mode 100644
index 320bf29..0000000
--- a/tests/jsonfiles/28-rule-log.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"input","handle":28,"expr":[{"type":"log","prefix":"test_chain","group":1,"snaplen":0,"qthreshold":0}]}}]}]}
diff --git a/tests/jsonfiles/29-rule-match.json b/tests/jsonfiles/29-rule-match.json
deleted file mode 100644
index 577c63a..0000000
--- a/tests/jsonfiles/29-rule-match.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"input","handle":9,"expr":[{"type":"match","name":"state"},{"type":"counter","pkts":0,"bytes":0}]}}]}]}
diff --git a/tests/jsonfiles/30-rule-lookup.json b/tests/jsonfiles/30-rule-lookup.json
deleted file mode 100644
index 3eed063..0000000
--- a/tests/jsonfiles/30-rule-lookup.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"input","handle":8,"expr":[{"type":"payload","dreg":1,"offset":12,"len":4,"base":"network"},{"type":"lookup","set":"set0","sreg":1,"dreg":0}]}}]}]}
diff --git a/tests/jsonfiles/31-rule-meta.json b/tests/jsonfiles/31-rule-meta.json
deleted file mode 100644
index 2c2d681..0000000
--- a/tests/jsonfiles/31-rule-meta.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":8,"expr":[{"type":"meta","dreg":1,"key":"protocol"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":4,"data0":"0x000003e8"}}},{"type":"counter","pkts":0,"bytes":0}]}}]}]}
diff --git a/tests/jsonfiles/32-rule-nat4.json b/tests/jsonfiles/32-rule-nat4.json
deleted file mode 100644
index 4ac8c87..0000000
--- a/tests/jsonfiles/32-rule-nat4.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"input","handle":10,"expr":[{"type":"nat","nat_type":"dnat","family":"ip","sreg_addr_min":1,"sreg_addr_max":2,"sreg_proto_min":3,"sreg_proto_max":4}]}}]}]}
diff --git a/tests/jsonfiles/33-rule-nat6.json b/tests/jsonfiles/33-rule-nat6.json
deleted file mode 100644
index 3e4b2e5..0000000
--- a/tests/jsonfiles/33-rule-nat6.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip6","table":"nat","chain":"output","handle":33,"expr":[{"type":"nat","nat_type":"snat","family":"ip6","sreg_addr_min":1,"sreg_addr_max":2,"sreg_proto_min":3,"sreg_proto_max":4,"flags":12}]}}]}]}
diff --git a/tests/jsonfiles/34-rule-payload.json b/tests/jsonfiles/34-rule-payload.json
deleted file mode 100644
index 127eb0c..0000000
--- a/tests/jsonfiles/34-rule-payload.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"input","handle":26,"expr":[{"type":"payload","dreg":1,"offset":9,"len":1,"base":"network"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":1,"data0":"0x00000006"}}},{"type":"payload","dreg":1,"offset":2,"len":2,"base":"transport"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":2,"data0":"0x00001600"}}},{"type":"immediate","dreg":0,"data":{"reg":{"type":"verdict","verdict":"accept"}}}]}}]}]}
diff --git a/tests/jsonfiles/35-rule-target.json b/tests/jsonfiles/35-rule-target.json
deleted file mode 100644
index 4ac72a8..0000000
--- a/tests/jsonfiles/35-rule-target.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"INPUT","handle":20,"expr":[{"type":"counter","pkts":17,"bytes":4436},{"type":"target","name":"LOG"}]}}]}]}
diff --git a/tests/jsonfiles/36-rule-real.json b/tests/jsonfiles/36-rule-real.json
deleted file mode 100644
index 65a0d62..0000000
--- a/tests/jsonfiles/36-rule-real.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":36,"expr":[{"type":"payload","dreg":1,"offset":12,"len":8,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":8,"data0":"0x0100a8c0","data1":"0x6400a8c0"}}},{"type":"counter","pkts":0,"bytes":0}]}}]}]}
diff --git a/tests/jsonfiles/37-rule-real.json b/tests/jsonfiles/37-rule-real.json
deleted file mode 100644
index cfd1c13..0000000
--- a/tests/jsonfiles/37-rule-real.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":37,"expr":[{"type":"payload","dreg":1,"offset":16,"len":4,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":4,"data0":"0x0100a8c0"}}}]}}]}]}
diff --git a/tests/jsonfiles/38-rule-real.json b/tests/jsonfiles/38-rule-real.json
deleted file mode 100644
index 71123aa..0000000
--- a/tests/jsonfiles/38-rule-real.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":38,"expr":[{"type":"payload","dreg":1,"offset":16,"len":4,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":4,"data0":"0x0100a8c0"}}}]}}]}]}
diff --git a/tests/jsonfiles/39-rule-real.json b/tests/jsonfiles/39-rule-real.json
deleted file mode 100644
index 7b05158..0000000
--- a/tests/jsonfiles/39-rule-real.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":39,"expr":[{"type":"payload","dreg":1,"offset":16,"len":4,"base":"link"},{"type":"cmp","sreg":1,"op":"gte","data":{"reg":{"type":"value","len":4,"data0":"0x0100a8c0"}}},{"type":"cmp","sreg":1,"op":"lte","data":{"reg":{"type":"value","len":4,"data0":"0xfa00a8c0"}}}]}}]}]}
diff --git a/tests/jsonfiles/40-rule-real.json b/tests/jsonfiles/40-rule-real.json
deleted file mode 100644
index 8b1259b..0000000
--- a/tests/jsonfiles/40-rule-real.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":40,"expr":[{"type":"payload","dreg":1,"offset":16,"len":4,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":4,"data0":"0x0100a8c0"}}},{"type":"counter","pkts":0,"bytes":0}]}}]}]}
diff --git a/tests/jsonfiles/41-rule-real.json b/tests/jsonfiles/41-rule-real.json
deleted file mode 100644
index 675a95c..0000000
--- a/tests/jsonfiles/41-rule-real.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":41,"expr":[{"type":"payload","dreg":1,"offset":16,"len":4,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":4,"data0":"0x0100a8c0"}}},{"type":"counter","pkts":0,"bytes":0},{"type":"immediate","dreg":0,"data":{"reg":{"type":"verdict","verdict":"drop"}}}]}}]}]}
diff --git a/tests/jsonfiles/42-rule-real.json b/tests/jsonfiles/42-rule-real.json
deleted file mode 100644
index b3d28d4..0000000
--- a/tests/jsonfiles/42-rule-real.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":42,"expr":[{"type":"payload","dreg":1,"offset":16,"len":4,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":4,"data0":"0x0100a8c0"}}},{"type":"counter","pkts":0,"bytes":0},{"type":"log","prefix":"(null)","group":0,"snaplen":0,"qthreshold":0}]}}]}]}
diff --git a/tests/jsonfiles/43-rule-real.json b/tests/jsonfiles/43-rule-real.json
deleted file mode 100644
index e0da9a8..0000000
--- a/tests/jsonfiles/43-rule-real.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":43,"expr":[{"type":"payload","dreg":1,"offset":9,"len":1,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":1,"data0":"0x00000006"}}},{"type":"payload","dreg":1,"offset":2,"len":2,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":2,"data0":"0x00001600"}}},{"type":"counter","pkts":0,"bytes":0}]}}]}]}
diff --git a/tests/jsonfiles/44-rule-real.json b/tests/jsonfiles/44-rule-real.json
deleted file mode 100644
index 50dd524..0000000
--- a/tests/jsonfiles/44-rule-real.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":44,"expr":[{"type":"payload","dreg":1,"offset":9,"len":1,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":1,"data0":"0x00000006"}}},{"type":"payload","dreg":1,"offset":0,"len":4,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":4,"data0":"0x16000004"}}},{"type":"counter","pkts":0,"bytes":0}]}}]}]}
diff --git a/tests/jsonfiles/45-rule-real.json b/tests/jsonfiles/45-rule-real.json
deleted file mode 100644
index be08598..0000000
--- a/tests/jsonfiles/45-rule-real.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":45,"expr":[{"type":"payload","dreg":1,"offset":12,"len":8,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":8,"data0":"0x0100a8c0","data1":"0x6400a8c0"}}},{"type":"counter","pkts":0,"bytes":0}]}}]}]}
diff --git a/tests/jsonfiles/46-rule-real.json b/tests/jsonfiles/46-rule-real.json
deleted file mode 100644
index 5ea3ca9..0000000
--- a/tests/jsonfiles/46-rule-real.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":46,"expr":[{"type":"payload","dreg":1,"offset":9,"len":1,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":1,"data0":"0x00000006"}}},{"type":"payload","dreg":1,"offset":0,"len":8,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":8,"data0":"0x16000004","data1":"0x00000000"}}}]}}]}]}
diff --git a/tests/jsonfiles/47-rule-real.json b/tests/jsonfiles/47-rule-real.json
deleted file mode 100644
index 6e9d084..0000000
--- a/tests/jsonfiles/47-rule-real.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":47,"expr":[{"type":"payload","dreg":1,"offset":9,"len":1,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":1,"data0":"0x00000006"}}},{"type":"payload","dreg":1,"offset":0,"len":8,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":8,"data0":"0x16000004","data1":"0x00000000"}}}]}}]}]}
diff --git a/tests/jsonfiles/48-rule-real.json b/tests/jsonfiles/48-rule-real.json
deleted file mode 100644
index 6387e94..0000000
--- a/tests/jsonfiles/48-rule-real.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":48,"expr":[{"type":"meta","dreg":1,"key":"len"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":4,"data0":"0x000003e8"}}},{"type":"counter","pkts":0,"bytes":0}]}}]}]}
diff --git a/tests/jsonfiles/49-rule-real.json b/tests/jsonfiles/49-rule-real.json
deleted file mode 100644
index e1c84d2..0000000
--- a/tests/jsonfiles/49-rule-real.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":49,"expr":[{"type":"meta","dreg":1,"key":"mark"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":4,"data0":"0x00000000"}}},{"type":"counter","pkts":55,"bytes":11407}]}}]}]}
diff --git a/tests/jsonfiles/50-rule-real.json b/tests/jsonfiles/50-rule-real.json
deleted file mode 100644
index 21de049..0000000
--- a/tests/jsonfiles/50-rule-real.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":50,"expr":[{"type":"meta","dreg":1,"key":"iif"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":4,"data0":"0x00000001"}}},{"type":"counter","pkts":0,"bytes":0}]}}]}]}
diff --git a/tests/jsonfiles/51-rule-real.json b/tests/jsonfiles/51-rule-real.json
deleted file mode 100644
index 46afd76..0000000
--- a/tests/jsonfiles/51-rule-real.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":51,"expr":[{"type":"meta","dreg":1,"key":"iifname"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":16,"data0":"0x00000000","data1":"0x00000000","data2":"0x65000000","data3":"0x00306874"}}},{"type":"counter","pkts":0,"bytes":0}]}}]}]}
diff --git a/tests/jsonfiles/52-rule-real.json b/tests/jsonfiles/52-rule-real.json
deleted file mode 100644
index e64fe80..0000000
--- a/tests/jsonfiles/52-rule-real.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":52,"expr":[{"type":"meta","dreg":1,"key":"oif"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":4,"data0":"0x00000001"}}},{"type":"counter","pkts":0,"bytes":0}]}}]}]}
diff --git a/tests/jsonfiles/53-rule-real.json b/tests/jsonfiles/53-rule-real.json
deleted file mode 100644
index 910a467..0000000
--- a/tests/jsonfiles/53-rule-real.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":53,"expr":[{"type":"meta","dreg":1,"key":"oifname"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":16,"data0":"0x00000000","data1":"0x00000000","data2":"0x65000000","data3":"0x00306874"}}},{"type":"counter","pkts":0,"bytes":0}]}}]}]}
diff --git a/tests/jsonfiles/54-rule-real.json b/tests/jsonfiles/54-rule-real.json
deleted file mode 100644
index f271d83..0000000
--- a/tests/jsonfiles/54-rule-real.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":54,"expr":[{"type":"meta","dreg":1,"key":"skuid"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":4,"data0":"0x000003e8"}}},{"type":"counter","pkts":0,"bytes":0}]}}]}]}
diff --git a/tests/jsonfiles/55-rule-real.json b/tests/jsonfiles/55-rule-real.json
deleted file mode 100644
index f36ebe5..0000000
--- a/tests/jsonfiles/55-rule-real.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":55,"expr":[{"type":"meta","dreg":1,"key":"skgid"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":4,"data0":"0x000003e8"}}},{"type":"counter","pkts":0,"bytes":0}]}}]}]}
diff --git a/tests/jsonfiles/56-rule-real.json b/tests/jsonfiles/56-rule-real.json
deleted file mode 100644
index 408b653..0000000
--- a/tests/jsonfiles/56-rule-real.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":56,"expr":[{"type":"meta","dreg":1,"key":"secmark"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":4,"data0":"0x00000000"}}},{"type":"counter","pkts":55,"bytes":11407}]}}]}]}
diff --git a/tests/jsonfiles/57-rule-real.json b/tests/jsonfiles/57-rule-real.json
deleted file mode 100644
index fc8a67a..0000000
--- a/tests/jsonfiles/57-rule-real.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":57,"expr":[{"type":"meta","dreg":1,"key":"len"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":4,"data0":"0x000003e8"}}},{"type":"counter","pkts":0,"bytes":0}]}}]}]}
diff --git a/tests/jsonfiles/58-rule-real.json b/tests/jsonfiles/58-rule-real.json
deleted file mode 100644
index abb90d5..0000000
--- a/tests/jsonfiles/58-rule-real.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":58,"expr":[{"type":"meta","dreg":1,"key":"protocol"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":2,"data0":"0x00000008"}}},{"type":"counter","pkts":55,"bytes":11407}]}}]}]}
diff --git a/tests/jsonfiles/59-rule-real.json b/tests/jsonfiles/59-rule-real.json
deleted file mode 100644
index ffe2288..0000000
--- a/tests/jsonfiles/59-rule-real.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":59,"expr":[{"type":"meta","dreg":1,"key":"mark"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":4,"data0":"0x00000000"}}},{"type":"counter","pkts":55,"bytes":11407}]}}]}]}
diff --git a/tests/jsonfiles/60-rule-real.json b/tests/jsonfiles/60-rule-real.json
deleted file mode 100644
index 9ec79cf..0000000
--- a/tests/jsonfiles/60-rule-real.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":60,"expr":[{"type":"meta","dreg":1,"key":"iif"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":4,"data0":"0x00000001"}}},{"type":"counter","pkts":0,"bytes":0}]}}]}]}
diff --git a/tests/jsonfiles/61-rule-real.json b/tests/jsonfiles/61-rule-real.json
deleted file mode 100644
index fd35d2c..0000000
--- a/tests/jsonfiles/61-rule-real.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":61,"expr":[{"type":"meta","dreg":1,"key":"iifname"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":16,"data0":"0x00000000","data1":"0x00000000","data2":"0x65000000","data3":"0x00306874"}}},{"type":"counter","pkts":0,"bytes":0}]}}]}]}
diff --git a/tests/jsonfiles/62-set.json b/tests/jsonfiles/62-set.json
deleted file mode 100644
index 616eabe..0000000
--- a/tests/jsonfiles/62-set.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"set":{"name":"set0","table":"filter","flags":3,"family":"ip","key_type":12,"key_len":2,"set_elem":[{"flags":0,"key":{"reg":{"type":"value","len":2,"data0":"0x00001700"}}},{"flags":0,"key":{"reg":{"type":"value","len":2,"data0":"0x00001600"}}}]}}]}]}
diff --git a/tests/jsonfiles/63-set.json b/tests/jsonfiles/63-set.json
deleted file mode 100644
index 02aa5fb..0000000
--- a/tests/jsonfiles/63-set.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"set":{"name":"map0","table":"f","flags":11,"family":"ip","key_type":12,"key_len":2,"data_type":4294967040,"data_len":16,"set_elem":[{"flags":0,"key":{"reg":{"type":"value","len":2,"data0":"0x00001700"}},"data":{"reg":{"type":"verdict","verdict":"goto","chain":"o"}}},{"flags":0,"key":{"reg":{"type":"value","len":2,"data0":"0x00001600"}},"data":{"reg":{"type":"verdict","verdict":"accept"}}}]}}]}]}
diff --git a/tests/jsonfiles/64-ruleset.json b/tests/jsonfiles/64-ruleset.json
deleted file mode 100644
index 54e27c0..0000000
--- a/tests/jsonfiles/64-ruleset.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"table":{"name":"filter","family":"ip","flags":0,"use":0}},{"table":{"name":"filter2","family":"ip6","flags":0,"use":0}},{"chain":{"name":"input","handle":1,"bytes":10681449,"packets":16216,"table":"filter","family":"ip","use":0,"type":"filter","hooknum":"input","prio":0,"policy":"accept"}},{"chain":{"name":"forward","handle":2,"bytes":0,"packets":0,"table":"filter","family":"ip","use":0,"type":"filter","hooknum":"forward","prio":0,"policy":"accept"}},{"chain":{"name":"output","handle":3,"bytes":2375830,"packets":15184,"table":"filter","family":"ip","use":0,"type":"filter","hooknum":"output","prio":0,"policy":"accept"}},{"chain":{"name":"chain1","handle":4,"bytes":0,"packets":0,"table":"filter","family":"ip","use":0}},{"set":{"name":"set0","table":"filter","flags":3,"family":"ip","key_type":12,"key_len":2}},{"rule":{"family":"ip","table":"filter","chain":"output","handle":6,"expr":[{"type":"payload","dreg":1,"offset":16,"len":4,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":4,"data0":"0x0100a8c0"}}},{"type":"counter","pkts":0,"bytes":0},{"type":"immediate","dreg":0,"data":{"reg":{"type":"verdict","verdict":"drop"}}}]}},{"rule":{"family":"ip","table":"filter","chain":"output","handle":9,"expr":[{"type":"payload","dreg":1,"offset":9,"len":1,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":1,"data0":"0x00000006"}}},{"type":"payload","dreg":1,"offset":2,"len":2,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":2,"data0":"0x00001600"}}},{"type":"counter","pkts":0,"bytes":0}]}},{"rule":{"family":"ip","table":"filter","chain":"output","handle":10,"expr":[{"type":"payload","dreg":1,"offset":16,"len":4,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":4,"data0":"0x0100a8c0"}}},{"type":"counter","pkts":0,"bytes":0}]}},{"rule":{"family":"ip","table":"filter","chain":"output","handle":11,"expr":[{"type":"payload","dreg":1,"offset":16,"len":4,"base":"link"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":4,"data0":"0x0100a8c0"}}},{"type":"counter","pkts":0,"bytes":0},{"type":"immediate","dreg":0,"data":{"reg":{"type":"verdict","verdict":"drop"}}}]}}]}]}
diff --git a/tests/jsonfiles/65-rule-meta-target.json b/tests/jsonfiles/65-rule-meta-target.json
deleted file mode 100644
index ab4e40c..0000000
--- a/tests/jsonfiles/65-rule-meta-target.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"output","handle":1,"expr":[{"type":"meta","key":"mark","sreg":1},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":4,"data0":"0x000003e8"}}},{"type":"counter","pkts":0,"bytes":0}]}}]}]}
diff --git a/tests/jsonfiles/66-rule-queue.json b/tests/jsonfiles/66-rule-queue.json
deleted file mode 100644
index 69a2eee..0000000
--- a/tests/jsonfiles/66-rule-queue.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"input","handle":43,"expr":[{"type":"queue","num":4,"total":2,"flags":0}]}}]}]}
diff --git a/tests/jsonfiles/67-rule-queue.json b/tests/jsonfiles/67-rule-queue.json
deleted file mode 100644
index 0471a98..0000000
--- a/tests/jsonfiles/67-rule-queue.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"input","handle":44,"position":43,"expr":[{"type":"queue","num":4,"total":2,"flags":3}]}}]}]}
diff --git a/tests/jsonfiles/68-rule-masq.json b/tests/jsonfiles/68-rule-masq.json
deleted file mode 100644
index e8f2a58..0000000
--- a/tests/jsonfiles/68-rule-masq.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip6","table":"nat","chain":"postrouting","handle":4,"expr":[{"type":"masq","flags":12}]}}]}]}
diff --git a/tests/jsonfiles/69-rule-redir.json b/tests/jsonfiles/69-rule-redir.json
deleted file mode 100644
index d0318f0..0000000
--- a/tests/jsonfiles/69-rule-redir.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip6","table":"nat","chain":"prerouting","handle":4,"expr":[{"type":"redir"}]}}]}]}
diff --git a/tests/jsonfiles/70-rule-real.json b/tests/jsonfiles/70-rule-real.json
deleted file mode 100644
index b38947f..0000000
--- a/tests/jsonfiles/70-rule-real.json
+++ /dev/null
@@ -1 +0,0 @@
-{"nftables":[{"add":[{"rule":{"family":"ip","table":"filter","chain":"input","handle":2,"expr":[{"type":"payload","dreg":1,"offset":9,"len":1,"base":"network"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":1,"data0":"0x00000006"}}},{"type":"payload","dreg":1,"offset":2,"len":2,"base":"transport"},{"type":"cmp","sreg":1,"op":"eq","data":{"reg":{"type":"value","len":2,"data0":"0x00001600"}}},{"type":"counter","pkts":0,"bytes":0}]}}]}]}
diff --git a/tests/nft-parsing-test.c b/tests/nft-parsing-test.c
deleted file mode 100644
index d25a73e..0000000
--- a/tests/nft-parsing-test.c
+++ /dev/null
@@ -1,283 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <dirent.h>
-#include <limits.h>
-#include <errno.h>
-#include <getopt.h>
-
-#include <libmnl/libmnl.h> /*nlmsghdr*/
-#include <libnftnl/ruleset.h>
-#include <libnftnl/table.h>
-#include <libnftnl/chain.h>
-#include <libnftnl/rule.h>
-#include <libnftnl/set.h>
-
-enum {
- TEST_XML_RULESET,
- TEST_JSON_RULESET,
-};
-
-static bool update = false;
-
-static void print_detail_error(char *a, char *b)
-{
- int i;
- int from = -1;
-
- for (i = 0; i < strlen(b); i++) {
- if (from == -1 && a[i] != b[i]) {
- from = i;
- break;
-
- }
- }
-
- if (from != -1) {
- int k = from - 10;
-
- if (k < 0)
- k = 0;
-
- fprintf(stderr, "from file: ");
- for (i = k; i < from + 10; i++)
- fprintf(stderr, "%c", a[i]);
-
- fprintf(stderr, "\nfrom snprintf: ");
- for (i = k; i < from + 10; i++)
- fprintf(stderr, "%c", b[i]);
-
- /* Don't look twice below this comment ;-) */
- fprintf(stderr, "\n ");
- for (i = k; i < from + 10; i++) {
- if (i == from)
- fprintf(stderr, "^");
- else
- fprintf(stderr, " ");
- }
- fprintf(stderr, "\n");
- }
-}
-
-static int compare_test(uint32_t type, struct nftnl_ruleset *rs,
- const char *filename, FILE *fp)
-{
- char orig[4096];
- char out[4096];
-
- switch (type) {
- case TEST_XML_RULESET:
- nftnl_ruleset_snprintf(out, sizeof(out), rs,
- NFTNL_OUTPUT_XML, NFTNL_OF_EVENT_NEW);
- break;
- case TEST_JSON_RULESET:
- nftnl_ruleset_snprintf(out, sizeof(out), rs,
- NFTNL_OUTPUT_JSON, NFTNL_OF_EVENT_NEW);
- break;
- default:
- errno = EINVAL;
- return -1;
- }
-
- rewind(fp);
- fgets(orig, sizeof(orig), fp);
-
- if (strncmp(orig, out, strlen(out)) == 0) {
- if (update)
- printf("%s: No changes to update\n", filename);
- return 0;
- }
- if (update) {
- FILE *fout;
- printf("%s: Updating test file\n", filename);
- fout = fopen(filename, "w");
- if (fout == NULL) {
- printf("unable to open file %s: %s\n", filename,
- strerror(errno));
- return -1;
- }
- fprintf(fout, "%s\n", out);
- fclose(fout);
- return 0;
- }
-
- printf("validating %s: ", filename);
- printf("\033[31mFAILED\e[0m\n");
- print_detail_error(orig, out);
- return -1;
-}
-
-static int test_json(const char *filename, struct nftnl_parse_err *err)
-{
- int ret = -1;
- struct nftnl_ruleset *rs;
- FILE *fp;
-
- fp = fopen(filename, "r");
- if (fp == NULL) {
- printf("unable to open file %s: %s\n", filename,
- strerror(errno));
- return -1;
- }
-
- rs = nftnl_ruleset_alloc();
- if (rs == NULL) {
- perror("nftnl_ruleset_alloc");
- return -1;
- }
-
- if (nftnl_ruleset_parse_file(rs, NFTNL_PARSE_JSON, fp, err) == 0)
- ret = compare_test(TEST_JSON_RULESET, rs, filename, fp);
- else
- goto failparsing;
-
- nftnl_ruleset_free(rs);
- fclose(fp);
-
- return ret;
-
-failparsing:
- fclose(fp);
- printf("parsing %s: ", filename);
- printf("\033[31mFAILED\e[0m (%s)\n", strerror(errno));
- nftnl_parse_perror("Reason", err);
- return -1;
-}
-
-static int execute_test(const char *dir_name)
-{
- DIR *d;
- struct dirent *dent;
- char path[PATH_MAX];
- int ret = 0, exit_code = 0;
- struct nftnl_parse_err *err;
-
- d = opendir(dir_name);
- if (d == NULL) {
- perror("opendir");
- exit(EXIT_FAILURE);
- }
-
- err = nftnl_parse_err_alloc();
- if (err == NULL) {
- perror("error");
- exit(EXIT_FAILURE);
- }
-
- while ((dent = readdir(d)) != NULL) {
- int len = strlen(dent->d_name);
-
- if (strcmp(dent->d_name, ".") == 0 ||
- strcmp(dent->d_name, "..") == 0)
- continue;
-
- snprintf(path, sizeof(path), "%s/%s", dir_name, dent->d_name);
-
- if (strcmp(&dent->d_name[len-5], ".json") == 0) {
- if ((ret = test_json(path, err)) == 0) {
- if (!update) {
- printf("parsing and validating %s: ",
- path);
- printf("\033[32mOK\e[0m\n");
- }
- }
- exit_code += ret;
- }
- }
-
- closedir(d);
- nftnl_parse_err_free(err);
-
- if (exit_code != 0)
- exit(EXIT_FAILURE);
-
- return 0;
-}
-
-static int execute_test_file(const char *filename)
-{
- char path[PATH_MAX];
- struct nftnl_parse_err *err;
- int ret = 0, len;
-
- err = nftnl_parse_err_alloc();
- if (err == NULL) {
- perror("error");
- exit(EXIT_FAILURE);
- }
-
- snprintf(path, sizeof(path), "%s", filename);
-
- len = strlen(filename);
- if (strcmp(&filename[len-5], ".json") == 0) {
- if ((ret = test_json(path, err)) == 0) {
- if (!update) {
- printf("parsing and validating %s: ",
- path);
- printf("\033[32mOK\e[0m\n");
- }
- }
- nftnl_parse_err_free(err);
- exit(EXIT_FAILURE);
- }
-
- nftnl_parse_err_free(err);
-
- return 0;
-}
-
-static void show_help(const char *name)
-{
- printf(
-"Usage: %s [option]\n"
-"\n"
-"Options:\n"
-" -d/--dir <directory> Check test files from <directory>.\n"
-" -u/--update <directory> Update test files from <directory>.\n"
-" -f/--file <file> Check test file <file>\n"
-"\n",
- name);
-}
-
-int main(int argc, char *argv[])
-{
- int val;
- int ret = 0;
- int option_index = 0;
- static struct option long_options[] = {
- { "dir", required_argument, 0, 'd' },
- { "update", required_argument, 0, 'u' },
- { "file", required_argument, 0, 'f' },
- { 0 }
- };
-
- if (argc != 3) {
- show_help(argv[0]);
- exit(EXIT_FAILURE);
- }
-
- while (1) {
- val = getopt_long(argc, argv, "d:u:f:", long_options,
- &option_index);
-
- if (val == -1)
- break;
-
- switch (val) {
- case 'd':
- ret = execute_test(optarg);
- break;
- case 'u':
- update = true;
- ret = execute_test(optarg);
- break;
- case 'f':
- ret = execute_test_file(optarg);
- break;
- default:
- show_help(argv[0]);
- break;
- }
- }
- return ret;
-}
diff --git a/tests/test-script.sh b/tests/test-script.sh
index 2bd7ef0..83dbda2 100755
--- a/tests/test-script.sh
+++ b/tests/test-script.sh
@@ -29,4 +29,3 @@
./nft-set-test
./nft-table-test
./nft-object-test
-./nft-parsing-test -d jsonfiles