in reply to Testing dll/dso using Perl

If you're lucky, Win32::API will be all of the glue code that you need, at least on the Windows side. On the Unix side, Inline may be sufficient. The basic goal is to make the functions in the shared library available as Perl subroutines. From there, you can use Test::More and friends to test just as you would a normal Perl subroutine.

I'm not sure how much more detail you need. Which part is giving you trouble?

Replies are listed 'Best First'.
Re^2: Testing dll/dso using Perl
by Excalibor (Pilgrim) on Mar 23, 2005 at 09:35 UTC

    Another possibility is having a look at SWIG http://www.swig.org/ which allows you to easily create interfaces from C and C++ to many languages, including, of course, Perl.

    It's easy to use, it has an IDL to describe your code, and creates a .so/.dll you can use from your Perl program as a normal Perl package, unless your code is so diabolical it's really hard to easily map into Perl. In that case, Inline and perlxs are your friends (sort of, anyway).

    I guess those are the candidates, as well, if you are trying to test performance of some sort (although I fail now why would you test that from Perl, or which value would it have unless the production environment was similarly through Perl, but I digress...)

    Good luck!

    --
    our $Perl6 is Fantastic;

Re^2: Testing dll/dso using Perl
by hiradhu (Acolyte) on Mar 23, 2005 at 09:43 UTC
    Hi, Thanks for the response. It was a good start for me. But Win32::API documentation says "With this module you can import and call arbitrary functions from Win32's Dynamic Link Libraries (DLL), without having to write an XS extension. Note, however, that this module can't do anything (parameters input and output is limited to simpler cases), and anyway a regular XS extension is always safer and faster." The application I'm gona test is kind of complex. I may need PerlXS. For example: one of the interface method (to read a file) signature is: int FileSystemInputStream::Read(void* destination, size_t size, Common::LogContext& log, int logAndExceptionLevel) How to call this method in Perl to test its functionality? Can u pls thro light on PerlXS? Is it possible to use the same PerlXS on both Windows(dll) & Unix(dso)? Thanks a lot!
      If you are going to pass around complex objects, you might find it nessesary to use XS, but maybe Inline::CPP is smart enough to get it to work. Try inline first, it shouldn't take long to test, and you can always convert to XS later.

      XS is more low-level, meaning it requires you to "spell out" more of the C/Perl-interface code, but it also gives you the most flexibility. Swig is like XS but language-independant (and from what I heard, slightly easier than XS) but I haven't used it at all. Both Swig and Inline::C(PP) produce XS code, by the way.

      It's possible to use the same XS code in win32 and unix; it should be slightly easier than writing portable C, since you're linking against perl, which provides a lot of platform-independent routines. See perlapi, for instance.