Exemple #1
0
static void
test_request_credentials_returns_raw_bytes(void **state)
{
	daos_iov_t	creds;
	size_t		expected_len;
	uint8_t		*expected_data;

	memset(&creds, 0, sizeof(daos_iov_t));

	/*
	 * Credential bytes == raw bytes of the packed SecurityCredential
	 */
	expected_len = security_credential__get_packed_size(
			drpc_call_resp_return_security_credential);
	D_ALLOC(expected_data, expected_len);
	security_credential__pack(drpc_call_resp_return_security_credential,
			expected_data);

	assert_int_equal(dc_sec_request_creds(&creds), DER_SUCCESS);

	assert_int_equal(creds.iov_buf_len, expected_len);
	assert_int_equal(creds.iov_len, expected_len);
	assert_memory_equal(creds.iov_buf, expected_data, expected_len);

	D_FREE(expected_data);
	daos_iov_free(&creds);
}
Exemple #2
0
CDocument::CDocument(
	CDocApp *app,
	const char *name)
	:	m_app(app),
		m_modified(false),
		m_named(false),
		m_valid(false),
		m_savePanel(NULL),
		m_saving(false)
{
	D_ALLOC(("CDocument::CDocument()\n"));

	BString entryName("./");

	m_app->AddDocument(this);
	
	//	Get a unique name
	if (name == NULL)
	{
		if (++s_newDocCount == 1)
			entryName << "Untitled";
		else
			entryName << "Untitled-" << s_newDocCount;
	}
	else
	{
		entryName << name;
	}

	//	Um, where should the default directory be?
	//	A preferences item?
	m_entry.SetTo(entryName.String());
}
Exemple #3
0
/* Callers are responsible for freeing *recs if this function returns zero. */
static int
find_hdls_to_close(struct rdb_tx *tx, struct cont_svc *svc, uuid_t *pool_hdls,
		   int n_pool_hdls, struct cont_tgt_close_rec **recs,
		   size_t *recs_size, int *nrecs)
{
	struct close_iter_arg	arg;
	int			rc;

	arg.cia_recs_size = 4096;
	D_ALLOC(arg.cia_recs, arg.cia_recs_size);
	if (arg.cia_recs == NULL)
		return -DER_NOMEM;
	arg.cia_nrecs = 0;
	arg.cia_pool_hdls = pool_hdls;
	arg.cia_n_pool_hdls = n_pool_hdls;

	rc = rdb_tx_iterate(tx, &svc->cs_hdls, false /* !backward */,
			    close_iter_cb, &arg);
	if (rc != 0) {
		D_FREE(arg.cia_recs);
		return rc;
	}

	*recs = arg.cia_recs;
	*recs_size = arg.cia_recs_size;
	*nrecs = arg.cia_nrecs;
	return 0;
}
ParameterWindow::~ParameterWindow() {
    D_ALLOC(("ParameterWindow::~ParameterWindow()\n"));

    if (m_notifyTarget) {
        delete m_notifyTarget;
    }
}
Exemple #5
0
static int
pool_iv_value_alloc_internal(d_sg_list_t *sgl)
{
	uint32_t	buf_size;
	uint32_t	pool_nr;
	int		rc;

	rc = daos_sgl_init(sgl, 1);
	if (rc)
		return rc;

	/* XXX Let's use primary group  + 1 domain per target now. */
	crt_group_size(NULL, &pool_nr);
	buf_size = pool_iv_ent_size((int)pool_nr * 2 * 10);
	D_ALLOC(sgl->sg_iovs[0].iov_buf, buf_size);
	if (sgl->sg_iovs[0].iov_buf == NULL)
		D_GOTO(free, rc = -DER_NOMEM);

	sgl->sg_iovs[0].iov_buf_len = buf_size;
free:
	if (rc)
		daos_sgl_fini(sgl, true);

	return rc;
}
Exemple #6
0
CDestination::~CDestination()
{
	D_ALLOC(("CDestination::~CDestination()\n"));

	// request all observers to stop immediately
	RequestDelete();
}
Exemple #7
0
CMenuTool::~CMenuTool()
{
	D_ALLOC(("CMenuTool::~CMenuTool()\n"));

	delete m_bitmap;
	delete m_disabledBitmap;
	delete m_menu;
}
Exemple #8
0
CDestinationDeleteUndoAction::CDestinationDeleteUndoAction(
	CDestination *dest)
	:	m_dest(dest),
		m_index(-1)
{
	D_ALLOC(("CDestinationDeleteUndoAction::CDestinationDeleteUndoAction()"));
	m_dest->Delete();
}
Exemple #9
0
int
drpc_call(struct drpc *ctx, int flags, Drpc__Call *msg,
		Drpc__Response **resp)
{
	/* Save off the params passed in */
	drpc_call_ctx = ctx;
	drpc_call_flags = flags;
	drpc_call_msg_ptr = msg;
	if (msg != NULL) {
		memcpy(&drpc_call_msg_content, msg, sizeof(Drpc__Call));

		/* Need a copy of the body data, it's separately allocated */
		D_ALLOC(drpc_call_msg_content.body.data, msg->body.len);
		memcpy(drpc_call_msg_content.body.data, msg->body.data,
				msg->body.len);
	}
	drpc_call_resp_ptr = resp;

	if (resp == NULL) {
		return drpc_call_return;
	}

	/* Fill out the mocked response */
	if (drpc_call_resp_return_ptr == NULL) {
		*resp = NULL;
	} else {
		size_t data_len =
				drpc_call_resp_return_content.body.len;

		/**
		 * Need to allocate a new copy to return - the
		 * production code will free the returned memory.
		 */
		D_ALLOC_PTR(*resp);
		memcpy(*resp, &drpc_call_resp_return_content,
				sizeof(Drpc__Response));

		D_ALLOC((*resp)->body.data, data_len);
		memcpy((*resp)->body.data,
				drpc_call_resp_return_content.body.data,
				data_len);
	}

	return drpc_call_return;
}
Exemple #10
0
CDocument::~CDocument()
{
	D_ALLOC(("CDocument::~CDocument()\n"));

	if (m_savePanel)
		delete m_savePanel;
	RequestDelete();
	m_app->RemoveDocument(this);
}
Exemple #11
0
static void
read_empty(void **state)
{
	test_arg_t	*arg = *state;
	daos_obj_id_t	 oid;
	daos_handle_t	 oh;
	daos_iov_t	 dkey;
	daos_sg_list_t	 sgl;
	daos_iov_t	 sg_iov;
	daos_iod_t	 iod;
	daos_recx_t	 recx;
	char		 *buf;
	daos_size_t	 buf_len;
	int		 rc;

	buf_len = 4194304;
	D_ALLOC(buf, buf_len);
	D_ASSERT(buf != NULL);

	/** open object */
	oid = dts_oid_gen(DAOS_OC_REPL_MAX_RW, 0, arg->myrank);
	rc = daos_obj_open(arg->coh, oid, 0, &oh, NULL);
	assert_int_equal(rc, 0);

	/** init dkey */
	daos_iov_set(&dkey, "dkey", strlen("dkey"));

	/** init scatter/gather */
	daos_iov_set(&sg_iov, buf, buf_len);
	sgl.sg_nr		= 1;
	sgl.sg_nr_out		= 0;
	sgl.sg_iovs		= &sg_iov;

	/** init I/O descriptor */
	daos_iov_set(&iod.iod_name, "akey", strlen("akey"));
	daos_csum_set(&iod.iod_kcsum, NULL, 0);
	iod.iod_nr	= 1;
	iod.iod_size	= 1;
	recx.rx_idx	= 0;
	recx.rx_nr	= buf_len;
	iod.iod_recxs	= &recx;
	iod.iod_eprs	= NULL;
	iod.iod_csums	= NULL;
	iod.iod_type	= DAOS_IOD_ARRAY;

	/** fetch */
	print_message("reading empty object ...\n");
	rc = daos_obj_fetch(oh, DAOS_TX_NONE, &dkey, 1, &iod, &sgl, NULL, NULL);
	assert_int_equal(rc, 0);

	/** close object */
	rc = daos_obj_close(oh, NULL);
	assert_int_equal(rc, 0);
	print_message("all good\n");
	D_FREE(buf);
}
Exemple #12
0
static void
pack_drpc_call_resp_body(SecurityCredential *cred)
{
	size_t len = security_credential__get_packed_size(cred);

	drpc_call_resp_return_content.body.len = len;
	D_ALLOC(drpc_call_resp_return_content.body.data, len);
	security_credential__pack(cred,
			drpc_call_resp_return_content.body.data);
}
Exemple #13
0
MediaIcon::MediaIcon(
	const dormant_node_info &nodeInfo,
	icon_size size)
	: BBitmap(BRect(0.0, 0.0, size - 1.0, size - 1.0), B_CMAP8),
	  m_size(size),
	  m_nodeKind(0) {
	D_ALLOC(("MediaIcon::MediaIcon(dormant_node_info '%s')\n", nodeInfo.name));

	_findIconFor(nodeInfo);
}
Exemple #14
0
CDestination::CDestination(
	unsigned long type,
	CMeVDoc *document)
	:	m_doc(document),
		m_type('MIDI'),
		m_id(0),
		m_latency(0),
		m_flags(0)
{
	D_ALLOC(("CDestination::CDestination(deserialize)\n"));
}
Exemple #15
0
StatusView::~StatusView() {
	D_ALLOC(("StatusView::~ParameterContainerView()\n"));

	// get the tip manager instance and reset
	TipManager *manager = TipManager::Instance();
	manager->removeAll(this);
	
	delete m_clock;
	
	freeBackBitmap();
}
Exemple #16
0
static void
process_drpc_request(Drpc__Call *drpc_req, Drpc__Response *drpc_resp)
{
	Mgmt__DaosResponse	*daos_resp = NULL;
	uint8_t			*body = NULL;
	size_t			len = 0;

	D_ALLOC_PTR(daos_resp);
	if (daos_resp == NULL) {
		drpc_resp->status = DRPC__STATUS__FAILURE;
		D_ERROR("Failed to allocate daos response ref\n");

		return;
	}

	switch (drpc_req->method) {
	case DRPC_METHOD_MGMT_KILL_RANK:
		/**
		 * Process drpc request and populate daos response,
		 * command errors should be indicated inside daos response.
		 */
		process_killrank_request(drpc_req, daos_resp);

		len = mgmt__daos_response__get_packed_size(daos_resp);
		D_ALLOC(body, len);
		if (body == NULL) {
			drpc_resp->status = DRPC__STATUS__FAILURE;
			D_ERROR("Failed to allocate drpc response body\n");

			break;
		}

		if (mgmt__daos_response__pack(daos_resp, body) != len) {
			drpc_resp->status = DRPC__STATUS__FAILURE;
			D_ERROR("Unexpected num bytes for daos resp\n");

			break;
		}

		/* Populate drpc response body with packed daos response */
		drpc_resp->body.len = len;
		drpc_resp->body.data = body;

		break;
	default:
		drpc_resp->status = DRPC__STATUS__UNKNOWN_METHOD;
		D_ERROR("Unknown method\n");
	}

	D_FREE(daos_resp);
}
Exemple #17
0
static void
test_request_credentials_fails_if_reply_body_malformed(void **state)
{
	daos_iov_t creds;

	memset(&creds, 0, sizeof(daos_iov_t));
	free_drpc_call_resp_body();
	D_ALLOC(drpc_call_resp_return_content.body.data, 1);
	drpc_call_resp_return_content.body.len = 1;

	assert_int_equal(dc_sec_request_creds(&creds), -DER_MISC);

	daos_iov_free(&creds);
}
Exemple #18
0
CDocument::CDocument(
	CDocApp *app,
	entry_ref &ref)
	:	m_entry(&ref),
		m_app(app),
		m_modified(false),
		m_named(true),
		m_valid(false),
		m_savePanel(NULL),
		m_saving(false)
{
	D_ALLOC(("CDocument::CDocument()\n"));

	m_app->AddDocument(this);
}
Exemple #19
0
CTool::~CTool()
{
	D_ALLOC(("CTool::~CTool()\n"));

	if (m_name)
	{
		delete [] m_name;
		m_name = NULL;
	}

	if (m_message)
	{
		delete m_message;
		m_message = NULL;
	}
}
Exemple #20
0
static int
crt_proc_daos_csum_buf_t(crt_proc_t proc, daos_csum_buf_t *csum)
{
	crt_proc_op_t	proc_op;
	int		rc;

	rc = crt_proc_get_op(proc, &proc_op);
	if (rc != 0)
		return -DER_HG;

	rc = crt_proc_uint16_t(proc, &csum->cs_type);
	if (rc != 0)
		return -DER_HG;

	rc = crt_proc_uint16_t(proc, &csum->cs_len);
	if (rc != 0)
		return -DER_HG;

	rc = crt_proc_uint32_t(proc, &csum->cs_buf_len);
	if (rc != 0)
		return -DER_HG;

	if (csum->cs_buf_len < csum->cs_len) {
		D_ERROR("invalid csum buf len %iu < csum len %hu\n",
			csum->cs_buf_len, csum->cs_len);
		return -DER_HG;
	}

	if (proc_op == CRT_PROC_DECODE && csum->cs_buf_len > 0) {
		D_ALLOC(csum->cs_csum, csum->cs_buf_len);
		if (csum->cs_csum == NULL)
			return -DER_NOMEM;
	} else if (proc_op == CRT_PROC_FREE && csum->cs_buf_len > 0) {
		D_FREE(csum->cs_csum);
	}

	if (csum->cs_len > 0) {
		rc = crt_proc_memcpy(proc, csum->cs_csum, csum->cs_len);
		if (rc != 0) {
			if (proc_op == CRT_PROC_DECODE)
				D_FREE(csum->cs_csum);
			return -DER_HG;
		}
	}

	return 0;
}
Exemple #21
0
CDestination::CDestination(
	unsigned long type,
	long id,
	const char *name,
	CMeVDoc *document)
	:	m_doc(document),
		m_type(type),
		m_id(id),
		m_latency(0),
		m_flags(0),
		m_color(DEFAULT_COLORS[id % 15])
{
	D_ALLOC(("CDestination::CDestination()\n"));

	CWriteLock lock(this);
	snprintf(m_name, DESTINATION_NAME_LENGTH, "%s %ld", name, id + 1);
}
Exemple #22
0
CTrackListView::CTrackListView(
	BRect frame,
	CMeVDoc *doc)
	:	BListView(frame, "TrackListView",
				  B_SINGLE_SELECTION_LIST,
				  B_FOLLOW_ALL_SIDES,
				  B_WILL_DRAW | B_FRAME_EVENTS),
		m_doc(doc),
		m_contextMenu(NULL),
		m_reordering(false),
		m_currentReorderMark(0.0, 0.0, -1.0, -1.0),
		m_lastReorderIndex(-1),
		m_lastReorderMark(0.0, 0.0, -1.0, -1.0)
{
	D_ALLOC(("CTrackListView::CTrackListView()\n"));

}
Exemple #23
0
static int
close_iter_cb(daos_handle_t ih, daos_iov_t *key, daos_iov_t *val, void *varg)
{
	struct close_iter_arg  *arg = varg;
	struct container_hdl   *hdl;

	D_ASSERT(arg->cia_recs != NULL);
	D_ASSERT(arg->cia_recs_size > sizeof(*arg->cia_recs));

	if (key->iov_len != sizeof(uuid_t) ||
	    val->iov_len != sizeof(*hdl)) {
		D_ERROR("invalid key/value size: key="DF_U64" value="DF_U64"\n",
			key->iov_len, val->iov_len);
		return -DER_IO;
	}

	hdl = val->iov_buf;

	if (!shall_close(hdl->ch_pool_hdl, arg->cia_pool_hdls,
			 arg->cia_n_pool_hdls))
		return 0;

	/* Make sure arg->cia_recs[] have enough space for this handle. */
	if (sizeof(*arg->cia_recs) * (arg->cia_nrecs + 1) >
	    arg->cia_recs_size) {
		struct cont_tgt_close_rec      *recs_tmp;
		size_t				recs_size_tmp;

		recs_size_tmp = arg->cia_recs_size * 2;
		D_ALLOC(recs_tmp, recs_size_tmp);
		if (recs_tmp == NULL)
			return -DER_NOMEM;
		memcpy(recs_tmp, arg->cia_recs,
		       arg->cia_recs_size);
		D_FREE(arg->cia_recs);
		arg->cia_recs = recs_tmp;
		arg->cia_recs_size = recs_size_tmp;
	}

	uuid_copy(arg->cia_recs[arg->cia_nrecs].tcr_hdl, key->iov_buf);
	arg->cia_recs[arg->cia_nrecs].tcr_hce = hdl->ch_hce;
	arg->cia_nrecs++;
	return 0;
}
Exemple #24
0
static int
crt_proc_msg_entry_t(crt_proc_t proc, msg_entry_t *p)
{
	crt_proc_op_t	proc_op;
	int		rc;

	rc = crt_proc_get_op(proc, &proc_op);
	if (rc != 0)
		return -DER_HG;
	rc = crt_proc_uint32_t(proc, &p->term);
	if (rc != 0)
		return -DER_HG;
	rc = crt_proc_uint32_t(proc, &p->id);
	if (rc != 0)
		return -DER_HG;
	rc = crt_proc_int32_t(proc, &p->type);
	if (rc != 0)
		return -DER_HG;
	rc = crt_proc_uint32_t(proc, &p->data.len);
	if (rc != 0)
		return -DER_HG;
	if (proc_op == CRT_PROC_DECODE) {
		if (p->data.len > 0) {
			D_ALLOC(p->data.buf, p->data.len);
			if (p->data.buf == NULL)
				return -DER_NOMEM;
		} else {
			p->data.buf = NULL;
		}
	}
	if (p->data.len > 0) {
		rc = crt_proc_memcpy(proc, p->data.buf, p->data.len);
		if (rc != 0) {
			if (proc_op == CRT_PROC_DECODE)
				D_FREE(p->data.buf);
			return -DER_HG;
		}
	}
	if (proc_op == CRT_PROC_FREE && p->data.buf != NULL)
		D_FREE(p->data.buf);

	return 0;
}
Exemple #25
0
int main(int argc, char **argv)
{
	int	rc, nr_failed = 0;

	fname = NULL;
	static struct option long_ops[] = {
		{ "fname",	required_argument,	NULL,	'f' },
		{ "size",	required_argument,	NULL,	's' },
		{ "help",	no_argument,		NULL,	'h' },
		{ NULL,		0,			NULL,	0   },
	};

	while ((rc = getopt_long(argc, argv,
				 "f:s:h", long_ops, NULL)) != -1) {
		switch (rc) {
		case 'f':
			D_ALLOC(fname, strlen(optarg));
			strcpy(fname, optarg);
			break;
		case 's':
			size = atoi(optarg);
			break;
		case 'h':
			print_usage();
			goto exit_1;
		default:
			print_error("unknown option %c\n", rc);
			print_usage();
			rc = -1;
			goto exit_1;
		}
	}

	nr_failed = cmocka_run_group_tests_name("SMD unit tests", smd_uts,
						smd_ut_setup, smd_ut_teardown);
	if (nr_failed)
		print_error("ERROR, %i TEST(S) FAILED\n", nr_failed);
	else
		print_message("\nSUCCESS! NO TEST FAILURES\n");
exit_1:
	return 0;
}
Exemple #26
0
__USE_CORTEX_NAMESPACE

