Changeset 429 for trunk/server/source4/torture
- Timestamp:
- Apr 9, 2010, 3:51:41 PM (15 years ago)
- Location:
- trunk/server
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
-
Property svn:mergeinfo
set to
/vendor/3.5.2 merged eligible /vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
trunk/server/source4/torture/rpc/spoolss.c
r414 r429 29 29 #include "librpc/gen_ndr/ndr_spoolss_c.h" 30 30 #include "param/param.h" 31 #include "lib/registry/registry.h" 31 32 32 33 #define TORTURE_WELLKNOWN_PRINTER "torture_wkn_printer" … … 119 120 120 121 #define CHECK_NEEDED_SIZE_ENUM_LEVEL(fn, info, level, count, ic, needed, align) do { \ 122 if (torture_setting_bool(tctx, "spoolss_check_size", false)) {\ 121 123 uint32_t size = ndr_size_##fn##_info(tctx, ic, level, count, info);\ 122 124 uint32_t round_size = DO_ROUND(size, align);\ … … 125 127 CHECK_ALIGN(size, align);\ 126 128 }\ 129 }\ 127 130 } while(0) 128 131 129 132 #define CHECK_NEEDED_SIZE_ENUM(fn, info, count, ic, needed, align) do { \ 133 if (torture_setting_bool(tctx, "spoolss_check_size", false)) {\ 130 134 uint32_t size = ndr_size_##fn##_info(tctx, ic, count, info);\ 131 135 uint32_t round_size = DO_ROUND(size, align);\ … … 134 138 CHECK_ALIGN(size, align);\ 135 139 }\ 140 }\ 136 141 } while(0) 137 142 138 143 #define CHECK_NEEDED_SIZE_LEVEL(fn, info, level, ic, needed, align) do { \ 144 if (torture_setting_bool(tctx, "spoolss_check_size", false)) {\ 139 145 uint32_t size = ndr_size_##fn(info, level, ic, 0);\ 140 146 uint32_t round_size = DO_ROUND(size, align);\ … … 142 148 torture_warning(tctx, __location__": "#fn" level %d got unexpected needed size: %d, we calculated: %d", level, needed, round_size);\ 143 149 CHECK_ALIGN(size, align);\ 150 }\ 144 151 }\ 145 152 } while(0) … … 2186 2193 const char *value_name, 2187 2194 enum winreg_Type *type_p, 2188 union spoolss_PrinterData *data_p) 2195 uint8_t **data_p, 2196 uint32_t *needed_p) 2189 2197 { 2190 2198 NTSTATUS status; … … 2199 2207 r.out.needed = &needed; 2200 2208 r.out.type = &type; 2201 r.out.data = &data;2209 r.out.data = talloc_zero_array(tctx, uint8_t, r.in.offered); 2202 2210 2203 2211 torture_comment(tctx, "Testing GetPrinterData(%s)\n", r.in.value_name); … … 2208 2216 if (W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA)) { 2209 2217 r.in.offered = needed; 2210 2218 r.out.data = talloc_zero_array(tctx, uint8_t, r.in.offered); 2211 2219 status = dcerpc_spoolss_GetPrinterData(p, tctx, &r); 2212 2220 torture_assert_ntstatus_ok(tctx, status, "GetPrinterData failed"); … … 2223 2231 2224 2232 if (data_p) { 2225 *data_p = data; 2233 *data_p = r.out.data; 2234 } 2235 2236 if (needed_p) { 2237 *needed_p = needed; 2226 2238 } 2227 2239 … … 2235 2247 const char *value_name, 2236 2248 enum winreg_Type *type_p, 2237 union spoolss_PrinterData *data_p) 2249 uint8_t **data_p, 2250 uint32_t *needed_p) 2238 2251 { 2239 2252 NTSTATUS status; … … 2249 2262 r.out.type = &type; 2250 2263 r.out.needed = &needed; 2251 r.out.data = &data;2264 r.out.data = talloc_zero_array(tctx, uint8_t, r.in.offered); 2252 2265 2253 2266 torture_comment(tctx, "Testing GetPrinterDataEx(%s - %s)\n", … … 2265 2278 if (W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA)) { 2266 2279 r.in.offered = needed; 2280 r.out.data = talloc_zero_array(tctx, uint8_t, r.in.offered); 2267 2281 status = dcerpc_spoolss_GetPrinterDataEx(p, tctx, &r); 2268 2282 torture_assert_ntstatus_ok(tctx, status, "GetPrinterDataEx failed"); … … 2279 2293 2280 2294 if (data_p) { 2281 *data_p = data; 2295 *data_p = r.out.data; 2296 } 2297 2298 if (needed_p) { 2299 *needed_p = needed; 2282 2300 } 2283 2301 … … 2308 2326 for (i=0; i < ARRAY_SIZE(list); i++) { 2309 2327 enum winreg_Type type, type_ex; 2310 union spoolss_PrinterData data, data_ex; 2311 2312 torture_assert(tctx, test_GetPrinterData(tctx, p, handle, list[i], &type, &data), 2328 uint8_t *data, *data_ex; 2329 uint32_t needed, needed_ex; 2330 2331 torture_assert(tctx, test_GetPrinterData(tctx, p, handle, list[i], &type, &data, &needed), 2313 2332 talloc_asprintf(tctx, "GetPrinterData failed on %s\n", list[i])); 2314 torture_assert(tctx, test_GetPrinterDataEx(tctx, p, handle, "random_string", list[i], &type_ex, &data_ex ),2333 torture_assert(tctx, test_GetPrinterDataEx(tctx, p, handle, "random_string", list[i], &type_ex, &data_ex, &needed_ex), 2315 2334 talloc_asprintf(tctx, "GetPrinterDataEx failed on %s\n", list[i])); 2316 2335 torture_assert_int_equal(tctx, type, type_ex, "type mismatch"); 2317 switch (type) { 2318 case REG_SZ: 2319 torture_assert_str_equal(tctx, data.string, data_ex.string, "REG_SZ mismatch"); 2320 break; 2321 case REG_DWORD: 2322 torture_assert_int_equal(tctx, data.value, data_ex.value, "REG_DWORD mismatch"); 2323 break; 2324 case REG_BINARY: 2325 torture_assert_data_blob_equal(tctx, data.binary, data_ex.binary, "REG_BINARY mismatch"); 2326 break; 2327 default: 2328 break; 2329 } 2336 torture_assert_int_equal(tctx, needed, needed_ex, "needed mismatch"); 2337 torture_assert_mem_equal(tctx, data, data_ex, needed, "data mismatch"); 2330 2338 } 2331 2339 … … 2380 2388 torture_assert_werr_ok(tctx, r.out.result, "EnumPrinterData failed"); 2381 2389 2382 torture_assert(tctx, test_GetPrinterData(tctx, p, handle, r.out.value_name, NULL, NULL ),2390 torture_assert(tctx, test_GetPrinterData(tctx, p, handle, r.out.value_name, NULL, NULL, NULL), 2383 2391 talloc_asprintf(tctx, "failed to call GetPrinterData for %s\n", r.out.value_name)); 2384 2392 2385 torture_assert(tctx, test_GetPrinterDataEx(tctx, p, handle, "PrinterDriverData", r.out.value_name, NULL, NULL ),2393 torture_assert(tctx, test_GetPrinterDataEx(tctx, p, handle, "PrinterDriverData", r.out.value_name, NULL, NULL, NULL), 2386 2394 talloc_asprintf(tctx, "failed to call GetPrinterDataEx on PrinterDriverData for %s\n", r.out.value_name)); 2387 2395 … … 2526 2534 2527 2535 enum winreg_Type type; 2528 union spoolss_PrinterData data; 2536 uint8_t *data; 2537 DATA_BLOB blob; 2538 uint32_t needed; 2539 2540 torture_assert(tctx, 2541 reg_string_to_val(tctx, lp_iconv_convenience(tctx->lp_ctx), 2542 "REG_SZ", "dog", &r.in.type, &blob), ""); 2529 2543 2530 2544 r.in.handle = handle; 2531 2545 r.in.value_name = values[i]; 2532 2546 r.in.type = REG_SZ; 2533 r.in.data.string = "dog"; 2547 r.in.data = blob.data; 2548 r.in.offered = blob.length; 2534 2549 2535 2550 torture_comment(tctx, "Testing SetPrinterData(%s)\n", … … 2541 2556 torture_assert_werr_ok(tctx, r.out.result, "SetPrinterData failed"); 2542 2557 2543 if (!test_GetPrinterData(tctx, p, handle, r.in.value_name, &type, &data )) {2558 if (!test_GetPrinterData(tctx, p, handle, r.in.value_name, &type, &data, &needed)) { 2544 2559 return false; 2545 2560 } 2546 2561 2547 2562 torture_assert_int_equal(tctx, r.in.type, type, "type mismatch"); 2548 torture_assert_str_equal(tctx, r.in.data.string, data.string, "data mismatch"); 2563 torture_assert_int_equal(tctx, r.in.offered, needed, "size mismatch"); 2564 torture_assert_mem_equal(tctx, blob.data, data, needed, "buffer mismatch"); 2549 2565 2550 2566 if (!test_DeletePrinterData(tctx, p, handle, r.in.value_name)) { … … 2600 2616 enum winreg_Type type; 2601 2617 const char **subkeys; 2602 union spoolss_PrinterData data; 2618 uint8_t *data_out; 2619 uint32_t needed; 2603 2620 2604 2621 r.in.handle = handle; … … 2606 2623 r.in.value_name = value_name; 2607 2624 r.in.type = REG_BINARY; 2608 r.in.data.binary = blob; 2625 r.in.data = blob.data; 2626 r.in.offered = blob.length; 2609 2627 2610 2628 torture_comment(tctx, "Testing SetPrinterDataEx(%s - %s)\n", r.in.key_name, value_name); … … 2615 2633 torture_assert_werr_ok(tctx, r.out.result, "SetPrinterDataEx failed"); 2616 2634 2617 key = talloc_strdup(tctx, r.in.key_name); 2618 2619 if (!test_GetPrinterDataEx(tctx, p, handle, r.in.key_name, value_name, &type, &data)) { 2635 if (!test_GetPrinterDataEx(tctx, p, handle, keys[i], value_name, &type, &data_out, &needed)) { 2620 2636 return false; 2621 2637 } 2622 2638 2623 torture_assert_int_equal(tctx, r.in.type, type, "type mismatch"); 2624 torture_assert_data_blob_equal(tctx, blob, data.binary, "data mismatch"); 2639 torture_assert_int_equal(tctx, type, REG_BINARY, "type mismatch"); 2640 torture_assert_int_equal(tctx, needed, blob.length, "size mismatch"); 2641 torture_assert_mem_equal(tctx, data_out, blob.data, blob.length, "buffer mismatch"); 2642 2643 key = talloc_strdup(tctx, keys[i]); 2625 2644 2626 2645 if (!test_EnumPrinterDataEx(tctx, p, handle, r.in.key_name)) { … … 2673 2692 { 2674 2693 enum winreg_Type type; 2675 union spoolss_PrinterData data; 2694 uint8_t *data; 2695 uint32_t needed; 2676 2696 2677 2697 torture_assert(tctx, 2678 test_GetPrinterData(tctx, p, handle, "ChangeID", &type, &data ),2698 test_GetPrinterData(tctx, p, handle, "ChangeID", &type, &data, &needed), 2679 2699 "failed to call GetPrinterData"); 2680 2700 2681 2701 torture_assert(tctx, type == REG_DWORD, "unexpected type"); 2682 2683 *change_id = data.value; 2702 torture_assert_int_equal(tctx, needed, 4, "unexpected size"); 2703 2704 *change_id = IVAL(data, 0); 2684 2705 2685 2706 return true; … … 2692 2713 { 2693 2714 enum winreg_Type type; 2694 union spoolss_PrinterData data; 2715 uint8_t *data; 2716 uint32_t needed; 2695 2717 2696 2718 torture_assert(tctx, 2697 test_GetPrinterDataEx(tctx, p, handle, "PrinterDriverData", "ChangeID", &type, &data ),2719 test_GetPrinterDataEx(tctx, p, handle, "PrinterDriverData", "ChangeID", &type, &data, &needed), 2698 2720 "failed to call GetPrinterData"); 2699 2721 2700 2722 torture_assert(tctx, type == REG_DWORD, "unexpected type"); 2701 2702 *change_id = data.value; 2723 torture_assert_int_equal(tctx, needed, 4, "unexpected size"); 2724 2725 *change_id = IVAL(data, 0); 2703 2726 2704 2727 return true; -
trunk/server/source4/torture/rpc/spoolss_win.c
r414 r429 161 161 uint32_t needed; 162 162 enum winreg_Type type; 163 u nion spoolss_PrinterData data;163 uint8_t *data = talloc_zero_array(tctx, uint8_t, 4); 164 164 165 165 torture_comment(tctx, "Testing GetPrinterData(%s).\n", value_name); … … 169 169 gpd.out.needed = &needed; 170 170 gpd.out.type = &type; 171 gpd.out.data = &data;171 gpd.out.data = data; 172 172 173 173 status = dcerpc_spoolss_GetPrinterData(p, tctx, &gpd); … … 177 177 178 178 if (W_ERROR_IS_OK(expected_werr)) { 179 torture_assert_int_equal(tctx, data.value, 179 uint32_t value = IVAL(data, 0); 180 torture_assert_int_equal(tctx, value, 180 181 expected_value, 181 182 talloc_asprintf(tctx, "GetPrinterData for %s did not return expected value.", value_name));
Note:
See TracChangeset
for help on using the changeset viewer.