Exemplo n.º 1
0
void game_test() {
  init_log();

  test_handles_draw();
  reset_log();
  success();

  test_handles_win();
  reset_log();
  success();

  test_gets_valid_move();
  reset_log();
  success();

  test_switches_turns();
  reset_log();
  success();

  destroy_log();
}
Exemplo n.º 2
0
void presenter_test() {
  init_log();

  test_display_empty_board();
  reset_log();
  success();

  test_display_played_board();
  reset_log();
  success();

  test_display_turn();
  reset_log();
  success();

  test_display_invalid_move();
  reset_log();
  success();

  test_show_winner();
  reset_log();
  success();

  test_show_draw();
  reset_log();
  success();

  test_get_move();
  success();

  destroy_log();
}
Exemplo n.º 3
0
x86log_context *x86log_create_context(const char *filename)
{
	x86log_context *log;

	/* allocate the log */
	log = alloc_clear_or_die(x86log_context);

	/* allocate the filename */
	log->filename = astring_dupc(filename);

	/* reset things */
	reset_log(log);
	return log;
}
Exemplo n.º 4
0
x86log_context *x86log_create_context(const char *filename)
{
	x86log_context *log;

	/* allocate the log */
	log = global_alloc_clear(x86log_context);

	/* allocate the filename */
	log->filename.cpy(filename);

	/* reset things */
	reset_log(log);
	return log;
}
Exemplo n.º 5
0
x86log_context *x86log_create_context(const char *filename)
{
	x86log_context *log;

	/* allocate the log */
	log = malloc_or_die(sizeof(*log));
	memset(log, 0, sizeof(*log));

	/* allocate the filename */
	log->filename = astring_dupc(filename);

	/* reset things */
	reset_log(log);
	return log;
}
Exemplo n.º 6
0
/**
 * \brief Test entering and exiting sleep 0 mode.
 *
 * \param test Current test case.
 */
static void run_sleep_0_test(const struct test_case *test)
{
	/* Wait for the printf operation to finish before
	setting the device in a power save mode. */
	delay_ms(30);

	reset_log();
	bpm_sleep(BPM, BPM_SM_SLEEP_0);
	log_event(EVENT_RUN);

	test_assert_true(test, IS_NB_EVENTS_OK(),
		"Unexpected number of events, should be 2");
	test_assert_true(test, IS_EVENTS_OK(),
		"Unexpected events sequence");
	wait_test_assert_idle();
}
Exemplo n.º 7
0
void x86log_disasm_code_range(x86log_context *log, const char *label, x86code *start, x86code *stop)
{
	const log_comment *lastcomment = &log->comment_list[log->comment_count];
	const log_comment *curcomment = &log->comment_list[0];
	const data_range_t *lastdata = &log->data_range[log->data_range_count];
	const data_range_t *curdata = &log->data_range[0];
	x86code *cur = start;

	/* print the optional label */
	if (label != NULL)
		x86log_printf(log, "\n%s\n", label);

	/* loop from the start until the cache top */
	while (cur < stop)
	{
		char buffer[100];
		int bytes;

		/* skip past any past data ranges */
		while (curdata < lastdata && cur > curdata->end)
			curdata++;

		/* skip past any past comments */
		while (curcomment < lastcomment && cur > curcomment->base)
			curcomment++;

		/* if we're in a data range, output the next chunk and continue */
		if (cur >= curdata->base && cur <= curdata->end)
		{
			bytes = curdata->size;
			switch (curdata->size)
			{
				default:
				case 1:		sprintf(buffer, "db      %02X", *cur); 				break;
				case 2:		sprintf(buffer, "dw      %04X", *(UINT16 *)cur); 	break;
				case 4:		sprintf(buffer, "dd      %08X", *(UINT32 *)cur); 	break;
				case 8:		sprintf(buffer, "dq      %08X%08X", ((UINT32 *)cur)[1], ((UINT32 *)cur)[0]); 	break;
			}
		}

		/* if we're not in the data range, skip filler opcodes */
		else if (*cur == 0xcc)
		{
			cur++;
			continue;
		}

		/* otherwise, do a disassembly of the current instruction */
		else
		{
#ifdef PTR64
			bytes = i386_dasm_one(buffer, (FPTR)cur, cur, 64) & DASMFLAG_LENGTHMASK;
#else
			bytes = i386_dasm_one(buffer, (FPTR)cur, cur, 32) & DASMFLAG_LENGTHMASK;
#endif
		}

		/* if we have a matching comment, output it */
		if (curcomment < lastcomment && cur == curcomment->base)
		{
			/* if we have additional matching comments at the same address, output them first */
			for ( ; curcomment + 1 < lastcomment && cur == curcomment[1].base; curcomment++)
				x86log_printf(log, "%p: %-50s; %s\n", cur, "", curcomment->string);
			x86log_printf(log, "%p: %-50s; %s\n", cur, buffer, curcomment->string);
		}

		/* if we don't, just print the disassembly and move on */
		else
			x86log_printf(log, "%p: %s\n", cur, buffer);

		/* advance past this instruction */
		cur += bytes;
	}

	/* reset our state */
	reset_log(log);
}