This file is indexed.

/usr/include/sipxtapi/sipxunit/TestUtilities.h is in libsipxtapi-dev 3.3.0~test17-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
//
// Copyright (C) 2004-2010 SIPfoundry Inc.
// Licensed by SIPfoundry under the LGPL license.
//
// Copyright (C) 2004-2010 SIPez LLC.  All rights reserved.
// Licensed to SIPfoundry under a Contributor Agreement.
//
// Copyright (C) 2004-2006 Pingtel Corp.  All rights reserved.
// Licensed to SIPfoundry under a Contributor Agreement.
//
// $$
///////////////////////////////////////////////////////////////////////////////

#ifndef _TestUtilities_h_
#define _TestUtilities_h_

#if defined(NO_CPPUNIT)
#include <utl/UtlString.h>
typedef UtlString string;

#else
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/TestCase.h>

#include <string>


using namespace std ;

// MACROS
#define MAX_BUG_MESSAGE_LEN 1024

/** 
 * Assert 2 character strings match character for character, NULLs ok
 */ 
#define ASSERT_STR_EQUAL(expected, actual) \
    ( TestUtilities::assertEquals((expected), (actual), \
      CPPUNIT_SOURCELINE(), ""))

/** 
 * Assert 2 character strings match character for character, NULLs ok
 * and include message to report if they aren't
 */ 
#define ASSERT_STR_EQUAL_MESSAGE(message, expected, actual) \
    ( TestUtilities::assertEquals((expected), (actual), \
      CPPUNIT_SOURCELINE(), (message)))

/** 
 * Call this just before a crash is known to happen. Obvisouly
 * you've attempted to fix the bug, but this is for bugs you cannot
 * fix for a very good reason, in which case you log a bug in JIRA 
 * and you enter that bug number here. BUG NUMBER MANDATORY!!!
 *
 * THIS MACRO WILL NOT RETURN, Assertion Exception will be thrown
 * and handled by framework.
 * 
 * Example:
 *   // see bug for more details
 *   KNOWN_FATAL_BUG("Segmentation Fault", "XPL-34");
 *   CPPUNIT_ASSERT_EQUAL(3, db->getRowCount());
 *   
 */
#define KNOWN_FATAL_BUG(message, bugNo) \
    ( TestUtilities::knownFatalBug((message), (bugNo), \
      CPPUNIT_SOURCELINE()))

/** 
 * Call this just before an assertion is known to fail. Obvisouly
 * you've attempted to fix the bug, but this is for bugs you cannot
 * fix for a very good reason, in which case you log a bug in JIRA 
 * and you enter that bug number here. BUG NUMBER MANDATORY!!!
 * 
 * Example:
 *   KNOWN_BUG("Will be zero until Joe can finish module", "XPL-36");
 *   CPPUNIT_ASSERT_EQUAL(3, db->getRowCount());
 */
#define KNOWN_BUG(message, bugNo) \
    ( TestUtilities::knownBug((message), (bugNo), \
      CPPUNIT_SOURCELINE()))

/**
 * Fatal bugs you only get when running Electric Fence. This will be
 * fatal if efence on, otherwise non-fatal bug. (Experimental)
 */
#define KNOWN_EFENCE_BUG(message, bugNo) \
    ( TestUtilities::knownEfenceBug((message), (bugNo), \
      CPPUNIT_SOURCELINE()))

#endif /* NO_CPPUNIT */

// FORWARD DECLARATIONS

/**
 * Common utility functions for unittests
 */
class TestUtilities
{
 public:

    /** Create a message using the arguments passed. The message is created by
    *   by appending all the arguments (which have to be of the type char*) starting
    *   off from the 3rd argument. 
    *
    *   @param 
    *   For example, if this method is called as <br>
    *       <code>createMessage(4, &msg, "Composite of ", "one ", "and two ", " as strings")</code>
    *   this would cause the variable msg to have the following string:-
    *       Composite of one and two as strings
    */
#if defined(NO_CPPUNIT)
   static void createMessage(int num,             /**< Number of char* messages that have been passed as arguments */
                             UtlString* outMsg, /**< string instance into which the generated message is written. 
                                                   *   It is the responsibility of the caller to create the string */
                             ...                  /**< variable list arguments of char* which represents the fragments
                                                   *   of the message  */
                             ) ;

#else
   static void createMessage(int num,             /**< Number of char* messages that have been passed as arguments */
                             std::string* outMsg, /**< string instance into which the generated message is written.
                                                   *   It is the responsibility of the caller to create the string */
                             ...                  /**< variable list arguments of char* which represents the fragments
                                                   *   of the message  */
                             ) ;


    /** Use macro, do not this call directly. */
    static void assertEquals(const char* expected, const char* actual, 
            CppUnit::SourceLine sourceLine, const std::string &message);

    /** Use macro, do not this call directly. */
    static bool testingKnownBug();

    /** Last known non-fatal bug messages return here, valid until next test starts */
    static const char *getKnownBugMessage();

    /** Called by unittest framework after exiting a test method */
    static void resetKnownBugTesting();

    /** 
     * Prints quotes around strings, work when w/trailing whitespaces
     *  important. Also will print NULL (no quotes) when sz is NULL.
     **/
    static std::string printString(const char* sz);

    /** Use macro, do not this call directly. */
    static void knownFatalBug(const char* message, const char* bugNo,
        CppUnit::SourceLine sourceLine);

    /** Use macro, do not this call directly. */
    static void knownBug(const char* message, const char* bugNo,
        CppUnit::SourceLine sourceLine);

    /** Use macro, do not this call directly. */
    static void knownEfenceBug(const char* message, const char* bugNo,
        CppUnit::SourceLine sourceLine);


 private:
    
    static std::string printBug(const char* message, const char *bugNo);

    static bool m_testingKnownBug;

    static char m_bugMessage[MAX_BUG_MESSAGE_LEN];

#endif /* NO_CPPUNIT */

};

#endif