winetest timeout question
I would like to change the wave tests to always play and record so all code paths can be exercised. A normal run for a single sound card takes over 2 minutes so the test times out before test completion. Has anyone considered changing the timeout logic to be reset every time something is printed? This would allow long tests that periodically output something to run more than 2 minutes. Timeout would only occur 2 minutes after the last output.
Robert Reif <reif(a)earthlink.net> writes:
Has anyone considered changing the timeout logic to be reset every time something is printed? This would allow long tests that periodically output something to run more than 2 minutes. Timeout would only occur 2 minutes after the last output.
Yes, that was the original idea. However, output redirection problems forced me to implement it the simple way. Basically, I couldn't make the same code work on WineLib and Windows. You can look at the related threads in the archive to get more precise information. I think the most sensible option would be to fix Wine so that redirecting Windows HANDLES has an effect on the libc filehandles, or change the testing framework so that it outputs through the Win32 API, not through the printf family in libc. That would also fix the present msvcrt inconsistency (the msvcrt tests' output doesn't get redirected under WineLib). But don't take my word on it, I'm talking from faint memory. Unfortunately I can't tell when I will have the time to do serious work on this. -- Feri.
Robert Reif wrote:
I would like to change the wave tests to always play and record so all code paths can be exercised. A normal run for a single sound card takes over 2 minutes so the test times out before test completion.
Actually there's a way to make the tests run faster. They take long because we play a 1 second tone for each supported format. We cannot make the tone shorter because humans need some time to analyze the tone and we want to check for stutter too which you can't do if the tone is too short. But when running in interactive mode we can easily drop the tone duration to 0.1 second. Then the test runs in about 16 seconds on my machine which supports all the tested sound formats (but has only one sound card). Here's a patch that changes the following: * test tones are always played * if not in interactive mode we only play silence * if not in interactive mode tones last only 0.1 (resp. 0.5) seconds * if not in interactive mode we don't touch the volume * if in interactive mode nothing is changed Note that this patch conflicts a bit with the previous check_position() patch so it probably won't apply 100% cleanly but it should be reasonably easy to fix. In any case if this looks ok I'll update it as soon as my previous patch is committed. What do you think? -- Francois Gouget fgouget(a)codeweavers.com Index: dlls/winmm/tests/wave.c =================================================================== RCS file: /var/cvs/wine/dlls/winmm/tests/wave.c,v retrieving revision 1.33 diff -u -r1.33 wave.c --- dlls/winmm/tests/wave.c 20 Jul 2004 01:22:47 -0000 1.33 +++ dlls/winmm/tests/wave.c 20 Jul 2004 11:54:51 -0000 @@ -45,12 +45,12 @@ #define PI 3.14159265358979323846 static char* wave_generate_la(WAVEFORMATEX* wfx, double duration, DWORD* size) { - int i; - int nb_samples; + DWORD i; + DWORD nb_samples; char* buf; char* b; - nb_samples=(int)(duration*wfx->nSamplesPerSec); + nb_samples=(DWORD)(duration*wfx->nSamplesPerSec); *size=nb_samples*wfx->nBlockAlign; b=buf=malloc(*size); for (i=0;i<nb_samples;i++) { @@ -75,6 +75,21 @@ return buf; } +static char* wave_generate_silence(WAVEFORMATEX* wfx, double duration, DWORD* size) +{ + DWORD nb_samples; + char* buf; + + nb_samples=(DWORD)(duration*wfx->nSamplesPerSec); + *size=nb_samples*wfx->nBlockAlign; + buf=malloc(*size); + if (wfx->wBitsPerSample==8) + memset(buf,0x80,*size); + else + memset(buf,0,*size); + return buf; +} + const char * dev_name(int device) { static char name[16]; @@ -278,6 +300,7 @@ WORD nChannels = pwfx->nChannels; WORD wBitsPerSample = pwfx->wBitsPerSample; DWORD nSamplesPerSec = pwfx->nSamplesPerSec; + char* wave_desc; hevent=CreateEvent(NULL,FALSE,FALSE,NULL); ok(hevent!=NULL,"CreateEvent: error=%ld\n",GetLastError()); @@ -319,7 +342,16 @@ pwfx->nSamplesPerSec, pwfx->wBitsPerSample, pwfx->nChannels, nSamplesPerSec, wBitsPerSample, nChannels); - frag.lpData=wave_generate_la(pwfx,duration,&frag.dwBufferLength); + if (winetest_interactive) + { + wave_desc="440Hz tone"; + frag.lpData=wave_generate_la(pwfx,duration,&frag.dwBufferLength); + } + else + { + wave_desc="silence"; + frag.lpData=wave_generate_silence(pwfx,duration,&frag.dwBufferLength); + } frag.dwFlags=0; frag.dwLoops=0; @@ -330,33 +362,41 @@ ok(rc==MMSYSERR_NOERROR, "waveOutPrepareHeader: device=%s rc=%s\n",dev_name(device),wave_out_error(rc)); - if (winetest_interactive && rc==MMSYSERR_NOERROR) { + if (rc==MMSYSERR_NOERROR) { DWORD start,end; - trace("Playing %g second 440Hz tone at %5ldx%2dx%d %s\n",duration, + double tolerance; + + trace("Playing %g second %s at %5ldx%2dx%d %s\n",duration,wave_desc, pwfx->nSamplesPerSec, pwfx->wBitsPerSample,pwfx->nChannels, flags & WAVE_FORMAT_DIRECT ? "WAVE_FORMAT_DIRECT" : flags & WAVE_MAPPED ? "WAVE_MAPPED" : ""); /* Check that the position is 0 at start */ - check_position(device, wout, 0.0, pwfx); + check_position(device, wout, 0, pwfx); - rc=waveOutSetVolume(wout,0x20002000); - ok(rc==MMSYSERR_NOERROR,"waveOutSetVolume: device=%s rc=%s\n",dev_name(device),wave_out_error(rc)); - WaitForSingleObject(hevent,INFINITE); + if (winetest_interactive) + { + rc=waveOutSetVolume(wout,0x20002000); + ok(rc==MMSYSERR_NOERROR,"waveOutSetVolume: device=%s rc=%s\n",dev_name(device),wave_out_error(rc)); + } + WaitForSingleObject(hevent,INFINITE); start=GetTickCount(); rc=waveOutWrite(wout, &frag, sizeof(frag)); ok(rc==MMSYSERR_NOERROR,"waveOutWrite: device=%s rc=%s\n",dev_name(device),wave_out_error(rc)); WaitForSingleObject(hevent,INFINITE); - /* Check the sound duration was within 10% of the expected value */ + /* Check that the tone duration was about right */ end=GetTickCount(); - trace("sound duration=%ld\n",end-start); - ok(fabs(1000*duration-end+start)<=100*duration,"The sound played for %ld ms instead of %g ms\n",end-start,1000*duration); - - rc=waveOutSetVolume(wout,volume); - ok(rc==MMSYSERR_NOERROR,"waveOutSetVolume: device=%s rc=%s\n",dev_name(device),wave_out_error(rc)); + tolerance=duration<1.0?0.2:0.1; + ok(fabs(1000*duration-end+start)<=10.0+tolerance*1000.0*duration,"The sound played for %ld ms instead of %g ms\n",end-start,1000*duration); + + if (winetest_interactive) + { + rc=waveOutSetVolume(wout,volume); + ok(rc==MMSYSERR_NOERROR,"waveOutSetVolume: device=%s rc=%s\n",dev_name(device),wave_out_error(rc)); + } check_position(device, wout, duration, pwfx); } @@ -384,6 +425,7 @@ BYTE * twoPages; SYSTEM_INFO sSysInfo; DWORD flOldProtect; + double duration; BOOL res; GetSystemInfo(&sSysInfo); @@ -435,9 +477,10 @@ caps.wChannels,caps.dwFormats,caps.dwSupport,wave_out_caps(caps.dwSupport)); free(name); - if (winetest_interactive && (device != WAVE_MAPPER)) + duration=winetest_interactive?1.0:0.1; + if (device != WAVE_MAPPER) { - trace("Playing a 5 seconds reference tone.\n"); + trace("Playing a %g seconds reference tone.\n",5*duration); trace("All subsequent tones should be identical to this one.\n"); trace("Listen for stutter, changes in pitch, volume, etc.\n"); format.wFormatTag=WAVE_FORMAT_PCM; @@ -447,7 +490,7 @@ format.nBlockAlign=format.nChannels*format.wBitsPerSample/8; format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign; format.cbSize=0; - wave_out_test_deviceOut(device,5.0,&format,WAVE_FORMAT_2M08,0,&caps); + wave_out_test_deviceOut(device,5*duration,&format,WAVE_FORMAT_2M08,0,&caps); } for (f=0;f<NB_WIN_FORMATS;f++) { @@ -458,13 +501,13 @@ format.nBlockAlign=format.nChannels*format.wBitsPerSample/8; format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign; format.cbSize=0; - wave_out_test_deviceOut(device,1.0,&format,win_formats[f][0],0,&caps); - wave_out_test_deviceOut(device,1.0,&format,win_formats[f][0],WAVE_FORMAT_DIRECT,&caps); + wave_out_test_deviceOut(device,duration,&format,win_formats[f][0],0,&caps); + wave_out_test_deviceOut(device,duration,&format,win_formats[f][0],WAVE_FORMAT_DIRECT,&caps); if (device != WAVE_MAPPER) - wave_out_test_deviceOut(device,1.0,&format,win_formats[f][0],WAVE_MAPPED,&caps); + wave_out_test_deviceOut(device,duration,&format,win_formats[f][0],WAVE_MAPPED,&caps); } - /* Try a PCMWAVEFORMAT aligned next to an unaccessable page for bounds checking */ + /* Try a PCMWAVEFORMAT aligned next to an unaccessible page for bounds checking */ twoPages = VirtualAlloc(NULL, 2 * dwPageSize, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); ok(twoPages!=NULL,"Failed to allocate 2 pages of memory\n"); if (twoPages) { @@ -478,10 +521,10 @@ pwfx->nSamplesPerSec=22050; pwfx->nBlockAlign=pwfx->nChannels*pwfx->wBitsPerSample/8; pwfx->nAvgBytesPerSec=pwfx->nSamplesPerSec*pwfx->nBlockAlign; - wave_out_test_deviceOut(device,1.0,pwfx,WAVE_FORMAT_2M08,0,&caps); - wave_out_test_deviceOut(device,1.0,pwfx,WAVE_FORMAT_2M08,WAVE_FORMAT_DIRECT,&caps); + wave_out_test_deviceOut(device,duration,pwfx,WAVE_FORMAT_2M08,0,&caps); + wave_out_test_deviceOut(device,duration,pwfx,WAVE_FORMAT_2M08,WAVE_FORMAT_DIRECT,&caps); if (device != WAVE_MAPPER) - wave_out_test_deviceOut(device,1.0,pwfx,WAVE_FORMAT_2M08,WAVE_MAPPED,&caps); + wave_out_test_deviceOut(device,duration,pwfx,WAVE_FORMAT_2M08,WAVE_MAPPED,&caps); } VirtualFree(twoPages, 2 * dwPageSize, MEM_RELEASE); }
participants (3)
-
Ferenc Wagner -
Francois Gouget -
Robert Reif