- Timestamp:
- Nov 14, 2008 3:05:30 PM (16 years ago)
- Location:
- trunk/src
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxControl/Makefile.kmk
r12446 r14220 22 22 SUB_DEPTH = ../../../../.. 23 23 include $(KBUILD_PATH)/subheader.kmk 24 25 # Include sub-makefile(s). 26 include $(PATH_SUB_CURRENT)/testcase/Makefile.kmk 24 27 25 28 # -
trunk/src/VBox/Additions/common/VBoxControl/VBoxControl.cpp
r13292 r14220 89 89 RTPrintf("%s -nologo ... suppress the logo\n\n", g_pszProgName); 90 90 91 #ifdef RT_OS_WINDOWS 91 /* Exclude the Windows bits from the test version. Anyone who needs to test 92 * them can fix this. */ 93 #if defined(RT_OS_WINDOWS) && !defined(VBOX_CONTROL_TEST) 92 94 if ((GET_VIDEO_ACCEL == eWhich) || (USAGE_ALL == eWhich)) 93 95 doUsage("\n", g_pszProgName, "getvideoacceleration"); … … 109 111 doUsage("set <property> [<value> [-flags <flags>]]\n", g_pszProgName, "guestproperty"); 110 112 doUsage("enumerate [-patterns <patterns>]\n", g_pszProgName, "guestproperty"); 113 doUsage("wait <patterns> [-timestamp <last timestamp>]\n", g_pszProgName, "guestproperty"); 114 doUsage("[-timeout <timeout>\n"); 111 115 } 112 116 #endif … … 130 134 } 131 135 132 #if def RT_OS_WINDOWS136 #if defined(RT_OS_WINDOWS) && !defined(VBOX_CONTROL_TEST) 133 137 134 138 LONG (WINAPI * gpfnChangeDisplaySettingsEx)(LPCTSTR lpszDeviceName, LPDEVMODE lpDevMode, HWND hwnd, DWORD dwflags, LPVOID lParam); … … 1094 1098 1095 1099 /** 1100 * Waits for notifications of changes to guest properties. 1101 * This is accessed through the "VBoxGuestPropSvc" HGCM service. 1102 * 1103 * @returns 0 on success, 1 on failure 1104 * @note see the command line API description for parameters 1105 */ 1106 int waitGuestProperty(int argc, char **argv) 1107 { 1108 using namespace guestProp; 1109 1110 /* 1111 * Handle arguments 1112 */ 1113 const char *pszPatterns = NULL; 1114 uint64_t u64TimestampIn = 0; 1115 uint32_t u32Timeout = RT_INDEFINITE_WAIT; 1116 bool usageOK = true; 1117 if (argc < 1) 1118 usageOK = false; 1119 pszPatterns = argv[0]; 1120 for (int i = 1; usageOK && i < argc; ++i) 1121 { 1122 if (strcmp(argv[i], "-timeout") == 0) 1123 { 1124 if ( i + 1 >= argc 1125 || RTStrToUInt32Full(argv[i + 1], 10, &u32Timeout) 1126 != VINF_SUCCESS 1127 ) 1128 usageOK = false; 1129 else 1130 ++i; 1131 } 1132 else if (strcmp(argv[i], "-timestamp") == 0) 1133 { 1134 if ( i + 1 >= argc 1135 || RTStrToUInt64Full(argv[i + 1], 10, &u64TimestampIn) 1136 != VINF_SUCCESS 1137 ) 1138 usageOK = false; 1139 else 1140 ++i; 1141 } 1142 else 1143 usageOK = false; 1144 } 1145 if (!usageOK) 1146 { 1147 usage(GUEST_PROP); 1148 return 1; 1149 } 1150 1151 /* 1152 * Connect to the service 1153 */ 1154 uint32_t u32ClientId = 0; 1155 int rc = VINF_SUCCESS; 1156 1157 rc = VbglR3GuestPropConnect(&u32ClientId); 1158 if (!RT_SUCCESS(rc)) 1159 VBoxControlError("Failed to connect to the guest property service, error %Rrc\n", rc); 1160 1161 /* 1162 * Retrieve the notification from the host 1163 */ 1164 char *pszName = NULL; 1165 char *pszValue = NULL; 1166 uint64_t u64TimestampOut = 0; 1167 char *pszFlags = NULL; 1168 /* The buffer for storing the data and its initial size. We leave a bit 1169 * of space here in case the maximum values are raised. */ 1170 void *pvBuf = NULL; 1171 uint32_t cbBuf = MAX_NAME_LEN + MAX_VALUE_LEN + MAX_FLAGS_LEN + 1024; 1172 /* Because there is a race condition between our reading the size of a 1173 * property and the guest updating it, we loop a few times here and 1174 * hope. Actually this should never go wrong, as we are generous 1175 * enough with buffer space. */ 1176 bool finish = false; 1177 for (unsigned i = 0; 1178 (RT_SUCCESS(rc) || rc == VERR_BUFFER_OVERFLOW) && !finish && (i < 10); 1179 ++i) 1180 { 1181 void *pvTmpBuf = RTMemRealloc(pvBuf, cbBuf); 1182 if (NULL == pvTmpBuf) 1183 { 1184 rc = VERR_NO_MEMORY; 1185 VBoxControlError("Out of memory\n"); 1186 } 1187 else 1188 { 1189 pvBuf = pvTmpBuf; 1190 rc = VbglR3GuestPropWait(u32ClientId, pszPatterns, pvBuf, cbBuf, 1191 u64TimestampIn, u32Timeout, 1192 &pszName, &pszValue, &u64TimestampOut, 1193 &pszFlags, &cbBuf); 1194 } 1195 if (VERR_BUFFER_OVERFLOW == rc) 1196 /* Leave a bit of extra space to be safe */ 1197 cbBuf += 1024; 1198 else 1199 finish = true; 1200 if (rc == VERR_TOO_MUCH_DATA) 1201 VBoxControlError("Temporarily unable to get a notification\n"); 1202 else if (rc == VERR_INTERRUPTED) 1203 VBoxControlError("The request timed out or was interrupted\n"); 1204 #ifndef RT_OS_WINDOWS /* Windows guests do not do this right */ 1205 else if (!RT_SUCCESS(rc) && (rc != VERR_NOT_FOUND)) 1206 VBoxControlError("Failed to get a notification, error %Rrc\n", rc); 1207 #endif 1208 } 1209 /* 1210 * And display it on the guest console. 1211 */ 1212 if (VERR_NOT_FOUND == rc) 1213 RTPrintf("No value set!\n"); 1214 else if (rc == VERR_BUFFER_OVERFLOW) 1215 RTPrintf("Internal error: unable to determine the size of the data!\n"); 1216 else if (RT_SUCCESS(rc)) 1217 { 1218 RTPrintf("Name: %s\n", pszName); 1219 RTPrintf("Value: %s\n", pszValue); 1220 RTPrintf("Timestamp: %lld ns\n", u64TimestampOut); 1221 RTPrintf("Flags: %s\n", pszFlags); 1222 } 1223 1224 if (u32ClientId != 0) 1225 VbglR3GuestPropDisconnect(u32ClientId); 1226 RTMemFree(pvBuf); 1227 return RT_SUCCESS(rc) ? 0 : 1; 1228 } 1229 1230 1231 /** 1096 1232 * Access the guest property store through the "VBoxGuestPropSvc" HGCM 1097 1233 * service. … … 1113 1249 else if (0 == strcmp(argv[0], "enumerate")) 1114 1250 return enumGuestProperty(argc - 1, argv + 1); 1251 else if (0 == strcmp(argv[0], "wait")) 1252 return waitGuestProperty(argc - 1, argv + 1); 1115 1253 /* else */ 1116 1254 usage(GUEST_PROP); … … 1131 1269 } g_commandHandlers[] = 1132 1270 { 1133 #if def RT_OS_WINDOWS1271 #if defined(RT_OS_WINDOWS) && !defined(VBOX_CONTROL_TEST) 1134 1272 { "getvideoacceleration", handleGetVideoAcceleration }, 1135 1273 { "setvideoacceleration", handleSetVideoAcceleration }, -
trunk/src/testcase/tstRunTestcases.cpp
r13836 r14220 72 72 "testcase/tstTime-3", 73 73 "testcase/tstSeamlessX11", 74 "testcase/tstVBoxControl", 74 75 "./tstRunTestcases", 75 76 "./tstAnimate",
Note:
See TracChangeset
for help on using the changeset viewer.