~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/utils/unittest/googletest/include/gtest/gtest-spi.h

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-03-12 11:30:04 UTC
  • mfrom: (0.41.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100312113004-b0fop4bkycszdd0z
Tags: 0.96~rc1+dfsg-0ubuntu1
* New upstream RC - FFE (LP: #537636):
  - Add OfficialDatabaseOnly option to clamav-base.postinst.in
  - Add LocalSocketGroup option to clamav-base.postinst.in
  - Add LocalSocketMode option to clamav-base.postinst.in
  - Add CrossFilesystems option to clamav-base.postinst.in
  - Add ClamukoScannerCount option to clamav-base.postinst.in
  - Add BytecodeSecurity opiton to clamav-base.postinst.in
  - Add DetectionStatsHostID option to clamav-freshclam.postinst.in
  - Add Bytecode option to clamav-freshclam.postinst.in
  - Add MilterSocketGroup option to clamav-milter.postinst.in
  - Add MilterSocketMode option to clamav-milter.postinst.in
  - Add ReportHostname option to clamav-milter.postinst.in
  - Bump libclamav SO version to 6.1.0 in libclamav6.install
  - Drop clamdmon from clamav.examples (no longer shipped by upstream)
  - Drop libclamav.a from libclamav-dev.install (not built by upstream)
  - Update SO version for lintian override for libclamav6
  - Add new Bytecode Testing Tool, usr/bin/clambc, to clamav.install
  - Add build-depends on python and python-setuptools for new test suite
  - Update debian/copyright for the embedded copy of llvm (using the system
    llvm is not currently feasible)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2007, Google Inc.
 
2
// All rights reserved.
 
3
//
 
4
// Redistribution and use in source and binary forms, with or without
 
5
// modification, are permitted provided that the following conditions are
 
6
// met:
 
7
//
 
8
//     * Redistributions of source code must retain the above copyright
 
9
// notice, this list of conditions and the following disclaimer.
 
10
//     * Redistributions in binary form must reproduce the above
 
11
// copyright notice, this list of conditions and the following disclaimer
 
12
// in the documentation and/or other materials provided with the
 
13
// distribution.
 
14
//     * Neither the name of Google Inc. nor the names of its
 
15
// contributors may be used to endorse or promote products derived from
 
16
// this software without specific prior written permission.
 
17
//
 
18
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 
19
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 
20
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 
21
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 
22
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 
23
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 
24
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 
25
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 
26
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
27
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
28
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
29
//
 
30
// Author: wan@google.com (Zhanyong Wan)
 
31
//
 
32
// Utilities for testing Google Test itself and code that uses Google Test
 
33
// (e.g. frameworks built on top of Google Test).
 
34
 
 
35
#ifndef GTEST_INCLUDE_GTEST_GTEST_SPI_H_
 
36
#define GTEST_INCLUDE_GTEST_GTEST_SPI_H_
 
37
 
 
38
#include <gtest/gtest.h>
 
39
 
 
40
namespace testing {
 
41
 
 
42
// This helper class can be used to mock out Google Test failure reporting
 
43
// so that we can test Google Test or code that builds on Google Test.
 
44
//
 
45
// An object of this class appends a TestPartResult object to the
 
46
// TestPartResultArray object given in the constructor whenever a Google Test
 
47
// failure is reported. It can either intercept only failures that are
 
48
// generated in the same thread that created this object or it can intercept
 
49
// all generated failures. The scope of this mock object can be controlled with
 
50
// the second argument to the two arguments constructor.
 
51
class ScopedFakeTestPartResultReporter
 
52
    : public TestPartResultReporterInterface {
 
53
 public:
 
54
  // The two possible mocking modes of this object.
 
55
  enum InterceptMode {
 
56
    INTERCEPT_ONLY_CURRENT_THREAD,  // Intercepts only thread local failures.
 
57
    INTERCEPT_ALL_THREADS           // Intercepts all failures.
 
58
  };
 
59
 
 
60
  // The c'tor sets this object as the test part result reporter used
 
61
  // by Google Test.  The 'result' parameter specifies where to report the
 
62
  // results. This reporter will only catch failures generated in the current
 
63
  // thread. DEPRECATED
 
64
  explicit ScopedFakeTestPartResultReporter(TestPartResultArray* result);
 
65
 
 
66
  // Same as above, but you can choose the interception scope of this object.
 
67
  ScopedFakeTestPartResultReporter(InterceptMode intercept_mode,
 
68
                                   TestPartResultArray* result);
 
69
 
 
70
  // The d'tor restores the previous test part result reporter.
 
71
  virtual ~ScopedFakeTestPartResultReporter();
 
72
 
 
73
  // Appends the TestPartResult object to the TestPartResultArray
 
74
  // received in the constructor.
 
75
  //
 
76
  // This method is from the TestPartResultReporterInterface
 
77
  // interface.
 
78
  virtual void ReportTestPartResult(const TestPartResult& result);
 
79
 private:
 
80
  void Init();
 
81
 
 
82
  const InterceptMode intercept_mode_;
 
83
  TestPartResultReporterInterface* old_reporter_;
 
84
  TestPartResultArray* const result_;
 
85
 
 
86
  GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedFakeTestPartResultReporter);
 
87
};
 
88
 
 
89
namespace internal {
 
90
 
 
91
// A helper class for implementing EXPECT_FATAL_FAILURE() and
 
92
// EXPECT_NONFATAL_FAILURE().  Its destructor verifies that the given
 
93
// TestPartResultArray contains exactly one failure that has the given
 
94
// type and contains the given substring.  If that's not the case, a
 
95
// non-fatal failure will be generated.
 
96
class SingleFailureChecker {
 
97
 public:
 
98
  // The constructor remembers the arguments.
 
99
  SingleFailureChecker(const TestPartResultArray* results,
 
100
                       TestPartResultType type,
 
101
                       const char* substr);
 
102
  ~SingleFailureChecker();
 
103
 private:
 
104
  const TestPartResultArray* const results_;
 
105
  const TestPartResultType type_;
 
106
  const String substr_;
 
107
 
 
108
  GTEST_DISALLOW_COPY_AND_ASSIGN_(SingleFailureChecker);
 
109
};
 
110
 
 
111
}  // namespace internal
 
112
 
 
113
}  // namespace testing
 
114
 
 
115
// A set of macros for testing Google Test assertions or code that's expected
 
116
// to generate Google Test fatal failures.  It verifies that the given
 
117
// statement will cause exactly one fatal Google Test failure with 'substr'
 
118
// being part of the failure message.
 
119
//
 
120
// There are two different versions of this macro. EXPECT_FATAL_FAILURE only
 
121
// affects and considers failures generated in the current thread and
 
122
// EXPECT_FATAL_FAILURE_ON_ALL_THREADS does the same but for all threads.
 
123
//
 
124
// The verification of the assertion is done correctly even when the statement
 
125
// throws an exception or aborts the current function.
 
126
//
 
127
// Known restrictions:
 
128
//   - 'statement' cannot reference local non-static variables or
 
129
//     non-static members of the current object.
 
130
//   - 'statement' cannot return a value.
 
131
//   - You cannot stream a failure message to this macro.
 
132
//
 
133
// Note that even though the implementations of the following two
 
134
// macros are much alike, we cannot refactor them to use a common
 
135
// helper macro, due to some peculiarity in how the preprocessor
 
136
// works.  The AcceptsMacroThatExpandsToUnprotectedComma test in
 
137
// gtest_unittest.cc will fail to compile if we do that.
 
138
#define EXPECT_FATAL_FAILURE(statement, substr) \
 
139
  do { \
 
140
    class GTestExpectFatalFailureHelper {\
 
141
     public:\
 
142
      static void Execute() { statement; }\
 
143
    };\
 
144
    ::testing::TestPartResultArray gtest_failures;\
 
145
    ::testing::internal::SingleFailureChecker gtest_checker(\
 
146
        &gtest_failures, ::testing::TPRT_FATAL_FAILURE, (substr));\
 
147
    {\
 
148
      ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
 
149
          ::testing::ScopedFakeTestPartResultReporter:: \
 
150
          INTERCEPT_ONLY_CURRENT_THREAD, &gtest_failures);\
 
151
      GTestExpectFatalFailureHelper::Execute();\
 
152
    }\
 
153
  } while (false)
 
