- Timestamp:
- Aug 15, 2016 9:33:32 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/testcase/tstGuestCtrlParseBuffer.cpp
r63258 r63504 32 32 #endif 33 33 34 #define STR_SIZE(a_sz) a_sz, sizeof(a_sz) 35 36 34 37 typedef struct VBOXGUESTCTRL_BUFFER_VALUE 35 38 { … … 60 63 */ 61 64 /* Invalid stuff. */ 62 { NULL, 0, 63 { NULL, 512, 64 { "", 0, 65 { "", 0, 66 { "foo=bar1", 0, 67 { "foo=bar2", 0, 65 { NULL, 0, 0, 0, 0, VERR_INVALID_POINTER }, 66 { NULL, 512, 0, 0, 0, VERR_INVALID_POINTER }, 67 { "", 0, 0, 0, 0, VERR_INVALID_PARAMETER }, 68 { "", 0, 0, 0, 0, VERR_INVALID_PARAMETER }, 69 { "foo=bar1", 0, 0, 0, 0, VERR_INVALID_PARAMETER }, 70 { "foo=bar2", 0, 50, 50, 0, VERR_INVALID_PARAMETER }, 68 71 /* Empty buffers. */ 69 { "", 1, 70 { "\0", 1, 72 { "", 1, 0, 1, 0, VINF_SUCCESS }, 73 { "\0", 1, 0, 1, 0, VINF_SUCCESS }, 71 74 /* Unterminated values (missing "\0"). */ 72 { "test1", sizeof("test1"),0, 0, 0, VERR_MORE_DATA },73 { "test2=", sizeof("test2="),0, 0, 0, VERR_MORE_DATA },74 { "test3=test3", sizeof("test3=test3"),0, 0, 0, VERR_MORE_DATA },75 { "test4=test4\0t41", sizeof("test4=test4\0t41"),0, sizeof("test4=test4\0") - 1, 1, VERR_MORE_DATA },76 { "test5=test5\0t51=t51", sizeof("test5=test5\0t51=t51"),0, sizeof("test5=test5\0") - 1, 1, VERR_MORE_DATA },75 { STR_SIZE("test1"), 0, 0, 0, VERR_MORE_DATA }, 76 { STR_SIZE("test2="), 0, 0, 0, VERR_MORE_DATA }, 77 { STR_SIZE("test3=test3"), 0, 0, 0, VERR_MORE_DATA }, 78 { STR_SIZE("test4=test4\0t41"), 0, sizeof("test4=test4\0") - 1, 1, VERR_MORE_DATA }, 79 { STR_SIZE("test5=test5\0t51=t51"), 0, sizeof("test5=test5\0") - 1, 1, VERR_MORE_DATA }, 77 80 /* Next block unterminated. */ 78 { "t51=t51\0t52=t52\0\0t53=t53", sizeof("t51=t51\0t52=t52\0\0t53=t53"),0, sizeof("t51=t51\0t52=t52\0") - 1, 2, VINF_SUCCESS },79 { "test6=test6\0\0t61=t61", sizeof("test6=test6\0\0t61=t61"),0, sizeof("test6=test6\0") - 1, 1, VINF_SUCCESS },81 { STR_SIZE("t51=t51\0t52=t52\0\0t53=t53"), 0, sizeof("t51=t51\0t52=t52\0") - 1, 2, VINF_SUCCESS }, 82 { STR_SIZE("test6=test6\0\0t61=t61"), 0, sizeof("test6=test6\0") - 1, 1, VINF_SUCCESS }, 80 83 /* Good stuff. */ 81 { "test61=\0test611=test611\0", sizeof("test61=\0test611=test611\0"),0, sizeof("test61=\0test611=test611\0") - 1, 2, VINF_SUCCESS },82 { "test7=test7\0\0", sizeof("test7=test7\0\0"),0, sizeof("test7=test7\0") - 1, 1, VINF_SUCCESS },83 { "test8=test8\0t81=t81\0\0", sizeof("test8=test8\0t81=t81\0\0"),0, sizeof("test8=test8\0t81=t81\0") - 1, 2, VINF_SUCCESS },84 { STR_SIZE("test61=\0test611=test611\0"), 0, sizeof("test61=\0test611=test611\0") - 1, 2, VINF_SUCCESS }, 85 { STR_SIZE("test7=test7\0\0"), 0, sizeof("test7=test7\0") - 1, 1, VINF_SUCCESS }, 86 { STR_SIZE("test8=test8\0t81=t81\0\0"), 0, sizeof("test8=test8\0t81=t81\0") - 1, 2, VINF_SUCCESS }, 84 87 /* Good stuff, but with a second block -- should be *not* taken into account since 85 88 * we're only interested in parsing/handling the first object. */ 86 { "t9=t9\0t91=t91\0\0t92=t92\0\0", sizeof("t9=t9\0t91=t91\0\0t92=t92\0\0"),0, sizeof("t9=t9\0t91=t91\0") - 1, 2, VINF_SUCCESS },89 { STR_SIZE("t9=t9\0t91=t91\0\0t92=t92\0\0"), 0, sizeof("t9=t9\0t91=t91\0") - 1, 2, VINF_SUCCESS }, 87 90 /* Nasty stuff. */ 88 { "äöü=fäö\0\0", sizeof("äöü=fäö\0\0"), 0, sizeof("äöü=fäö\0") - 1, 1, VINF_SUCCESS }, 89 { "äöü=fäö\0ööö=äää", sizeof("äöü=fäö\0ööö=äää"), 0, sizeof("äöü=fäö\0") - 1, 1, VERR_MORE_DATA }, 91 /* iso 8859-1 encoding (?) of 'aou' all with diaeresis '=f' and 'ao' with diaeresis. */ 92 { STR_SIZE("\xe4\xf6\xfc=\x66\xe4\xf6\0\0"), 0, sizeof("\xe4\xf6\xfc=\x66\xe4\xf6\0") - 1, 1, VINF_SUCCESS }, 93 /* Like above, but after the first '\0' it adds 'ooo=aaa' all letters with diaeresis. */ 94 { STR_SIZE("\xe4\xf6\xfc=\x66\xe4\xf6\0\xf6\xf6\xf6=\xe4\xe4\xe4"), 95 0, sizeof("\xe4\xf6\xfc=\x66\xe4\xf6\0") - 1, 1, VERR_MORE_DATA }, 90 96 /* Some "real world" examples. */ 91 { "hdr_id=vbt_stat\0hdr_ver=1\0name=foo.txt\0\0", 92 sizeof("hdr_id=vbt_stat\0hdr_ver=1\0name=foo.txt\0\0"), 93 0, sizeof("hdr_id=vbt_stat\0hdr_ver=1\0name=foo.txt\0") - 1, 97 { STR_SIZE("hdr_id=vbt_stat\0hdr_ver=1\0name=foo.txt\0\0"), 0, sizeof("hdr_id=vbt_stat\0hdr_ver=1\0name=foo.txt\0") - 1, 94 98 3, VINF_SUCCESS } 95 99 }; … … 136 140 137 141 GuestProcessStream stream; 138 rc = stream.AddData((BYTE *)s_aTest[iTest].pbData, s_aTest[iTest].cbData);142 rc = stream.AddData((BYTE *)s_aTest[iTest].pbData, s_aTest[iTest].cbData); 139 143 140 144 for (;;)
Note:
See TracChangeset
for help on using the changeset viewer.