Skip to content

Commit

Permalink
s4:torture: Add driver parsing wrapper
Browse files Browse the repository at this point in the history
Add wrapper function to parse inf driver file and get
validated driver information.

Signed-off-by: Justin Stephenson <[email protected]>
Reviewed-by: Andreas Schneider <[email protected]>
Reviewed-by: Bjoern Jacke <[email protected]>
  • Loading branch information
justin-stephenson authored and Bjoern Jacke committed Jan 28, 2019
1 parent 7783c62 commit 1ac1b3e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
35 changes: 35 additions & 0 deletions source4/torture/rpc/iremotewinspool_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "torture/rpc/torture_rpc.h"
#include "libcli/registry/util_reg.h"
#include "torture/rpc/iremotewinspool_common.h"
#include "lib/printer_driver/printer_driver.h"

struct spoolss_UserLevel1 test_get_client_info(struct torture_context *tctx,
enum client_os_version os,
Expand Down Expand Up @@ -198,3 +199,37 @@ bool test_AsyncGetPrinterData_args(struct torture_context *tctx,
NULL,
type_p, data_p, needed_p);
}

/* Parse a driver inf file */
bool parse_inf_driver(struct torture_context *tctx,
const char *driver_name,
const char *abs_inf_path,
const char *driver_arch,
const char *core_driver_inf,
struct spoolss_AddDriverInfo8 **_parsed_dinfo)
{
struct spoolss_AddDriverInfo8 *drv_info;
const char *source_disk_name = NULL;
NTSTATUS status;
bool ok = true;

drv_info = talloc_zero(tctx, struct spoolss_AddDriverInfo8);
torture_assert_not_null_goto(tctx, drv_info, ok, done, "Cannot allocate memory");

status = driver_inf_parse(tctx,
core_driver_inf,
abs_inf_path,
driver_arch,
driver_name,
drv_info,
&source_disk_name);

if (NT_STATUS_EQUAL(status, NT_STATUS_DRIVER_INTERNAL_ERROR)) {
torture_comment(tctx, "--- Verify the correct torture option:driver_name is provided\n");
}
torture_assert_ntstatus_ok_goto(tctx, status, ok, done, "Failed to parse driver inf\n");

*_parsed_dinfo = drv_info;
done:
return ok;
}
7 changes: 7 additions & 0 deletions source4/torture/rpc/iremotewinspool_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,10 @@ bool test_AsyncGetPrinterData_args(struct torture_context *tctx,
enum winreg_Type *type_p,
uint8_t **data_p,
uint32_t *needed_p);

bool parse_inf_driver(struct torture_context *tctx,
const char *driver_name,
const char *abs_inf_path,
const char *driver_arch,
const char *core_driver_inf,
struct spoolss_AddDriverInfo8 **_parsed_dinfo);

0 comments on commit 1ac1b3e

Please sign in to comment.