VirtualBox

Changeset 46300 in vbox for trunk/src/VBox/Devices/VMMDev


Ignore:
Timestamp:
May 28, 2013 3:31:18 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
86048
Message:

VMMDev: Fixed missing destructor call (not in function table, duh.) and integrated the testing output with RTTest.

Location:
trunk/src/VBox/Devices/VMMDev
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/VMMDev/VMMDev.cpp

    r45025 r46300  
    35663566 * @interface_method_impl{PDMDEVREG,pfnDestruct}
    35673567 */
    3568 static DECLCALLBACK(int) vmmdevDestroy(PPDMDEVINS pDevIns)
     3568static DECLCALLBACK(int) vmmdevDestruct(PPDMDEVINS pDevIns)
    35693569{
    35703570    PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);
     
    35803580        pThis->pCredentials = NULL;
    35813581    }
     3582
     3583#ifndef VBOX_WITHOUT_TESTING_FEATURES
     3584    /*
     3585     * Clean up the testing device.
     3586     */
     3587    vmmdevTestingTerminate(pDevIns);
     3588#endif
    35823589
    35833590    return VINF_SUCCESS;
     
    36723679                                  "GuestCoreDumpDir|"
    36733680                                  "GuestCoreDumpCount|"
    3674                                   "TestingEnabled"
     3681                                  "TestingEnabled|"
     3682                                  "TestintXmlOutputFile"
    36753683                                  ,
    36763684                                  "");
     
    37303738        return PDMDEV_SET_ERROR(pDevIns, rc,
    37313739                                N_("Configuration error: Failed querying \"TestingEnabled\" as a boolean"));
     3740    rc = CFGMR3QueryStringAllocDef(pCfg, "TestintXmlOutputFile", &pThis->pszTestingXmlOutput, NULL);
     3741    if (RT_FAILURE(rc))
     3742        return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed querying \"TestintXmlOutputFile\" as a string"));
    37323743    /** @todo image-to-load-filename? */
    37333744#endif
     
    39133924    vmmdevConstruct,
    39143925    /* pfnDestruct */
    3915     NULL,
     3926    vmmdevDestruct,
    39163927    /* pfnRelocate */
    39173928    vmmdevRelocate,
  • trunk/src/VBox/Devices/VMMDev/VMMDevState.h

    r44777 r46300  
    55
    66/*
    7  * Copyright (C) 2006-2012 Oracle Corporation
     7 * Copyright (C) 2006-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2222#include <VBox/vmm/pdmdev.h>
    2323#include <VBox/vmm/pdmifs.h>
     24#ifndef VBOX_WITHOUT_TESTING_FEATURES
     25# include <iprt/test.h>
     26#endif
    2427
    2528#define VMMDEV_WITH_ALT_TIMESYNC
     
    348351        } Value;
    349352    } TestingData;
     353    /** The XML output file name (can be a named pipe, doesn't matter to us). */
     354    R3PTRTYPE(char *)       pszTestingXmlOutput;
     355    /** Testing instance for dealing with the output. */
     356    RTTEST                  hTestingTest;
    350357#endif /* !VBOX_WITHOUT_TESTING_FEATURES */
    351358} VMMDevState;
  • trunk/src/VBox/Devices/VMMDev/VMMDevTesting.cpp

    r44528 r46300  
    3232#include <iprt/string.h>
    3333#include <iprt/time.h>
    34 #ifdef IN_RING3
    35 # include <iprt/stream.h>
    36 #endif
     34#include <iprt/test.h>
    3735
    3836#include "VMMDevState.h"
     
    4745        LogAlways(a);\
    4846        LogRel(a);\
    49         RTPrintf a; \
    5047    } while (0)
    5148
     
    235232                        {
    236233#ifdef IN_RING3
     234                            pThis->TestingData.String.sz[off] = '\0';
    237235                            switch (uCmd)
    238236                            {
    239237                                case VMMDEV_TESTING_CMD_INIT:
    240                                     VMMDEV_TESTING_OUTPUT(("testing: INIT '%.*s'\n",
    241                                                            sizeof(pThis->TestingData.String.sz) - 1, pThis->TestingData.String.sz));
     238                                    VMMDEV_TESTING_OUTPUT(("testing: INIT '%s'\n", pThis->TestingData.String.sz));
     239                                    RTTestChangeName(pThis->hTestingTest, pThis->TestingData.String.sz);
     240                                    RTTestBanner(pThis->hTestingTest);
    242241                                    break;
    243242                                case VMMDEV_TESTING_CMD_SUB_NEW:
    244                                     VMMDEV_TESTING_OUTPUT(("testing: SUB_NEW  '%.*s'\n",
    245                                                            sizeof(pThis->TestingData.String.sz) - 1, pThis->TestingData.String.sz));
     243                                    VMMDEV_TESTING_OUTPUT(("testing: SUB_NEW  '%s'\n", pThis->TestingData.String.sz));
     244                                    RTTestSub(pThis->hTestingTest, pThis->TestingData.String.sz);
    246245                                    break;
    247246                                case VMMDEV_TESTING_CMD_FAILED:
    248                                     VMMDEV_TESTING_OUTPUT(("testing: FAILED '%.*s'\n",
    249                                                            sizeof(pThis->TestingData.String.sz) - 1, pThis->TestingData.String.sz));
     247                                    RTTestFailed(pThis->hTestingTest, "%s", pThis->TestingData.String.sz);
     248                                    VMMDEV_TESTING_OUTPUT(("testing: FAILED '%s'\n", pThis->TestingData.String.sz));
    250249                                    break;
    251250                                case VMMDEV_TESTING_CMD_SKIPPED:
    252                                     VMMDEV_TESTING_OUTPUT(("testing: SKIPPED '%.*s'\n",
    253                                                            sizeof(pThis->TestingData.String.sz) - 1, pThis->TestingData.String.sz));
     251                                    if (off)
     252                                        RTTestSkipped(pThis->hTestingTest, "%s", pThis->TestingData.String.sz);
     253                                    else
     254                                        RTTestSkipped(pThis->hTestingTest, NULL);
     255                                    VMMDEV_TESTING_OUTPUT(("testing: SKIPPED '%s'\n", pThis->TestingData.String.sz));
    254256                                    break;
    255257                            }
     
    270272                        pThis->TestingData.Error.c = u32;
    271273                        if (uCmd == VMMDEV_TESTING_CMD_TERM)
     274                        {
     275                            while (RTTestErrorCount(pThis->hTestingTest) < u32)
     276                                RTTestErrorInc(pThis->hTestingTest); /* A bit stupid, but does the trick. */
     277                            RTTestSubDone(pThis->hTestingTest);
    272278                            VMMDEV_TESTING_OUTPUT(("testing: TERM - %u errors\n", u32));
     279                        }
    273280                        else
     281                        {
     282                            while (RTTestSubErrorCount(pThis->hTestingTest) < u32)
     283                                RTTestErrorInc(pThis->hTestingTest); /* A bit stupid, but does the trick. */
     284                            RTTestSubDone(pThis->hTestingTest);
    274285                            VMMDEV_TESTING_OUTPUT(("testing: SUB_DONE - %u errors\n", u32));
     286                        }
    275287                        return VINF_SUCCESS;
    276288#else
     
    296308                    if (   off >= 12
    297309                        && cb  == 1
    298                         && off < sizeof(pThis->TestingData.Value.szName) - 1 - 12)
     310                        && off - 12 < sizeof(pThis->TestingData.Value.szName) - 1)
    299311                    {
    300312                        if (u32)
     
    306318                        {
    307319#ifdef IN_RING3
    308                             VMMDEV_TESTING_OUTPUT(("testing: VALUE '%.*s'%*s: %'9llu (%#llx) [%u]\n",
    309                                                    sizeof(pThis->TestingData.Value.szName) - 1, pThis->TestingData.Value.szName,
     320                            pThis->TestingData.Value.szName[off - 12] = '\0';
     321
     322                            RTTESTUNIT enmUnit = (RTTESTUNIT)pThis->TestingData.Value.u32Unit;
     323                            if (enmUnit <= RTTESTUNIT_INVALID || enmUnit >= RTTESTUNIT_END)
     324                            {
     325                                VMMDEV_TESTING_OUTPUT(("Invalid log value unit %#x\n", pThis->TestingData.Value.u32Unit));
     326                                enmUnit = RTTESTUNIT_NONE;
     327                            }
     328                            RTTestValue(pThis->hTestingTest, pThis->TestingData.Value.szName,
     329                                        pThis->TestingData.Value.u64Value.u, enmUnit);
     330
     331                            VMMDEV_TESTING_OUTPUT(("testing: VALUE '%s'%*s: %'9llu (%#llx) [%u]\n",
     332                                                   pThis->TestingData.Value.szName,
    310333                                                   off - 12 > 48 ? 0 : 48 - (off - 12), "",
    311334                                                   pThis->TestingData.Value.u64Value.u, pThis->TestingData.Value.u64Value.u,
     
    316339                        }
    317340                        return VINF_SUCCESS;
    318 
    319 #ifdef IN_RING3
    320                         pThis->TestingData.Error.c = u32;
    321                         if (uCmd == VMMDEV_TESTING_CMD_TERM)
    322                             VMMDEV_TESTING_OUTPUT(("testing: TERM - %u errors\n", u32));
    323                         else
    324                             VMMDEV_TESTING_OUTPUT(("testing: SUB_DONE - %u errors\n", u32));
    325                         return VINF_SUCCESS;
    326 #else
    327                         return VINF_IOM_R3_IOPORT_WRITE;
    328 #endif
    329341                    }
    330342                    break;
     
    443455 * @param   pDevIns             The VMMDev device instance.
    444456 */
     457void vmmdevTestingTerminate(PPDMDEVINS pDevIns)
     458{
     459    VMMDevState *pThis = PDMINS_2_DATA(pDevIns, VMMDevState *);
     460    if (!pThis->fTestingEnabled)
     461        return;
     462
     463    if (pThis->hTestingTest != NIL_RTTEST)
     464    {
     465        RTTestSummaryAndDestroy(pThis->hTestingTest);
     466        pThis->hTestingTest = NIL_RTTEST;
     467    }
     468}
     469
     470
     471/**
     472 * Initializes the testing part of the VMMDev if enabled.
     473 *
     474 * @returns VBox status code.
     475 * @param   pDevIns             The VMMDev device instance.
     476 */
    445477int vmmdevTestingInitialize(PPDMDEVINS pDevIns)
    446478{
     
    496528    }
    497529
     530    /*
     531     * Open the XML output file(/pipe/whatever) if specfied.
     532     */
     533    rc = RTTestCreateEx("VMMDevTesting", RTTEST_C_USE_ENV | RTTEST_C_NO_TLS | RTTEST_C_XML_DELAY_TOP_TEST,
     534                        RTTESTLVL_INVALID, -1 /*iNativeTestPipe*/, pThis->pszTestingXmlOutput, &pThis->hTestingTest);
     535    if (RT_FAILURE(rc))
     536        return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, "Error creating testing instance");
     537
    498538    return VINF_SUCCESS;
    499539}
  • trunk/src/VBox/Devices/VMMDev/VMMDevTesting.h

    r30724 r46300  
    2525RT_C_DECLS_BEGIN
    2626
    27 int vmmdevTestingInitialize(PPDMDEVINS pDevIns);
     27int  vmmdevTestingInitialize(PPDMDEVINS pDevIns);
     28void vmmdevTestingTerminate(PPDMDEVINS pDevIns);
    2829
    2930RT_C_DECLS_END
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette