1 : // Copyright 2015 Google Inc. All Rights Reserved.
2 : //
3 : // Licensed under the Apache License, Version 2.0 (the "License");
4 : // you may not use this file except in compliance with the License.
5 : // You may obtain a copy of the License at
6 : //
7 : // http://www.apache.org/licenses/LICENSE-2.0
8 : //
9 : // Unless required by applicable law or agreed to in writing, software
10 : // distributed under the License is distributed on an "AS IS" BASIS,
11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : // See the License for the specific language governing permissions and
13 : // limitations under the License.
14 : //
15 : // Contains utilities for early aborting tests that should only run in one
16 : // memory model: Large Address Aware or otherwise.
17 :
18 : #ifndef SYZYGY_TESTING_LAA_H_
19 : #define SYZYGY_TESTING_LAA_H_
20 :
21 m : namespace testing {
22 :
23 : // Returns the size of the memory model of the current process, in GB.
24 : // Returns 2 (for non-LAA processes), or 4 (for LAA processes).
25 m : size_t GetAddressSpaceSize();
26 :
27 : // Returns true if the test should be skipped because it only supports
28 : // the given address space size.
29 m : bool ShouldSkipTest(size_t required_address_space_size);
30 :
31 : // Macros to be used to early exit a test that should only run in a 2GB/4GB
32 : // memory model. This is meant to be used as the first line in a test body,
33 : // and/or in the SetUp and TearDown functions of a fixture.
34 : #define TEST_ONLY_SUPPORTS_2G() \
35 m : if (::testing::ShouldSkipTest(2)) \
36 m : return;
37 : #define TEST_ONLY_SUPPORTS_4G() \
38 m : if (::testing::ShouldSkipTest(4)) \
39 m : return;
40 :
41 : // Macros to be used in declaring tests that only run in certain memory models.
42 : #define TEST_2G(test_case_name, test_name) \
43 m : TEST(test_case_name, test_name ## _2G)
44 : #define TEST_F_2G(test_case_name, test_name) \
45 m : TEST_F(test_case_name, test_name ## _2G)
46 : #define TEST_4G(test_case_name, test_name) \
47 m : TEST(test_case_name, test_name ## _4G)
48 : #define TEST_F_4G(test_case_name, test_name) \
49 m : TEST_F(test_case_name, test_name ## _4G)
50 :
51 m : } // namespace testing
52 :
53 : #endif // SYZYGY_TESTING_LAA_H_
|