Message ID | 20240813193611.14529-1-phil@nwl.cc |
---|---|
State | Accepted |
Headers | show |
Series | [nft] tests: shell: Extend table persist flag test a bit | expand |
Phil Sutter <phil@nwl.cc> wrote:
> Using a co-process, assert owner flag is effective.
Thanks, please just push it out.
On Tue, Aug 13, 2024 at 09:36:11PM +0200, Phil Sutter wrote: > Using a co-process, assert owner flag is effective. > > Signed-off-by: Phil Sutter <phil@nwl.cc> Patch applied.
diff --git a/tests/shell/testcases/owner/0002-persist b/tests/shell/testcases/owner/0002-persist index cf4b8f1327ec1..98a8eb1368bc1 100755 --- a/tests/shell/testcases/owner/0002-persist +++ b/tests/shell/testcases/owner/0002-persist @@ -33,4 +33,46 @@ EOF die "retake ownership failed" } +EXPECT="table ip t { + flags persist +}" +diff -u <(echo "$EXPECT") <($NFT list ruleset) || { + die "unexpected ruleset before coproc setup" +} + +coproc $NFT -i +sleep 1 + +cat >&"${COPROC[1]}" <<EOF +add table ip t { flags owner, persist; } +EOF + +EXPECT="table ip t { # progname nft + flags owner,persist +}" +diff -u <(echo "$EXPECT") <($NFT list ruleset) || { + die "unexpected ruleset after coproc setup" +} + +$NFT flush ruleset +$NFT list ruleset | grep -q 'table ip t' || { + die "flushed owned table" +} + +$NFT add table 'ip t { flags owner, persist; }' && { + die "stole owned table" +} + +cat >&"${COPROC[1]}" <<EOF +delete table ip t +EOF + +[[ -z $($NFT list ruleset) ]] || { + die "owner should be able to delete the table" +} + +eval "exec ${COPROC[1]}>&-" +wait $COPROC_PID + + exit 0 diff --git a/tests/shell/testcases/owner/dumps/0002-persist.json-nft b/tests/shell/testcases/owner/dumps/0002-persist.json-nft index f0c336a86e52f..546cc5977db61 100644 --- a/tests/shell/testcases/owner/dumps/0002-persist.json-nft +++ b/tests/shell/testcases/owner/dumps/0002-persist.json-nft @@ -6,14 +6,6 @@ "release_name": "RELEASE_NAME", "json_schema_version": 1 } - }, - { - "table": { - "family": "ip", - "name": "t", - "handle": 0, - "flags": "persist" - } } ] } diff --git a/tests/shell/testcases/owner/dumps/0002-persist.nft b/tests/shell/testcases/owner/dumps/0002-persist.nft index b47027d35a30c..e69de29bb2d1d 100644 --- a/tests/shell/testcases/owner/dumps/0002-persist.nft +++ b/tests/shell/testcases/owner/dumps/0002-persist.nft @@ -1,3 +0,0 @@ -table ip t { - flags persist -}
Using a co-process, assert owner flag is effective. Signed-off-by: Phil Sutter <phil@nwl.cc> --- tests/shell/testcases/owner/0002-persist | 42 +++++++++++++++++++ .../owner/dumps/0002-persist.json-nft | 8 ---- .../testcases/owner/dumps/0002-persist.nft | 3 -- 3 files changed, 42 insertions(+), 11 deletions(-)