X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=images%2Fimage-test.c;h=0aad5057a8ccb65d54f46d0b994f32d731179b20;hb=b56cd57bdce6b573ac0fc973ba4d16057c1e2ca5;hp=c751e8a0225ccd3c0bc0f3ed7407784c3d056976;hpb=54caf9eea63bd7f50bbe201b60c80aa93b0f6a01;p=libucw.git diff --git a/images/image-test.c b/images/image-test.c index c751e8a0..0aad5057 100644 --- a/images/image-test.c +++ b/images/image-test.c @@ -1,8 +1,18 @@ +/* + * Image Library -- Simple automatic tests + * + * (c) 2006 Pavel Charvat + * + * This software may be freely distributed and used according to the terms + * of the GNU Lesser General Public License. + */ + #undef LOCAL_DEBUG -#include "lib/lib.h" -#include "lib/mempool.h" -#include "lib/fastbuf.h" +#include "ucw/lib.h" +#include "ucw/mempool.h" +#include "ucw/fastbuf.h" +#include "ucw/threads.h" #include "images/images.h" #include "images/color.h" @@ -54,7 +64,7 @@ test_image_iface(void) ASSERT(i1->pixel_size == 4); ASSERT(IMAGE_SSE_ALIGN_SIZE >= 16); ASSERT(!(i1->row_size & (IMAGE_SSE_ALIGN_SIZE - 1))); - ASSERT(!((addr_int_t)i1->pixels & (IMAGE_SSE_ALIGN_SIZE - 1))); + ASSERT(!((uintptr_t)i1->pixels & (IMAGE_SSE_ALIGN_SIZE - 1))); image_destroy(i1); i1 = image_new(&ctx, 283, 329, COLOR_SPACE_RGB, NULL); @@ -83,6 +93,8 @@ test_image_iface(void) mp_delete(pool); } +#ifdef CONFIG_UCW_THREADS + #define TEST_THREADS_COUNT 4 static void * @@ -129,7 +141,7 @@ test_threads_thread(void *param UNUSED) uns format = 0; while (!format) { - switch (random_max(2)) + switch (random_max(3)) { case 0: #if defined(CONFIG_IMAGES_LIBJPEG) || defined(CONFIG_IMAGES_LIBMAGICK) @@ -139,6 +151,11 @@ test_threads_thread(void *param UNUSED) case 1: #if defined(CONFIG_IMAGES_LIBPNG) || defined(CONFIG_IMAGES_LIBMAGICK) format = IMAGE_FORMAT_PNG; +#endif + break; + case 2: +#if defined(CONFIG_IMAGES_LIBMAGICK) + format = IMAGE_FORMAT_GIF; #endif break; default: @@ -172,13 +189,16 @@ test_threads_thread(void *param UNUSED) return NULL; } +#endif + static void test_threads(void) { +#ifdef CONFIG_UCW_THREADS pthread_t threads[TEST_THREADS_COUNT - 1]; pthread_attr_t attr; if (pthread_attr_init(&attr) < 0 || - pthread_attr_setstacksize(&attr, 1 << 20) < 0) + pthread_attr_setstacksize(&attr, ucwlib_thread_stack_size) < 0) ASSERT(0); for (uns i = 0; i < TEST_THREADS_COUNT - 1; i++) { @@ -189,6 +209,9 @@ test_threads(void) for (uns i = 0; i < TEST_THREADS_COUNT - 1; i++) if (pthread_join(threads[i], NULL) < 0) die("Cannot join thread: %m"); +#else + msg(L_WARN, "Disabled CONFIG_UCW_THREADS, threaded tests skipped"); +#endif } int @@ -203,12 +226,12 @@ main(int argc, char **argv) die("Invalid parameter"); srandom(time(NULL) ^ getpid()); - + if (want_image_iface) test_image_iface(); if (want_threads) test_threads(); - + return 0; }