Config-AutoConf
view release on metacpan or search on metacpan
t/02.compile.t view on Meta::CPAN
ok $ac->check_types(["SV *", "AV *", "HV *"], {prologue => $include_perl}), "[SAH]V * are valid types";
# check size of perl types
my $typesize = $ac->check_sizeof_type("I32", {prologue => $include_perl});
ok $typesize, "I32 has size of " . ($typesize ? $typesize : "n/a") . " bytes";
ok $ac->check_sizeof_types(["I32", "SV *", "AV", "HV *", "SV.sv_refcnt"], {prologue => $include_perl}),
"Could determined sizes for I32, SV *, AV, HV *, SV.sv_refcnt";
my $compute = $ac->compute_int("-sizeof(I32)", {prologue => $include_perl});
cmp_ok($compute, "==", 0 - $typesize, "Compute (-sizeof(I32))");
# check perl data structure members
ok $ac->check_member("struct av.sv_any", {prologue => $include_perl}), "have struct av.sv_any member";
ok $ac->check_members(["struct hv.sv_any", "struct STRUCT_SV.sv_any"], {prologue => $include_perl}),
"have struct hv.sv_any and struct STRUCT_SV.sv_any members";
my $struct_in_struct_prlg = <<EOP;
struct S1 {
int i;
int j;
};
struct S2 {
struct S2 *next;
struct S1 s1;
};
EOP
ok $ac->check_member("struct S2.s1", {prologue => $struct_in_struct_prlg}), "have struct S2.s1 member";
# check aligning
ok $ac->check_alignof_type("I32", {prologue => $include_perl}), "Align of I32";
ok $ac->check_alignof_type("SV.sv_refcnt", {prologue => $include_perl}), "Align of SV.sv_refcnt";
ok $ac->check_alignof_types(["I32", "U32", "AV", "HV *", "SV.sv_refcnt"], {prologue => $include_perl}),
"Could determine the sizes of I32, U32, AV, HV *, SV.sv_refcnt";
#
# Let's take REGEXP structure members as of perlreapi to test check_members
#
my @members =
qw/jdd jdd2 engine mother_re extflags minlen minlenret gofs substrs nparens intflags pprivate lastparen lastcloseparen swap offs subbeg saved_copy sublen suboffset subcoffset prelen precomp wrapped wraplen seen_evals paren_names refcnt/;
ok(
$ac->check_members(
[map { "struct regexp.$_" } @members],
{
prologue => "#include \"EXTERN.h\"
#include \"perl.h\"
#include \"XSUB.h\""
}
),
"Check struct regexp"
);
Config::AutoConf->write_config_h();
ok(-f "config.h", "default config.h created");
my $fsize;
ok($fsize = (stat("config.h"))[7], "config.h contains content");
$ac->write_config_h();
ok(-f "config.h", "default config.h created");
cmp_ok((stat("config.h"))[7], ">", $fsize, "2nd config.h is bigger than first (more checks made)");
my ($fh, $fbuf, $dbuf);
open($fh, "<", "config.h");
{ local $/; $fbuf = <$fh>; }
close($fh);
if ($] < 5.008)
{
require IO::String;
$fh = IO::String->new($dbuf);
}
else
{
open($fh, "+>", \$dbuf);
}
$ac->write_config_h($fh);
close($fh);
$fh = undef;
cmp_ok($dbuf, "eq", $fbuf, "file and direct write computes equal");
like($dbuf, qr/COMPLETE_USELESS_DATATYPE/, "complete_useless_datatype in config.h even if injected");
TODO:
{
-f "META.yml" or $ENV{AUTOMATED_TESTING} = 1;
local $TODO = "Quick fix: TODO - analyse diag later" unless $ENV{AUTOMATED_TESTING};
my @old_logfh;
$dbuf = "";
if ($] < 5.008)
{
$fh = IO::String->new($dbuf);
}
else
{
open($fh, "+>", \$dbuf);
}
@old_logfh = @{$ac->{logfh}};
$ac->add_log_fh($fh);
cmp_ok(scalar @{$ac->{logfh}}, "==", 2, "Successfully added 2nd loghandle");
ok($ac->check_compile_perlapi(), "Could compile perl extensions") or diag($dbuf);
scalar @old_logfh and $ac->delete_log_fh($fh);
scalar @old_logfh and is_deeply(\@old_logfh, $ac->{logfh}, "add_log_fh/delete_log_fh");
defined $fh and close($fh);
$fh = undef;
}
SCOPE:
{
local $ENV{ac_cv_insane_h} = "/usr/include/insane.h";
my $insane_h = $ac->check_header("insane.h");
is($insane_h, $ENV{ac_cv_insane_h}, "Cache override for header files work");
}
done_testing;
( run in 1.008 second using v1.01-cache-2.11-cpan-39bf76dae61 )