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, *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.'''
322
323 srcs = SourceList()
324 for src in sources:
325 if not isinstance(src, SourceFile):
326 src = Source(src, tags=str(target))
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)
333
334class GTest(UnitTest):
335 '''Create a unit test based on the google test framework.'''
336 all = []
337 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 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:
1084 test_sources = Source.all.with_tag(str(test.target))
1085 test_objs = [ s.static(new_env) for s in test_sources ]
1086 if test.main:
1087 test_objs += main_objs
1088 path = 'unittest/%s.%s' % (test.target, label)
1089 new_env.Program(path, 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 ---