#include <Debug.h>
#define D_ALLOC(x) //PRINT (x)
#define D_INTERNAL(x) //PRINT (x)

// -------------------------------------------------------- //
// *** ctor/dtor
// -------------------------------------------------------- //

MediaIcon::MediaIcon(
	const live_node_info &nodeInfo,
	icon_size size)
	: BBitmap(BRect(0.0, 0.0, size - 1.0, size - 1.0), B_CMAP8),
	  m_size(size),
	  m_nodeKind(nodeInfo.node.kind) {
	D_ALLOC(("MediaIcon::MediaIcon(live_node_info '%s')\n", nodeInfo.name));

	_findIconFor(nodeInfo);
}
Exemple #27
0
CStatusBar::CStatusBar(
	BRect frame,
	BScrollBar *scrollBar,
	bool dimOnDeactivate,
	uint32 resizingMode)
	:	BView(frame, "StatusBar", resizingMode,
					B_FRAME_EVENTS | B_WILL_DRAW),
		m_scrollBar(scrollBar),
		m_dragging(false),
		m_backBitmap(NULL),
		m_backView(NULL),
		m_dirty(true),
		m_minWidth(10.0),
		m_dimOnDeactivate(dimOnDeactivate) {
	D_ALLOC(("CStatusBar::CStatusBar()\n"));

	SetViewColor(B_TRANSPARENT_COLOR);

	if (m_dimOnDeactivate)
		SetFlags(Flags() | B_DRAW_ON_CHILDREN);
}
Exemple #28
0
__USE_CORTEX_NAMESPACE

