1 | /* $Id: tstVDCompact.vd 44943 2013-03-06 23:07:00Z vboxsync $ */
|
---|
2 | /**
|
---|
3 | * Storage: Testcase for compacting disks.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2011 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | void tstCompact(string strMsg, string strBackend)
|
---|
19 | {
|
---|
20 | print(strMsg);
|
---|
21 |
|
---|
22 | /* Create disk containers, read verification is on. */
|
---|
23 | createdisk("disk", true);
|
---|
24 | create("disk", "base", "tstCompact.disk", "dynamic", strBackend, 200M, false);
|
---|
25 |
|
---|
26 | /* Fill the disk with random data. */
|
---|
27 | io("disk", false, 1, "seq", 64K, 0, 200M, 200M, 100, "none");
|
---|
28 | /* Read the data to verify it once. */
|
---|
29 | io("disk", false, 1, "seq", 64K, 0, 200M, 200M, 0, "none");
|
---|
30 | /* Fill a part with 0's. */
|
---|
31 | io("disk", false, 1, "seq", 64K, 100M, 150M, 50M, 100, "zero");
|
---|
32 |
|
---|
33 | /* Now compact. */
|
---|
34 | compact("disk", 0);
|
---|
35 | /* Read again to verify that the content hasn't changed. */
|
---|
36 | io("disk", false, 1, "seq", 64K, 0, 200M, 200M, 0, "none");
|
---|
37 | /* Fill everything with 0. */
|
---|
38 | io("disk", false, 1, "seq", 64K, 0, 200M, 200M, 100, "zero");
|
---|
39 | /* Now compact again. */
|
---|
40 | compact("disk", 0);
|
---|
41 | /* Read again to verify that the content hasn't changed. */
|
---|
42 | io("disk", false, 1, "seq", 64K, 0, 200M, 200M, 0, "none");
|
---|
43 |
|
---|
44 | close("disk", "single", true);
|
---|
45 | destroydisk("disk");
|
---|
46 | }
|
---|
47 |
|
---|
48 | void main()
|
---|
49 | {
|
---|
50 | /* Init I/O RNG for generating random data for writes. */
|
---|
51 | iorngcreate(10M, "manual", 1234567890);
|
---|
52 |
|
---|
53 | /* Create zero pattern */
|
---|
54 | iopatterncreatefromnumber("zero", 1M, 0);
|
---|
55 |
|
---|
56 | tstCompact("Testing VDI", "VDI");
|
---|
57 | tstCompact("Testing VHD", "VHD");
|
---|
58 |
|
---|
59 | /* Destroy RNG and pattern */
|
---|
60 | iopatterndestroy("zero");
|
---|
61 | iorngdestroy();
|
---|
62 | }
|
---|