Skip to contentSkip to conversation

tests: xlate: print tests passed and error for testfile argument

PATCH In review Harsha Sharma 2 participants 5 messages Oct 17, 2017 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 tests: xlate: print tests passed and error for testfile argument

Print tests passed with errors and warnings when run with only specified test file.

---
Changes in v2:
-Change subject
-print the errors if no argument is passed

 xlate-test.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xlate-test.py +2 -2
index 43c4be19..0a582af1 100755
@@ -51,7 +51,7 @@ def run_test(name, payload):
                     result.append(magenta("exp: ") + expected)
                     result.append(magenta("res: ") + translation + "\n")
                     test_passed = False
-                elif args.all:
+                elif args.all or args.test:
                     result.append(green("Ok"))
                     result.append(magenta("src: ") + line.rstrip(" \n"))
                     result.append(magenta("res: ") + translation + "\n")
@@ -60,7 +60,7 @@ def run_test(name, payload):
                 result.append(red("Error: ") + "iptables-translate failure")
                 result.append(error.decode("utf-8"))
 
-    if not test_passed or args.all:
+    if not test_passed or args.all or args.test:
         print("\n".join(result))
 
 
Signature · 1 line
2.11.0
#1 lore raw
Quoted 2 lines · Harsha Sharma

Print tests passed with errors and warnings when run with only specified test file.

I would expect this works like this, for consistency with other test infrastructure we have:

# python xlate-test.py extensions/libxt_ecn.txlate 
Error: test file does not exist

I can see here this works like this:

# python xlate-test.py libxt_ecn.txlate 

But as said, it is counterintuitive. Would you revisit this patch?

Thanks.

#2 lore raw
Quoted 7 lines · Pablo Neira Ayuso
Quoted 2 lines · Harsha Sharma

Print tests passed with errors and warnings when run with only specified test file.

I would expect this works like this, for consistency with other test infrastructure we have:

Quoted 8 lines
# python xlate-test.py extensions/libxt_ecn.txlate
Error: test file does not exist

I can see here this works like this:

# python xlate-test.py libxt_ecn.txlate

But as said, it is counterintuitive. Would you revisit this patch?

What I have tried to do int this patch is
for e.g.

# sudo python xlate-test.py libxt_ecn.txlate
will not result into any output as all tests are passed
but with this patch
# sudo python xlate-test.py libxt_ecn.txlate  (gives output)
## libxt_ecn
Ok
src: iptables-translate -A INPUT -m ecn --ecn-ip-ect 0
res: nft add rule ip filter INPUT ip ecn not-ect counter

Ok
src: iptables-translate -A INPUT -m ecn --ecn-ip-ect 1
res: nft add rule ip filter INPUT ip ecn ect1 counter

which is expected output as one should get to know if the tests are passed or not .

Thanks. Please let me know if this is expected output or not.

Quoted 2 lines

Thanks.

#3 lore raw
Quoted 28 lines · Harsha Sharma
Quoted 7 lines · Pablo Neira Ayuso
Quoted 2 lines · Harsha Sharma

Print tests passed with errors and warnings when run with only specified test file.

I would expect this works like this, for consistency with other test infrastructure we have:

Quoted 8 lines
# python xlate-test.py extensions/libxt_ecn.txlate
Error: test file does not exist

I can see here this works like this:

# python xlate-test.py libxt_ecn.txlate

But as said, it is counterintuitive. Would you revisit this patch?

What I have tried to do int this patch is
for e.g.

# sudo python xlate-test.py libxt_ecn.txlate
will not result into any output as all tests are passed
but with this patch
# sudo python xlate-test.py libxt_ecn.txlate  (gives output)
## libxt_ecn
Ok
src: iptables-translate -A INPUT -m ecn --ecn-ip-ect 0
res: nft add rule ip filter INPUT ip ecn not-ect counter
Quoted 8 lines

Ok
src: iptables-translate -A INPUT -m ecn --ecn-ip-ect 1
res: nft add rule ip filter INPUT ip ecn ect1 counter

which is expected output as one should get to know if the tests are passed or not .

Thanks. Please let me know if this is expected output or not.

I see, thanks for explaining.

I would prefer you make this converge with the output of iptables-test.py. It would be great if you can update the xlate-tests.py so the output looks the same.

Thanks!

#4 lore raw
Quoted 36 lines · Pablo Neira Ayuso
Quoted 35 lines · Harsha Sharma
Quoted 7 lines · Pablo Neira Ayuso
Quoted 2 lines · Harsha Sharma

Print tests passed with errors and warnings when run with only specified test file.

I would expect this works like this, for consistency with other test infrastructure we have:

Quoted 8 lines
# python xlate-test.py extensions/libxt_ecn.txlate
Error: test file does not exist

I can see here this works like this:

# python xlate-test.py libxt_ecn.txlate

But as said, it is counterintuitive. Would you revisit this patch?

What I have tried to do int this patch is
for e.g.

# sudo python xlate-test.py libxt_ecn.txlate
will not result into any output as all tests are passed
but with this patch
# sudo python xlate-test.py libxt_ecn.txlate  (gives output)
## libxt_ecn
Ok
src: iptables-translate -A INPUT -m ecn --ecn-ip-ect 0
res: nft add rule ip filter INPUT ip ecn not-ect counter

Ok
src: iptables-translate -A INPUT -m ecn --ecn-ip-ect 1
res: nft add rule ip filter INPUT ip ecn ect1 counter

which is expected output as one should get to know if the tests are passed or not .

Quoted 7 lines
Quoted 1 line

Thanks. Please let me know if this is expected output or not.

I see, thanks for explaining.

I would prefer you make this converge with the output of iptables-test.py. It would be great if you can update the xlate-tests.py so the output looks the same.

If you can fix xlate-tests.py to work with:

# python xlate-test.py extensions/libxt_ecn.txlate

that would be great too :-).