VirtualBox

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

Last change on this file since 97698 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 KB
Line 
1/* $Id: tstVDCompact.vd 96407 2022-08-22 17:43:14Z vboxsync $ */
2/**
3 * Storage: Testcase for compacting disks.
4 */
5
6/*
7 * Copyright (C) 2011-2022 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28void tstCompact(string strMsg, string strBackend)
29{
30 print(strMsg);
31
32 /* Create disk containers, read verification is on. */
33 createdisk("disk", true);
34 create("disk", "base", "tstCompact.disk", "dynamic", strBackend, 200M, false, false);
35
36 /* Fill the disk with random data. */
37 io("disk", false, 1, "seq", 64K, 0, 200M, 200M, 100, "none");
38 /* Read the data to verify it once. */
39 io("disk", false, 1, "seq", 64K, 0, 200M, 200M, 0, "none");
40 /* Fill a part with 0's. */
41 io("disk", false, 1, "seq", 64K, 100M, 150M, 50M, 100, "zero");
42
43 /* Now compact. */
44 compact("disk", 0);
45 /* Read again to verify that the content hasn't changed. */
46 io("disk", false, 1, "seq", 64K, 0, 200M, 200M, 0, "none");
47 /* Fill everything with 0. */
48 io("disk", false, 1, "seq", 64K, 0, 200M, 200M, 100, "zero");
49 /* Now compact again. */
50 compact("disk", 0);
51 /* Read again to verify that the content hasn't changed. */
52 io("disk", false, 1, "seq", 64K, 0, 200M, 200M, 0, "none");
53
54 close("disk", "single", true);
55 destroydisk("disk");
56}
57
58void tstSnapshotCompact(string strMsg, string strBackend)
59{
60 print(strMsg);
61
62 /* Create disk containers, read verification is on. */
63 createdisk("disk", true);
64 create("disk", "base", "tstCompact.disk", "dynamic", strBackend, 200M, false, false);
65
66 /* Fill the disk with random data. */
67 io("disk", false, 1, "seq", 64K, 0, 100M, 100M, 100, "none");
68
69 create("test", "diff", "tst2.disk", "dynamic", strBackend, 200M, false /* fIgnoreFlush */, true /* fHonorSame */);
70
71 io("disk", false, 1, "seq", 64K, 100M, 200M, 100M, 100, "none");
72 io("disk", false, 1, "seq", 64K, 100M, 150M, 50M, 100, "zero");
73
74 create("disk", "diff", "tst3.disk", "dynamic", strBackend, 200M, false /* fIgnoreFlush */, true /* fHonorSame */);
75 merge("disk", 1, 2);
76
77 compact("disk", 1);
78
79 close("disk", "single", true);
80 close("disk", "single", true);
81 close("disk", "single", true);
82 destroydisk("disk");
83}
84
85void main()
86{
87 /* Init I/O RNG for generating random data for writes. */
88 iorngcreate(10M, "manual", 1234567890);
89
90 /* Create zero pattern */
91 iopatterncreatefromnumber("zero", 1M, 0);
92
93 tstCompact("Testing VDI", "VDI");
94 tstCompact("Testing VHD", "VHD");
95
96 tstSnapshotCompact("Testing Snapshot VDI", "VDI");
97 tstSnapshotCompact("Testing Snapshot VHD", "VHD");
98
99 /* Destroy RNG and pattern */
100 iopatterndestroy("zero");
101 iorngdestroy();
102}
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