# Copyright 2008, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Import('env') env = env.Clone() env.Prepend( CPPPATH = [ '../..', ], ) # Some of the sandbox sources include "gtest.h", so we need it # in the base env here, not just in env_tests. env.Append( CPPPATH = [ '$GTEST_DIR/include', ], ) env.Append( CCFLAGS = [ '/TP', '/WX', # treat warnings as errors '/Wp64', # warn about potential 64-bit problems ], ) 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() 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.exe', '../sbox_unittests.ilk', '../sbox_unittests.pdb'], 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', '$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() 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.exe', '../sbox_integration_tests.ilk', '../sbox_integration_tests.lib', '../sbox_integration_tests.exp', '../sbox_integration_tests.pdb'], 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): 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.exe', '../sbox_validation_tests.ilk', '../sbox_validation_tests.lib', '../sbox_validation_tests.exp', '../sbox_validation_tests.pdb'], validation_test_files, ) # Install tests to a path where they can find their inputs. installed_tests = env.Install('$OBJ_ROOT', unit_tests + validation_tests + integration_tests) # Setup alias for sandbox related targets. env.Alias('sandbox', ['.', installed_tests])