VirtualBox

source: kBuild/vendor/gnumake/current/tests/scripts/features/loadapi@ 3208

最後變更 在這個檔案從3208是 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 shared object load API.";
3
4$details = "Verify the different aspects of the shared object API.";
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(testapi.c testapi.so));
13
14open(my $F, '> testapi.c') or die "open: testapi.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
23static char *
24test_eval (const char *buf)
25{
26 gmk_eval (buf, 0);
27 return NULL;
28}
29
30static char *
31test_expand (const char *val)
32{
33 return gmk_expand (val);
34}
35
36static char *
37test_noexpand (const char *val)
38{
39 char *str = gmk_alloc (strlen (val) + 1);
40 strcpy (str, val);
41 return str;
42}
43
44static char *
45func_test (const char *funcname, unsigned int argc, char **argv)
46{
47 char *mem;
48
49 if (strcmp (funcname, "test-expand") == 0)
50 return test_expand (argv[0]);
51
52 if (strcmp (funcname, "test-eval") == 0)
53 return test_eval (argv[0]);
54
55 if (strcmp (funcname, "test-noexpand") == 0)
56 return test_noexpand (argv[0]);
57
58 mem = gmk_alloc (sizeof ("unknown"));
59 strcpy (mem, "unknown");
60 return mem;
61}
62
63int
64testapi_gmk_setup ()
65{
66 gmk_add_function ("test-expand", func_test, 1, 1, GMK_FUNC_DEFAULT);
67 gmk_add_function ("test-noexpand", func_test, 1, 1, GMK_FUNC_NOEXPAND);
68 gmk_add_function ("test-eval", func_test, 1, 1, GMK_FUNC_DEFAULT);
69 gmk_add_function ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.", func_test, 0, 0, 0);
70 return 1;
71}
72EOF
73close($F) or die "close: testapi.c: $!\n";
74
75my $sobuild = "$CONFIG_FLAGS{CC} ".($srcdir? "-I$srcdir":'')." $CONFIG_FLAGS{CPPFLAGS} $CONFIG_FLAGS{CFLAGS} -shared -fPIC $CONFIG_FLAGS{LDFLAGS} -o testapi.so testapi.c";
76
77my $clog = `$sobuild 2>&1`;
78if ($? != 0) {
79 $verbose and print "Failed to build testapi.so:\n$sobuild\n$_";
80 return -1;
81}
82
83# TEST 1
84# Check the gmk_expand() function
85run_make_test(q!
86EXPAND = expansion
87all: ; @echo $(test-expand $$(EXPAND))
88load testapi.so
89!,
90 '', "expansion\n");
91
92# TEST 2
93# Check the eval operation. Prove that the argument is expanded only once
94run_make_test(q!
95load testapi.so
96TEST = bye
97ASSIGN = VAR = $(TEST) $(shell echo there)
98$(test-eval $(value ASSIGN))
99TEST = hi
100all:;@echo '$(VAR)'
101!,
102 '', "hi there\n");
103
104# TEST 2
105# Check the no-expand capability
106run_make_test(q!
107load testapi.so
108TEST = hi
109all:;@echo '$(test-noexpand $(TEST))'
110!,
111 '', "\$(TEST)\n");
112
113unlink(qw(testapi.c testapi.so)) unless $keep;
114
115# This tells the test driver that the perl test script executed properly.
1161;
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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