VirtualBox

source: vbox/trunk/src/VBox/Storage/testcase/tstVDCompact.vd@ 67954

Last change on this file since 67954 was 66664, checked in by vboxsync, 7 years ago

Storage/testcase/*.vd: Add a few forgottin close() calls to delete all files

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 KB
Line 
1/* $Id: tstVDCompact.vd 66664 2017-04-24 18:42:49Z 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
18void 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, 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
48void tstSnapshotCompact(string strMsg, string strBackend)
49{
50 print(strMsg);
51
52 /* Create disk containers, read verification is on. */
53 createdisk("disk", true);
54 create("disk", "base", "tstCompact.disk", "dynamic", strBackend, 200M, false, false);
55
56 /* Fill the disk with random data. */
57 io("disk", false, 1, "seq", 64K, 0, 100M, 100M, 100, "none");
58
59 create("test", "diff", "tst2.disk", "dynamic", strBackend, 200M, false /* fIgnoreFlush */, true /* fHonorSame */);
60
61 io("disk", false, 1, "seq", 64K, 100M, 200M, 100M, 100, "none");
62 io("disk", false, 1, "seq", 64K, 100M, 150M, 50M, 100, "zero");
63
64 create("disk", "diff", "tst3.disk", "dynamic", strBackend, 200M, false /* fIgnoreFlush */, true /* fHonorSame */);
65 merge("disk", 1, 2);
66
67 compact("disk", 1);
68
69 close("disk", "single", true);
70 close("disk", "single", true);
71 close("disk", "single", true);
72 destroydisk("disk");
73}
74
75void main()
76{
77 /* Init I/O RNG for generating random data for writes. */
78 iorngcreate(10M, "manual", 1234567890);
79
80 /* Create zero pattern */
81 iopatterncreatefromnumber("zero", 1M, 0);
82
83 tstCompact("Testing VDI", "VDI");
84 tstCompact("Testing VHD", "VHD");
85
86 tstSnapshotCompact("Testing Snapshot VDI", "VDI");
87 tstSnapshotCompact("Testing Snapshot VHD", "VHD");
88
89 /* Destroy RNG and pattern */
90 iopatterndestroy("zero");
91 iorngdestroy();
92}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette