#include <stdio.h>
#include <unistd.h>
#include <ipc/ipc.h>
#include "../tester.h"


char * test_debug1(bool quiet)
{
	int taskid;
	int rc;
	int phoneid;
	int i;
	unsigned sc_args[6];
	unsigned copied;
	unsigned ev_type;
	unsigned sc_id;
	int sc_rc;

	printf("running debug1 test\n");
	taskid = 12;
	printf("ipc_connect_task(%d)...\n", taskid);
	rc = ipc_connect_task(taskid);
	printf("-> %d\n", rc);
	phoneid = rc;

	printf("send IPC_M_DEBUG_BEGIN message\n");
	rc = ipc_call_sync_0_0(phoneid, IPC_M_DEBUG_BEGIN);
	printf("-> %d\n", rc);

	while (1) {
		rc = ipc_call_sync_0_3(phoneid, IPC_M_DEBUG_GO, &ev_type,
		    &sc_id, &sc_rc);
		rc = ipc_call_sync_3_1(phoneid, IPC_M_DEBUG_ARGS_READ, NULL,
		    sc_args, 6 * sizeof(unsigned), &copied);
		if (rc >= 0) {
			printf("id %u(%u, %u, %u, %u, %u, %u) -> %d\n",
			    sc_id,
			    sc_args[0], sc_args[1], sc_args[2],
			    sc_args[3], sc_args[4], sc_args[5],
			    sc_rc);
		}
	}

	printf("done\n");
	return NULL;
}
