SConscript (12563:8d59ed22ae79) SConscript (12757:114f34a90feb)
1# -*- mode:python -*-
2
3# Copyright (c) 2004-2005 The Regents of The University of Michigan
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are
8# met: redistributions of source code must retain the above copyright

--- 301 unchanged lines hidden (view full) ---

310 # only need to track the source and header.
311 self.cc_file = File(modname + '.pb.cc')
312 self.hh_file = File(modname + '.pb.h')
313
314class UnitTest(object):
315 '''Create a UnitTest'''
316
317 all = []
1# -*- mode:python -*-
2
3# Copyright (c) 2004-2005 The Regents of The University of Michigan
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are
8# met: redistributions of source code must retain the above copyright

--- 301 unchanged lines hidden (view full) ---

310 # only need to track the source and header.
311 self.cc_file = File(modname + '.pb.cc')
312 self.hh_file = File(modname + '.pb.h')
313
314class UnitTest(object):
315 '''Create a UnitTest'''
316
317 all = []
318 def __init__(self, target, *sources, **kwargs):
319 '''Specify the target name and any sources. Sources that are
320 not SourceFiles are evalued with Source(). All files are
321 tagged with the name of the UnitTest target.'''
318 def __init__(self, target, *srcs_and_filts, **kwargs):
319 '''Specify the target name and any sources. Sources that are
320 not SourceFiles are evalued with Source().'''
322
321
322 isFilter = lambda arg: isinstance(arg, SourceFilter)
323 self.filters = filter(isFilter, srcs_and_filts)
324 sources = filter(lambda a: not isFilter(a), srcs_and_filts)
325
323 srcs = SourceList()
324 for src in sources:
325 if not isinstance(src, SourceFile):
326 srcs = SourceList()
327 for src in sources:
328 if not isinstance(src, SourceFile):
326 src = Source(src, tags=str(target))
329 src = Source(src, tags=[])
327 srcs.append(src)
328
329 self.sources = srcs
330 self.target = target
331 self.main = kwargs.get('main', False)
332 self.all.append(self)
330 srcs.append(src)
331
332 self.sources = srcs
333 self.target = target
334 self.main = kwargs.get('main', False)
335 self.all.append(self)
336 self.dir = Dir('.')
333
334class GTest(UnitTest):
335 '''Create a unit test based on the google test framework.'''
336 all = []
337 def __init__(self, *args, **kwargs):
337
338class GTest(UnitTest):
339 '''Create a unit test based on the google test framework.'''
340 all = []
341 def __init__(self, *args, **kwargs):
338 isFilter = lambda arg: isinstance(arg, SourceFilter)
339 self.filters = filter(isFilter, args)
340 args = filter(lambda a: not isFilter(a), args)
341 super(GTest, self).__init__(*args, **kwargs)
342 super(GTest, self).__init__(*args, **kwargs)
342 self.dir = Dir('.')
343 self.skip_lib = kwargs.pop('skip_lib', False)
344
345# Children should have access
346Export('Source')
347Export('PySource')
348Export('SimObject')
349Export('ProtoBuf')
350Export('UnitTest')

--- 725 unchanged lines hidden (view full) ---

1076 # link against m5.
1077 static_lib = new_env.StaticLibrary(libname, static_objs)
1078 shared_lib = new_env.SharedLibrary(libname, shared_objs)
1079
1080 # Now link a stub with main() and the static library.
1081 main_objs = [ s.static(new_env) for s in Source.all.with_tag('main') ]
1082
1083 for test in UnitTest.all:
343 self.skip_lib = kwargs.pop('skip_lib', False)
344
345# Children should have access
346Export('Source')
347Export('PySource')
348Export('SimObject')
349Export('ProtoBuf')
350Export('UnitTest')

--- 725 unchanged lines hidden (view full) ---

1076 # link against m5.
1077 static_lib = new_env.StaticLibrary(libname, static_objs)
1078 shared_lib = new_env.SharedLibrary(libname, shared_objs)
1079
1080 # Now link a stub with main() and the static library.
1081 main_objs = [ s.static(new_env) for s in Source.all.with_tag('main') ]
1082
1083 for test in UnitTest.all:
1084 test_sources = Source.all.with_tag(str(test.target))
1084 test_sources = list(test.sources)
1085 for f in test.filters:
1086 test_sources += Source.all.apply_filter(f)
1085 test_objs = [ s.static(new_env) for s in test_sources ]
1086 if test.main:
1087 test_objs += main_objs
1087 test_objs = [ s.static(new_env) for s in test_sources ]
1088 if test.main:
1089 test_objs += main_objs
1088 path = 'unittest/%s.%s' % (test.target, label)
1089 new_env.Program(path, test_objs + static_objs)
1090 new_env.Program(test.dir.File('%s.%s' % (test.target, label)),
1091 test_objs + static_objs)
1090
1091 gtest_env = new_env.Clone()
1092 gtest_env.Append(LIBS=gtest_env['GTEST_LIBS'])
1093 gtest_env.Append(CPPFLAGS=gtest_env['GTEST_CPPFLAGS'])
1094 gtestlib_sources = Source.all.with_tag('gtest lib')
1095 gtest_out_dir = Dir(new_env['BUILDDIR']).Dir('unittests.%s' % label)
1096 for test in GTest.all:
1097 test_sources = list(test.sources)

--- 138 unchanged lines hidden ---
1092
1093 gtest_env = new_env.Clone()
1094 gtest_env.Append(LIBS=gtest_env['GTEST_LIBS'])
1095 gtest_env.Append(CPPFLAGS=gtest_env['GTEST_CPPFLAGS'])
1096 gtestlib_sources = Source.all.with_tag('gtest lib')
1097 gtest_out_dir = Dir(new_env['BUILDDIR']).Dir('unittests.%s' % label)
1098 for test in GTest.all:
1099 test_sources = list(test.sources)

--- 138 unchanged lines hidden ---