From adddfb382dbb46943efd08b20634a716caf3456b Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Fri, 30 Oct 2009 13:47:32 -0400 Subject: Remove progress bars from tests, as parallel-tests hides output anyway. --- tests/libdimension/gl.c | 10 +-- tests/libdimension/png.c | 172 ++++++++++++++++++--------------------------- tests/libdimension/tests.c | 94 ------------------------- tests/libdimension/tests.h | 11 --- 4 files changed, 75 insertions(+), 212 deletions(-) (limited to 'tests/libdimension') diff --git a/tests/libdimension/gl.c b/tests/libdimension/gl.c index 8b999af..83648cd 100644 --- a/tests/libdimension/gl.c +++ b/tests/libdimension/gl.c @@ -24,7 +24,7 @@ int main() { dmnsn_display *display; - dmnsn_progress *progress, *barprogress; + dmnsn_progress *progress; dmnsn_scene *scene; dmnsn_canvas *canvas; @@ -55,6 +55,7 @@ main() { /* Render the scene */ + printf("Rendering scene\n"); progress = dmnsn_raytrace_scene_async(scene); if (!progress) { dmnsn_delete_display(display); @@ -63,8 +64,6 @@ main() { return EXIT_FAILURE; } - barprogress = dmnsn_progressbar_async("Raytracing scene: ", progress); - /* Display the scene as it's rendered */ while (dmnsn_get_progress(progress) < 1.0) { if (dmnsn_gl_write_canvas(scene->canvas) != 0) { @@ -76,8 +75,6 @@ main() { dmnsn_display_flush(display); } - dmnsn_finish_progress(barprogress); - if (dmnsn_finish_progress(progress) != 0) { dmnsn_delete_display(display); dmnsn_delete_default_scene(scene); @@ -86,6 +83,7 @@ main() { } /* Make sure we show the completed rendering */ + printf("Drawing to OpenGL\n"); if (dmnsn_gl_write_canvas(scene->canvas) != 0) { dmnsn_delete_display(display); dmnsn_delete_default_scene(scene); @@ -98,6 +96,7 @@ main() { sleep(1); /* Read a canvas from the GL buffer */ + printf("Reading from OpenGL\n"); canvas = dmnsn_gl_read_canvas(0, 0, scene->canvas->x, scene->canvas->y); if (!canvas) { dmnsn_delete_display(display); @@ -107,6 +106,7 @@ main() { } /* And write it back */ + printf("Drawing to OpenGL\n"); if (dmnsn_gl_write_canvas(canvas) != 0) { dmnsn_delete_canvas(canvas); dmnsn_delete_display(display); diff --git a/tests/libdimension/png.c b/tests/libdimension/png.c index 488cd56..0937a87 100644 --- a/tests/libdimension/png.c +++ b/tests/libdimension/png.c @@ -23,7 +23,6 @@ int main() { - dmnsn_progress *progress; FILE *ifile, *ofile; dmnsn_scene *scene; dmnsn_canvas *canvas; @@ -31,125 +30,94 @@ main() { /* Set the resilience low for tests */ dmnsn_set_resilience(DMNSN_SEVERITY_LOW); - /* Render the scene */ - { - /* Allocate our default scene */ - scene = dmnsn_new_default_scene(); - if (!scene) { - fprintf(stderr, "--- Allocation of default scene failed! ---\n"); - return EXIT_FAILURE; - } - - /* Optimize the canvas for PNG export */ - if (dmnsn_png_optimize_canvas(scene->canvas) != 0) { - dmnsn_delete_default_scene(scene); - fprintf(stderr, "--- Couldn't optimize canvas for PNG! ---\n"); - return EXIT_FAILURE; - } - - /* Render scene */ - - progress = dmnsn_raytrace_scene_async(scene); - if (!progress) { - dmnsn_delete_default_scene(scene); - fprintf(stderr, "--- Couldn't start raytracing worker thread! ---\n"); - return EXIT_FAILURE; - } - - dmnsn_progressbar("Raytracing scene: ", progress); - - if (dmnsn_finish_progress(progress) != 0) { - dmnsn_delete_default_scene(scene); - fprintf(stderr, "--- Raytracing failed! ---\n"); - return EXIT_FAILURE; - } - - /* Write the image to PNG */ - - ofile = fopen("png1.png", "wb"); - if (!ofile) { - dmnsn_delete_default_scene(scene); - fprintf(stderr, "--- Couldn't open 'png1.png' for writing! ---\n"); - return EXIT_FAILURE; - } - - progress = dmnsn_png_write_canvas_async(scene->canvas, ofile); - if (!progress) { - fclose(ofile); - dmnsn_delete_default_scene(scene); - fprintf(stderr, "--- Couldn't start PNG writing worker thread! ---\n"); - return EXIT_FAILURE; - } - - dmnsn_progressbar("Writing PNG file: ", progress); - - if (dmnsn_finish_progress(progress) != 0) { - fclose(ofile); - dmnsn_delete_default_scene(scene); - fprintf(stderr, "--- Writing canvas to PNG failed! ---\n"); - return EXIT_FAILURE; - } + /* + * Render the scene + */ - fclose(ofile); + /* Allocate our default scene */ + scene = dmnsn_new_default_scene(); + if (!scene) { + fprintf(stderr, "--- Allocation of default scene failed! ---\n"); + return EXIT_FAILURE; + } + + /* Optimize the canvas for PNG export */ + if (dmnsn_png_optimize_canvas(scene->canvas) != 0) { dmnsn_delete_default_scene(scene); + fprintf(stderr, "--- Couldn't optimize canvas for PNG! ---\n"); + return EXIT_FAILURE; } - /* Now test PNG import/export */ - { - /* Read the image back from PNG */ + /* Render scene */ - ifile = fopen("png1.png", "rb"); - if (!ifile) { - fprintf(stderr, "--- Couldn't open 'png1.png' for reading! ---\n"); - return EXIT_FAILURE; - } + printf("Rendering scene\n"); + if (dmnsn_raytrace_scene(scene) != 0) { + dmnsn_delete_default_scene(scene); + fprintf(stderr, "--- Raytracing failed! ---\n"); + return EXIT_FAILURE; + } - progress = dmnsn_png_read_canvas_async(&canvas, ifile); - if (!progress) { - fclose(ifile); - fprintf(stderr, "--- Couldn't start PNG reading worker thread! ---\n"); - return EXIT_FAILURE; - } + /* Write the image to PNG */ - dmnsn_progressbar("Reading PNG file: ", progress); + printf("Writing scene to PNG\n"); + ofile = fopen("png1.png", "wb"); + if (!ofile) { + dmnsn_delete_default_scene(scene); + fprintf(stderr, "--- Couldn't open 'png1.png' for writing! ---\n"); + return EXIT_FAILURE; + } - if (dmnsn_finish_progress(progress) != 0) { - fclose(ifile); - fprintf(stderr, "--- Reading canvas from PNG failed! ---\n"); - return EXIT_FAILURE; - } + if (dmnsn_png_write_canvas(scene->canvas, ofile) != 0) { + fclose(ofile); + dmnsn_delete_default_scene(scene); + fprintf(stderr, "--- Writing canvas to PNG failed! ---\n"); + return EXIT_FAILURE; + } - fclose(ifile); + fclose(ofile); + dmnsn_delete_default_scene(scene); + + /* + * Now test PNG import/export + */ - /* And write it back */ + /* Read the image back from PNG */ - ofile = fopen("png2.png", "wb"); - if (!ofile) { - fprintf(stderr, "--- Couldn't open 'png2.png' for writing! ---\n"); - dmnsn_delete_canvas(canvas); - return EXIT_FAILURE; - } + printf("Reading scene from PNG\n"); + ifile = fopen("png1.png", "rb"); + if (!ifile) { + fprintf(stderr, "--- Couldn't open 'png1.png' for reading! ---\n"); + return EXIT_FAILURE; + } - progress = dmnsn_png_write_canvas_async(canvas, ofile); - if (!progress) { - fclose(ofile); - dmnsn_delete_canvas(canvas); - fprintf(stderr, "--- Couldn't start PNG writing worker thread! ---\n"); - return EXIT_FAILURE; - } + canvas = dmnsn_png_read_canvas(ifile); + if (!canvas) { + fclose(ifile); + fprintf(stderr, "--- Reading canvas from PNG failed! ---\n"); + return EXIT_FAILURE; + } - dmnsn_progressbar("Writing PNG file: ", progress); + fclose(ifile); - if (dmnsn_finish_progress(progress) != 0) { - fclose(ofile); - dmnsn_delete_canvas(canvas); - fprintf(stderr, "--- Writing canvas to PNG failed! ---\n"); - return EXIT_FAILURE; - } + /* And write it back */ + printf("Writing scene to PNG\n"); + ofile = fopen("png2.png", "wb"); + if (!ofile) { + fprintf(stderr, "--- Couldn't open 'png2.png' for writing! ---\n"); + dmnsn_delete_canvas(canvas); + return EXIT_FAILURE; + } + + if (dmnsn_png_write_canvas(canvas, ofile) != 0) { fclose(ofile); dmnsn_delete_canvas(canvas); + fprintf(stderr, "--- Writing canvas to PNG failed! ---\n"); + return EXIT_FAILURE; } + fclose(ofile); + dmnsn_delete_canvas(canvas); + return EXIT_SUCCESS; } diff --git a/tests/libdimension/tests.c b/tests/libdimension/tests.c index e1cf55e..783c0f9 100644 --- a/tests/libdimension/tests.c +++ b/tests/libdimension/tests.c @@ -262,97 +262,3 @@ dmnsn_display_flush(dmnsn_display *display) glXWaitX(); glXSwapBuffers(display->dpy, display->win); } - -/* Print a progress bar of the progress of `progress' */ -void -dmnsn_progressbar(const char *str, const dmnsn_progress *progress) -{ - dmnsn_progress *barprogress = dmnsn_progressbar_async(str, progress); - if (dmnsn_finish_progress(barprogress) != 0) { - dmnsn_error(DMNSN_SEVERITY_HIGH, - "Progress bar background thread failed."); - } -} - -typedef struct { - dmnsn_progress *barprogress; - const char *str; - const dmnsn_progress *progress; -} dmnsn_progressbar_payload; - -/* Progress bar thread callback */ -static void *dmnsn_progressbar_thread(void *ptr); - -/* Print a progress bar in the background */ -dmnsn_progress * -dmnsn_progressbar_async(const char *str, const dmnsn_progress *progress) -{ - dmnsn_progress *barprogress = dmnsn_new_progress(); - dmnsn_progressbar_payload *payload; - - if (barprogress) { - payload = malloc(sizeof(dmnsn_progressbar_payload)); - if (!payload) { - dmnsn_error(DMNSN_SEVERITY_HIGH, - "Couldn't allocate progress bar payload."); - } - - payload->barprogress = barprogress; - payload->str = str; - payload->progress = progress; - - /* Create the worker thread */ - if (pthread_create(&barprogress->thread, NULL, &dmnsn_progressbar_thread, - payload) != 0) - { - dmnsn_error(DMNSN_SEVERITY_HIGH, - "Couldn't start progress bar background thread."); - } - } - - return barprogress; -} - -/* Actual progress bar implementation */ -static int dmnsn_progressbar_impl(dmnsn_progress *barprogress, const char *str, - const dmnsn_progress *progress); - -/* Progress bar thread callback */ -static void * -dmnsn_progressbar_thread(void *ptr) -{ - dmnsn_progressbar_payload *payload = ptr; - int *retval = malloc(sizeof(int)); - if (retval) { - *retval = dmnsn_progressbar_impl(payload->barprogress, - payload->str, payload->progress); - } - dmnsn_done_progress(payload->barprogress); - free(payload); - return retval; -} - -/* Actual progress bar implementation */ -static int -dmnsn_progressbar_impl(dmnsn_progress *barprogress, - const char *str, const dmnsn_progress *progress) -{ - const unsigned int increments = 32; - unsigned int i; - - dmnsn_new_progress_element(barprogress, increments); - - printf("%s|", str); - fflush(stdout); - for (i = 0; i < increments; ++i) { - dmnsn_wait_progress(progress, ((double)(i + 1))/increments); - - printf("="); - fflush(stdout); - dmnsn_increment_progress(barprogress); - } - printf("|\n"); - fflush(stdout); - - return 0; -} diff --git a/tests/libdimension/tests.h b/tests/libdimension/tests.h index 3569bbe..68cb726 100644 --- a/tests/libdimension/tests.h +++ b/tests/libdimension/tests.h @@ -57,17 +57,6 @@ void dmnsn_delete_display(dmnsn_display *display); /* Flush the GL buffers */ void dmnsn_display_flush(dmnsn_display *display); -/* - * Asynchronicity - */ - -/* Print a progress bar of the progress of `progress' */ -void dmnsn_progressbar(const char *str, const dmnsn_progress *progress); -/* Print a progress bar asynchronously, convienently guaranteed to succeed if - it returns so our tests don't get cluttered up */ -dmnsn_progress *dmnsn_progressbar_async(const char *str, - const dmnsn_progress *progress); - #ifdef __cplusplus } #endif -- cgit v1.2.3