Paul Smith ac2142e1a3 * tests/*: Quote backticked command paths
When using Perl's backticks make sure that the path to the command
invoked is quoted.  On Windows, in particular, paths to commands such
as diff, etc. may contain whitespace.
2025-08-26 22:54:34 -04:00

93 lines
1.8 KiB
Perl

# -*-perl-*-
$description = "Test the realpath functions.";
$details = "";
# Check the local directory's realpath
run_make_test('
ifneq ($(realpath .),$(CURDIR))
$(warning $(realpath .) != $(CURDIR))
endif
ifneq ($(realpath ./),$(CURDIR))
$(warning $(realpath ./) != $(CURDIR))
endif
ifneq ($(realpath .///),$(CURDIR))
$(warning $(realpath .///) != $(CURDIR))
endif
.PHONY: all
all: ; @:
',
'', '');
# Find the realpath to the root of the partition
create_file('root.mk', 'all:;$(info $(realpath /))');
my $root = `"$make_path" -sf root.mk`;
unlink('root.mk');
$root =~ s/\r?\n//g;
my $tst = '
ifneq ($(realpath /.),#ROOT#)
$(warning $(realpath /.) != #ROOT#)
endif
ifneq ($(realpath /./),#ROOT#)
$(warning $(realpath /./) != #ROOT#)
endif
ifneq ($(realpath /.///),#ROOT#)
$(warning $(realpath /.///) != #ROOT#)
endif
ifneq ($(realpath /..),#ROOT#)
$(warning $(realpath /..) != #ROOT#)
endif
ifneq ($(realpath /../),#ROOT#)
$(warning $(realpath /../) != #ROOT#)
endif
ifneq ($(realpath /..///),#ROOT#)
$(warning $(realpath /..///) != #ROOT#)
endif
ifneq ($(realpath . /..),$(CURDIR) #ROOT#)
$(warning $(realpath . /..) != $(CURDIR) #ROOT#)
endif
.PHONY: all
all: ; @:
';
$tst =~ s/#ROOT#/$root/g;
run_make_test($tst, '', '');
# On Windows platforms "//" means something special. So, don't do these tests
# there.
if ($port_type ne 'W32') {
$tst = '
ifneq ($(realpath ///),#ROOT#)
$(warning $(realpath ///) != #ROOT#)
endif
ifneq ($(realpath ///.),#ROOT#)
$(warning $(realpath ///.) != #ROOT#)
endif
ifneq ($(realpath ///..),#ROOT#)
$(warning $(realpath ///..) != #ROOT#)
endif
.PHONY: all
all: ; @:';
$tst =~ s/#ROOT#/$root/g;
run_make_test($tst, '', '');
}
# This tells the test driver that the perl test script executed properly.
1;