[Spice-devel] [PATCH spice-common 2/2] test: Add a test for subject_to_x509_name function
Christophe Fergeau
cfergeau at redhat.com
Tue Jan 8 12:02:27 UTC 2019
On Tue, Dec 18, 2018 at 12:19:28PM -0500, Frediano Ziglio wrote:
> > On Thu, Dec 13, 2018 at 02:20:25PM +0000, Frediano Ziglio wrote:
> > > Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> > > ---
> > > common/ssl_verify.c | 5 +-
> > > common/ssl_verify.h | 4 ++
> > > tests/Makefile.am | 20 ++++++
> > > tests/test-ssl-verify.c | 141 ++++++++++++++++++++++++++++++++++++++++
> > > 4 files changed, 169 insertions(+), 1 deletion(-)
> > > create mode 100644 tests/test-ssl-verify.c
> > >
> > > diff --git a/common/ssl_verify.c b/common/ssl_verify.c
> > > index 74f95bb..3ccb52d 100644
> > > --- a/common/ssl_verify.c
> > > +++ b/common/ssl_verify.c
> > > @@ -278,7 +278,10 @@ static int verify_hostname(X509* cert, const char
> > > *hostname)
> > > return cn_match;
> > > }
> > >
> > > -static X509_NAME* subject_to_x509_name(const char *subject, int *nentries)
> > > +#if !ENABLE_EXTRA_CHECKS
> > > +static
> > > +#endif
> > > +X509_NAME* subject_to_x509_name(const char *subject, int *nentries)
> >
> > I'd prefer we don't go down that road...
> >
> > Christophe
> >
>
> Any alternative suggestion?
> Adding the test at the end of the module?
> #Include the source module into the test program?
>
> All are quite hacky but mocking/testing in C is often hacky.
#including "common/ssl_verify.c" sounds indeed like a better option, at
least the testing does not require changing the library code.
Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20190108/69346337/attachment.sig>
More information about the Spice-devel
mailing list