Deleted Added
sdiff udiff text old ( 12563:8d59ed22ae79 ) new ( 12757:114f34a90feb )
full compact
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, *srcs_and_filts, **kwargs):
319 '''Specify the target name and any sources. Sources that are
320 not SourceFiles are evalued with Source().'''
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
326 srcs = SourceList()
327 for src in sources:
328 if not isinstance(src, SourceFile):
329 src = Source(src, tags=[])
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('.')
337
338class GTest(UnitTest):
339 '''Create a unit test based on the google test framework.'''
340 all = []
341 def __init__(self, *args, **kwargs):
342 super(GTest, self).__init__(*args, **kwargs)
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 = list(test.sources)
1085 for f in test.filters:
1086 test_sources += Source.all.apply_filter(f)
1087 test_objs = [ s.static(new_env) for s in test_sources ]
1088 if test.main:
1089 test_objs += main_objs
1090 new_env.Program(test.dir.File('%s.%s' % (test.target, label)),
1091 test_objs + static_objs)
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 ---