Example #1
0
int run_tests(int benchmark_output) {
  int total;
  int passed;
  int failed;
  int todos;
  int skipped;
  int current;
  int test_result;
  task_entry_t* task;

  /* Count the number of tests. */
  total = 0;
  for (task = TASKS; task->main; task++) {
    if (!task->is_helper) {
      total++;
    }
  }

  if (tap_output) {
    fprintf(stderr, "1..%d\n", total);
    fflush(stderr);
  }

  /* Run all tests. */
  passed = 0;
  failed = 0;
  todos = 0;
  skipped = 0;
  current = 1;
  for (task = TASKS; task->main; task++) {
    if (task->is_helper) {
      continue;
    }

    if (!tap_output)
      rewind_cursor();

    if (!benchmark_output && !tap_output) {
      log_progress(total, passed, failed, todos, skipped, task->task_name);
    }

    test_result = run_test(task->task_name, benchmark_output, current);
    switch (test_result) {
    case TEST_OK: passed++; break;
    case TEST_TODO: todos++; break;
    case TEST_SKIP: skipped++; break;
    default: failed++;
    }
    current++;
  }

  if (!tap_output)
    rewind_cursor();

  if (!benchmark_output && !tap_output) {
    log_progress(total, passed, failed, todos, skipped, "Done.\n");
  }

  return failed;
}
Example #2
0
void test_close_raster(Raster *r)
/*****************************************************************************
 *
 ****************************************************************************/
{
	if (r == NULL || r->lib == NULL || r->lib->close_raster == NULL ||
		is_generic(r->lib, close_raster))
		return;

	log_progress("Testing close_raster()...\n");
	r->lib->close_raster(r);
	log_progress("...testing of close_raster() completed.\n\n");
}
Example #3
0
File: runner.c Project: Isszul/node
int run_tests(int timeout, int benchmark_output) {
  int total, passed, failed, current;
  task_entry_t* task;

  /* Count the number of tests. */
  total = 0;
  for (task = TASKS; task->main; task++) {
    if (!task->is_helper) {
      total++;
    }
  }

  if (tap_output) {
    LOGF("1..%d\n", total);
  }

  /* Run all tests. */
  passed = 0;
  failed = 0;
  current = 1;
  for (task = TASKS; task->main; task++) {
    if (task->is_helper) {
      continue;
    }

    rewind_cursor();
    if (!benchmark_output && !tap_output) {
      log_progress(total, passed, failed, task->task_name);
    }

    if (run_test(task->task_name, timeout, benchmark_output, current) == 0) {
      passed++;
    } else {
      failed++;
    }
    current++;
  }

  rewind_cursor();

  if (!benchmark_output && !tap_output) {
    log_progress(total, passed, failed, "Done.\n");
  }

  return failed;
}
Example #4
0
void
unit_test_log::finish( unit_test_counter test_cases_amount )
{
    if( test_cases_amount == 1 )
        *this << log_progress();

    m_pimpl->m_log_formatter->finish_log( m_pimpl->stream() );
}
Example #5
0
void test_colors(Raster *r)
/*****************************************************************************
 *
 ****************************************************************************/
{
Rastlib 	*rlib = r->lib;
short		counter;
Vsyncfunc_t wait_vsync;
Colorfunc_t set_colors;
UBYTE		cmap[COLORS][CHANNELS];
int 		i,j;

	wait_vsync = rlib->wait_vsync;
	set_colors = rlib->set_colors;

	log_progress("Testing wait_vsync()...\n");
	counter = 30;
	while (--counter)
		wait_vsync(r);
	log_progress("...wait_vsync() testing complete.\n\n");

	log_start("Testing set_colors()...\n");

	for (j=0; j<CHANNELS; j++)
		{
		ramp_cmap(cmap, j);
		for (i=0; i<COLORS; i+=2)
			{
			wait_vsync(r);
			set_colors(r, 0, COLORS, cmap);
			cycle_cmap(cmap);
			}
		}

	log_end("...testing of set_colors() complete.\n\n");

	set_default_colors(r);

}
Example #6
0
File: main.cpp Project: CCJY/coliru
int main()
{
    volatile int sink=0;

    auto t1 = std::chrono::high_resolution_clock::now();
    for(int j=0; j<5; ++j)
    {
        for(int n=0; n<10000; ++n)
            for(int m=0; m<20000; ++m)
                sink += m*n; // do some work
        auto now = std::chrono::high_resolution_clock::now();
        log_progress(now - t1);
    }
    std::cout << '\n';
}
Example #7
0
File: main.cpp Project: CCJY/coliru
int main()
{
    std::cout.sync_with_stdio(false); // on some platforms, stdout flushes on \n
    volatile int sink = 0;
 
    auto t1 = std::chrono::high_resolution_clock::now();
    for (int j=0; j<5; ++j)
    {
        for (int n=0; n<10000; ++n)
            for (int m=0; m<20000; ++m)
                sink += m*n; // do some work
        auto now = std::chrono::high_resolution_clock::now();
        log_progress(now - t1);
    }
}
Example #8
0
void test_rastxors(Raster *r)
/*****************************************************************************
 *
 ****************************************************************************/
{
Raster			*bmr = &tcb.bytemap_raster;
Raster			*vbr = &tcb.verification_raster;
Rastlib			*rlib = r->lib;
Coor			x;
Coor			y;
Pixel			color;
Ucoor			width;
Ucoor			height;
short			iteration_count;
short			iteration_limit;

	width = r->width;
	height = r->height;

	/*-----------------------------------------------------------------------
	 * xor_in_card testing...
	 *   if the driver didn't provide a routine, and we're not testing via
	 *   generics, skip the testing.
	 *---------------------------------------------------------------------*/
	
	if (is_generic(rlib,xor_rast[0]) && !tcb.test_via_generics)
		{
		log_bypass("xor_in_card(), xor_to_ram(), xor_from_ram()");
		goto XRAST_DONE;
		}

	/*------------------------------------------------------------------------
	 * xor_in_card testing..
	 *----------------------------------------------------------------------*/

	if (r == &tcb.display_raster)
		{
		log_progress("Testing bypassed for xor_in_card(), current raster is "
					 "primary display raster.\n\n");
		goto XRAST_IN_CARD_DONE;
		}

	iteration_limit = (tcb.timing_only_run) ? XRAST_TIME_ITCOUNT : 1;

	log_start("Testing xor_in_card()...\n");

	iteration_count = iteration_limit;
	clear_screen();
	while (iteration_count--)
		{
		}

	log_end("...xor_in_card() testing complete.\n\n");

	if (!single_step())
		return;

XRAST_IN_CARD_DONE:

	/*------------------------------------------------------------------------
	 * xor_to_ram testing..
	 *----------------------------------------------------------------------*/

	iteration_limit = (tcb.timing_only_run) ? XRAST_TIME_ITCOUNT : 1;

	log_start("Testing xor_to_ram()...\n");

	iteration_count = iteration_limit;

	pj_set_rast(r,   0);
	pj_set_rast(bmr, 0);
	pj_set_rast(vbr, 0);

	rlib->wait_vsync(r);
	while (iteration_count--)
		{
		color = iteration_count + 1;
		for (x = 0; x < width; x += 2*(WPAT/3))
			pj_set_rect(bmr, color, x, 0, WPAT/3, height);
		for (y = 0; y < height; y += 2*(HPAT/3))
			pj_set_rect(r, ~color, 0, y, width, HPAT/3);
		time_it(
			pj_xor_rast(r, bmr);
			);
		}
Example #9
0
void run_dla(params p) {
	time_t start, now;
	FILE *fp;

	fp = fopen(p.output_filename, "w");
	if (fp == NULL) {
		fprintf(stderr,"ERROR: could not open output file '%s'\n",
			p.output_filename);
		exit(EXIT_FAILURE);
	}

	if(KDT_DIM == 2) {
		fprintf(fp,"n x y\n");
	}
	else if(KDT_DIM == 3) {
		fprintf(fp,"n x y z\n");
	}
	else {
		fprintf(stderr, "DLA not defined for KDT_DIM=%d\n", KDT_DIM);
		exit(1);
	}

	setuprandom(p.seed);

	// setup initial world conditions
	point_list *buffer = kdt_new_point_list(p.n);
	tree_node *root = kdt_new_tree();
	point *zero = (point *)malloc(sizeof(point));
	vec_zero(zero);
	kdt_add_point(root, zero);
	double curr_max_radius = 0.0f;	
	double starting_rad = starting_radius(p.min_inner_radius, curr_max_radius, p.inner_mult, p.step_size);
	double death_rad = death_radius(p.min_inner_radius, curr_max_radius, p.inner_mult, p.step_size, p.outer_mult);

	time(&start);
	time(&now);
	int i;
	for(i=0; i < p.n && (now - start) < p.max_secs; i++) {
		if(i % (p.n / 10) == 0 && p.log_progress == 1) {
			log_progress((double)i / (double)p.n * 100.0f, curr_max_radius, starting_rad, kdt_max_depth(root));
		}
		point dir, end, col;
		point *pt = (point *)malloc(sizeof(point));
		vec_rand_unit(pt);
		vec_scalar_mult(pt, pt, starting_rad);
		int walking = 1;
		while(walking) {
			vec_rand_unit(&dir);
			vec_scalar_mult(&dir, &dir, p.step_size);
			vec_add(&end, pt, &dir);
			if(kdt_collision_detect(root, pt, &end, &col, p.epsilon, buffer) && sticks(p.stickiness)) {
				vec_copy(pt, &col);
				kdt_add_point(root, pt);
				double pt_radius = vec_length(pt);
				if(pt_radius > curr_max_radius) {
					curr_max_radius = pt_radius;
					starting_rad = starting_radius(p.min_inner_radius, curr_max_radius, p.inner_mult, p.step_size);
					death_rad = death_radius(p.min_inner_radius, curr_max_radius, p.inner_mult, p.step_size, p.outer_mult);
				}
				walking = 0;
			} 
			else {
				vec_copy(pt, &end);
				if(vec_length(pt) >= death_rad) {
					// if we have moved outside the max radius, start over
					vec_rand_unit(pt);
					vec_scalar_mult(pt, pt, starting_rad);
				}
			}
		}
		print_point(fp, i, pt);
		time(&now);
	}
	if (p.log_progress == 1) {
		log_progress((double)i / (double)p.n * 100.0f, curr_max_radius, 
			starting_rad, kdt_max_depth(root));
	}
	fclose(fp);
}
Example #10
0
void check_raster_sanity(Raster *r, USHORT rastnum)
/*****************************************************************************
 * perform sanity check on Raster and Rastlib structures.
 ****************************************************************************/
{
Rastlib 	*rlib = r->lib;
void		**glib_array = (void **)(tcb.vd->grclib);
void		**rlib_array = (void **)(rlib);
USHORT		counter;
char		rastname[50];
char		fromdriver[] = "* (Driver  Library)";
char		fromgrc[]	 = "  (Generic Library)";
char		*fromlib;
void		*libroutine;

	if (rastnum == RASTER_PRIMARY)
		sprintf(rastname,"primary display raster");
	else
		sprintf(rastname,"secondary raster %hu",rastnum);

	/*------------------------------------------------------------------------
	 * print the contents of the raster and rastlib structures...
	 *----------------------------------------------------------------------*/

	log_data("  Contents of Raster structure for %s:\n"
			 "    type            = %hd\n"
			 "    pdepth          = %hd\n"
			 "    lib             = %p\n"
			 "    aspect_dx       = %hd\n"
			 "    aspect_dy       = %hd\n"
			 "    width           = %hu\n"
			 "    height          = %hu\n"
			 "    x               = %hd\n"
			 "    y               = %hd\n\n",
			 rastname,
			 r->type,
			 r->pdepth,
			 r->lib,
			 r->aspect_dx,
			 r->aspect_dy,
			 r->width,
			 r->height,
			 r->x,
			 r->y
			);

	log_data("  Contents of Rastlib structure for %s:\n", rastname);
	for (counter = 0; counter < RASTLIB_FUNC_COUNT; counter++)
		{
		if (rlib_array[counter] == NULL ||
			rlib_array[counter] == glib_array[counter])
			{
			libroutine = glib_array[counter];
			fromlib = fromgrc;
			}
		else
			{
			libroutine = rlib_array[counter];
			fromlib = fromdriver;
			}
		log_data(rastlib_fmt_strings[counter], libroutine, fromlib);
		rlib_array[counter] = libroutine;
		}
	log_data("\n");

	/*-----------------------------------------------------------------------
	 * do sanity check on Raster structure...
	 *---------------------------------------------------------------------*/

	log_progress("Verifying contents of Raster structure for %s...\n", rastname);

	if (r->type < tcb.vd->first_rtype)
		{
		log_error("Raster structure element 'type' has a value of %d, it should\n"
				  "be greater than or equal to 'vdev->first_rtype'.\n", r->type);
		return;
		}

	if (r->pdepth != 8)
		{
		log_error("Raster structure element 'pdepth' currently must be 8.\n");
		return;
		}

	if (r->width == 0 || r->height == 0)
		{
		log_error("Raster structure elements 'width' and 'height'"
					"must not be zero.\n");
		}

	if (r->aspect_dx == 0 || r->aspect_dy == 0)
		{
		log_warning("Raster structure elements 'aspect_dx' and 'aspect_dy'"
					"should not be zero.\n");
		}

	if (rlib == NULL)
		{
		log_error("Raster structure element 'lib' must not be a NULL pointer.\n");
		return;
		}

	log_progress("...verification of Raster structure complete.\n\n");

	/*-----------------------------------------------------------------------
	 * do sanity check on Rastlib structure...
	 *---------------------------------------------------------------------*/

	log_progress("Verifying contents of Rastlib structure for %s...\n",rastname);

	if (rlib->set_colors == NULL)
		log_error("Required raster function 'set_colors' not provided by driver.\n");

	if (rlib->get_dot == NULL)
		log_error("Required raster function 'get_dot' not provided by driver.\n");

	if (rlib->put_dot == NULL)
		log_error("Required raster function 'put_dot' not provided by driver.\n");


	log_progress("...verification of Rastlib structure complete.\n\n");

}
Example #11
0
static void log_progress(const SkString& str) { log_progress(str.c_str()); }
Example #12
0
Boolean verify_raster(Raster *sr, Raster *vr, Boolean do_logging)
/*****************************************************************************
 * verify that contents of raster sr exactly match bytemap raster vr.
 *	(sr and vr have to have identical width/height!)
 ****************************************************************************/
{
	int 	errors;
	int 	x;
	int 	y;
	int 	width = sr->width;
	int 	height = sr->height;
	Pixel	*pvrastpix = vr->hw.bm.bp[0];
	Pixel	segbuf[2048];

	/*------------------------------------------------------------------------
	 * if there is a playback verify buffer allocated, that means our caller
	 * is the playback testing.  in this case, we know we don't need logging,
	 * and we suck in the whole hardware raster then do a single fast compare
	 * of the buffer with the bytemap raster.  if they're equal, we return
	 * TRUE right away.  if unequal, we fall into our line-at-a-time routine
	 * which will report the x/y locations of the errors.  if the playback
	 * routines can't get enough memory for the playback buffer, the slower
	 * loop will be used, so that either way the comparison gets done.
	 *----------------------------------------------------------------------*/

	if (tcb.playback_verify_buffer != NULL) {
		pj_get_rectpix(sr, tcb.playback_verify_buffer, 0, 0, width, height);
		if (fast_compare(tcb.playback_verify_buffer, pvrastpix, width*height))
			return TRUE;
	}

	/*------------------------------------------------------------------------
	 * if logging was requested, do it.
	 *----------------------------------------------------------------------*/

	if (do_logging) {
		char	*rastname;
		if (sr->type == RT_BYTEMAP)
			rastname = "bytemap";
		else if (sr == &tcb.display_raster)
			rastname = "primary display";
		else
			rastname = "secondary hardware";

		log_progress("   Verifying contents of %s raster...\n", rastname);
	}

	/*------------------------------------------------------------------------
	 * if we got a non-equal comparison in the monolithic fast_compare(),
	 * or if this isn't a playback test comparison, do a line-at-a-time
	 * comparison, and report the x/y locations of differences.
	 *----------------------------------------------------------------------*/

	errors = 0;

	for (y = 0; y < height; ++y, pvrastpix += width) {
		pj_get_hseg(sr, segbuf, 0, y, width);
		if (!fast_compare(segbuf, pvrastpix, width)) {
			for (x = 0; x < width; ++x) {
				if (pvrastpix[x] != segbuf[x]) {
					log_verror(x, y, segbuf[x], pvrastpix[x]);
					if (++errors >= 10)
						goto ERROR_EXIT;
				}
			}
		}
	}

	if (do_logging)
		if (errors == 0)
			log_progress("   ...verification complete.\n");

ERROR_EXIT:

	return (errors == 0);

}