s4:torture: Add driver parsing wrapper
authorJustin Stephenson <jstephen@redhat.com>
Mon, 15 Oct 2018 17:28:01 +0000 (13:28 -0400)
committerBjoern Jacke <bjacke@samba.org>
Mon, 28 Jan 2019 14:44:19 +0000 (15:44 +0100)
Add wrapper function to parse inf driver file and get
validated driver information.

Signed-off-by: Justin Stephenson <jstephen@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Bjoern Jacke <bjacke@samba.org>
source4/torture/rpc/iremotewinspool_common.c
source4/torture/rpc/iremotewinspool_common.h

index 9fe5d061551da5b87788d371575a33cd570c7e10..1d5b7046fea90dbe75e604dcbe16ef44cf8c5584 100644 (file)
@@ -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,
@@ -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;
+}
index 39bd9672b686e4d7fd42cb10760d34412d703375..b68b70f4052cb7e271e092ac9613ecfc2cbba7bc 100644 (file)
@@ -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);