1 | /* $Id: tstVDShareable.vd 52371 2014-08-13 19:00:27Z vboxsync $ */
|
---|
2 | /**
|
---|
3 | * Storage: Testcase for shareable 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 main()
|
---|
19 | {
|
---|
20 | /* Init I/O RNG for generating random data for writes. */
|
---|
21 | iorngcreate(10M, "manual", 1234567890);
|
---|
22 |
|
---|
23 | /* Create disk containers. */
|
---|
24 | createdisk("shared1", false);
|
---|
25 | createdisk("shared2", false);
|
---|
26 |
|
---|
27 | /* Create the disk and close it. */
|
---|
28 | create("shared1", "base", "tstShared.vdi", "fixed", "VDI", 20M, false, false);
|
---|
29 | close("shared1", "all", false);
|
---|
30 |
|
---|
31 | /* Open the disk with sharing enabled. */
|
---|
32 | open("shared1", "tstShared.vdi", "VDI", true /* fAsync */, true /* fShareable */, false, false, false, false);
|
---|
33 | open("shared2", "tstShared.vdi", "VDI", true /* fAsync */, true /* fShareable */, false, false, false, false);
|
---|
34 |
|
---|
35 | /* Write to one disk and verify that the other disk can see the content. */
|
---|
36 | io("shared1", true, 32, "seq", 64K, 0, 20M, 20M, 100, "none");
|
---|
37 | comparedisks("shared1", "shared2");
|
---|
38 |
|
---|
39 | /* Write to the second disk and verify that the first can see the content. */
|
---|
40 | io("shared2", true, 64, "seq", 8K, 0, 20M, 20M, 50, "none");
|
---|
41 | comparedisks("shared1", "shared2");
|
---|
42 |
|
---|
43 | /* Close but don't delete yet. */
|
---|
44 | close("shared1", "all", false);
|
---|
45 | close("shared2", "all", false);
|
---|
46 |
|
---|
47 | /* Open and delete. */
|
---|
48 | open("shared1", "tstShared.vdi", "VDI", false /* fAsync */, false /* fShareable */, false, false, false, false);
|
---|
49 | close("shared1", "single", true);
|
---|
50 |
|
---|
51 | /* Cleanup */
|
---|
52 | destroydisk("shared1");
|
---|
53 | destroydisk("shared2");
|
---|
54 | iorngdestroy();
|
---|
55 | }
|
---|
56 |
|
---|