00001
00002
00003
00004
00005
00006
00007 #include "platform.h"
00008 #include "extractor.h"
00009 #include <pthread.h>
00010
00011 struct TaskData
00012 {
00013 int id;
00014 };
00015
00016 static volatile int done = 0;
00017
00018 static volatile int failed = 0;
00019
00020 static void *
00021 test_plugins (void *arg)
00022 {
00023 struct TaskData *td = (struct TaskData *) arg;
00024 EXTRACTOR_ExtractorList *el;
00025 int i;
00026
00027 while (!done)
00028 {
00029 el = EXTRACTOR_addLibrary (NULL, "libextractor_thumbnailgtk");
00030 el = EXTRACTOR_removeLibrary (el, "libextractor_thumbnailgtk");
00031 if (el != NULL)
00032 {
00033 printf ("add-remove test failed (gtk) in thread %d!\n", td->id);
00034 failed = 1;
00035 }
00036 el = EXTRACTOR_addLibrary (NULL, "libextractor_thumbnailqt");
00037 el = EXTRACTOR_removeLibrary (el, "libextractor_thumbnailqt");
00038 if (el != NULL)
00039 {
00040 printf ("add-remove test failed (qt) in thread %d!\n", td->id);
00041 failed = 1;
00042 }
00043 el = EXTRACTOR_addLibrary (NULL, "libextractor_thumbnailffmpeg");
00044 el = EXTRACTOR_removeLibrary (el, "libextractor_thumbnailffmpeg");
00045 if (el != NULL)
00046 {
00047 printf ("add-remove test failed (ffmpeg) in thread %d!\n", td->id);
00048 failed = 1;
00049 }
00050 }
00051 return 0;
00052 }
00053
00054 #define TEST_SECS 10
00055
00056 #define NUM_TASKS 10
00057
00058 int
00059 main (int argc, char *argv[])
00060 {
00061 pthread_t task_list[NUM_TASKS];
00062 struct TaskData td[NUM_TASKS];
00063 int ret = 0;
00064 int i;
00065 int max = NUM_TASKS;
00066 void * unused;
00067
00068 printf("testing for %d seconds\n", TEST_SECS);
00069 for (i = 0; i < NUM_TASKS; i++)
00070 {
00071 td[i].id = i;
00072 ret = pthread_create (&task_list[i], NULL, &test_plugins, &td[i]);
00073 if (ret != 0)
00074 {
00075 printf ("ERROR: pthread_create failed for thread %d\n", i);
00076 max = i;
00077 done = 1;
00078 break;
00079 }
00080 }
00081 printf("Threads running!\n");
00082 if (!done)
00083 sleep (TEST_SECS);
00084 printf("Shutting down...\n");
00085 done = 1;
00086 for (i = 0; i < max; i++)
00087 {
00088 if (pthread_join (task_list[i], &unused) != 0)
00089 printf ("WARNING: pthread_join failed for thread %d\n", i);
00090 }
00091
00092 return failed;
00093 }