From 47ca2e98a51848142ef7d4994b45e92363006646 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Thu, 10 Jan 2019 19:21:33 +0000 Subject: [PATCH] testcrypt.py: look past 'opt_' prefix on argument types. When testcrypt.h lists a function argument as 'opt_val_foo', it means that the argument is optional in the sense that the C function can take a null pointer in place of a valid foo, and so the Python wrapper module should accept None in the corresponding argument slot from the client code and translate it into the special string "NULL" in the wire protocol. This works fine at argument translation time, but the code that reads testcrypt.h wasn't looking at it, so if you said 'opt_val_foo_suffix' in place of 'opt_val_foo' (indicating that that argument is optional _and_ the C function expects it in a translated form), then the initial pass over testcrypt.h wouldn't strip the _suffix, and would set up data structures with mismatched type names. --- test/testcrypt.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/testcrypt.py b/test/testcrypt.py index 77152429..69706d7a 100644 --- a/test/testcrypt.py +++ b/test/testcrypt.py @@ -190,9 +190,13 @@ def _setup(scope): prefix, suffix = "FUNC(", ")" valprefix = "val_" outprefix = "out_" + optprefix = "opt_" consprefix = "consumed_" def trim_argtype(arg): + if arg.startswith(optprefix): + return optprefix + trim_argtype(arg[len(optprefix):]) + if (arg.startswith(valprefix) and "_" in arg[len(valprefix):]): # Strip suffixes like val_string_asciz