]> Repos - portaudio/commitdiff
Move paqa_devs and paqa_errs to qa folder. Clean up tests.
authorphilburk <philburk@0f58301d-fd10-0410-b4af-bbb618454e57>
Thu, 8 Sep 2011 05:32:07 +0000 (05:32 +0000)
committerphilburk <philburk@0f58301d-fd10-0410-b4af-bbb618454e57>
Thu, 8 Sep 2011 05:32:07 +0000 (05:32 +0000)
Makefile.in
qa/paqa_devs.c [moved from test/paqa_devs.c with 95% similarity]
qa/paqa_errs.c [moved from test/paqa_errs.c with 98% similarity]
qa/paqa_latency.c

index 45d1be950bfc77872b5ef62ab52deed078713ad9..97f5c7c5666ac1ca73cf8139f6b6fce9a9180211 100644 (file)
@@ -78,9 +78,12 @@ EXAMPLES = \
        bin/paex_write_sine \
        bin/paex_write_sine_nonint
 
-TESTS = \
+SELFTESTS = \
        bin/paqa_devs \
        bin/paqa_errs \
+       bin/paqa_latency
+       
+TESTS = \
        bin/patest1 \
        bin/patest_buffer \
        bin/patest_callbackstop \
@@ -152,12 +155,14 @@ SRC_DIRS = \
 SUBDIRS =
 @ENABLE_CXX_TRUE@SUBDIRS += bindings/cpp
 
-all: lib/$(PALIB) all-recursive tests examples
+all: lib/$(PALIB) all-recursive tests examples selftests
 
 tests: bin-stamp $(TESTS)
 
 examples: bin-stamp $(EXAMPLES)
 
+selftests: bin-stamp $(SELFTESTS)
+
 loopback: bin-stamp bin/paloopback
 
 # With ASIO enabled we must link libportaudio and all test programs with CXX
@@ -173,6 +178,10 @@ $(EXAMPLES): bin/%: lib/$(PALIB) $(MAKEFILE) $(PAINC) examples/%.c
        @WITH_ASIO_FALSE@ $(LIBTOOL) --mode=link $(CC) -o $@ $(CFLAGS) $(top_srcdir)/examples/$*.c lib/$(PALIB) $(LIBS)
        @WITH_ASIO_TRUE@  $(LIBTOOL) --mode=link --tag=CXX $(CXX) -o $@ $(CXXFLAGS) $(top_srcdir)/examples/$*.c lib/$(PALIB) $(LIBS)
 
+$(SELFTESTS): bin/%: lib/$(PALIB) $(MAKEFILE) $(PAINC) qa/%.c
+       @WITH_ASIO_FALSE@ $(LIBTOOL) --mode=link $(CC) -o $@ $(CFLAGS) $(top_srcdir)/qa/$*.c lib/$(PALIB) $(LIBS)
+       @WITH_ASIO_TRUE@  $(LIBTOOL) --mode=link --tag=CXX $(CXX) -o $@ $(CXXFLAGS) $(top_srcdir)/qa/$*.c lib/$(PALIB) $(LIBS)
+
 bin/paloopback: lib/$(PALIB) $(MAKEFILE) $(PAINC) $(LOOPBACK_OBJS)
        @WITH_ASIO_FALSE@ $(LIBTOOL) --mode=link $(CC) -o $@ $(CFLAGS) $(LOOPBACK_OBJS) lib/$(PALIB) $(LIBS)
        @WITH_ASIO_TRUE@ $(LIBTOOL) --mode=link --tag=CXX $(CXX) -o $@ $(CXXFLAGS)  $(LOOPBACK_OBJS) lib/$(PALIB) $(LIBS)
