VirtualBox

source: vbox/trunk/src/VBox/Storage/testcase/tstVDDiscard.vd@ 107044

Last change on this file since 107044 was 106061, checked in by vboxsync, 2 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.3 KB
Line 
1/* $Id: tstVDDiscard.vd 106061 2024-09-16 14:03:52Z vboxsync $ */
2/**
3 * Storage: Testcase for discarding data in a disk.
4 */
5
6/*
7 * Copyright (C) 2011-2024 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 main()
29{
30 /* Init I/O RNG for generating random data for writes. */
31 iorngcreate(10M, "manual", 1234567890);
32
33 print("Testing VDI");
34
35 /* Create disk containers, read verification is on. */
36 createdisk("disk", true /* fVerify */);
37 /* Create the disk. */
38 create("disk", "base", "tstCompact.vdi", "dynamic", "VDI", 2G, false /* fIgnoreFlush */, false);
39 /* Fill the disk with random data */
40 io("disk", false, 1, "seq", 64K, 0, 200M, 200M, 100, "none");
41 /* Read the data to verify it once. */
42 io("disk", false, 1, "seq", 64K, 0, 200M, 200M, 0, "none");
43 close("disk", "single", false);
44
45 open("disk", "tstCompact.vdi", "VDI", true, false, false, true, false, false);
46 printfilesize("disk", 0);
47 discard("disk", true, "6,0M,512K,1M,512K,2M,512K,3M,512K,4M,512K,5M,512K");
48 discard("disk", true, "6,6M,512K,7M,512K,8M,512K,9M,512K,10M,512K,11M,512K");
49 discard("disk", true, "1,512K,512K");
50 discard("disk", false, "1,1024K,64K");
51 printfilesize("disk", 0);
52
53 print("Discard whole block");
54 discard("disk", true, "1,20M,1M");
55 printfilesize("disk", 0);
56
57 print("Split Discard");
58 discard("disk", true, "1,21M,512K");
59 printfilesize("disk", 0);
60 discard("disk", true, "1,22016K,512K");
61 printfilesize("disk", 0);
62
63 /* Cleanup */
64 close("disk", "single", true);
65 destroydisk("disk");
66
67 /* Destroy RNG and pattern */
68 iorngdestroy();
69}
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