1 | /* $Id: tstVDDiscard.vd 44943 2013-03-06 23:07:00Z vboxsync $ */
|
---|
2 | /**
|
---|
3 | * Storage: Testcase for discarding data in a disk.
|
---|
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 main()
|
---|
19 | {
|
---|
20 | /* Init I/O RNG for generating random data for writes. */
|
---|
21 | iorngcreate(10M, "manual", 1234567890);
|
---|
22 |
|
---|
23 | print("Testing VDI");
|
---|
24 |
|
---|
25 | /* Create disk containers, read verification is on. */
|
---|
26 | createdisk("disk", true /* fVerify */);
|
---|
27 | /* Create the disk. */
|
---|
28 | create("disk", "base", "tstCompact.vdi", "dynamic", "VDI", 2G, false /* fIgnoreFlush */);
|
---|
29 | /* Fill the disk with random data */
|
---|
30 | io("disk", false, 1, "seq", 64K, 0, 2G, 2G, 100, "none");
|
---|
31 | /* Read the data to verify it once. */
|
---|
32 | io("disk", false, 1, "seq", 64K, 0, 2G, 2G, 0, "none");
|
---|
33 | close("disk", "single", false);
|
---|
34 |
|
---|
35 | open("disk", "tstCompact.vdi", "VDI", true, false, false, true, false);
|
---|
36 | printfilesize("disk", 0);
|
---|
37 | discard("disk", true, "6,0M,512K,1M,512K,2M,512K,3M,512K,4M,512K,5M,512K");
|
---|
38 | discard("disk", true, "6,6M,512K,7M,512K,8M,512K,9M,512K,10M,512K,11M,512K");
|
---|
39 | discard("disk", true, "1,512K,512K");
|
---|
40 | discard("disk", false, "1,1024K,64K");
|
---|
41 | printfilesize("disk", 0);
|
---|
42 |
|
---|
43 | print("Discard whole block");
|
---|
44 | discard("disk", true, "1,20M,1M");
|
---|
45 | printfilesize("disk", 0);
|
---|
46 |
|
---|
47 | print("Split Discard");
|
---|
48 | discard("disk", true, "1,21M,512K");
|
---|
49 | printfilesize("disk", 0);
|
---|
50 | discard("disk", true, "1,22016K,512K");
|
---|
51 | printfilesize("disk", 0);
|
---|
52 |
|
---|
53 | /* Cleanup */
|
---|
54 | close("disk", "single", true);
|
---|
55 | destroydisk("disk");
|
---|
56 |
|
---|
57 | /* Destroy RNG and pattern */
|
---|
58 | iorngdestroy();
|
---|
59 | }
|
---|