Commit | Line | Data |
f1feeb72 |
1 | #!./perl |
2 | |
3 | BEGIN { |
4 | chdir 't' if -d 't'; |
5 | unshift @INC, '../lib'; |
6 | } |
7 | use Config; |
8 | use ExtUtils::Embed; |
9 | |
10 | open(my $fh,">embed_test.c") || die "Cannot open embed_test.c:$!"; |
11 | print $fh <DATA>; |
12 | close($fh); |
13 | |
14 | $| = 1; |
15 | print "1..9\n"; |
16 | my @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"; |
21 | print "not " if system(join(' ',@cmd)); |
22 | print "ok 1\n"; |
23 | print "not " if system("embed_test"); |
24 | print "ok 9\n"; |
25 | unlink("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 | |
38 | char *cmds[] = { "perl","-e", "print qq[ok 5\\n]", NULL }; |
39 | |
40 | int 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 | |