示例#1
0
int
xmmsv_coll_compare (xmmsv_t *a, xmmsv_t *b)
{
	xmmsv_coll_type_t type;
	xmmsv_t *_a, *_b;

	type = xmmsv_coll_get_type (a);
	if (xmmsv_coll_get_type (b) != type) {
		return 0;
	}

	_a = xmmsv_coll_idlist_get (a);
	_b = xmmsv_coll_idlist_get (b);
	if (!xmmsv_compare (_a, _b)) {
		return 0;
	}

	_a = xmmsv_coll_attributes_get (a);
	_b = xmmsv_coll_attributes_get (b);
	if (!xmmsv_compare (_a, _b)) {
		return 0;
	}

	_a = xmmsv_coll_operands_get (a);
	_b = xmmsv_coll_operands_get (b);
	if (!xmmsv_compare (_a, _b)) {
		return 0;
	}

	return 1;
}
示例#2
0
/**
 * Unit test predicate
 */
static void
run_unit_test (xmms_medialib_t *mlib, const gchar *name, xmmsv_t *content,
               xmmsv_coll_t *coll, xmmsv_t *specification, xmmsv_t *expected,
               gint format, const gchar *datasetname)
{
	gboolean matches, ordered = FALSE;
	xmmsv_t *ret, *value;
	xmms_error_t err;
	xmms_medialib_t *medialib;
	xmms_medialib_session_t *session;

	g_debug ("Running test: %s", name);

	xmms_ipc_init ();
	xmms_config_init ("memory://");
	xmms_config_property_register ("medialib.path", "memory://", NULL, NULL);

	medialib = xmms_medialib_init ();

	populate_medialib (medialib, content);

	session = xmms_medialib_session_begin (medialib);
	ret = xmms_medialib_query (session, coll, specification, &err);
	xmms_medialib_session_commit (session);

	xmmsv_dict_get (expected, "result", &value);
	xmmsv_dict_entry_get_int (expected, "ordered", &ordered);

	if (ordered) {
		matches = xmmsv_compare (ret, value);
	} else {
		matches = xmmsv_compare_unordered (ret, value);
	}

	if (matches) {
		if (format == FORMAT_CSV) {
			g_print ("\"%s\", 1\n", name);
		} else {
			g_print ("............................................................ Success!");
			g_print ("\r%s \n", name);
		}

	} else {
		if (format == FORMAT_CSV) {
			g_print ("\"%s\", 0\n", name);
		} else {
			g_print ("............................................................ Failure!");
			g_print ("\r%s \n", name);
		}

		g_printerr ("The result: ");
		xmmsv_dump (ret);
		g_printerr ("Does not equal: ");
		xmmsv_dump (value);
	}

	xmmsv_unref (ret);

	xmms_object_unref (medialib);
	xmms_config_shutdown ();
	xmms_ipc_shutdown ();
}
示例#3
0
/**
 * Unit test predicate
 */
static gboolean
run_unit_test (xmms_medialib_t *mlib, const gchar *name, xmmsv_t *content,
               xmmsv_t *coll, xmmsv_t *specification, xmmsv_t *expected,
               gint format, const gchar *datasetname)
{
	gboolean matches, ordered = FALSE;
	xmmsv_t *ret, *value;
	xmms_medialib_t *medialib;
	xmms_coll_dag_t *dag;
	gint status;

	g_debug ("Running test: %s", name);

	xmms_ipc_init ();
	xmms_config_init ("memory://");
	xmms_config_property_register ("medialib.path", "memory://", NULL, NULL);

	medialib = xmms_medialib_init ();
	dag = xmms_collection_init (medialib);

	populate_medialib (medialib, content);

	memory_status_calibrate (name);

	ret = XMMS_IPC_CALL (dag, XMMS_IPC_CMD_QUERY,
	                     xmmsv_ref (coll),
	                     xmmsv_ref (specification));

	status = memory_status_verify (name);

	xmmsv_dict_get (expected, "result", &value);
	xmmsv_dict_entry_get_int (expected, "ordered", &ordered);

	if (!xmmsv_is_type (ret, XMMSV_TYPE_ERROR)) {
		if (ordered) {
			matches = xmmsv_compare (ret, value);
		} else {
			matches = xmmsv_compare_unordered (ret, value);
		}
	} else {
		matches = FALSE;
	}

	if (matches && status == MEMORY_OK) {
		if (format == FORMAT_CSV) {
			g_print ("\"%s\", 1\n", name);
		} else {
			g_print ("............................................................ Success!");
			g_print ("\r%s \n", name);
		}

	} else {
		if (format == FORMAT_CSV) {
			g_print ("\"%s\", 0\n", name);
		} else {
			g_print ("............................................................ Failure!");
			if (status & MEMORY_LEAK) {
				g_print (" Memory Leaks!");
			}
			if (status & MEMORY_ERROR) {
				g_print (" Memory errors!");
			}

			g_print ("\r%s \n", name);
		}

		if (!matches) {
			g_printerr ("The result:\n");
			xmmsv_dump (ret);
			g_printerr ("Does not equal:\n");
			xmmsv_dump (value);
		}
	}

	xmmsv_unref (ret);

	xmms_object_unref (medialib);
	xmms_object_unref (dag);
	xmms_config_shutdown ();
	xmms_ipc_shutdown ();

	return matches && status == MEMORY_OK;
}