VirtualBox

source: kBuild/vendor/gnumake/current/tests/scripts/features/load

最後變更 在這個檔案是 3138,由 bird 提交於 7 年 前

Imported make 4.2.1 (2e55f5e4abdc0e38c1d64be703b446695e70b3b6) from https://git.savannah.gnu.org/git/make.git.

  • 屬性 svn:eol-style 設為 native
檔案大小: 2.7 KB
 
1# -*-perl-*-
2$description = "Test the load operator.";
3
4$details = "Test dynamic loading of modules.";
5
6# Don't do anything if this system doesn't support "load"
7exists $FEATURES{load} or return -1;
8
9# First build a shared object
10# Provide both a default and non-default load symbol
11
12unlink(qw(testload.c testload.so));
13
14open(my $F, '> testload.c') or die "open: testload.c: $!\n";
15print $F <<'EOF' ;
16#include <string.h>
17#include <stdio.h>
18
19#include "gnumake.h"
20
21int plugin_is_GPL_compatible;
22
23int
24testload_gmk_setup (gmk_floc *pos)
25{
26 (void)pos;
27 gmk_eval ("TESTLOAD = implicit", 0);
28 return 1;
29}
30
31int
32explicit_setup (gmk_floc *pos)
33{
34 (void)pos;
35 gmk_eval ("TESTLOAD = explicit", 0);
36 return 1;
37}
38EOF
39close($F) or die "close: testload.c: $!\n";
40
41# Make sure we can compile
42# CONFIG_FLAGS are loaded from config-flags.pm and set by configure
43
44my $sobuild = "$CONFIG_FLAGS{CC} ".($srcdir? "-I$srcdir":'')." $CONFIG_FLAGS{CPPFLAGS} $CONFIG_FLAGS{CFLAGS} -shared -fPIC $CONFIG_FLAGS{LDFLAGS} -o testload.so testload.c";
45
46my $clog = `$sobuild 2>&1`;
47if ($? != 0) {
48 $verbose and print "Failed to build testload.so:\n$sobuild\n$_";
49 return -1;
50}
51
52# TEST 1
53run_make_test(q!
54PRE := $(.LOADED)
55load testload.so
56POST := $(.LOADED)
57all: ; @echo pre=$(PRE) post=$(POST) $(TESTLOAD)
58!,
59 '--warn-undefined-variables', "pre= post=testload.so implicit\n");
60
61# TEST 2
62# Load using an explicit function
63run_make_test(q!
64PRE := $(.LOADED)
65load ./testload.so(explicit_setup)
66POST := $(.LOADED)
67all: ; @echo pre=$(PRE) post=$(POST) $(TESTLOAD)
68!,
69 '', "pre= post=testload.so explicit\n");
70
71# TEST 4
72# Check multiple loads
73run_make_test(q!
74PRE := $(.LOADED)
75load ./testload.so
76load testload.so(explicit_setup)
77POST := $(.LOADED)
78all: ; @echo pre=$(PRE) post=$(POST) $(TESTLOAD)
79!,
80 '', "pre= post=testload.so implicit\n");
81
82# TEST 5
83# Check auto-rebuild of loaded file that's out of date
84utouch(-10, 'testload.so');
85touch('testload.c');
86
87run_make_test(q!
88PRE := $(.LOADED)
89load ./testload.so
90POST := $(.LOADED)
91all: ; @echo pre=$(PRE) post=$(POST) $(TESTLOAD)
92testload.so: testload.c ; @echo "rebuilding $@"; !.$sobuild,
93 '', "rebuilding testload.so\npre= post=testload.so implicit\n");
94
95# TEST 5
96# Check auto-rebuild of loaded file when it doesn't exist
97unlink('testload.so');
98
99run_make_test(q!
100PRE := $(.LOADED)
101-load ./testload.so(explicit_setup)
102POST := $(.LOADED)
103all: ; @echo pre=$(PRE) post=$(POST) $(TESTLOAD)
104%.so: %.c ; @echo "rebuilding $@"; !.$sobuild,
105 '', "rebuilding testload.so\npre= post=testload.so explicit\n");
106
107unlink(qw(testload.c testload.so)) unless $keep;
108
109# This tells the test driver that the perl test script executed properly.
1101;
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette