1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

testprogs: make sure to do the same tests as in smbtorture in test_PrinterData().

Guenther
This commit is contained in:
Günther Deschner 2010-03-02 17:25:35 +01:00
parent f73c27116c
commit 74703e4897
3 changed files with 58 additions and 23 deletions

View File

@ -1142,7 +1142,7 @@ void print_printer_keys(LPSTR buffer)
} }
} }
static LPSTR reg_type_str(DWORD type) LPSTR reg_type_str(DWORD type)
{ {
switch (type) { switch (type) {
case REG_DWORD: case REG_DWORD:

View File

@ -54,6 +54,7 @@ void print_driver_info_8(PDRIVER_INFO_8 info);
void print_driver_info_bylevel(DWORD level, LPBYTE buffer, DWORD count); void print_driver_info_bylevel(DWORD level, LPBYTE buffer, DWORD count);
void print_doc_info_1(PDOC_INFO_1 info); void print_doc_info_1(PDOC_INFO_1 info);
void print_printer_keys(LPSTR buffer); void print_printer_keys(LPSTR buffer);
LPSTR reg_type_str(DWORD type);
void print_printer_data(LPSTR keyname, LPSTR valuename, DWORD size, LPBYTE buffer, DWORD type); void print_printer_data(LPSTR keyname, LPSTR valuename, DWORD size, LPBYTE buffer, DWORD type);
void print_printer_enum_values(PRINTER_ENUM_VALUES *info); void print_printer_enum_values(PRINTER_ENUM_VALUES *info);
#undef _PRINTF_ATTRIBUTE #undef _PRINTF_ATTRIBUTE

View File

@ -1375,35 +1375,69 @@ static BOOL test_PrinterData(struct torture_context *tctx,
LPSTR printername, LPSTR printername,
HANDLE handle) HANDLE handle)
{ {
char tmp[1024];
LPSTR keyname = "torture_key"; LPSTR keyname = "torture_key";
LPSTR valuename = "torture_value"; LPSTR valuename = "torture_value";
BOOL ret = TRUE; BOOL ret = TRUE;
DWORD type, type_ex; DWORD types[] = {
LPBYTE buffer, buffer_ex; REG_SZ,
DWORD size, size_ex; REG_DWORD,
REG_BINARY
};
DWORD value = 12345678;
LPSTR str = "abcdefghijklmnopqrstuvwxzy";
DWORD t, s;
torture_comment(tctx, "Testing PrinterData"); for (t=0; t < ARRAY_SIZE(types); t++) {
for (s=0; s < strlen(str); s++) {
type = REG_SZ; DWORD type, type_ex;
size = 4; LPBYTE buffer, buffer_ex;
buffer = malloc(size); DWORD size, size_ex;
if (!buffer) {
return FALSE; if (types[t] == REG_DWORD) {
s = 0xffff;
}
switch (types[t]) {
case REG_BINARY:
buffer = malloc(s);
memcpy(buffer, str, s);
size = s;
break;
case REG_DWORD:
buffer = malloc(4);
size = 4;
break;
case REG_SZ:
buffer = malloc(s);
memcpy(buffer, str, s);
size = s;
break;
default:
sprintf(tmp, "type %d untested\n", types[t]);
torture_fail(tctx, tmp);
break;
}
type = types[t];
torture_comment(tctx, "Testing PrinterData (type: %s, size: 0x%08x)", reg_type_str(type), size);
ret &= test_SetPrinterDataEx(tctx, printername, keyname, valuename, handle, type, buffer, size);
ret &= test_GetPrinterDataEx(tctx, printername, keyname, valuename, handle, &type_ex, &buffer_ex, &size_ex);
if (ret == TRUE) {
if (!PrinterDataEqual(tctx, type_ex, type, size_ex, size, buffer_ex, buffer)) {
torture_warning(tctx, "GetPrinterDataEx does not return the same info as we set with SetPrinterDataEx");
ret = FALSE;
}
}
ret &= test_DeletePrinterDataEx(tctx, printername, keyname, valuename, handle);
ret &= test_DeletePrinterKey(tctx, printername, keyname, handle);
free(buffer);
} }
buffer[0] = 'c';
buffer[1] = 'r';
buffer[2] = 'a';
buffer[3] = 'p';
ret &= test_SetPrinterDataEx(tctx, printername, keyname, valuename, handle, type, buffer, size);
ret &= test_GetPrinterDataEx(tctx, printername, keyname, valuename, handle, &type_ex, &buffer_ex, &size_ex);
if (ret == TRUE) {
ret &= PrinterDataEqual(tctx, type_ex, type, size_ex, size, buffer_ex, buffer);
} }
ret &= test_DeletePrinterDataEx(tctx, printername, keyname, valuename, handle);
ret &= test_DeletePrinterKey(tctx, printername, keyname, handle);
free(buffer);
return TRUE; return TRUE;
} }