#include <Debug.h>
#define D_ALLOC(x) //PRINT (x)		// ctor/dtor
#define D_HOOK(x) //PRINT (x)		// BListView impl.
#define D_MESSAGE(x) //PRINT (x)	// MessageReceived()
#define D_INTERNAL(x) //PRINT (x)	// internal operations

// -------------------------------------------------------- //
// ctor/dtor (public)
// -------------------------------------------------------- //

DormantNodeView::DormantNodeView(
	BRect frame,
	const char *name,
	uint32 resizeMode)
	: BListView(frame, name, B_SINGLE_SELECTION_LIST, resizeMode),
	  m_lastItemUnder(0) {
	D_ALLOC(("DormantNodeView::DormantNodeView()\n"));

}
Exemple #29
0
CMenuTool::CMenuTool(
	const char *name,
	BBitmap *bitmap,
	BPopUpMenu *menu,
	BMessage *message,
	int32 mode,
	uint32 flags)
	:	CTool(name, message, mode, flags),
		m_bitmap(NULL),
		m_disabledBitmap(NULL),
		m_menu(menu)
{
	D_ALLOC(("CMenuTool::CMenuTool()\n"));

	SetBitmap(bitmap);

	if (!m_menu)
	{
		// create an empty menu
		m_menu = new BPopUpMenu("", false, false);
	}
}
Exemple #30
0
static int
rdb_kvs_alloc_ref(void *key, unsigned int ksize, void *varg,
		  struct daos_llink **link)
{
	struct rdb_kvs_alloc_arg       *arg = varg;
	struct rdb_kvs		       *kvs;
	int				rc;

	if (!arg->dea_alloc) {
		rc = -DER_NONEXIST;
		goto err;
	}

	D_ALLOC(kvs, sizeof(*kvs) + ksize);
	if (kvs == NULL) {
		rc = -DER_NOMEM;
		goto err;
	}

	/* kvs->de_path */
	memcpy(kvs->de_buf, key, ksize);
	daos_iov_set(&kvs->de_path, kvs->de_buf, ksize);

	/* kvs->de_object */
	rc = rdb_kvs_open_path(arg->dea_db, arg->dea_index, &kvs->de_path,
			       &kvs->de_object);
	if (rc != 0)
		goto err_kvs;

	D_DEBUG(DB_TRACE, DF_DB": created %p len %u\n", DP_DB(arg->dea_db), kvs,
		ksize);
	*link = &kvs->de_entry;
	return 0;

err_kvs:
	D_FREE(kvs);
err:
	return rc;
}