Skip to content

Commit a739c24

Browse files
committed
hack/test-port-forwarding.pl: use platform-independent path on hostSocket
Signed-off-by: Norio Nomura <[email protected]>
1 parent dab62e5 commit a739c24

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

hack/test-port-forwarding.pl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use warnings;
1717

1818
use Config qw(%Config);
19+
use File::Spec::Functions qw(catfile);
1920
use IO::Handle qw();
2021
use Socket qw(inet_ntoa);
2122
use Sys::Hostname qw(hostname);
@@ -35,6 +36,8 @@
3536

3637
my $instDir = qx(limactl list "$instance" --yq .dir);
3738
chomp $instDir;
39+
# platform independent way to add trailing path separator
40+
my $sockDir = catfile($instDir, "sock", "");
3841

3942
# If $instance is a filename, add our portForwards to it to enable testing
4043
if (-f $instance) {
@@ -97,10 +100,10 @@
97100
s/sshLocalPort/$sshLocalPort/g;
98101
s/ipv4/$ipv4/g;
99102
s/ipv6/$ipv6/g;
100-
s/instDir/$instDir/g;
103+
s/sockDir\//$sockDir/g;
101104
# forward: 127.0.0.1 899 → 127.0.0.1 799
102105
# ignore: 127.0.0.2 8888
103-
/^(forward|ignore):\s+([0-9.:]+)\s+(\d+)(?:\s+→)?(?:\s+(?:([0-9.:]+)(?:\s+(\d+))|(\/\S+))?)?/;
106+
/^(forward|ignore):\s+([0-9.:]+)\s+(\d+)(?:\s+→)?(?:\s+(?:([0-9.:]+)(?:\s+(\d+))|(\S+))?)?/;
104107
die "Cannot parse test '$_'" unless $1;
105108
my %test; @test{qw(mode guest_ip guest_port host_ip host_port host_socket)} = ($1, $2, $3, $4, $5, $6);
106109

@@ -350,6 +353,6 @@ sub JoinHostPort {
350353
hostIP: 0.0.0.0
351354
352355
- guestPort: 5000
353-
hostSocket: "{{.Dir}}/sock/port5000.sock"
356+
hostSocket: port5000.sock
354357
355-
# forward: 127.0.0.1 5000 → instDir/sock/port5000.sock
358+
# forward: 127.0.0.1 5000 → sockDir/port5000.sock

0 commit comments

Comments
 (0)