From 0f544f1ea84276cba649b68ed09a5c6a9faf768b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 27 Apr 2011 09:54:17 +0000 Subject: [PATCH] * Add a command `forwardPort' to forward a TCP port on the host to a TCP port on the guest. Useful during testing (e.g. to access a web server in the guest through a web browser on the host). svn path=/nixos/trunk/; revision=26987 --- lib/test-driver/Machine.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/test-driver/Machine.pm b/lib/test-driver/Machine.pm index 919ab7c0764..68b374c86aa 100644 --- a/lib/test-driver/Machine.pm +++ b/lib/test-driver/Machine.pm @@ -519,4 +519,14 @@ sub sleep { } +# Forward a TCP port on the host to a TCP port on the guest. Useful +# during interactive testing. +sub forwardPort { + my ($self, $hostPort, $guestPort) = @_; + $hostPort = 8080 unless defined $hostPort; + $guestPort = 80 unless defined $guestPort; + $self->sendMonitorCommand("hostfwd_add tcp::$hostPort-:$guestPort"); +} + + 1;