154
 
 
155
#define EXPECT_FATAL_FAILURE_ON_ALL_THREADS(statement, substr) \
 
156
  do { \
 
157
    class GTestExpectFatalFailureHelper {\
 
158
     public:\
 
159
      static void Execute() { statement; }\
 
160
    };\
 
161
    ::testing::TestPartResultArray gtest_failures;\
 
162
    ::testing::internal::SingleFailureChecker gtest_checker(\
 
163
        &gtest_failures, ::testing::TPRT_FATAL_FAILURE, (substr));\
 
164
    {\
 
165
      ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
 
166
          ::testing::ScopedFakeTestPartResultReporter:: \
 
167
          INTERCEPT_ALL_THREADS, &gtest_failures);\
 
168
      GTestExpectFatalFailureHelper::Execute();\
 
169
    }\
 
170
  } while (false)
 
171
 
 
172
// A macro for testing Google Test assertions or code that's expected to
 
173
// generate Google Test non-fatal failures.  It asserts that the given
 
174
// statement will cause exactly one non-fatal Google Test failure with 'substr'
 
175
// being part of the failure message.
 
176
//
 
177
// There are two different versions of this macro. EXPECT_NONFATAL_FAILURE only
 
178
// affects and considers failures generated in the current thread and
 
179
// EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS does the same but for all threads.
 
