Changeset 52111 in vbox
- Timestamp:
- Jul 21, 2014 1:28:54 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 95134
- Location:
- trunk/src/VBox/Storage/testcase
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Storage/testcase/Makefile.kmk
r50052 r52111 51 51 PROGRAMS += tstVDIo 52 52 53 # 54 # VD I/O test scripts to built in -> .cpp 55 # 56 TSTVDIO_BUILTIN_TESTS_FILE = $(tstVDIo_0_OUTDIR)/BuiltinTests.cpp 57 TSTVDIO_BUILTIN_TESTS := \ 58 tstVDIo=tstVDIo.vd \ 59 tstVDResize=tstVDResize.vd \ 60 tstVDCompact=tstVDCompact.vd \ 61 tstVDCopy=tstVDCopy.vd \ 62 tstVDDiscard=tstVDDiscard.vd \ 63 tstVDShareable=tstVDShareable.vd 64 TSTVDIO_BUILTIN_TEST_NAMES := $(foreach test,$(TSTVDIO_BUILTIN_TESTS),$(firstword $(subst =,$(SPACE) ,$(test)))) 65 TSTVDIO_PATH_TESTS := $(PATH_SUB_CURRENT) 66 67 # 1=name, 2=filter 68 TSTVDIO_GEN_TEST_MACRO = 'TSTVDIOTESTENTRY const g_a$(1)[] =' '{' \ 69 $(foreach testnm,$(filter $(2),$(TSTVDIO_BUILTIN_TEST_NAMES)), ' TSTVDIOTESTENTRY_GEN(g_ab$(testnm)),') \ 70 '};' 'unsigned const g_c$(1) = RT_ELEMENTS(g_a$(1));' '' '' 71 72 $$(TSTVDIO_BUILTIN_TESTS_FILE): $(MAKEFILE_CURRENT) \ 73 $(foreach test,$(TSTVDIO_BUILTIN_TESTS),$(TSTVDIO_PATH_TESTS)/$(lastword $(subst =,$(SPACE) ,$(test)))) \ 74 $(VBOX_BIN2C) \ 75 | $$(dir $$@) 76 $(QUIET)$(RM) -f -- $@ $@.vd 77 $(QUIET)$(APPEND) -n "$@" \ 78 '' \ 79 '#include "BuiltinTests.h"' \ 80 '' 81 $(foreach test,$(TSTVDIO_BUILTIN_TESTS), $(NLTAB)$(VBOX_BIN2C) -ascii --append \ 82 "$(firstword $(subst =,$(SP) ,$(test)))" \ 83 "$(TSTVDIO_PATH_TESTS)/$(lastword $(subst =,$(SP) ,$(test)))" \ 84 "$@") 85 86 # Generate certificate lists. 87 $(QUIET)$(APPEND) -n "$@" '' \ 88 $(call TSTVDIO_GEN_TEST_MACRO,VDIoTests,%) \ 89 53 90 tstVDIo_TEMPLATE = VBOXR3TSTEXE 91 tstVDIo_INCS := $(PATH_SUB_CURRENT) 54 92 tstVDIo_SOURCES = tstVDIo.cpp \ 55 93 VDIoBackend.cpp \ … … 60 98 VDScriptAst.cpp \ 61 99 VDScriptChecker.cpp \ 62 VDScriptInterp.cpp 100 VDScriptInterp.cpp \ 101 $(TSTVDIO_BUILTIN_TESTS_FILE) 63 102 tstVDIo_LIBS = \ 64 103 $(LIB_DDU) \ -
trunk/src/VBox/Storage/testcase/tstVDIo.cpp
r46247 r52111 39 39 40 40 #include "VDScript.h" 41 #include "BuiltinTests.h" 41 42 42 43 /** … … 2648 2649 2649 2650 /** 2651 * Executes the given script. 2652 * 2653 * @returns nothing. 2654 * @param pszScript The script to execute. 2655 */ 2656 static void tstVDIoScriptExec(const char *pszScript) 2657 { 2658 int rc = VINF_SUCCESS; 2659 VDTESTGLOB GlobTest; /**< Global test data. */ 2660 2661 memset(&GlobTest, 0, sizeof(VDTESTGLOB)); 2662 RTListInit(&GlobTest.ListFiles); 2663 RTListInit(&GlobTest.ListDisks); 2664 RTListInit(&GlobTest.ListPatterns); 2665 GlobTest.pszIoBackend = RTStrDup("memory"); 2666 if (!GlobTest.pszIoBackend) 2667 { 2668 RTPrintf("Out of memory allocating I/O backend string\n"); 2669 return; 2670 } 2671 2672 /* Init global test data. */ 2673 GlobTest.VDIfError.pfnError = tstVDError; 2674 GlobTest.VDIfError.pfnMessage = tstVDMessage; 2675 2676 rc = VDInterfaceAdd(&GlobTest.VDIfError.Core, "tstVDIo_VDIError", VDINTERFACETYPE_ERROR, 2677 NULL, sizeof(VDINTERFACEERROR), &GlobTest.pInterfacesDisk); 2678 AssertRC(rc); 2679 2680 GlobTest.VDIfIo.pfnOpen = tstVDIoFileOpen; 2681 GlobTest.VDIfIo.pfnClose = tstVDIoFileClose; 2682 GlobTest.VDIfIo.pfnDelete = tstVDIoFileDelete; 2683 GlobTest.VDIfIo.pfnMove = tstVDIoFileMove; 2684 GlobTest.VDIfIo.pfnGetFreeSpace = tstVDIoFileGetFreeSpace; 2685 GlobTest.VDIfIo.pfnGetModificationTime = tstVDIoFileGetModificationTime; 2686 GlobTest.VDIfIo.pfnGetSize = tstVDIoFileGetSize; 2687 GlobTest.VDIfIo.pfnSetSize = tstVDIoFileSetSize; 2688 GlobTest.VDIfIo.pfnWriteSync = tstVDIoFileWriteSync; 2689 GlobTest.VDIfIo.pfnReadSync = tstVDIoFileReadSync; 2690 GlobTest.VDIfIo.pfnFlushSync = tstVDIoFileFlushSync; 2691 GlobTest.VDIfIo.pfnReadAsync = tstVDIoFileReadAsync; 2692 GlobTest.VDIfIo.pfnWriteAsync = tstVDIoFileWriteAsync; 2693 GlobTest.VDIfIo.pfnFlushAsync = tstVDIoFileFlushAsync; 2694 2695 rc = VDInterfaceAdd(&GlobTest.VDIfIo.Core, "tstVDIo_VDIIo", VDINTERFACETYPE_IO, 2696 &GlobTest, sizeof(VDINTERFACEIO), &GlobTest.pInterfacesImages); 2697 AssertRC(rc); 2698 2699 /* Init I/O backend. */ 2700 rc = VDIoBackendCreate(&GlobTest.pIoBackend); 2701 if (RT_SUCCESS(rc)) 2702 { 2703 VDSCRIPTCTX hScriptCtx = NULL; 2704 rc = VDScriptCtxCreate(&hScriptCtx); 2705 if (RT_SUCCESS(rc)) 2706 { 2707 rc = VDScriptCtxCallbacksRegister(hScriptCtx, g_aScriptActions, g_cScriptActions, &GlobTest); 2708 AssertRC(rc); 2709 2710 rc = VDScriptCtxLoadScript(hScriptCtx, pszScript); 2711 if (RT_FAILURE(rc)) 2712 { 2713 RTPrintf("Loading the script failed rc=%Rrc\n", rc); 2714 } 2715 else 2716 rc = VDScriptCtxCallFn(hScriptCtx, "main", NULL, 0); 2717 VDScriptCtxDestroy(hScriptCtx); 2718 } 2719 VDIoBackendDestroy(GlobTest.pIoBackend); 2720 } 2721 else 2722 RTPrintf("Creating the I/O backend failed rc=%Rrc\n"); 2723 2724 RTStrFree(GlobTest.pszIoBackend); 2725 } 2726 2727 /** 2650 2728 * Executes the given I/O script using the new scripting engine. 2651 2729 * … … 2657 2735 { 2658 2736 int rc = VINF_SUCCESS; 2659 VDTESTGLOB GlobTest; /**< Global test data. */2660 2737 void *pvFile = NULL; 2661 2738 size_t cbFile = 0; 2662 2739 2663 memset(&GlobTest, 0, sizeof(VDTESTGLOB));2664 RTListInit(&GlobTest.ListFiles);2665 RTListInit(&GlobTest.ListDisks);2666 RTListInit(&GlobTest.ListPatterns);2667 GlobTest.pszIoBackend = RTStrDup("memory");2668 if (!GlobTest.pszIoBackend)2669 {2670 RTPrintf("Out of memory allocating I/O backend string\n");2671 return;2672 }2673 2674 2740 rc = RTFileReadAll(pcszFilename, &pvFile, &cbFile); 2675 2741 if (RT_SUCCESS(rc)) … … 2679 2745 2680 2746 AssertPtr(pszScript); 2681 /* Init global test data. */ 2682 GlobTest.VDIfError.pfnError = tstVDError; 2683 GlobTest.VDIfError.pfnMessage = tstVDMessage; 2684 2685 rc = VDInterfaceAdd(&GlobTest.VDIfError.Core, "tstVDIo_VDIError", VDINTERFACETYPE_ERROR, 2686 NULL, sizeof(VDINTERFACEERROR), &GlobTest.pInterfacesDisk); 2687 AssertRC(rc); 2688 2689 GlobTest.VDIfIo.pfnOpen = tstVDIoFileOpen; 2690 GlobTest.VDIfIo.pfnClose = tstVDIoFileClose; 2691 GlobTest.VDIfIo.pfnDelete = tstVDIoFileDelete; 2692 GlobTest.VDIfIo.pfnMove = tstVDIoFileMove; 2693 GlobTest.VDIfIo.pfnGetFreeSpace = tstVDIoFileGetFreeSpace; 2694 GlobTest.VDIfIo.pfnGetModificationTime = tstVDIoFileGetModificationTime; 2695 GlobTest.VDIfIo.pfnGetSize = tstVDIoFileGetSize; 2696 GlobTest.VDIfIo.pfnSetSize = tstVDIoFileSetSize; 2697 GlobTest.VDIfIo.pfnWriteSync = tstVDIoFileWriteSync; 2698 GlobTest.VDIfIo.pfnReadSync = tstVDIoFileReadSync; 2699 GlobTest.VDIfIo.pfnFlushSync = tstVDIoFileFlushSync; 2700 GlobTest.VDIfIo.pfnReadAsync = tstVDIoFileReadAsync; 2701 GlobTest.VDIfIo.pfnWriteAsync = tstVDIoFileWriteAsync; 2702 GlobTest.VDIfIo.pfnFlushAsync = tstVDIoFileFlushAsync; 2703 2704 rc = VDInterfaceAdd(&GlobTest.VDIfIo.Core, "tstVDIo_VDIIo", VDINTERFACETYPE_IO, 2705 &GlobTest, sizeof(VDINTERFACEIO), &GlobTest.pInterfacesImages); 2706 AssertRC(rc); 2707 2708 /* Init I/O backend. */ 2709 rc = VDIoBackendCreate(&GlobTest.pIoBackend); 2710 if (RT_SUCCESS(rc)) 2711 { 2712 VDSCRIPTCTX hScriptCtx = NULL; 2713 rc = VDScriptCtxCreate(&hScriptCtx); 2714 if (RT_SUCCESS(rc)) 2715 { 2716 rc = VDScriptCtxCallbacksRegister(hScriptCtx, g_aScriptActions, g_cScriptActions, &GlobTest); 2717 AssertRC(rc); 2718 2719 rc = VDScriptCtxLoadScript(hScriptCtx, pszScript); 2720 if (RT_FAILURE(rc)) 2721 { 2722 RTPrintf("Loading the script failed rc=%Rrc\n", rc); 2723 } 2724 else 2725 rc = VDScriptCtxCallFn(hScriptCtx, "main", NULL, 0); 2726 VDScriptCtxDestroy(hScriptCtx); 2727 } 2728 VDIoBackendDestroy(GlobTest.pIoBackend); 2729 } 2730 else 2731 RTPrintf("Creating the I/O backend failed rc=%Rrc\n"); 2732 } 2733 else 2734 RTPrintf("Opening script failed rc=%Rrc\n", rc); 2735 2736 RTStrFree(GlobTest.pszIoBackend); 2747 tstVDIoScriptExec(pszScript); 2748 } 2749 else 2750 RTPrintf("Opening the script failed: %Rrc\n", rc); 2751 2752 } 2753 2754 /** 2755 * Run builtin tests. 2756 * 2757 * @returns nothing. 2758 */ 2759 static void tstVDIoRunBuiltinTests(void) 2760 { 2761 for (unsigned i = 0; i < g_cVDIoTests; i++) 2762 { 2763 char *pszScript = RTStrDupN((const char *)g_aVDIoTests[i].pch, g_aVDIoTests[i].cb); 2764 2765 AssertPtr(pszScript); 2766 tstVDIoScriptExec(pszScript); 2767 } 2737 2768 } 2738 2769 … … 2748 2779 static const RTGETOPTDEF g_aOptions[] = 2749 2780 { 2750 { "--script", 's', RTGETOPT_REQ_STRING } 2781 { "--script", 's', RTGETOPT_REQ_STRING }, 2782 { "--help", 'h', RTGETOPT_REQ_NOTHING } 2751 2783 }; 2752 2784 … … 2759 2791 char c; 2760 2792 2761 if (argc != 3)2762 {2763 printUsage();2764 return RTEXITCODE_FAILURE;2765 }2766 2767 2793 rc = VDInit(); 2768 2794 if (RT_FAILURE(rc)) 2769 2795 return RTEXITCODE_FAILURE; 2770 2796 2797 if (argc == 1) 2798 { 2799 tstVDIoRunBuiltinTests(); 2800 return RTEXITCODE_SUCCESS; 2801 } 2802 2771 2803 RTGetOptInit(&GetState, argc, argv, g_aOptions, 2772 2804 RT_ELEMENTS(g_aOptions), 1, RTGETOPTINIT_FLAGS_NO_STD_OPTS); … … 2780 2812 tstVDIoScriptRun(ValueUnion.psz); 2781 2813 break; 2782 default:2814 case 'h': 2783 2815 printUsage(); 2816 break; 2817 default: /* Default is to run built in tests if no arguments are given (automated testing). */ 2818 tstVDIoRunBuiltinTests(); 2784 2819 } 2785 2820 } -
trunk/src/VBox/Storage/testcase/tstVDIo.vd
r44943 r52111 37 37 } 38 38 39 void tstIoUnaligned(string strMessage, string strBackend) 40 { 41 print(strMessage); 42 createdisk("test", true); 43 create("test", "base", "tst.disk", "dynamic", strBackend, 2G, false); 44 io("test", false, 1, "seq", 512, 3584, 4096, 512, 100, "none"); 45 io("test", false, 1, "seq", 512, 3584, 4096, 512, 0, "none"); 46 destroydisk("test"); 47 } 48 39 49 void main() 40 50 {
Note:
See TracChangeset
for help on using the changeset viewer.