Skip Menu |

This queue is for tickets about the Devel-CheckLib CPAN distribution.

Report information
The Basics
Id: 61645
Status: new
Priority: 0/
Queue: Devel-CheckLib

People
Owner: Nobody in particular
Requestors: TONYC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: no way to define extra functions for use in test code
Devel::CheckLib allows a function parameter which can be used to supply the body for the main function, which is useful for testing the library. Unfortunately this doesn't allow testing where: - the library API accepts function pointer for callbacks - the library API defines macros for headers to be included For example with libfreetype, your C code starts out something like: #include <ft2build.h> #include FT_FREETYPE_H Attached, a patch that adds a prologue parameter.
Subject: checklib-prologue.diff
Index: Devel/CheckLib.pm =================================================================== --- Devel/CheckLib.pm (revision 1833) +++ Devel/CheckLib.pm (working copy) @@ -138,6 +138,23 @@ =back +If you need to perform know more than "does it link?" you can provide +code to be compiled and run: + +=over + +=item function + +the body of the <main()> function. If not provided C<return 0;> is +used. + +=item prologue + +code to insert between the C<#include> of the headers and the +definition of main. + +=back + =head2 check_lib_or_exit This behaves exactly the same as C<assert_lib()> except that instead of @@ -281,6 +298,7 @@ 'assertlibXXXXXXXX', SUFFIX => '.c' ); print $ch qq{#include <$_>\n} foreach (@headers); + print $ch "\n$args{prologue}\n" if $args{prologue}; print $ch "int main(void) { ".($args{function} || 'return 0;')." }\n"; close($ch); for my $link_cfg ( @link_cfgs ) {