summaryrefslogtreecommitdiffstats
path: root/sandbox/src/SConscript
blob: 961257b98920c9120b886dd6bc5b2600ed844743 (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
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

Import('env')

env = env.Clone()

# Some of the sandbox sources include "gtest.h", so we need it
# in the base env here, not just in env_tests.
env.Prepend(
    CPPPATH = [
        '$ROOT_DIR',
        '$GTEST_DIR/include',
        '$GTEST_DIR',
        '../..',
    ],
    CPPDEFINES = [
        'CHROMIUM_BUILD',
        '_SECURE_ATL',
    ],
)

env.Append(
    CCFLAGS = [
        '/TP',
        '/WX',          # treat warnings as errors
    ],
)

env.Dir('$OBJ_ROOT/sandbox/src').addRepository(env.Dir('$ROOT_DIR/sandbox'))

env_tests = env.Clone(
    TESTS_DIR = 'tests',
    INTEGRATION_TESTS_DIR = '$TESTS_DIR/integration_tests',
    UNIT_TESTS_DIR = '$TESTS_DIR/unit_tests',
    VALIDATION_TESTS_DIR = '$TESTS_DIR/validation_tests',
)


input_files = [
    'Wow64.cc',
    'acl.cc',
    'broker_services.cc',
    'crosscall_server.cc',
    'dep.cc',
    'eat_resolver.cc',
    'filesystem_dispatcher.cc',
    'filesystem_interception.cc',
    'filesystem_policy.cc',
    'interception.cc',
    'interception_agent.cc',
    'job.cc',
    'named_pipe_dispatcher.cc',
    'named_pipe_interception.cc',
    'named_pipe_policy.cc',
    'pe_image.cc',
    'policy_broker.cc',
    'policy_engine_opcodes.cc',
    'policy_engine_processor.cc',
    'policy_low_level.cc',
    'policy_target.cc',
    'process_thread_dispatcher.cc',
    'process_thread_interception.cc',
    'process_thread_policy.cc',
    'registry_dispatcher.cc',
    'registry_interception.cc',
    'registry_policy.cc',
    'resolver.cc',
    'restricted_token.cc',
    'restricted_token_utils.cc',
    'sandbox.cc',
    'sandbox_nt_util.cc',
    'sandbox_policy_base.cc',
    'sandbox_utils.cc',
    'service_resolver.cc',
    'shared_handles.cc',
    'sharedmem_ipc_client.cc',
    'sharedmem_ipc_server.cc',
    'sid.cc',
    'sidestep/ia32_modrm_map.cpp',
    'sidestep/ia32_opcode_map.cpp',
    'sidestep/mini_disassembler.cpp',
    'sidestep/preamble_patcher_with_stub.cpp',
    'sidestep_resolver.cc',
    'sync_dispatcher.cc',
    'sync_interception.cc',
    'sync_policy.cc',
    'target_interceptions.cc',
    'target_process.cc',
    'target_services.cc',
    'win2k_threadpool.cc',
    'win_utils.cc',
]

# TODO(bradnelson): This step generates sandbox.pch.ib_tag
#                   SCons doesn't know.
env_p = env.Clone()
env_p.Append(CCFLAGS='/Ylsandbox')
pch, obj = env_p.PCH(['sandbox.pch', 'stdafx.obj'], 'stdafx.cc')
env['PCH'] = pch
env['PCHSTOP'] = 'stdafx.h'
env.Append(CCPCHFLAGS = ['/FIstdafx.h'])


env.ChromeStaticLibrary('sandbox', input_files + [obj])


env_tests.Prepend(
    LINKFLAGS = [
        '/DELAYLOAD:dwmapi.dll',
        '/DELAYLOAD:uxtheme.dll',
        '/MACHINE:X86',
        '/FIXED:No',
        '/safeseh',
        '/dynamicbase',
        '/ignore:4199',
        '/nxcompat',
    ],
    LIBS = [
        'base',
        'gtest',
        'sandbox',
    ],
    LIBPATH = [
        '.',
        '$BASE_DIR'
    ],
)

controller_obj = env_tests.StaticObject('$TESTS_DIR/common/controller.cc')


# Unit Tests

env_unit_tests = env_tests.Clone()

unit_test_files = [
    'interception_unittest.cc',
    'ipc_unittest.cc',
    'job_unittest.cc',
    'pe_image_unittest.cc',
    'policy_engine_unittest.cc',
    'policy_low_level_unittest.cc',
    'policy_opcodes_unittest.cc',
    'restricted_token_unittest.cc',
    'service_resolver_unittest.cc',
    'sid_unittest.cc',
    'threadpool_unittest.cc',

    '$UNIT_TESTS_DIR/unit_tests$OBJSUFFIX',
    # The VisualStudio build link with the old gtest.obj file directly,
    # although we no longer remember why.  Since we're linking with all
    # of gtest.lib now, this shouldn't be necessary (hey, the unit tests
    # all pass!), but we're leaving this here, commented out, just in case.
    #'$GTEST_DIR/src/gtest$OBJSUFFIX',
    controller_obj,
]


# TODO(bradnelson): This step generates unittests_tests.pch.ib_tag
#                   SCons doesn't know.
env_p = env_unit_tests.Clone()
# TODO(bradnelson): Make this automatic.
env_p['COMPONENT_PLATFORM_SETUP'](env_p, 'ComponentTestProgram')
pch, obj = env_p.PCH(['$UNIT_TESTS_DIR/unit_tests.pch',
                      '$UNIT_TESTS_DIR/unit_tests.obj'],
                     '$UNIT_TESTS_DIR/unit_tests.cc')
env_unit_tests['PCH'] = pch
env_unit_tests['PCHSTOP'] = 'stdafx.h'
env_unit_tests.Append(CCPCHFLAGS = ['/FIstdafx.h'])


unit_tests = env_unit_tests.ChromeTestProgram(
    'sbox_unittests',
    unit_test_files,
)

# Integration Tests

env_integration_tests = env_tests.Clone()

integration_test_files = [
    '$INTEGRATION_TESTS_DIR/integration_tests_test.cc',
#    'dep_test.cc',
    'file_policy_test.cc',
    'integrity_level_test.cc',
    'ipc_ping_test.cc',
    'named_pipe_policy_test.cc',
    'policy_target_test.cc',
    'process_policy_test.cc',
    'registry_policy_test.cc',
    'sync_policy_test.cc',
    'unload_dll_test.cc',

    '$INTEGRATION_TESTS_DIR/integration_tests$OBJSUFFIX',
    # The VisualStudio build link with the old gtest.obj file directly,
    # although we no longer remember why.  Since we're linking with all
    # of gtest.lib now, this shouldn't be necessary (hey, the unit tests
    # all pass!), but we're leaving this here, commented out, just in case.
    #'$GTEST_DIR/src/gtest$OBJSUFFIX',
    controller_obj,
]


# TODO(bradnelson): This step generates integration_tests.pch.ib_tag
#                   SCons doesn't know.
env_p = env_integration_tests.Clone()
# TODO(bradnelson): Make this automatic.
env_p['COMPONENT_PLATFORM_SETUP'](env_p, 'ComponentTestProgram')
pch, obj = env_p.PCH(['$INTEGRATION_TESTS_DIR/integration_tests.pch',
                      '$INTEGRATION_TESTS_DIR/integration_tests.obj'],
                     '$INTEGRATION_TESTS_DIR/integration_tests.cc')
env_integration_tests['PCH'] = pch
env_integration_tests['PCHSTOP'] = 'stdafx.h'
env_integration_tests.Append(CCPCHFLAGS = ['/FIstdafx.h'])

integration_tests = env_integration_tests.ChromeTestProgram(
    'sbox_integration_tests',
    integration_test_files,
)


# Validation Tests #

env_validation_tests = env_tests.Clone()

env_validation_tests.Prepend(LIBS=['shlwapi.lib'])

validation_test_files = [
    '$VALIDATION_TESTS_DIR/suite.cc',
    '$VALIDATION_TESTS_DIR/commands.cc',
    '$VALIDATION_TESTS_DIR/unit_tests$OBJSUFFIX',
    # The VisualStudio build link with the old gtest.obj file directly,
    # although we no longer remember why.  Since we're linking with all
    # of gtest.lib now, this shouldn't be necessary (hey, the unit tests
    # all pass!), but we're leaving this here, commented out, just in case.
    #'$GTEST_DIR/src/gtest$OBJSUFFIX',
    controller_obj,
]

env_p = env_validation_tests.Clone()
# TODO(bradnelson): Make this automatic.
env_p['COMPONENT_PLATFORM_SETUP'](env_p, 'ComponentTestProgram')
# TODO(bradnelson): This step generates unittests_tests.pch.ib_tag
#                   SCons doesn't know.
pch, obj = env_p.PCH(['$VALIDATION_TESTS_DIR/unit_tests.pch',
                      '$VALIDATION_TESTS_DIR/unit_tests.obj'],
                     '$VALIDATION_TESTS_DIR/unit_tests.cc')
env_validation_tests['PCH'] = pch
env_validation_tests['PCHSTOP'] = 'stdafx.h'
env_validation_tests.Append(CCPCHFLAGS = ['/FIstdafx.h'])

validation_tests = env_validation_tests.ChromeTestProgram(
    'sbox_validation_tests',
    validation_test_files,
)


# Install tests to where the buildbot expects them for now.
installed_tests = env.Install('$MAIN_DIR/Hammer',
    unit_tests + validation_tests + integration_tests)


# Setup alias for sandbox related targets.
env.Alias('sandbox', ['.', installed_tests])