X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=images%2Fimage-test.c;h=2e6c3d51785b42b40611a3f1b3fd3e82f03f322f;hb=b8667492cf36a609939ee35ac42900ff0b0cc80f;hp=de47695d611f841dd35cc7e8c1e791bb8ce7ae49;hpb=487f19b958da5875f0c05e53d5c229874662735e;p=libucw.git diff --git a/images/image-test.c b/images/image-test.c index de47695d..2e6c3d51 100644 --- a/images/image-test.c +++ b/images/image-test.c @@ -1,10 +1,20 @@ +/* + * 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 "images/images.h" -#include "images/color.h" +#include +#include +#include +#include +#include +#include #include #include @@ -12,8 +22,8 @@ #include #include -static uns want_image_iface; -static uns want_threads; +static uint want_image_iface; +static uint want_threads; #define TRY(x) do { if (!(x)) ASSERT(0); } while (0) @@ -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 * @@ -94,7 +106,7 @@ test_threads_thread(void *param UNUSED) image_context_init(&ctx); TRY(image_io_init(&ctx, &io)); - for (uns num = 0; num < 200; num++) + for (uint num = 0; num < 200; num++) { int r0 = random_max(100); @@ -126,7 +138,7 @@ test_threads_thread(void *param UNUSED) struct fastbuf *wfb = fbmem_create(10000); struct fastbuf *rfb; - uns format = 0; + uint format = 0; while (!format) { switch (random_max(3)) @@ -177,23 +189,29 @@ 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++) + for (uint i = 0; i < TEST_THREADS_COUNT - 1; i++) { if (pthread_create(threads + i, &attr, test_threads_thread, NULL) < 0) die("Unable to create thread: %m"); } test_threads_thread(NULL); - for (uns i = 0; i < TEST_THREADS_COUNT - 1; i++) + for (uint 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