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 $sobuild = '$(CC) '.($srcdir? "-I$srcdir":'').' -g -shared -fPIC -o $@ $<';
11 # First build a shared object
12 # Provide both a default and non-default load symbol
14 unlink(qw(testload.c testload.so));
16 open(my $F, '> testload.c') or die "open: testload.c: $!\n";
23 int plugin_is_GPL_compatible;
26 testload_gmk_setup (gmk_floc *pos)
28 gmk_eval ("TESTLOAD = implicit", 0);
33 explicit_setup (gmk_floc *pos)
35 gmk_eval ("TESTLOAD = explicit", 0);
39 close($F) or die "close: testload.c: $!\n";
41 # Make sure we can compile
42 run_make_test('testload.so: testload.c ; @'.$sobuild, '', '');
49 all: ; @echo pre=$(PRE) post=$(POST) $(TESTLOAD)
51 '', "pre= post=testload.so implicit\n");
54 # Load using an explicit function
57 load ./testload.so(explicit_setup)
59 all: ; @echo pre=$(PRE) post=$(POST) $(TESTLOAD)
61 '', "pre= post=testload.so explicit\n");
64 # Check multiple loads
68 load testload.so(explicit_setup)
70 all: ; @echo pre=$(PRE) post=$(POST) $(TESTLOAD)
72 '', "pre= post=testload.so implicit\n");
75 # Check auto-rebuild of loaded file that's out of date
76 utouch(-10, 'testload.so');
83 all: ; @echo pre=$(PRE) post=$(POST) $(TESTLOAD)
84 testload.so: testload.c ; @echo "rebuilding $@"; !.$sobuild,
85 '', "rebuilding testload.so\npre= post=testload.so implicit\n");
88 # Check auto-rebuild of loaded file when it doesn't exist
89 unlink('testload.so');
93 -load ./testload.so(explicit_setup)
95 all: ; @echo pre=$(PRE) post=$(POST) $(TESTLOAD)
96 %.so: %.c ; @echo "rebuilding $@"; !.$sobuild,
97 '', "rebuilding testload.so\npre= post=testload.so explicit\n");
99 unlink(qw(testload.c testload.so)) unless $keep;
101 # This tells the test driver that the perl test script executed properly.