Changeset 39240 in vbox for trunk/src/VBox/HostServices
- Timestamp:
- Nov 8, 2011 1:20:28 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/GuestProperties/testcase/tstGuestPropSvc.cpp
r39236 r39240 672 672 673 673 /* Test "buffer too small" */ 674 char achBuffer[MAX_NAME_LEN + MAX_VALUE_LEN + MAX_FLAGS_LEN];675 674 static char s_szPattern[] = ""; 676 675 VBOXHGCMCALLHANDLE_TYPEDEF callHandle = { VINF_SUCCESS }; 677 676 VBOXHGCMSVCPARM aParms[4]; 678 aParms[0].setPointer((void *)s_szPattern, sizeof(s_szPattern)); 679 aParms[1].setUInt64(1); 680 aParms[2].setPointer((void *)achBuffer, g_aGetNotifications[0].cbBuffer - 1); 681 pTable->pfnCall(pTable->pvService, &callHandle, 0, NULL, GET_NOTIFICATION, 4, aParms); 682 683 uint32_t cbRetNeeded; 684 if ( callHandle.rc != VERR_BUFFER_OVERFLOW 685 || RT_FAILURE(aParms[3].getUInt32(&cbRetNeeded)) 686 || cbRetNeeded != g_aGetNotifications[0].cbBuffer 687 ) 688 { 689 RTTestIFailed("Getting notification for property '%s' with a too small buffer did not fail correctly.", 690 g_aGetNotifications[0].pchBuffer); 691 return; 677 uint32_t cbRetNeeded; 678 679 for (uint32_t cbBuf = 1; 680 cbBuf < g_aGetNotifications[0].cbBuffer - 1; 681 cbBuf++) 682 { 683 void *pvBuf = RTTestGuardedAllocTail(g_hTest, cbBuf); 684 RTTESTI_CHECK_BREAK(pvBuf); 685 memset(pvBuf, 0x55, cbBuf); 686 687 aParms[0].setPointer((void *)s_szPattern, sizeof(s_szPattern)); 688 aParms[1].setUInt64(1); 689 aParms[2].setPointer(pvBuf, cbBuf); 690 pTable->pfnCall(pTable->pvService, &callHandle, 0, NULL, GET_NOTIFICATION, 4, aParms); 691 692 if ( callHandle.rc != VERR_BUFFER_OVERFLOW 693 || RT_FAILURE(aParms[3].getUInt32(&cbRetNeeded)) 694 || cbRetNeeded != g_aGetNotifications[0].cbBuffer 695 ) 696 { 697 RTTestIFailed("Getting notification for property '%s' with a too small buffer did not fail correctly: %Rrc", 698 g_aGetNotifications[0].pchBuffer, callHandle.rc); 699 } 700 RTTestGuardedFree(g_hTest, pvBuf); 692 701 } 693 702 … … 697 706 for (unsigned i = 0; i < RT_ELEMENTS(g_aGetNotifications); ++i) 698 707 { 708 uint32_t cbBuf = g_aGetNotifications[i].cbBuffer + _1K; 709 void *pvBuf = RTTestGuardedAllocTail(g_hTest, cbBuf); 710 RTTESTI_CHECK_BREAK(pvBuf); 711 memset(pvBuf, 0x55, cbBuf); 712 699 713 aParms[0].setPointer((void *)s_szPattern, sizeof(s_szPattern)); 700 714 aParms[1].setUInt64(u64Timestamp); 701 aParms[2].setPointer( (void *)achBuffer, sizeof(achBuffer));715 aParms[2].setPointer(pvBuf, cbBuf); 702 716 pTable->pfnCall(pTable->pvService, &callHandle, 0, NULL, GET_NOTIFICATION, 4, aParms); 703 717 if ( RT_FAILURE(callHandle.rc) … … 706 720 || RT_FAILURE(aParms[3].getUInt32(&cbRetNeeded)) 707 721 || cbRetNeeded != g_aGetNotifications[i].cbBuffer 708 || memcmp( achBuffer, g_aGetNotifications[i].pchBuffer, cbRetNeeded) != 0722 || memcmp(pvBuf, g_aGetNotifications[i].pchBuffer, cbRetNeeded) != 0 709 723 ) 710 724 { … … 712 726 g_aGetNotifications[i].pchBuffer, callHandle.rc); 713 727 } 728 RTTestGuardedFree(g_hTest, pvBuf); 714 729 } 715 730 }
Note:
See TracChangeset
for help on using the changeset viewer.