similarity index 95%
rename from test/paqa_devs.c
rename to qa/paqa_devs.c
index 3374829ee8911db11e40d982c21178b10bb314cd..4a19968fe948adf42d9394290d076bd4dcc028fc 100644 (file)
@@ -1,5 +1,5 @@
 /** @file paqa_devs.c
-       @ingroup test_src
+       @ingroup qa_src
     @brief Self Testing Quality Assurance app for PortAudio
        Try to open each device and run through all the
        possible configurations. This test does not verify
@@ -213,7 +213,7 @@ int main(void)
 error:
     Pa_Terminate();
     printf("QA Report: %d passed, %d failed.\n", gNumPassed, gNumFailed );
-    return 0;
+    return (gNumFailed > 0) ? 1 : 0;
 }
 
 /*******************************************************************
@@ -237,7 +237,9 @@ static void TestDevices( int mode )
         
         for( jc=1; jc<=maxChannels; jc++ )
         {
-            printf("Name         = %s\n", pdi->name );
+            printf("\n========================================================================\n");
+            printf("            Device = %s\n", pdi->name );
+            printf("========================================================================\n");
             /* Try each standard sample rate. */
             for( i=0; standardSampleRates[i] > 0; i++ )
             {
@@ -266,9 +268,10 @@ static int TestAdvance( int mode, PaDeviceIndex deviceID, double sampleRate,
     PaError result = paNoError;
     PaQaData myData;
     #define FRAMES_PER_BUFFER  (64)
+    const int kNumSeconds = 100;
     
     /* Setup data for synthesis thread. */
-    myData.framesLeft = (unsigned long) (sampleRate * 100); /* 100 seconds */
+    myData.framesLeft = (unsigned long) (sampleRate * kNumSeconds);
     myData.numChannels = numChannels;
     myData.mode = mode;
     myData.format = format;
@@ -297,8 +300,11 @@ static int TestAdvance( int mode, PaDeviceIndex deviceID, double sampleRate,
         ipp = &inputParameters;
     }
     else
-        ipp = NULL;
-    if( mode == MODE_OUTPUT )           /* Pa_GetDeviceInfo(paNoDevice) COREDUMPS!!! */
+    {
+          ipp = NULL;
+       }
+       
+    if( mode == MODE_OUTPUT )
     {
         outputParameters.device       = deviceID;
         outputParameters.channelCount = numChannels;
@@ -308,8 +314,10 @@ static int TestAdvance( int mode, PaDeviceIndex deviceID, double sampleRate,
         opp = &outputParameters;
     }
     else
-        opp = NULL;
-
+    {
+               opp = NULL;
+       }
+       
     if(paFormatIsSupported == Pa_IsFormatSupported( ipp, opp, sampleRate ))
     {
         printf("------ TestAdvance: %s, device = %d, rate = %g, numChannels = %d, format = %lu -------\n",
@@ -341,7 +349,7 @@ static int TestAdvance( int mode, PaDeviceIndex deviceID, double sampleRate,
             oldStamp = Pa_GetStreamTime(stream);
             Pa_Sleep(msec);
             newStamp = Pa_GetStreamTime(stream);
-            printf("oldStamp = %g,newStamp = %g\n", oldStamp, newStamp ); /**/
+            printf("oldStamp = %g, newStamp = %g\n", oldStamp, newStamp ); /**/
             EXPECT( (oldStamp < newStamp) );
             /* Check to make sure callback is decrementing framesLeft. */
             oldFrames = myData.framesLeft;
@@ -352,7 +360,8 @@ static int TestAdvance( int mode, PaDeviceIndex deviceID, double sampleRate,
             stream = NULL;
         }
     }
+    return 0;
 error:
     if( stream != NULL ) Pa_CloseStream( stream );
-    return result;
+    return -1;
 }
similarity index 98%
rename from test/paqa_errs.c
rename to qa/paqa_errs.c
index ac933001507da96cd453f74fee29873fc27701d5..524978ddb9892e7608cd7f99aa7901ca83f5a7e7 100644 (file)
@@ -1,5 +1,5 @@
 /** @file paqa_errs.c
-       @ingroup test_src
+       @ingroup qa_src
        @brief Self Testing Quality Assurance app for PortAudio
        Do lots of bad things to test error reporting.
        @author Phil Burk  http://www.softsynth.com
@@ -342,6 +342,7 @@ static int TestBadOpens( void )
 static int TestBadActions( void )
 {
     PaStream*           stream = NULL;
+    const PaDeviceInfo* deviceInfo = NULL;
     PaError             result;
     PaQaData            myData;
     PaStreamParameters  opp;
@@ -365,7 +366,9 @@ static int TestBadActions( void )
                                          SAMPLE_RATE, FRAMES_PER_BUFFER,
                                          paClipOff, QaCallback, &myData )) == paNoError));
     }
-
+    HOPEFOR(((deviceInfo = Pa_GetDeviceInfo(paNoDevice))    == NULL));
+    HOPEFOR(((deviceInfo = Pa_GetDeviceInfo(87654))    == NULL));
     HOPEFOR(((result = Pa_StartStream(NULL))    == paBadStreamPtr));
     HOPEFOR(((result = Pa_StopStream(NULL))     == paBadStreamPtr));
     HOPEFOR(((result = Pa_IsStreamStopped(NULL)) == paBadStreamPtr));
index 130ee6844b5247932e569c2ed45ad8774060565f..8fe08e7ab2a2312418fe766916e8c19b60bc4fc2 100644 (file)
@@ -1,6 +1,6 @@
-/** @file patest_sine.c
-       @ingroup test_src
-       @brief Play a sine wave for several seconds.
+/** @file paqa_latency.c
+       @ingroup qa_src
+       @brief Test latency estimates.
        @author Ross Bencina <rossb@audiomulch.com>
     @author Phil Burk <philburk@softsynth.com>
 */
@@ -138,7 +138,6 @@ PaError paqaCheckLatency( PaStreamParameters *outputParamsPtr,
     dataPtr->maxDeltaDacTime = 0.0;
     dataPtr->callbackCount = 0;
     
-    printf("-------------------------------------\n");
     printf("Stream parameter: suggestedOutputLatency = %g\n", outputParamsPtr->suggestedLatency );
     if( framesPerBuffer == paFramesPerBufferUnspecified ){
         printf("Stream parameter: user framesPerBuffer = paFramesPerBufferUnspecified\n" );
@@ -178,10 +177,12 @@ PaError paqaCheckLatency( PaStreamParameters *outputParamsPtr,
     Pa_Sleep( 1 * 1000 );
 
     
+    printf("-------------------------------------\n");
     return err;
 error2:
     Pa_CloseStream( stream );
 error1:
+    printf("-------------------------------------\n");
     return err;
 }
 
@@ -225,36 +226,44 @@ int main(void)
     printf("Device info: defaultHighOutputLatency = %f seconds\n", deviceInfo->defaultHighOutputLatency);
     outputParameters.hostApiSpecificStreamInfo = NULL;
     
+    
     // Try to use a small buffer that is smaller than we think the device can handle.
     // Try to force combining multiple user buffers into a host buffer.
+    printf("------------- Try a very small buffer.\n");
     framesPerBuffer = 9;
     outputParameters.suggestedLatency = deviceInfo->defaultLowOutputLatency;
     err = paqaCheckLatency( &outputParameters, &data, sampleRate, framesPerBuffer );
     if( err != paNoError ) goto error;
     
+    printf("------------- 64 frame buffer with 1.1 * defaultLow latency.\n");
     framesPerBuffer = 64;
     outputParameters.suggestedLatency = deviceInfo->defaultLowOutputLatency * 1.1;
     err = paqaCheckLatency( &outputParameters, &data, sampleRate, framesPerBuffer );
     if( err != paNoError ) goto error;
 
     // Try to create a huge buffer that is bigger than the allowed device maximum.
+    printf("------------- Try a huge buffer.\n");
     framesPerBuffer = 16*1024;
     outputParameters.suggestedLatency = ((double)framesPerBuffer) / sampleRate; // approximate
     err = paqaCheckLatency( &outputParameters, &data, sampleRate, framesPerBuffer );
     if( err != paNoError ) goto error;
     
+    printf("------------- Try suggestedLatency = 0.0\n");
     outputParameters.suggestedLatency = 0.0;
     err = paqaCheckLatency( &outputParameters, &data, sampleRate, paFramesPerBufferUnspecified );
     if( err != paNoError ) goto error;
     
+    printf("------------- Try suggestedLatency = defaultLowOutputLatency\n");
     outputParameters.suggestedLatency = deviceInfo->defaultLowOutputLatency;
     err = paqaCheckLatency( &outputParameters, &data, sampleRate, paFramesPerBufferUnspecified );
     if( err != paNoError ) goto error;
     
+    printf("------------- Try suggestedLatency = defaultHighOutputLatency\n");
     outputParameters.suggestedLatency = deviceInfo->defaultHighOutputLatency;
     err = paqaCheckLatency( &outputParameters, &data, sampleRate, paFramesPerBufferUnspecified );
     if( err != paNoError ) goto error;
-        
+    
+    printf("------------- Try suggestedLatency = defaultHighOutputLatency * 4\n");
     outputParameters.suggestedLatency = deviceInfo->defaultHighOutputLatency * 4;
     err = paqaCheckLatency( &outputParameters, &data, sampleRate, paFramesPerBufferUnspecified );
     if( err != paNoError ) goto error;