Home | History | Annotate | Download | only in auto_test
      1 /*
      2  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
      3  *
      4  *  Use of this source code is governed by a BSD-style license
      5  *  that can be found in the LICENSE file in the root of the source
      6  *  tree. An additional intellectual property rights grant can be found
      7  *  in the file PATENTS.  All contributing project authors may
      8  *  be found in the AUTHORS file in the root of the source tree.
      9  */
     10 
     11 #ifndef WEBRTC_VOICE_ENGINE_VOE_TEST_DEFINES_H
     12 #define WEBRTC_VOICE_ENGINE_VOE_TEST_DEFINES_H
     13 
     14 #include "webrtc/voice_engine/test/auto_test/voe_test_common.h"
     15 
     16 // Read WEBRTC_VOICE_ENGINE_XXX_API compiler flags
     17 #include "webrtc/engine_configurations.h"
     18 
     19 // Select the tests to execute, list order below is same as they will be
     20 // executed. Note that, all settings below will be overriden by sub-API
     21 // settings in engine_configurations.h.
     22 #define _TEST_BASE_
     23 #define _TEST_RTP_RTCP_
     24 #define _TEST_HARDWARE_
     25 #define _TEST_CODEC_
     26 #define _TEST_DTMF_
     27 #define _TEST_VOLUME_
     28 #define _TEST_AUDIO_PROCESSING_
     29 #define _TEST_FILE_
     30 #define _TEST_NETWORK_
     31 #define _TEST_VIDEO_SYNC_
     32 #define _TEST_NETEQ_STATS_
     33 #define _TEST_XMEDIA_
     34 
     35 #define TESTED_AUDIO_LAYER kAudioPlatformDefault
     36 //#define TESTED_AUDIO_LAYER kAudioLinuxPulse
     37 
     38 // #define _ENABLE_VISUAL_LEAK_DETECTOR_ // Enables VLD to find memory leaks
     39 // #define _ENABLE_IPV6_TESTS_      // Enables IPv6 tests in network xtest
     40 // #define _USE_EXTENDED_TRACE_     // Adds unique trace files for extended test
     41 // #define _MEMORY_TEST_
     42 
     43 // Enable this when running instrumentation of some kind to exclude tests
     44 // that will not pass due to slowed down execution.
     45 // #define _INSTRUMENTATION_TESTING_
     46 
     47 // Exclude (override) API tests given preprocessor settings in
     48 // engine_configurations.h
     49 #ifndef WEBRTC_VOICE_ENGINE_CODEC_API
     50 #undef _TEST_CODEC_
     51 #endif
     52 #ifndef WEBRTC_VOICE_ENGINE_VOLUME_CONTROL_API
     53 #undef _TEST_VOLUME_
     54 #endif
     55 #ifndef WEBRTC_VOICE_ENGINE_DTMF_API
     56 #undef _TEST_DTMF_
     57 #endif
     58 #ifndef WEBRTC_VOICE_ENGINE_RTP_RTCP_API
     59 #undef _TEST_RTP_RTCP_
     60 #endif
     61 #ifndef WEBRTC_VOICE_ENGINE_AUDIO_PROCESSING_API
     62 #undef _TEST_AUDIO_PROCESSING_
     63 #endif
     64 #ifndef WEBRTC_VOICE_ENGINE_FILE_API
     65 #undef _TEST_FILE_
     66 #endif
     67 #ifndef WEBRTC_VOICE_ENGINE_VIDEO_SYNC_API
     68 #undef _TEST_VIDEO_SYNC_
     69 #endif
     70 #ifndef WEBRTC_VOICE_ENGINE_HARDWARE_API
     71 #undef _TEST_HARDWARE_
     72 #endif
     73 #ifndef WEBRTC_VOICE_ENGINE_EXTERNAL_MEDIA_API
     74 #undef _TEST_XMEDIA_
     75 #endif
     76 #ifndef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API
     77 #undef _TEST_NETEQ_STATS_
     78 #endif
     79 
     80 // Some parts can cause problems while running Insure
     81 #ifdef __INSURE__
     82 #define _INSTRUMENTATION_TESTING_
     83 #endif
     84 
     85 #define MARK() TEST_LOG("."); fflush(NULL);             // Add test marker
     86 #define ANL() TEST_LOG("\n")                            // Add New Line
     87 #define AOK() TEST_LOG("[Test is OK]"); fflush(NULL);   // Add OK
     88 #if defined(_WIN32)
     89 #define PAUSE                                      \
     90     {                                               \
     91         TEST_LOG("Press any key to continue...");   \
     92         _getch();                                   \
     93         TEST_LOG("\n");                             \
     94     }
     95 #else
     96 #define PAUSE                                          \
     97     {                                                   \
     98         TEST_LOG("Continuing (pause not supported)\n"); \
     99     }
    100 #endif
    101 
    102 #define TEST(s)                         \
    103     {                                   \
    104         TEST_LOG("Testing: %s", #s);    \
    105     }                                   \
    106 
    107 #ifdef _INSTRUMENTATION_TESTING_
    108 // Don't stop execution if error occurs
    109 #define TEST_MUSTPASS(expr)                                               \
    110     {                                                                     \
    111         if ((expr))                                                       \
    112         {                                                                 \
    113             TEST_LOG_ERROR("Error at line:%i, %s \n",__LINE__, #expr);    \
    114             TEST_LOG_ERROR("Error code: %i\n",voe_base_->LastError());    \
    115         }                                                                 \
    116     }
    117 #define TEST_ERROR(code)                                                \
    118     {                                                                   \
    119         int err = voe_base_->LastError();                               \
    120         if (err != code)                                                \
    121         {                                                               \
    122             TEST_LOG_ERROR("Invalid error code (%d, should be %d) at line %d\n",
    123                            code, err, __LINE__);
    124 }
    125 }
    126 #else
    127 #define ASSERT_TRUE(expr) TEST_MUSTPASS(!(expr))
    128 #define ASSERT_FALSE(expr) TEST_MUSTPASS(expr)
    129 #define TEST_MUSTFAIL(expr) TEST_MUSTPASS(!((expr) == -1))
    130 #define TEST_MUSTPASS(expr)                                              \
    131     {                                                                    \
    132         if ((expr))                                                      \
    133         {                                                                \
    134             TEST_LOG_ERROR("\nError at line:%i, %s \n",__LINE__, #expr); \
    135             TEST_LOG_ERROR("Error code: %i\n", voe_base_->LastError());  \
    136             PAUSE                                                        \
    137             return -1;                                                   \
    138         }                                                                \
    139     }
    140 #define TEST_ERROR(code) \
    141     {																                                         \
    142       int err = voe_base_->LastError();                                      \
    143       if (err != code)                                                       \
    144       {                                                                      \
    145         TEST_LOG_ERROR("Invalid error code (%d, should be %d) at line %d\n", \
    146                        err, code, __LINE__);                                 \
    147         PAUSE                                                                \
    148         return -1;                                                           \
    149       }															                                         \
    150     }
    151 #endif  // #ifdef _INSTRUMENTATION_TESTING_
    152 #define EXCLUDE()                                                   \
    153     {                                                               \
    154         TEST_LOG("\n>>> Excluding test at line: %i <<<\n\n",__LINE__);  \
    155     }
    156 
    157 #define INCOMPLETE()                                                \
    158     {                                                               \
    159         TEST_LOG("\n>>> Incomplete test at line: %i <<<\n\n",__LINE__);  \
    160     }
    161 
    162 #endif // WEBRTC_VOICE_ENGINE_VOE_TEST_DEFINES_H
    163