Changeset 14104 in vbox for trunk/src/VBox/HostServices/GuestProperties/testcase
- Timestamp:
- Nov 11, 2008 7:16:32 PM (16 years ago)
- Location:
- trunk/src/VBox/HostServices/GuestProperties/testcase
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/GuestProperties/testcase/Makefile.kmk
r13916 r14104 34 34 tstGuestPropSvc_SOURCES = tstGuestPropSvc.cpp ../service.cpp 35 35 tstGuestPropSvc_LIBS = $(LIB_RUNTIME) 36 # For now! 37 tstGuestPropSvc_CXXFLAGS.win = -EHsc 36 38 37 39 # Set this in LocalConfig.kmk if you are working on the guest property service -
trunk/src/VBox/HostServices/GuestProperties/testcase/tstGuestPropSvc.cpp
r13971 r14104 241 241 242 242 /** Result string sizes for zeroth enumeration test */ 243 static const size_t cchEnumResult0[] =243 static const uint32_t cchEnumResult0[] = 244 244 { 245 245 sizeof("test/name/\0test/value/\0""0\0"), … … 254 254 * the - 1 at the end is because of the hidden zero terminator 255 255 */ 256 static const size_t cchEnumBuffer0 =256 static const uint32_t cchEnumBuffer0 = 257 257 sizeof("test/name/\0test/value/\0""0\0\0" 258 258 "test name\0test value\0""999\0TRANSIENT, READONLY\0" … … 269 269 270 270 /** Result string sizes for first and second enumeration test */ 271 static const size_t cchEnumResult1[] =271 static const uint32_t cchEnumResult1[] = 272 272 { 273 273 sizeof("TEST NAME\0TEST VALUE\0""999999\0RDONLYHOST"), … … 280 280 * the - 1 at the end is because of the hidden zero terminator 281 281 */ 282 static const size_t cchEnumBuffer1 =282 static const uint32_t cchEnumBuffer1 = 283 283 sizeof("TEST NAME\0TEST VALUE\0""999999\0RDONLYHOST\0" 284 284 "/test/name\0/test/value\0""999999999999\0RDONLYGUEST\0\0\0\0\0") - 1; … … 289 289 const char *pcszPatterns; 290 290 /** The size of the pattern string */ 291 const size_t cchPatterns;291 const uint32_t cchPatterns; 292 292 /** The expected enumeration output strings */ 293 293 const char **ppcchResult; 294 294 /** The size of the output strings */ 295 const size_t *pcchResult;295 const uint32_t *pcchResult; 296 296 /** The size of the buffer needed for the enumeration */ 297 const size_t cchBuffer;297 const uint32_t cchBuffer; 298 298 } 299 299 enumStrings[] = … … 693 693 VBOXHGCMCALLHANDLE_TYPEDEF callHandle = { VINF_SUCCESS }; 694 694 char chBuffer[MAX_NAME_LEN + MAX_VALUE_LEN + MAX_FLAGS_LEN]; 695 static char szPattern[] = ""; 695 696 696 697 RTPrintf("Testing the GET_NOTIFICATION call.\n"); 697 uint64_t u64Timestamp = 0;698 uint64_t u64Timestamp; 698 699 uint32_t u32Size = 0; 699 VBOXHGCMSVCPARM paParms[ 3];700 VBOXHGCMSVCPARM paParms[4]; 700 701 701 702 /* Test "buffer too small" */ 702 paParms[0].setUInt64 (u64Timestamp); 703 paParms[1].setPointer ((void *) chBuffer, getNotifications[0].cchBuffer - 1); 703 u64Timestamp = 1; 704 paParms[0].setPointer ((void *) szPattern, sizeof(szPattern)); 705 paParms[1].setUInt64 (u64Timestamp); 706 paParms[2].setPointer ((void *) chBuffer, getNotifications[0].cchBuffer - 1); 704 707 pTable->pfnCall(pTable->pvService, &callHandle, 0, NULL, 705 GET_NOTIFICATION, 3, paParms);708 GET_NOTIFICATION, 4, paParms); 706 709 if ( callHandle.rc != VERR_BUFFER_OVERFLOW 707 || RT_FAILURE(paParms[ 2].getUInt32 (&u32Size))710 || RT_FAILURE(paParms[3].getUInt32 (&u32Size)) 708 711 || u32Size != getNotifications[0].cchBuffer 709 712 ) … … 714 717 } 715 718 716 /* Test successful notification queries */ 719 /* Test successful notification queries. Start with an unknown timestamp 720 * to get the oldest available notification. */ 721 u64Timestamp = 1; 717 722 for (unsigned i = 0; RT_SUCCESS(rc) && (getNotifications[i].pchBuffer != NULL); 718 723 ++i) 719 724 { 720 paParms[0].setUInt64 (u64Timestamp); 721 paParms[1].setPointer ((void *) chBuffer, sizeof(chBuffer)); 725 paParms[0].setPointer ((void *) szPattern, sizeof(szPattern)); 726 paParms[1].setUInt64 (u64Timestamp); 727 paParms[2].setPointer ((void *) chBuffer, sizeof(chBuffer)); 722 728 pTable->pfnCall(pTable->pvService, &callHandle, 0, NULL, 723 GET_NOTIFICATION, 3, paParms);729 GET_NOTIFICATION, 4, paParms); 724 730 if ( RT_FAILURE(callHandle.rc) 725 || RT_FAILURE(paParms[0].getUInt64 (&u64Timestamp)) 726 || RT_FAILURE(paParms[2].getUInt32 (&u32Size)) 731 || (i == 0 && callHandle.rc != VWRN_NOT_FOUND) 732 || RT_FAILURE(paParms[1].getUInt64 (&u64Timestamp)) 733 || RT_FAILURE(paParms[3].getUInt32 (&u32Size)) 727 734 || u32Size != getNotifications[i].cchBuffer 728 735 || memcmp(chBuffer, getNotifications[i].pchBuffer, u32Size) != 0 … … 734 741 } 735 742 } 736 737 /* Test a query with an unknown timestamp */738 paParms[0].setUInt64 (1);739 paParms[1].setPointer ((void *) chBuffer, sizeof(chBuffer));740 if (RT_SUCCESS(rc))741 pTable->pfnCall(pTable->pvService, &callHandle, 0, NULL,742 GET_NOTIFICATION, 3, paParms);743 if ( RT_SUCCESS(rc)744 && ( callHandle.rc != VWRN_NOT_FOUND745 || RT_FAILURE(callHandle.rc)746 || RT_FAILURE(paParms[0].getUInt64 (&u64Timestamp))747 || RT_FAILURE(paParms[2].getUInt32 (&u32Size))748 || u32Size != getNotifications[0].cchBuffer749 || memcmp(chBuffer, getNotifications[0].pchBuffer, u32Size) != 0750 )751 )752 {753 RTPrintf("Problem getting notification for property '%s' with unknown timestamp, rc=%Rrc.\n",754 getNotifications[0].pchBuffer, callHandle.rc);755 rc = VERR_UNRESOLVED_ERROR;756 }757 743 return rc; 758 744 } 759 745 760 /** 761 * Test the GET_NOTIFICATION function when no notifications are available. 746 /** Paramters for the asynchronous guest notification call */ 747 struct asyncNotification_ 748 { 749 /** Call parameters */ 750 VBOXHGCMSVCPARM aParms[4]; 751 /** Result buffer */ 752 char chBuffer[MAX_NAME_LEN + MAX_VALUE_LEN + MAX_FLAGS_LEN]; 753 /** Return value */ 754 VBOXHGCMCALLHANDLE_TYPEDEF callHandle; 755 } asyncNotification; 756 757 /** 758 * Set up the test for the asynchronous GET_NOTIFICATION function. 762 759 * @returns iprt status value to indicate whether the test went as expected. 763 760 * @note prints its own diagnostic information to stdout. 764 761 */ 765 int testNoNotifications(VBOXHGCMSVCFNTABLE *pTable, VBOXHGCMCALLHANDLE_TYPEDEF *callHandle, 766 VBOXHGCMSVCPARM *paParms, char *pchBuffer, size_t cchBuffer) 762 int setupAsyncNotification(VBOXHGCMSVCFNTABLE *pTable) 767 763 { 768 764 int rc = VINF_SUCCESS; … … 771 767 uint64_t u64Timestamp = 0; 772 768 uint32_t u32Size = 0; 773 774 paParms[0].setUInt64 (u64Timestamp); 775 paParms[1].setPointer ((void *) pchBuffer, cchBuffer); 776 callHandle->rc = VINF_HGCM_ASYNC_EXECUTE; 777 pTable->pfnCall(pTable->pvService, callHandle, 0, NULL, 778 GET_NOTIFICATION, 3, paParms); 779 if (callHandle->rc != VINF_HGCM_ASYNC_EXECUTE) 780 { 781 RTPrintf("GET_NOTIFICATION call completed when new notifications should be available.\n"); 769 static char szPattern[] = ""; 770 771 asyncNotification.aParms[0].setPointer ((void *) szPattern, sizeof(szPattern)); 772 asyncNotification.aParms[1].setUInt64 (u64Timestamp); 773 asyncNotification.aParms[2].setPointer ((void *) asyncNotification.chBuffer, 774 sizeof(asyncNotification.chBuffer)); 775 asyncNotification.callHandle.rc = VINF_HGCM_ASYNC_EXECUTE; 776 pTable->pfnCall(pTable->pvService, &asyncNotification.callHandle, 0, NULL, 777 GET_NOTIFICATION, 4, asyncNotification.aParms); 778 if (RT_FAILURE(asyncNotification.callHandle.rc)) 779 { 780 RTPrintf("GET_NOTIFICATION call failed, rc=%Rrc.\n", asyncNotification.callHandle.rc); 781 rc = VERR_UNRESOLVED_ERROR; 782 } 783 else if (asyncNotification.callHandle.rc != VINF_HGCM_ASYNC_EXECUTE) 784 { 785 RTPrintf("GET_NOTIFICATION call completed when no new notifications should be available.\n"); 786 rc = VERR_UNRESOLVED_ERROR; 787 } 788 return rc; 789 } 790 791 /** 792 * Test the asynchronous GET_NOTIFICATION function. 793 * @returns iprt status value to indicate whether the test went as expected. 794 * @note prints its own diagnostic information to stdout. 795 */ 796 int testAsyncNotification(VBOXHGCMSVCFNTABLE *pTable) 797 { 798 int rc = VINF_SUCCESS; 799 uint64_t u64Timestamp; 800 uint32_t u32Size; 801 if ( asyncNotification.callHandle.rc != VINF_SUCCESS 802 || RT_FAILURE(asyncNotification.aParms[1].getUInt64 (&u64Timestamp)) 803 || RT_FAILURE(asyncNotification.aParms[3].getUInt32 (&u32Size)) 804 || u32Size != getNotifications[0].cchBuffer 805 || memcmp(asyncNotification.chBuffer, getNotifications[0].pchBuffer, u32Size) != 0 806 ) 807 { 808 RTPrintf("Asynchronous GET_NOTIFICATION call did not complete as expected, rc=%Rrc\n", 809 asyncNotification.callHandle.rc); 782 810 rc = VERR_UNRESOLVED_ERROR; 783 811 } … … 789 817 VBOXHGCMSVCFNTABLE svcTable; 790 818 VBOXHGCMSVCHELPERS svcHelpers; 791 /* Paramters for the asynchronous guest notification call */792 VBOXHGCMSVCPARM aParm[3];793 char chBuffer[MAX_NAME_LEN + MAX_VALUE_LEN + MAX_FLAGS_LEN];794 VBOXHGCMCALLHANDLE_TYPEDEF callHandleStruct;795 819 796 820 initTable(&svcTable, &svcHelpers); … … 808 832 if (RT_FAILURE(testEnumPropsHost(&svcTable))) 809 833 return 1; 810 /* Asynchronous notification call */ 811 if (RT_FAILURE(testNoNotifications(&svcTable, &callHandleStruct, aParm, 812 chBuffer, sizeof(chBuffer)))) 834 /* Set up the asynchronous notification test */ 835 if (RT_FAILURE(setupAsyncNotification(&svcTable))) 813 836 return 1; 814 837 if (RT_FAILURE(testSetProp(&svcTable))) … … 816 839 RTPrintf("Checking the data returned by the asynchronous notification call.\n"); 817 840 /* Our previous notification call should have completed by now. */ 818 uint64_t u64Timestamp; 819 uint32_t u32Size; 820 if ( callHandleStruct.rc != VINF_SUCCESS 821 || RT_FAILURE(aParm[0].getUInt64 (&u64Timestamp)) 822 || RT_FAILURE(aParm[2].getUInt32 (&u32Size)) 823 || u32Size != getNotifications[0].cchBuffer 824 || memcmp(chBuffer, getNotifications[0].pchBuffer, u32Size) != 0 825 ) 826 { 827 RTPrintf("Asynchronous GET_NOTIFICATION call did not complete as expected, rc=%Rrc\n", 828 callHandleStruct.rc); 829 return 1; 830 } 841 if (RT_FAILURE(testAsyncNotification(&svcTable))) 842 return 1; 831 843 if (RT_FAILURE(testDelProp(&svcTable))) 832 844 return 1;
Note:
See TracChangeset
for help on using the changeset viewer.