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 # First build a shared object
10 # Provide both a default and non-default load symbol
12 unlink(qw(testload.c testload.so));
14 open(my $F, '> testload.c') or die "open: testload.c: $!\n";
19 void define_new_function (void *, const char *, int, int, int,
20 char *(*)(char *, char **, const char *));
22 char *variable_buffer_output (char *, const char *, unsigned int);
25 func_test(char *o, char **argv, const char *funcname)
27 return variable_buffer_output (o, funcname, strlen (funcname));
31 testload_gmake_setup ()
33 define_new_function (0, "func-a", 1, 1, 1, func_test);
40 define_new_function (0, "func-b", 1, 1, 1, func_test);
44 close($F) or die "close: testload.c: $!\n";
46 run_make_test('testload.so: testload.c ; @$(CC) -g -shared -fPIC -o $@ $<',
51 all: ; @echo $(func-a foo) $(func-b bar)
57 # Load a different function
59 all: ; @echo $(func-a foo) $(func-b bar)
60 load ./testload.so(explicit_setup)
65 # Verify the .LOADED variable
67 all: ; @echo $(filter ./testload.so,$(.LOADED)) $(func-a foo) $(func-b bar)
68 load ./testload.so(explicit_setup)
70 '', "./testload.so func-b\n");
73 # Check multiple loads
75 all: ; @echo $(filter ./testload.so,$(.LOADED)) $(func-a foo) $(func-b bar)
77 load ./testload.so(explicit_setup)
79 '', "./testload.so func-a\n");
81 unlink(qw(testload.c testload.so)) unless $keep;
83 # This tells the test driver that the perl test script executed properly.