コード例 #1
0
ファイル: irpc.c プロジェクト: Alexandr-Galko/samba
/*
  test a echodata call over the internal messaging system
*/
static bool test_echodata(struct torture_context *tctx,
						  const void *tcase_data,
						  const void *test_data)
{
	struct echo_EchoData r;
	NTSTATUS status;
	const struct irpc_test_data *data = (const struct irpc_test_data *)tcase_data;
	TALLOC_CTX *mem_ctx = tctx;
	struct dcerpc_binding_handle *irpc_handle;

	irpc_handle = irpc_binding_handle(mem_ctx, data->msg_ctx1,
					  cluster_id(0, MSG_ID2),
					  &ndr_table_rpcecho);
	torture_assert(tctx, irpc_handle, "no memory");

	/* make the call */
	r.in.in_data = (unsigned char *)talloc_strdup(mem_ctx, "0123456789");
	r.in.len = strlen((char *)r.in.in_data);

	status = dcerpc_echo_EchoData_r(irpc_handle, mem_ctx, &r);
	torture_assert_ntstatus_ok(tctx, status, "EchoData failed");

	/* check the answer */
	if (memcmp(r.out.out_data, r.in.in_data, r.in.len) != 0) {
		NDR_PRINT_OUT_DEBUG(echo_EchoData, &r);
		torture_fail(tctx, "EchoData wrong answer");
	}

	torture_comment(tctx, "Echo '%*.*s' -> '%*.*s'\n", 
	       r.in.len, r.in.len,
	       r.in.in_data,
	       r.in.len, r.in.len,
	       r.out.out_data);
	return true;
}
コード例 #2
0
ファイル: echo.c プロジェクト: DavidMulder/samba
/*
  test the EchoData interface
*/
static bool test_echodata(struct torture_context *tctx,
			  struct dcerpc_pipe *p)
{
	int i;
	uint8_t *data_in, *data_out;
	int len;
	struct echo_EchoData r;
	struct dcerpc_binding_handle *b = p->binding_handle;

	if (torture_setting_bool(tctx, "quick", false) &&
	    (p->conn->flags & DCERPC_DEBUG_VALIDATE_BOTH)) {
		len = 1 + (random() % 500);
	} else {
		len = 1 + (random() % 5000);
	}

	data_in = talloc_array(tctx, uint8_t, len);
	data_out = talloc_array(tctx, uint8_t, len);
	for (i=0;i<len;i++) {
		data_in[i] = i;
	}
	
	r.in.len = len;
	r.in.in_data = data_in;

	torture_assert_ntstatus_ok(tctx, dcerpc_echo_EchoData_r(b, tctx, &r),
		talloc_asprintf(tctx, "EchoData(%d) failed\n", len));

	data_out = r.out.out_data;

	for (i=0;i<len;i++) {
		if (data_in[i] != data_out[i]) {
			torture_comment(tctx, "Bad data returned for len %d at offset %d\n", 
			       len, i);
			torture_comment(tctx, "in:\n");
			dump_data(0, data_in+i, MIN(len-i, 16));
			torture_comment(tctx, "out:\n");
			dump_data(0, data_out+i, MIN(len-1, 16));
			return false;
		}
	}
	return true;
}