Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
This commit is contained in:
parent
a0bc602061
commit
16a40598f6
47 changed files with 616 additions and 505 deletions
|
@ -30,17 +30,15 @@ ThreadFunc(void *data)
|
|||
int threadnum = (int) (uintptr_t) data;
|
||||
while (alive) {
|
||||
SDL_SemWait(sem);
|
||||
fprintf(stderr,
|
||||
"Thread number %d has got the semaphore (value = %d)!\n",
|
||||
SDL_Log("Thread number %d has got the semaphore (value = %d)!\n",
|
||||
threadnum, SDL_SemValue(sem));
|
||||
SDL_Delay(200);
|
||||
SDL_SemPost(sem);
|
||||
fprintf(stderr,
|
||||
"Thread number %d has released the semaphore (value = %d)!\n",
|
||||
SDL_Log("Thread number %d has released the semaphore (value = %d)!\n",
|
||||
threadnum, SDL_SemValue(sem));
|
||||
SDL_Delay(1); /* For the scheduler */
|
||||
}
|
||||
printf("Thread number %d exiting.\n", threadnum);
|
||||
SDL_Log("Thread number %d exiting.\n", threadnum);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -59,7 +57,7 @@ TestWaitTimeout(void)
|
|||
int retval;
|
||||
|
||||
sem = SDL_CreateSemaphore(0);
|
||||
printf("Waiting 2 seconds on semaphore\n");
|
||||
SDL_Log("Waiting 2 seconds on semaphore\n");
|
||||
|
||||
start_ticks = SDL_GetTicks();
|
||||
retval = SDL_SemWaitTimeout(sem, 2000);
|
||||
|
@ -69,13 +67,13 @@ TestWaitTimeout(void)
|
|||
|
||||
/* Accept a little offset in the effective wait */
|
||||
if (duration > 1900 && duration < 2050)
|
||||
printf("Wait done.\n");
|
||||
SDL_Log("Wait done.\n");
|
||||
else
|
||||
fprintf(stderr, "Wait took %d milliseconds\n", duration);
|
||||
SDL_Log("Wait took %d milliseconds\n", duration);
|
||||
|
||||
/* Check to make sure the return value indicates timed out */
|
||||
if (retval != SDL_MUTEX_TIMEDOUT)
|
||||
fprintf(stderr, "SDL_SemWaitTimeout returned: %d; expected: %d\n", retval, SDL_MUTEX_TIMEDOUT);
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_SemWaitTimeout returned: %d; expected: %d\n", retval, SDL_MUTEX_TIMEDOUT);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -85,14 +83,17 @@ main(int argc, char **argv)
|
|||
uintptr_t i;
|
||||
int init_sem;
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "Usage: %s init_value\n", argv[0]);
|
||||
SDL_Log("Usage: %s init_value\n", argv[0]);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* Load the SDL library */
|
||||
if (SDL_Init(0) < 0) {
|
||||
fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
return (1);
|
||||
}
|
||||
signal(SIGTERM, killed);
|
||||
|
@ -101,7 +102,7 @@ main(int argc, char **argv)
|
|||
init_sem = atoi(argv[1]);
|
||||
sem = SDL_CreateSemaphore(init_sem);
|
||||
|
||||
printf("Running %d threads, semaphore value = %d\n", NUM_THREADS,
|
||||
SDL_Log("Running %d threads, semaphore value = %d\n", NUM_THREADS,
|
||||
init_sem);
|
||||
/* Create all the threads */
|
||||
for (i = 0; i < NUM_THREADS; ++i) {
|
||||
|
@ -114,12 +115,12 @@ main(int argc, char **argv)
|
|||
SDL_Delay(10 * 1000);
|
||||
|
||||
/* Wait for all threads to finish */
|
||||
printf("Waiting for threads to finish\n");
|
||||
SDL_Log("Waiting for threads to finish\n");
|
||||
alive = 0;
|
||||
for (i = 0; i < NUM_THREADS; ++i) {
|
||||
SDL_WaitThread(threads[i], NULL);
|
||||
}
|
||||
printf("Finished waiting for threads\n");
|
||||
SDL_Log("Finished waiting for threads\n");
|
||||
|
||||
SDL_DestroySemaphore(sem);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue