summaryrefslogtreecommitdiff
path: root/source4/torture/rpc
diff options
context:
space:
mode:
authorJustin Stephenson <jstephen@redhat.com>2018-10-15 13:55:37 -0400
committerBjoern Jacke <bjacke@samba.org>2019-01-28 15:44:19 +0100
commit01f1bd3ff1c8916c26e2fc833cedd7120cc76f6e (patch)
tree683b4be3e5962276338c392da7450753158fecba /source4/torture/rpc
parent1ac1b3e12fb5d981e94887e30669f7326ff5d6f7 (diff)
downloadsamba-01f1bd3ff1c8916c26e2fc833cedd7120cc76f6e.tar.gz
s4:torture: Add test_init_driver_info function
Validate torture options, obtain and retrieve driver information, and call driver parsing function to retrieve driver info needed for performing the test. Signed-off-by: Justin Stephenson <jstephen@redhat.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Bjoern Jacke <bjacke@samba.org>
Diffstat (limited to 'source4/torture/rpc')
-rw-r--r--source4/torture/rpc/iremotewinspool_common.h16
-rw-r--r--source4/torture/rpc/iremotewinspool_driver.c128
2 files changed, 144 insertions, 0 deletions
diff --git a/source4/torture/rpc/iremotewinspool_common.h b/source4/torture/rpc/iremotewinspool_common.h
index b68b70f4052..de1bd959fc1 100644
--- a/source4/torture/rpc/iremotewinspool_common.h
+++ b/source4/torture/rpc/iremotewinspool_common.h
@@ -21,10 +21,26 @@
#include "torture/rpc/torture_rpc.h"
+struct test_driver_info {
+ struct smbcli_state *cli;
+ struct spoolss_AddDriverInfo8 *info;
+ const char *local_driver_path;
+ size_t driver_path_len;
+ char *server_name;
+ char *share_name;
+ char *print_upload_guid_dir;
+ const char *inf_file;
+ const char *uploaded_inf_path;
+ const char *driver_name;
+ const char *driver_arch;
+ const char *core_driver_inf;
+};
+
struct test_iremotewinspool_context {
struct GUID object_uuid;
struct dcerpc_pipe *iremotewinspool_pipe;
struct policy_handle server_handle;
+ struct test_driver_info *dinfo;
const char *environment;
};
diff --git a/source4/torture/rpc/iremotewinspool_driver.c b/source4/torture/rpc/iremotewinspool_driver.c
index f7562e418c4..8e80d1bb0fc 100644
--- a/source4/torture/rpc/iremotewinspool_driver.c
+++ b/source4/torture/rpc/iremotewinspool_driver.c
@@ -27,6 +27,100 @@
#include "libcli/registry/util_reg.h"
#include "torture/rpc/iremotewinspool_common.h"
+static bool test_get_driver_torture_options(struct torture_context *tctx,
+ const char **_local_driver_path,
+ const char **_inf_file,
+ const char **_driver_name,
+ const char **_driver_arch,
+ const char **_core_driver_inf)
+{
+ const char *local_driver_path = NULL;
+ const char *inf_file = NULL;
+ const char *driver_name = NULL;
+ const char *driver_arch = NULL;
+ const char *core_driver_inf = NULL;
+ const char *arches_list[] = {
+ SPOOLSS_ARCHITECTURE_x64,
+ SPOOLSS_ARCHITECTURE_NT_X86,
+ SPOOLSS_ARCHITECTURE_IA_64,
+ SPOOLSS_ARCHITECTURE_ARM,
+ SPOOLSS_ARCHITECTURE_4_0,
+ NULL,
+ };
+ const char **p;
+ bool valid = false;
+ bool ok = true;
+
+ local_driver_path = torture_setting_string(tctx, "driver_path", NULL);
+ if (local_driver_path == NULL) {
+ torture_fail(tctx,
+ "option --option=torture:driver_path="
+ "/full/path/to/local/driver/dir\n");
+ }
+
+ inf_file = torture_setting_string(tctx, "inf_file", NULL);
+ if (inf_file == NULL) {
+ torture_fail(tctx,
+ "option --option=torture:inf_file="
+ "filename.inf\n");
+ }
+
+ driver_name = torture_setting_string(tctx, "driver_name", NULL);
+ if (driver_name == NULL) {
+ torture_fail(tctx,
+ "option --option=torture:driver_name="
+ "driver name\n");
+ }
+
+ driver_arch = torture_setting_string(tctx, "driver_arch", NULL);
+ if (driver_arch == NULL) {
+ torture_fail(tctx,
+ "option --option=torture:driver_arch="
+ "driver arch\n");
+ }
+
+ core_driver_inf = torture_setting_string(tctx, "core_driver_inf", NULL);
+
+ for (p = arches_list; *p != NULL; p++) {
+ if (strequal(*p, driver_arch) == 0) {
+ valid = true;
+ break;
+ }
+ }
+ torture_assert_goto(tctx, valid, ok, done, "Invalid driver arch provided");
+
+ *_local_driver_path = local_driver_path;
+ *_inf_file = inf_file;
+ *_driver_name = driver_name;
+ *_driver_arch = driver_arch;
+ *_core_driver_inf = core_driver_inf;
+done:
+ return ok;
+}
+
+
+static bool test_get_misc_driver_info(struct torture_context *tctx,
+ struct test_driver_info *dinfo,
+ const char **_abs_inf_path,
+ size_t *_driver_path_len)
+{
+ const char *abs_inf_path;
+ size_t driver_path_len;
+ bool ok = true;
+
+ driver_path_len = strlen(dinfo->local_driver_path);
+ torture_assert_int_not_equal_goto(tctx, driver_path_len, 0, ok, done, "driver path length is 0");
+
+ abs_inf_path = talloc_asprintf(tctx, "%s/%s", dinfo->local_driver_path, dinfo->inf_file);
+ torture_assert_not_null_goto(tctx, abs_inf_path, ok, done, "Cannot allocate memory");
+
+ *_abs_inf_path = abs_inf_path;
+ *_driver_path_len = driver_path_len;
+done:
+
+ return ok;
+}
+
static bool test_init_iremotewinspool_conn(struct torture_context *tctx,
struct test_iremotewinspool_context *t)
{
@@ -80,6 +174,40 @@ done:
return ok;
}
+static bool test_init_driver_info(struct torture_context *tctx,
+ struct test_iremotewinspool_context *t)
+{
+ bool ok = true;
+ const char *abs_inf_path;
+ struct test_driver_info *drv_info = {0};
+
+ drv_info = talloc_zero(tctx, struct test_driver_info);
+ torture_assert_not_null_goto(tctx, drv_info, ok, done, "Cannot allocate memory");
+
+ t->dinfo = drv_info;
+
+ ok = test_get_driver_torture_options(tctx,
+ &drv_info->local_driver_path,
+ &drv_info->inf_file,
+ &drv_info->driver_name,
+ &drv_info->driver_arch,
+ &drv_info->core_driver_inf);
+ torture_assert_goto(tctx, ok, ok, done, "Failed to get driver torture options");
+
+ ok = test_get_misc_driver_info(tctx, drv_info,
+ &abs_inf_path,
+ &drv_info->driver_path_len);
+ torture_assert_goto(tctx, ok, ok, done, "Failed to get misc driver info");
+
+ ok = parse_inf_driver(tctx, drv_info->driver_name, abs_inf_path, drv_info->driver_arch,
+ drv_info->core_driver_inf, &drv_info->info);
+ torture_assert_goto(tctx, ok, ok, done, "Failed to parse inf driver");
+
+done:
+ return ok;
+
+}
+
static bool torture_rpc_iremotewinspool_drv_setup_common(struct torture_context *tctx,
struct test_iremotewinspool_context *t)
{