2 $description = "Test the load operator.";
4 $details = "Test dynamic loading of modules.";
6 # Don't do anything if this system doesn't support "load"
7 exists $FEATURES{load} or return -1;
9 my $cc = get_config('CC');
11 $verbose and print "Skipping load test: no CC defined\n";
15 # First build a shared object
16 # Provide both a default and non-default load symbol
18 unlink(qw(testload.c testload.so));
20 open(my $F, '> testload.c') or die "open: testload.c: $!\n";
27 int plugin_is_GPL_compatible;
30 testload_gmk_setup (gmk_floc *pos)
33 gmk_eval ("TESTLOAD = implicit", 0);
38 explicit_setup (gmk_floc *pos)
41 gmk_eval ("TESTLOAD = explicit", 0);
45 close($F) or die "close: testload.c: $!\n";
47 # Make sure we can compile
49 my $cflags = get_config('CFLAGS');
50 my $cppflags = get_config('CPPFLAGS');
51 my $ldflags = get_config('LDFLAGS');
52 my $sobuild = "$cc ".($srcdir? "-I$srcdir/src":'')." $cppflags $cflags -shared -fPIC $ldflags -o testload.so testload.c";
54 my $clog = `$sobuild 2>&1`;
56 $verbose and print "Failed to build testload.so:\n$sobuild\n$_";
65 all: ; @echo pre=$(PRE) post=$(POST) $(TESTLOAD)
67 '--warn-undefined-variables', "pre= post=testload.so implicit\n");
70 # Load using an explicit function
73 load ./testload.so(explicit_setup)
75 all: ; @echo pre=$(PRE) post=$(POST) $(TESTLOAD)
77 '', "pre= post=testload.so explicit\n");
80 # Check multiple loads
84 load testload.so(explicit_setup)
86 all: ; @echo pre=$(PRE) post=$(POST) $(TESTLOAD)
88 '', "pre= post=testload.so implicit\n");
91 # Check auto-rebuild of loaded file that's out of date
92 utouch(-10, 'testload.so');
99 all: ; @echo pre=$(PRE) post=$(POST) $(TESTLOAD)
100 testload.so: testload.c ; @echo "rebuilding $@"; !.$sobuild,
101 '', "rebuilding testload.so\npre= post=testload.so implicit\n");
104 # Check auto-rebuild of loaded file when it doesn't exist
105 unlink('testload.so');
109 -load ./testload.so(explicit_setup)
111 all: ; @echo pre=$(PRE) post=$(POST) $(TESTLOAD)
112 %.so: %.c ; @echo "rebuilding $@"; !.$sobuild,
113 '', "rebuilding testload.so\npre= post=testload.so explicit\n");
115 unlink(qw(testload.c testload.so)) unless $keep;
117 # This tells the test driver that the perl test script executed properly.