- Timestamp:
- Feb 12, 2020 5:45:51 PM (5 years ago)
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Makefile.kmk
r82968 r83062 1351 1351 tstDevice_SOURCES = \ 1352 1352 testcase/tstDevice.cpp \ 1353 testcase/tstDeviceCfg.cpp \ 1353 1354 testcase/tstDevicePdmDevHlp.cpp 1354 1355 endif -
trunk/src/VBox/Devices/testcase/tstDevice.cpp
r82968 r83062 39 39 40 40 #include "tstDeviceInternal.h" 41 #include "tstDeviceCfg.h" 41 42 42 43 … … 805 806 806 807 807 static TSTDEVCFGITEM s_aTestcaseCfg[] =808 {809 {"CtrlMemBufSize", TSTDEVCFGITEMTYPE_INTEGER, "0" },810 {NULL, TSTDEVCFGITEMTYPE_INVALID, NULL }811 };812 813 static TSTDEVTESTCASEREG s_TestcaseDef =814 {815 "test",816 "Testcase during implementation",817 "serial",818 0,819 &s_aTestcaseCfg[0],820 NULL,821 };822 823 808 /** 824 809 * Create a new PDM device with default config. … … 826 811 * @returns VBox status code. 827 812 * @param pszName Name of the device to create. 828 */ 829 static int tstDevPdmDevCreate(const char *pszName) 813 * @param fR0Enabled Flag whether R0 support should be enabled for this device. 814 * @param fRCEnabled Flag whether RC support should be enabled for this device. 815 * @param pDut The device under test structure the created PDM device instance is exercised under. 816 */ 817 static int tstDevPdmDevCreate(const char *pszName, bool fR0Enabled, bool fRCEnabled, PTSTDEVDUTINT pDut) 830 818 { 831 819 int rc = VINF_SUCCESS; … … 833 821 if (RT_LIKELY(pPdmDev)) 834 822 { 835 TSTDEVDUTINT Dut;836 Dut.pTestcaseReg = &s_TestcaseDef;837 Dut.enmCtx = TSTDEVDUTCTX_R3;838 Dut.pVm = NULL;839 Dut.SupSession.pDut = &Dut;840 RTListInit(&Dut.LstIoPorts);841 RTListInit(&Dut.LstTimers);842 RTListInit(&Dut.LstMmHeap);843 RTListInit(&Dut.LstPdmThreads);844 RTListInit(&Dut.SupSession.LstSupSem);845 CFGMNODE Cfg;846 Cfg.pDut = &Dut;847 848 rc = RTCritSectRwInit(&Dut.CritSectLists);849 AssertRC(rc);850 851 rc = RTCritSectInitEx(&Dut.CritSectNop.s.CritSect, RTCRITSECT_FLAGS_NOP, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "DutNop");852 AssertRC(rc);853 854 823 PPDMCRITSECT pCritSect; 855 824 /* Figure out how much we need. */ … … 872 841 pDevIns->pvInstanceDataR3 = &pDevIns->achInstanceData[0]; 873 842 pDevIns->pHlpR3 = &g_tstDevPdmDevHlpR3; 874 pDevIns->pCfg = & Cfg;875 pDevIns->Internal.s.pDut = &Dut;843 pDevIns->pCfg = &pDut->Cfg; 844 pDevIns->Internal.s.pDut = pDut; 876 845 pDevIns->cbRing3 = cb; 877 //pDevIns->fR0Enabled = false;878 //pDevIns->fRCEnabled = false;846 pDevIns->fR0Enabled = fR0Enabled; 847 pDevIns->fRCEnabled = fRCEnabled; 879 848 pDevIns->pvInstanceDataR3 = (uint8_t *)pDevIns + offShared; 880 849 pDevIns->pvInstanceDataForR3 = &pDevIns->achInstanceData[0]; … … 894 863 } 895 864 896 rc = pPdmDev->pReg->pfnConstruct(pDevIns, 0, &Cfg);865 rc = pPdmDev->pReg->pfnConstruct(pDevIns, 0, pDevIns->pCfg); 897 866 if (RT_SUCCESS(rc)) 898 { 899 PRTDEVDUTIOPORT pIoPort = RTListGetFirst(&Dut.LstIoPorts, RTDEVDUTIOPORT, NdIoPorts); 900 uint32_t uVal = 0; 901 /*PDMCritSectEnter(pDevIns->pCritSectRoR3, VERR_IGNORED);*/ 902 pIoPort->pfnInR0(pDevIns, pIoPort->pvUserR0, pIoPort->PortStart, &uVal, sizeof(uint8_t)); 903 /*PDMCritSectLeave(pDevIns->pCritSectRoR3);*/ 867 pDut->pDevIns = pDevIns; 868 else 869 { 870 rc = pPdmDev->pReg->pfnDestruct(pDevIns); 871 RTMemFree(pDevIns); 904 872 } 905 873 } … … 909 877 return rc; 910 878 } 879 880 881 /** 882 * Run a given test config. 883 * 884 * @returns VBox status code. 885 * @param pDevTstCfg The test config to run. 886 */ 887 static int tstDevTestsRun(PCTSTDEVCFG pDevTstCfg) 888 { 889 int rc = VINF_SUCCESS; 890 891 for (uint32_t i = 0; i < pDevTstCfg->cTests; i++) 892 { 893 PCTSTDEVTEST pTest = &pDevTstCfg->aTests[i]; 894 895 TSTDEVDUTINT Dut; 896 Dut.pTest = pTest; 897 Dut.enmCtx = TSTDEVDUTCTX_R3; 898 Dut.pVm = NULL; 899 Dut.SupSession.pDut = &Dut; 900 Dut.Cfg.pDut = &Dut; 901 RTListInit(&Dut.LstIoPorts); 902 RTListInit(&Dut.LstTimers); 903 RTListInit(&Dut.LstMmHeap); 904 RTListInit(&Dut.LstPdmThreads); 905 RTListInit(&Dut.LstSsmHandlers); 906 RTListInit(&Dut.SupSession.LstSupSem); 907 908 rc = RTCritSectRwInit(&Dut.CritSectLists); 909 AssertRC(rc); 910 911 rc = RTCritSectInitEx(&Dut.CritSectNop.s.CritSect, RTCRITSECT_FLAGS_NOP, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "DutNop"); 912 AssertRC(rc); 913 914 rc = tstDevPdmDevCreate(pDevTstCfg->pszDevName, pTest->fR0Enabled, pTest->fRCEnabled, &Dut); 915 if (RT_SUCCESS(rc)) 916 { 917 /** @todo Next */ 918 } 919 } 920 921 return rc; 922 } 923 911 924 912 925 int main(int argc, char *argv[]) … … 924 937 RTListInit(&g_LstPdmDevs); 925 938 926 rc = tstDevLoadPlugin("TSTDevTestcases"); 927 if (RT_SUCCESS(rc) || true) 928 { 929 rc = tstDevPdmLoadMod(argv[1], TSTDEVPDMMODTYPE_R3); 939 PCTSTDEVCFG pDevTstCfg = NULL; 940 rc = tstDevCfgLoad(argv[1], NULL, &pDevTstCfg); 941 if (RT_SUCCESS(rc)) 942 { 943 if (pDevTstCfg->pszTstDevMod) 944 rc = tstDevLoadPlugin(pDevTstCfg->pszTstDevMod); 930 945 if (RT_SUCCESS(rc)) 931 rc = tstDevPdmDevCreate("serial"); 946 { 947 rc = tstDevPdmLoadMod(pDevTstCfg->pszPdmR3Mod, TSTDEVPDMMODTYPE_R3); 948 if ( RT_SUCCESS(rc) 949 && pDevTstCfg->pszPdmR0Mod) 950 rc = tstDevPdmLoadMod(pDevTstCfg->pszPdmR0Mod, TSTDEVPDMMODTYPE_R0); 951 if ( RT_SUCCESS(rc) 952 && pDevTstCfg->pszPdmRCMod) 953 rc = tstDevPdmLoadMod(pDevTstCfg->pszPdmRCMod, TSTDEVPDMMODTYPE_RC); 954 955 if (RT_SUCCESS(rc)) 956 rc = tstDevTestsRun(pDevTstCfg); 957 else 958 rcExit = RTEXITCODE_FAILURE; 959 } 932 960 else 933 961 rcExit = RTEXITCODE_FAILURE; 934 962 } 935 else 936 rcExit = RTEXITCODE_FAILURE; 937 938 //rcExit = tstDevParseOptions(argc, argv); 963 964 tstDevCfgDestroy(pDevTstCfg); 939 965 } 940 966 else -
trunk/src/VBox/Devices/testcase/tstDeviceInternal.h
r82968 r83062 28 28 #include <iprt/critsect.h> 29 29 30 #include "tstDeviceCfg.h" 30 31 #include "tstDevicePlugin.h" 31 32 … … 330 331 typedef struct TSTDEVDUTINT 331 332 { 332 /** Pointer to the test case this device is part of. */333 PCTSTDEVTEST CASEREG pTestcaseReg;333 /** Pointer to the test this device is running under. */ 334 PCTSTDEVTEST pTest; 334 335 /** Pointer to the PDM device instance. */ 335 336 PPDMDEVINS pDevIns; 337 /** CFGM root config node for the device. */ 338 CFGMNODE Cfg; 336 339 /** Current device context. */ 337 340 TSTDEVDUTCTX enmCtx; -
trunk/src/VBox/Devices/testcase/tstDevicePdmDevHlp.cpp
r82968 r83062 78 78 * @returns VBox status code. 79 79 * @param paDevCfg The array of config items. 80 * @param cCfgItems Number of config items in the array. 80 81 * @param pszName Name of a byte string value. 81 82 * @param ppItem Where to store the pointer to the item. 82 83 */ 83 static int tstDev_CfgmR3ResolveItem(PCTSTDEVCFGITEM paDevCfg, const char *pszName, PCTSTDEVCFGITEM *ppItem)84 static int tstDev_CfgmR3ResolveItem(PCTSTDEVCFGITEM paDevCfg, uint32_t cCfgItems, const char *pszName, PCTSTDEVCFGITEM *ppItem) 84 85 { 85 86 *ppItem = NULL; … … 89 90 size_t cchName = strlen(pszName); 90 91 PCTSTDEVCFGITEM pDevCfgItem = paDevCfg; 91 while (pDevCfgItem->pszKey != NULL) 92 93 for (uint32_t i = 0; i < cCfgItems; i++) 92 94 { 93 95 size_t cchKey = strlen(pDevCfgItem->pszKey); … … 1436 1438 1437 1439 PCTSTDEVCFGITEM pCfgItem; 1438 int rc = tstDev_CfgmR3ResolveItem(pNode->pDut->pTest caseReg->paDevCfg, pszName, &pCfgItem);1440 int rc = tstDev_CfgmR3ResolveItem(pNode->pDut->pTest->paCfgItems, pNode->pDut->pTest->cCfgItems, pszName, &pCfgItem); 1439 1441 if (RT_SUCCESS(rc)) 1440 1442 { … … 1446 1448 1447 1449 case TSTDEVCFGITEMTYPE_STRING: 1448 *pcb = strlen(pCfgItem-> pszVal) + 1;1450 *pcb = strlen(pCfgItem->u.psz) + 1; 1449 1451 break; 1450 1452 … … 1469 1471 1470 1472 PCTSTDEVCFGITEM pCfgItem; 1471 int rc = tstDev_CfgmR3ResolveItem(pNode->pDut->pTest caseReg->paDevCfg, pszName, &pCfgItem);1473 int rc = tstDev_CfgmR3ResolveItem(pNode->pDut->pTest->paCfgItems, pNode->pDut->pTest->cCfgItems, pszName, &pCfgItem); 1472 1474 if (RT_SUCCESS(rc)) 1473 1475 { 1474 1476 if (pCfgItem->enmType == TSTDEVCFGITEMTYPE_INTEGER) 1475 *pu64 = RTStrToUInt64(pCfgItem->pszVal);1477 *pu64 = (uint64_t)pCfgItem->u.i64; 1476 1478 else 1477 1479 rc = VERR_CFGM_NOT_INTEGER; … … 1502 1504 1503 1505 PCTSTDEVCFGITEM pCfgItem; 1504 int rc = tstDev_CfgmR3ResolveItem(pNode->pDut->pTest caseReg->paDevCfg, pszName, &pCfgItem);1506 int rc = tstDev_CfgmR3ResolveItem(pNode->pDut->pTest->paCfgItems, pNode->pDut->pTest->cCfgItems, pszName, &pCfgItem); 1505 1507 if (RT_SUCCESS(rc)) 1506 1508 { … … 1509 1511 case TSTDEVCFGITEMTYPE_STRING: 1510 1512 { 1511 size_t cchVal = strlen(pCfgItem-> pszVal);1513 size_t cchVal = strlen(pCfgItem->u.psz); 1512 1514 if (cchString <= cchVal + 1) 1513 memcpy(pszString, pCfgItem-> pszVal, cchVal);1515 memcpy(pszString, pCfgItem->u.psz, cchVal); 1514 1516 else 1515 1517 rc = VERR_CFGM_NOT_ENOUGH_SPACE; … … 2018 2020 static DECLCALLBACK(bool) pdmR3DevHlp_CFGMAreValuesValid(PCFGMNODE pNode, const char *pszzValid) 2019 2021 { 2020 if (pNode && pNode->pDut->pTest caseReg->paDevCfg)2022 if (pNode && pNode->pDut->pTest->paCfgItems) 2021 2023 { 2022 PCTSTDEVCFGITEM pDevCfgItem = pNode->pDut->pTest caseReg->paDevCfg;2023 while (pDevCfgItem->pszKey != NULL)2024 PCTSTDEVCFGITEM pDevCfgItem = pNode->pDut->pTest->paCfgItems; 2025 for (uint32_t i = 0; i < pNode->pDut->pTest->cCfgItems; i++) 2024 2026 { 2025 2027 size_t cchKey = strlen(pDevCfgItem->pszKey); -
trunk/src/VBox/Devices/testcase/tstDevicePlugin.h
r82968 r83062 22 22 23 23 #include <VBox/types.h> 24 25 /**26 * Config item type.27 */28 typedef enum TSTDEVCFGITEMTYPE29 {30 /** Invalid type. */31 TSTDEVCFGITEMTYPE_INVALID = 0,32 /** String type. */33 TSTDEVCFGITEMTYPE_STRING,34 /** Integer value encoded in the string. */35 TSTDEVCFGITEMTYPE_INTEGER,36 /** Raw bytes. */37 TSTDEVCFGITEMTYPE_BYTES,38 /** 32bit hack. */39 TSTDEVCFGITEMTYPE_32BIT_HACK = 0x7fffffff40 } TSTDEVCFGITEMTYPE;41 /** Pointer to a config item type. */42 typedef TSTDEVCFGITEMTYPE *PTSTDEVCFGITEMTYPE;43 44 45 /**46 * Testcase config item.47 */48 typedef struct TSTDEVCFGITEM49 {50 /** The key of the item. */51 const char *pszKey;52 /** Type of the config item. */53 TSTDEVCFGITEMTYPE enmType;54 /** The value of the item (as a string/number of bytes to make static55 * instantiation easier). */56 const char *pszVal;57 } TSTDEVCFGITEM;58 /** Pointer to a testcase config item. */59 typedef TSTDEVCFGITEM *PTSTDEVCFGITEM;60 /** Pointer to a constant testcase config item. */61 typedef const TSTDEVCFGITEM *PCTSTDEVCFGITEM;62 63 24 64 25 /** Device under test handle. */
Note:
See TracChangeset
for help on using the changeset viewer.