Adapt testcase from Doug Maceachern <dougm@covalent.net> for perlio_destruct
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / Embed.t
CommitLineData
f1feeb72 1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
5 unshift @INC, '../lib';
6}
7use Config;
8use ExtUtils::Embed;
9
10open(my $fh,">embed_test.c") || die "Cannot open embed_test.c:$!";
11print $fh <DATA>;
12close($fh);
13
14$| = 1;
15print "1..9\n";
16my @cmd = ($Config{'cc'},-o => 'embed_test',"-I$INC[0]/..",
17 ccopts(),
18 'embed_test.c',"-L$INC[0]/..",'-lperl',ldopts()
19 );
20#print "#@cmd\n";
21print "not " if system(join(' ',@cmd));
22print "ok 1\n";
23print "not " if system("embed_test");
24print "ok 9\n";
25unlink("embed_test","embed_test.c");
26
27#gcc -g -I.. -L../ -o perl_test perl_test.c -lperl `../perl -I../lib -MExtUtils::Embed -I../ -e ccopts -e ldopts`
28
29__END__
30
31/* perl_test.c */
32
33#include <EXTERN.h>
34#include <perl.h>
35
36#define my_puts(a) if(puts(a) < 0) exit(666)
37
38char *cmds[] = { "perl","-e", "print qq[ok 5\\n]", NULL };
39
40int main(int argc, char **argv, char **env)
41{
42 PerlInterpreter *my_perl = perl_alloc();
43
44 my_puts("ok 2");
45
46 perl_construct(my_perl);
47
48 my_puts("ok 3");
49
50 perl_parse(my_perl, NULL, (sizeof(cmds)/sizeof(char *))-1, cmds, env);
51
52 my_puts("ok 4");
53
54 fflush(stdout);
55
56 perl_run(my_perl);
57
58 my_puts("ok 6");
59
60 perl_destruct(my_perl);
61
62 my_puts("ok 7");
63
64 perl_free(my_perl);
65
66 my_puts("ok 8");
67
68 return 0;
69}
70
71
72
73