コード例 #1
0
ファイル: spoolss.c プロジェクト: endisd/samba
static BOOL test_PrinterData(struct torture_context *tctx,
			     LPSTR servername,
			     HANDLE handle)
{
	BOOL ret = TRUE;
	DWORD i;
	DWORD type, type_ex;
	LPBYTE buffer, buffer_ex;
	DWORD size, size_ex;
	LPSTR valuenames[] = {
		SPLREG_DEFAULT_SPOOL_DIRECTORY,
		SPLREG_MAJOR_VERSION,
		SPLREG_MINOR_VERSION,
		SPLREG_DS_PRESENT,
		SPLREG_DNS_MACHINE_NAME,
		SPLREG_ARCHITECTURE,
		SPLREG_OS_VERSION
	};

	for (i=0; i < ARRAY_SIZE(valuenames); i++) {
		ret &= test_GetPrinterData(tctx, servername, valuenames[i], handle, &type, &buffer, &size);
		ret &= test_GetPrinterDataEx(tctx, servername, "random", valuenames[i], handle, &type_ex, &buffer_ex, &size_ex);
		torture_assert_int_equal(tctx, type, type_ex, "type mismatch");
		torture_assert_int_equal(tctx, size, size_ex, "size mismatch");
		torture_assert_mem_equal(tctx, buffer, buffer_ex, size, "buffer mismatch");
		free(buffer);
		free(buffer_ex);
	}

	return ret;
}
コード例 #2
0
ファイル: spoolss_win.c プロジェクト: DavidMulder/samba
static bool test_WinXP(struct torture_context *tctx, struct dcerpc_pipe *p)
{
	bool ret = true;
	struct test_spoolss_win_context *ctx, *tmp_ctx;
	struct policy_handle handle01, handle02, handle03, handle04;
	/* Sometimes a handle stays unused. In order to make this clear in the
	 * code, the unused_handle structures are used for that. */
	struct policy_handle unused_handle1, unused_handle2;
	char *server_name;
	uint32_t i;
	struct dcerpc_binding_handle *b = p->binding_handle;

	ctx = talloc_zero(tctx, struct test_spoolss_win_context);
	tmp_ctx = talloc_zero(tctx, struct test_spoolss_win_context);

	ret &= test_OpenPrinterSequence(tctx, p, &handle01);
	ret &= test_GetPrinterData(tctx, b, &handle01,"UISingleJobStatusString",
			WERR_INVALID_PARAMETER, 0);
	torture_comment(tctx, "Skip RemoteFindNextPrinterChangeNotifyEx test\n");

	server_name = talloc_asprintf(ctx, "\\\\%s", dcerpc_server_name(p));
	ret &= test_OpenPrinterEx(tctx, b, &unused_handle1, server_name, 0);

	ret &= test_EnumPrinters(tctx, p, ctx, 1024);

	ret &= test_OpenPrinterEx(tctx, b, &handle02, server_name, 0);
	ret &= test_GetPrinterData(tctx, b, &handle02, "MajorVersion", WERR_OK,
			3);
	ret &= test_ClosePrinter(tctx, b, &handle02);

	/* If no printers were found, skip all tests that need a printer */
	if (ctx->printer_count == 0) {
		goto end_testWinXP;
	}

	ret &= test_OpenPrinterEx(tctx, b, &handle02,
			ctx->printer_info[0].info2.printername,
			PRINTER_ACCESS_USE);
	ret &= test_GetPrinter(tctx, b, &handle02, ctx, 2, 0);

	torture_assert_str_equal(tctx, ctx->current_info->info2.printername,
			ctx->printer_info[0].info2.printername,
			"GetPrinter returned unexpected printername");
	/*FIXME: Test more components of the PrinterInfo2 struct */

	ret &= test_OpenPrinterEx(tctx, b, &handle03,
			ctx->printer_info[0].info2.printername, 0);
	ret &= test_GetPrinter(tctx, b, &handle03, ctx, 0, 1164);
	ret &= test_GetPrinter(tctx, b, &handle03, ctx, 2, 0);

	ret &= test_OpenPrinterEx(tctx, b, &handle04,
			ctx->printer_info[0].info2.printername, 0);
	ret &= test_GetPrinter(tctx, b, &handle04, ctx, 2, 0);
	ret &= test_ClosePrinter(tctx, b, &handle04);

	ret &= test_OpenPrinterEx(tctx, b, &handle04,
			ctx->printer_info[0].info2.printername, 0);
	ret &= test_GetPrinter(tctx, b, &handle04, ctx, 2, 4096);
	ret &= test_ClosePrinter(tctx, b, &handle04);

	ret &= test_OpenPrinterAsAdmin(tctx, b,
			ctx->printer_info[0].info2.printername);

	ret &= test_OpenPrinterEx(tctx, b, &handle04,
			ctx->printer_info[0].info2.printername, PRINTER_READ);
	ret &= test_GetPrinterData(tctx, b, &handle04,"UISingleJobStatusString",
			WERR_FILE_NOT_FOUND, 0);
	torture_comment(tctx, "Skip RemoteFindNextPrinterChangeNotifyEx test\n");

	ret &= test_OpenPrinterEx(tctx, b, &unused_handle2,
			ctx->printer_info[0].info2.printername, 0);

	ret &= test_EnumJobs(tctx, b, &handle04);
	ret &= test_GetPrinter(tctx, b, &handle04, ctx, 2, 4096);

	ret &= test_ClosePrinter(tctx, b, &unused_handle2);
	ret &= test_ClosePrinter(tctx, b, &handle04);

	ret &= test_EnumPrinters(tctx, p, ctx, 1556);
	ret &= test_GetPrinterDriver2(tctx, b, ctx, &handle03);
	ret &= test_EnumForms(tctx, b, &handle03, 0);

	ret &= test_EnumPrinterKey(tctx, b, &handle03, "", ctx);

	for (i=0; ctx->printer_keys && ctx->printer_keys[i] != NULL; i++) {

		ret &= test_EnumPrinterKey(tctx, b, &handle03,
					   ctx->printer_keys[i],
					   tmp_ctx);
		ret &= test_EnumPrinterDataEx(tctx, b, &handle03,
					      ctx->printer_keys[i], 0,
					      WERR_OK);
	}

	ret &= test_EnumPrinterDataEx(tctx, b, &handle03, "", 0,
			WERR_INVALID_PARAMETER);

	ret &= test_GetPrinter(tctx, b, &handle03, tmp_ctx, 2, 0);

	ret &= test_OpenPrinterEx(tctx, b, &unused_handle2,
			ctx->printer_info[0].info2.printername, 0);
	ret &= test_ClosePrinter(tctx, b, &unused_handle2);

	ret &= test_GetPrinter(tctx, b, &handle03, tmp_ctx, 2, 2556);

	ret &= test_OpenPrinterEx(tctx, b, &unused_handle2,
			ctx->printer_info[0].info2.printername, 0);
	ret &= test_ClosePrinter(tctx, b, &unused_handle2);

	ret &= test_OpenPrinterEx(tctx, b, &unused_handle2,
			ctx->printer_info[0].info2.printername, 0);
	ret &= test_ClosePrinter(tctx, b, &unused_handle2);

	ret &= test_GetPrinter(tctx, b, &handle03, tmp_ctx, 7, 0);

	ret &= test_OpenPrinterEx(tctx, b, &unused_handle2,
			ctx->printer_info[0].info2.printername, 0);
	ret &= test_ClosePrinter(tctx, b, &unused_handle2);

	ret &= test_ClosePrinter(tctx, b, &handle03);

	ret &= test_OpenPrinterEx(tctx, b, &unused_handle2,
			ctx->printer_info[0].info2.printername, 0);
	ret &= test_ClosePrinter(tctx, b, &unused_handle2);

	ret &= test_OpenPrinterEx(tctx, b, &handle03, server_name, 0);
	ret &= test_GetPrinterData(tctx, b, &handle03, "W3SvcInstalled",
			WERR_OK, 0);
	ret &= test_ClosePrinter(tctx, b, &handle03);

	ret &= test_ClosePrinter(tctx, b, &unused_handle1);
	ret &= test_ClosePrinter(tctx, b, &handle02);

	ret &= test_OpenPrinterEx(tctx, b, &handle02,
			ctx->printer_info[0].info2.sharename, 0);
	ret &= test_GetPrinter(tctx, b, &handle02, tmp_ctx, 2, 0);
	ret &= test_ClosePrinter(tctx, b, &handle02);

end_testWinXP:
	ret &= test_ClosePrinter(tctx, b, &handle01);

	talloc_free(tmp_ctx);
	talloc_free(ctx);
	return ret;
}