summaryrefslogtreecommitdiff
path: root/tests/autotest-remote-server.pl
blob: a8410a15bbb53603a96c3e2d10da8f467ab7c4f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/perl

use IO::Socket;

$vm = shift;
$log = shift;

# start virtualbox gui in minimized mode - this should be the first thing we do since this process
# inherits all handles and we want our sockets/log file closed
system("start /min virtualbox --startvm $vm");

# start a server; vm will connect to the server via autotest-remote-host.pl
my $server = new IO::Socket::INET(LocalPort => 7183, Listen => 1);
die "Could not create socket: $!\n" unless $server;

open LOG, ">> $log" || die "Could not open log file: $!\n";

print LOG "Listening for connection...\n";

my $client = $server->accept();

# echo all input to log file
print LOG $_ while (<$client>);
close LOG;

$client->close();
$server->close();