mirror of
https://github.com/mirror/make.git
synced 2025-03-04 14:51:11 +08:00
[SV 63044] load: Update .LOADED if the setup function returns -1
* src/load.c (load_file): Update .LOADED if setup returns non-0. * tests/scripts/features/load: Change the return value based on an environment variable. Ensure that returning -1 still adds to .LOADED. Also add a test that verifies that make doesn't try to rebuild the loaded file if -1 is returned.
This commit is contained in:
parent
820210ab85
commit
77734be2af
@ -211,8 +211,9 @@ load_file (const floc *flocp, const char **ldname, int noerror)
|
|||||||
/* Invoke the symbol. */
|
/* Invoke the symbol. */
|
||||||
r = (*symp) (flocp);
|
r = (*symp) (flocp);
|
||||||
|
|
||||||
/* If it succeeded, add the load file to the loaded variable. */
|
/* If it succeeded, add the load file to the loaded variable.
|
||||||
if (r > 0)
|
Anything other than 0, including -1, is a success. */
|
||||||
|
if (r)
|
||||||
{
|
{
|
||||||
size_t loadlen = strlen (loaded);
|
size_t loadlen = strlen (loaded);
|
||||||
char *newval = alloca (loadlen + strlen (*ldname) + 2);
|
char *newval = alloca (loadlen + strlen (*ldname) + 2);
|
||||||
|
@ -19,11 +19,10 @@ unlink(qw(testload.c testload.so));
|
|||||||
|
|
||||||
open(my $F, '> testload.c') or die "open: testload.c: $!\n";
|
open(my $F, '> testload.c') or die "open: testload.c: $!\n";
|
||||||
print $F <<'EOF' ;
|
print $F <<'EOF' ;
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "gnumake.h"
|
#include "gnumake.h"
|
||||||
|
|
||||||
|
char* getenv (const char*);
|
||||||
|
|
||||||
int plugin_is_GPL_compatible;
|
int plugin_is_GPL_compatible;
|
||||||
|
|
||||||
int testload_gmk_setup (gmk_floc *);
|
int testload_gmk_setup (gmk_floc *);
|
||||||
@ -34,6 +33,8 @@ testload_gmk_setup (gmk_floc *pos)
|
|||||||
{
|
{
|
||||||
(void)pos;
|
(void)pos;
|
||||||
gmk_eval ("TESTLOAD = implicit", 0);
|
gmk_eval ("TESTLOAD = implicit", 0);
|
||||||
|
if (getenv("TESTAPI_KEEP"))
|
||||||
|
return -1;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,6 +43,8 @@ explicit_setup (gmk_floc *pos)
|
|||||||
{
|
{
|
||||||
(void)pos;
|
(void)pos;
|
||||||
gmk_eval ("TESTLOAD = explicit", 0);
|
gmk_eval ("TESTLOAD = explicit", 0);
|
||||||
|
if (getenv("TESTAPI_KEEP"))
|
||||||
|
return -1;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
@ -79,7 +82,7 @@ all: ; @echo pre=$(PRE) post=$(POST) $(TESTLOAD)
|
|||||||
!,
|
!,
|
||||||
'', "pre= post=testload.so explicit\n");
|
'', "pre= post=testload.so explicit\n");
|
||||||
|
|
||||||
# TEST 4
|
# TEST 3
|
||||||
# Check multiple loads
|
# Check multiple loads
|
||||||
run_make_test(q!
|
run_make_test(q!
|
||||||
PRE := $(.LOADED)
|
PRE := $(.LOADED)
|
||||||
@ -90,7 +93,7 @@ all: ; @echo pre=$(PRE) post=$(POST) $(TESTLOAD)
|
|||||||
!,
|
!,
|
||||||
'', "pre= post=testload.so implicit\n");
|
'', "pre= post=testload.so implicit\n");
|
||||||
|
|
||||||
# TEST 5
|
# TEST 4
|
||||||
# Check auto-rebuild of loaded file that's out of date
|
# Check auto-rebuild of loaded file that's out of date
|
||||||
utouch(-10, 'testload.so');
|
utouch(-10, 'testload.so');
|
||||||
touch('testload.c');
|
touch('testload.c');
|
||||||
@ -115,6 +118,32 @@ all: ; @echo pre=$(PRE) post=$(POST) $(TESTLOAD)
|
|||||||
%.so: %.c ; @echo "rebuilding $@"; !.$sobuild,
|
%.so: %.c ; @echo "rebuilding $@"; !.$sobuild,
|
||||||
'', "rebuilding testload.so\npre= post=testload.so explicit\n");
|
'', "rebuilding testload.so\npre= post=testload.so explicit\n");
|
||||||
|
|
||||||
|
# sv 63044.
|
||||||
|
# Test that the loaded shared object is present in .LOADED when the setup
|
||||||
|
# routine returns -1.
|
||||||
|
$ENV{TESTAPI_KEEP} = 1;
|
||||||
|
run_make_test(q!
|
||||||
|
PRE := $(.LOADED)
|
||||||
|
load testload.so
|
||||||
|
POST := $(.LOADED)
|
||||||
|
all: ; @echo pre=$(PRE) post=$(POST) $(TESTLOAD)
|
||||||
|
!,
|
||||||
|
'--warn-undefined-variables', "pre= post=testload.so implicit\n");
|
||||||
|
|
||||||
|
# Check that we don't auto-rebuild of loaded file that's out of date
|
||||||
|
# if we return -1 from the setup
|
||||||
|
utouch(-10, 'testload.so');
|
||||||
|
touch('testload.c');
|
||||||
|
|
||||||
|
$ENV{TESTAPI_KEEP} = 1;
|
||||||
|
run_make_test(q!
|
||||||
|
PRE := $(.LOADED)
|
||||||
|
load ./testload.so
|
||||||
|
POST := $(.LOADED)
|
||||||
|
all: ; @echo pre=$(PRE) post=$(POST) $(TESTLOAD)
|
||||||
|
testload.so: testload.c ; @echo "rebuilding $@"; !.$sobuild,
|
||||||
|
'', "pre= post=testload.so implicit\n");
|
||||||
|
|
||||||
unlink(qw(testload.c testload.so)) unless $keep;
|
unlink(qw(testload.c testload.so)) unless $keep;
|
||||||
|
|
||||||
# This tells the test driver that the perl test script executed properly.
|
# This tells the test driver that the perl test script executed properly.
|
||||||
|
Loading…
Reference in New Issue
Block a user