blob: d55f1dac76a6a08cd16c01ed8ca7502d1e1618d0 (
plain)
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
|
#ifndef TESTING_GTEST_MOZILLA_HELPERS_H_
#define TESTING_GTEST_MOZILLA_HELPERS_H_
#include "gtest/gtest.h"
#include "nsCOMPtr.h"
#include "nsServiceManagerUtils.h"
#include "nsICrashReporter.h"
#if defined(DEBUG) && !defined(XP_WIN) && !defined(ANDROID)
# define HAS_GDB_SLEEP_DURATION 1
extern unsigned int _gdb_sleep_duration;
#endif
namespace mozilla::gtest {
#if defined(HAS_GDB_SLEEP_DURATION)
# define ZERO_GDB_SLEEP() _gdb_sleep_duration = 0;
# define SAVE_GDB_SLEEP(v) \
v = _gdb_sleep_duration; \
ZERO_GDB_SLEEP();
# define RESTORE_GDB_SLEEP(v) _gdb_sleep_duration = v;
// Some use needs to be in the global namespace
# define SAVE_GDB_SLEEP_GLOBAL(v) \
v = ::_gdb_sleep_duration; \
ZERO_GDB_SLEEP();
# define RESTORE_GDB_SLEEP_GLOBAL(v) ::_gdb_sleep_duration = v;
# define SAVE_GDB_SLEEP_LOCAL() \
unsigned int _old_gdb_sleep_duration; \
SAVE_GDB_SLEEP(_old_gdb_sleep_duration);
# define RESTORE_GDB_SLEEP_LOCAL() RESTORE_GDB_SLEEP(_old_gdb_sleep_duration);
#else // defined(HAS_GDB_SLEEP_DURATION)
# define ZERO_GDB_SLEEP() ;
# define SAVE_GDB_SLEEP(v)
# define SAVE_GDB_SLEEP_GLOBAL(v)
# define SAVE_GDB_SLEEP_LOCAL()
# define RESTORE_GDB_SLEEP(v)
# define RESTORE_GDB_SLEEP_GLOBAL(v)
# define RESTORE_GDB_SLEEP_LOCAL()
#endif // defined(HAS_GDB_SLEEP_DURATION)
// Death tests are too slow on OSX because of the system crash reporter.
#if !defined(XP_DARWIN)
// Wrap ASSERT_DEATH_IF_SUPPORTED to disable the crash reporter
// when entering the subprocess, so that the expected crashes don't
// create a minidump that the gtest harness will interpret as an error.
# define ASSERT_DEATH_WRAP(a, b) \
ASSERT_DEATH_IF_SUPPORTED( \
{ \
mozilla::gtest::DisableCrashReporter(); \
a; \
}, \
b)
#else
# define ASSERT_DEATH_WRAP(a, b)
#endif
void DisableCrashReporter();
} // namespace mozilla::gtest
#endif // TESTING_GTEST_MOZILLA_HELPERS_H_
|