-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.pl
More file actions
executable file
·57 lines (41 loc) · 1.37 KB
/
test.pl
File metadata and controls
executable file
·57 lines (41 loc) · 1.37 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/perl
use strict;
use warnings;
use feature 'say';
use Getopt::Long;
use Test::More tests => 5;
my $keep_vbox_vm;
GetOptions( 'keep' => \$keep_vbox_vm);
my $disk = $ARGV[0];
if ($disk && ! -f $disk){
die "usage: $0 [ --keep ] disk image" if ! -f $disk;
}
$disk = "ubuntu-18.04-minimal-cloudimg-amd64.img" if ! $disk;
if (! -f $disk) {
system("wget https://cloud-images.ubuntu.com/minimal/releases/bionic/release/$disk");
}
my $vm_name = 'test_vm';
assert("./import2vbox.pl --vcpus 2 --memory 384 $disk --name $vm_name",
'successfull ovf generation');
assert("VBoxManage import ${vm_name}.ovf", "VBoxManage import ${vm_name}.ovf");
assert("ovftool --verifyOnly ${vm_name}.ovf", "ovftool --verifyOnly ${vm_name}.ovf");
open my $conf, "-|", "VBoxManage showvminfo $vm_name --machinereadable";
while (<$conf>) {
if ($_ =~ m/^storagecontrollerportcount0="(.+)"$/) {
my $sata_port_count = $1;
ok($sata_port_count == 1, "1 SATA port found");
}
if ($_ =~ m/^graphicscontroller="(.+)"$/) {
my $display_type = $1;
ok($display_type eq "vmsvga", "Default display set to vmsvga");
}
}
done_testing();
system("VBoxManage unregistervm $vm_name --delete >/dev/null 2>&1") if !$keep_vbox_vm;
unlink "${vm_name}.ovf";
unlink "ubuntu-18.vmdk";
sub assert {
my ($command, $description) = @_;
my $rc = system("$command >/dev/null 2>&1");
ok($rc == 0, $description);
}