/** @file * * Test utility for new VBoxHDD functions. */ /* * Copyright (c) 2008 Kristian Vlaardingerbroek * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, * copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following * conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ #include #include #include #include #include #include static void VDErrorCallback(void *pvUser, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va) { /* @todo Do something here. */ } int dotest(const char *pszFilename) { PVBOXHDD pDisk = NULL; int rc = VINF_SUCCESS; #define CHECK(str) \ do \ { \ RTPrintf("%s rc=%Vrc\n", str, rc); \ if (VBOX_FAILURE(rc)) \ { \ VDCloseAll(pDisk); \ return rc; \ } \ } while (0) rc = VDCreate("VDI", VDErrorCallback, NULL, &pDisk); CHECK("VDCreate()"); PDMMEDIAGEOMETRY PCHSGeometry = {1, 1, 1}; PDMMEDIAGEOMETRY LCHSGeometry = {0, 0, 0}; rc = VDCreateBase(pDisk, pszFilename, VD_IMAGE_TYPE_NORMAL, (1000 * 1024 * 1024ULL), VD_IMAGE_FLAGS_NONE, "Test image", &PCHSGeometry, &LCHSGeometry, VD_OPEN_FLAGS_NORMAL, NULL, NULL); CHECK("VDCreateBase()"); VDCloseAll(pDisk); #undef CHECK return 0; } int main() { RTR3Init(); RTFileDelete("tmpVBoxHDD.vdi"); int rc = dotest("tmpVBoxHDD.vdi"); if (!rc) RTPrintf("tstVBoxHDD: SUCCESS\n"); else RTPrintf("tstVBoxHDD: FAILURE\n"); return !!rc; }