180
//
 
181
// 'statement' is allowed to reference local variables and members of
 
182
// the current object.
 
183
//
 
184
// The verification of the assertion is done correctly even when the statement
 
185
// throws an exception or aborts the current function.
 
186
//
 
187
// Known restrictions:
 
188
//   - You cannot stream a failure message to this macro.
 
189
//
 
190
// Note that even though the implementations of the following two
 
191
// macros are much alike, we cannot refactor them to use a common
 
192
// helper macro, due to some peculiarity in how the preprocessor
 
193
// works.  The AcceptsMacroThatExpandsToUnprotectedComma test in
 
194
// gtest_unittest.cc will fail to compile if we do that.
 
195
#define EXPECT_NONFATAL_FAILURE(statement, substr) \
 
196
  do {\
 
197
    ::testing::TestPartResultArray gtest_failures;\
 
198
    ::testing::internal::SingleFailureChecker gtest_checker(\
 
199
        &gtest_failures, ::testing::TPRT_NONFATAL_FAILURE, (substr));\
 
200
    {\
 
201
      ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
 
202
          ::testing::ScopedFakeTestPartResultReporter:: \
 
203
          INTERCEPT_ONLY_CURRENT_THREAD, &gtest_failures);\
 
204
      statement;\
 
205
    }\
 
206
  } while (false)
 
207
 
 
208
#define EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(statement, substr) \
 
209
  do {\
 
210
    ::testing::TestPartResultArray gtest_failures;\
 
211
    ::testing::internal::SingleFailureChecker gtest_checker(\
 
212
        &gtest_failures, ::testing::TPRT_NONFATAL_FAILURE, (substr));\
 
213
    {\
 
214
      ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
 
215
          ::testing::ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS,\
 
216
          &gtest_failures);\
 
217
      statement;\
 
218
    }\
 
219
  } while (false)
 
220
 
 
221
#endif  // GTEST_INCLUDE_GTEST_GTEST_SPI_H_