def RunUnitTest(env, target, source, timeout = 60): if env['ENV'].has_key('BUILD_ONLY'): return import subprocess test = str(source[0].abspath) logfile = open(target[0].abspath, 'w') # env['_venv'] = {target: venv} tgt = target[0].name if '_venv' in env and tgt in env['_venv'] and env['_venv'][tgt]: cmd = ['/bin/bash', '-c', 'source %s/bin/activate && %s' % ( env[env['_venv'][tgt]]._path, test)] else: cmd = [test] ShEnv = {env['ENV_SHLIB_PATH']: 'build/lib', 'DB_ITERATION_TO_YIELD': '1', 'PATH': os.environ['PATH'], 'USER': os.environ['USER']} heap_check = True try: # Skip HEAPCHECK in CentOS 6.4 subprocess.check_call("grep -q \"CentOS release 6.4\" /etc/issue 2>/dev/null", shell=True) heap_check = False except: pass if heap_check or env['ENV'].has_key('HEAPCHECK'): ShEnv['HEAPCHECK'] = 'normal' ShEnv['PPROF'] = 'build/bin/pprof' proc = subprocess.Popen(cmd, stdout=logfile, stderr=logfile, env=ShEnv) # 60 second timeout for i in range(timeout): code = proc.poll() if not code is None: break time.sleep(1) if code is None: proc.kill() logfile.write('[ TIMEOUT ] ') print test + '\033[91m' + " TIMEOUT" + '\033[0m' return if code == 0: print test + '\033[94m' + " PASS" + '\033[0m' else: logfile.write('[ FAILED ] ') if code < 0: logfile.write('Terminated by signal: ' + str(-code) + '\n') else: logfile.write('Program returned ' + str(code) + '\n') print test + '\033[91m' + " FAIL" + '\033[0m' raise convert_to_BuildError(code)
def CheckBuildConfiguration(conf): # gcc 4.7.0 generates buggy code when optimization is turned on. opt_level = GetOption('opt') if ((opt_level == 'production' or opt_level == 'profile') and \ (conf.env['CC'].endswith("gcc") or conf.env['CC'].endswith("g++"))): if commands.getoutput(conf.env['CC'] + ' -dumpversion') == "4.7.0": print "Unsupported/Buggy compiler gcc 4.7.0 for building " + \ "optimized binaries" raise convert_to_BuildError(1) return conf.Finish()
def CheckBuildConfiguration(conf): # gcc 4.7.0 generates buggy code when optimization is turned on. opt_level = GetOption("opt") if (opt_level == "production" or opt_level == "profile") and ( conf.env["CC"].endswith("gcc") or conf.env["CC"].endswith("g++") ): if commands.getoutput(conf.env["CC"] + " -dumpversion") == "4.7.0": print "Unsupported/Buggy compiler gcc 4.7.0 for building " + "optimized binaries" raise convert_to_BuildError(1) return conf.Finish()
def RunUnitTest(env, target, source, timeout=60): if env['ENV'].has_key('BUILD_ONLY'): return import subprocess test = str(source[0].abspath) logfile = open(target[0].abspath, 'w') # env['_venv'] = {target: venv} tgt = target[0].name if '_venv' in env and tgt in env['_venv'] and env['_venv'][tgt]: cmd = [ '/bin/bash', '-c', 'source %s/bin/activate && %s' % (env[env['_venv'][tgt]]._path, test) ] else: cmd = [test] ShEnv = { env['ENV_SHLIB_PATH']: 'build/lib', 'DB_ITERATION_TO_YIELD': '1', 'PATH': os.environ['PATH'], 'USER': os.environ['USER'], 'TOP_OBJECT_PATH': env['TOP'][1:] } heap_check = True try: # Skip HEAPCHECK in CentOS 6.4 subprocess.check_call( "grep -q \"CentOS release 6.4\" /etc/issue 2>/dev/null", shell=True) heap_check = False except: pass if heap_check or env['ENV'].has_key('HEAPCHECK'): ShEnv['HEAPCHECK'] = 'normal' ShEnv['PPROF_PATH'] = 'build/bin/pprof' # Fix for frequent crash in gperftools ListerThread during exit # https://code.google.com/p/gperftools/issues/detail?id=497 ShEnv['LD_BIND_NOW'] = '1' proc = subprocess.Popen(cmd, stdout=logfile, stderr=logfile, env=ShEnv) # 60 second timeout for i in range(timeout): code = proc.poll() if not code is None: break time.sleep(1) if code is None: proc.kill() logfile.write('[ TIMEOUT ] ') print test + '\033[91m' + " TIMEOUT" + '\033[0m' return if code == 0: print test + '\033[94m' + " PASS" + '\033[0m' else: logfile.write('[ FAILED ] ') if code < 0: logfile.write('Terminated by signal: ' + str(-code) + '\n') else: logfile.write('Program returned ' + str(code) + '\n') print test + '\033[91m' + " FAIL" + '\033[0m' raise convert_to_BuildError(code)
def RunUnitTest(env, target, source, timeout = 300): if env['ENV'].has_key('BUILD_ONLY'): return import subprocess if env['ENV'].has_key('CONTRAIL_UT_TEST_TIMEOUT'): timeout = int(env['ENV']['CONTRAIL_UT_TEST_TIMEOUT']) test = str(source[0].abspath) logfile = open(target[0].abspath, 'w') # env['_venv'] = {target: venv} tgt = target[0].name if '_venv' in env and tgt in env['_venv'] and env['_venv'][tgt]: cmd = ['/bin/bash', '-c', 'source %s/bin/activate && %s' % ( env[env['_venv'][tgt]]._path, test)] elif env.get('OPT') == 'valgrind': cmd = ['valgrind', '--track-origins=yes', '--num-callers=50', '--show-possibly-lost=no', '--leak-check=full', '--error-limit=no', test] else: cmd = [test] ShEnv = env['ENV'].copy() ShEnv.update({env['ENV_SHLIB_PATH']: 'build/lib', 'DB_ITERATION_TO_YIELD': '1', 'TOP_OBJECT_PATH': env['TOP'][1:]}) ShEnv.update(GetTestEnvironment(test)) # Use gprof unless NO_HEAPCHECK is set or in CentOS heap_check = ShEnv.has_key('NO_HEAPCHECK') == False if heap_check: try: # Skip HEAPCHECK in CentOS 6.4 subprocess.check_call("grep -q \"CentOS release 6.4\" /etc/issue 2>/dev/null", shell=True) heap_check = False except: pass if heap_check: ShEnv['HEAPCHECK'] = 'normal' ShEnv['PPROF_PATH'] = 'build/bin/pprof' # Fix for frequent crash in gperftools ListerThread during exit # https://code.google.com/p/gperftools/issues/detail?id=497 ShEnv['LD_BIND_NOW'] = '1' proc = subprocess.Popen(cmd, stdout=logfile, stderr=logfile, env=ShEnv) # 60 second timeout for i in range(timeout): code = proc.poll() if not code is None: break time.sleep(1) if code is None: proc.kill() logfile.write('[ TIMEOUT ] ') print test + '\033[91m' + " TIMEOUT" + '\033[0m' raise convert_to_BuildError(code) return if code == 0: print test + '\033[94m' + " PASS" + '\033[0m' else: logfile.write('[ FAILED ] ') if code < 0: logfile.write('Terminated by signal: ' + str(-code) + '\n') else: logfile.write('Program returned ' + str(code) + '\n') print test + '\033[91m' + " FAIL" + '\033[0m' raise convert_to_BuildError(code)
def RunUnitTest(env, target, source, timeout=300): if env['ENV'].has_key('BUILD_ONLY'): return import subprocess if env['ENV'].has_key('CONTRAIL_UT_TEST_TIMEOUT'): timeout = int(env['ENV']['CONTRAIL_UT_TEST_TIMEOUT']) test = str(source[0].abspath) logfile = open(target[0].abspath, 'w') # env['_venv'] = {target: venv} tgt = target[0].name if '_venv' in env and tgt in env['_venv'] and env['_venv'][tgt]: cmd = [ '/bin/bash', '-c', 'source %s/bin/activate && %s' % (env[env['_venv'][tgt]]._path, test) ] elif env.get('OPT') == 'valgrind': cmd = [ 'valgrind', '--track-origins=yes', '--num-callers=50', '--show-possibly-lost=no', '--leak-check=full', '--error-limit=no', test ] else: cmd = [test] ShEnv = env['ENV'].copy() ShEnv.update({ env['ENV_SHLIB_PATH']: 'build/lib', 'DB_ITERATION_TO_YIELD': '1', 'TOP_OBJECT_PATH': env['TOP'][1:] }) ShEnv.update(GetTestEnvironment(test)) # Use gprof unless NO_HEAPCHECK is set or in CentOS heap_check = ShEnv.has_key('NO_HEAPCHECK') == False if heap_check: try: # Skip HEAPCHECK in CentOS 6.4 subprocess.check_call( "grep -q \"CentOS release 6.4\" /etc/issue 2>/dev/null", shell=True) heap_check = False except: pass if heap_check: ShEnv['HEAPCHECK'] = 'normal' ShEnv['PPROF_PATH'] = 'build/bin/pprof' # Fix for frequent crash in gperftools ListerThread during exit # https://code.google.com/p/gperftools/issues/detail?id=497 ShEnv['LD_BIND_NOW'] = '1' if 'CONCURRENCY_CHECK_ENABLE' not in ShEnv: ShEnv['CONCURRENCY_CHECK_ENABLE'] = 'true' proc = subprocess.Popen(cmd, stdout=logfile, stderr=logfile, env=ShEnv) # 60 second timeout for i in range(timeout): code = proc.poll() if not code is None: break time.sleep(1) if code is None: proc.kill() logfile.write('[ TIMEOUT ] ') print test + '\033[91m' + " TIMEOUT" + '\033[0m' raise convert_to_BuildError(code) return if code == 0: print test + '\033[94m' + " PASS" + '\033[0m' else: logfile.write('[ FAILED ] ') if code < 0: logfile.write('Terminated by signal: ' + str(-code) + '\n') else: logfile.write('Program returned ' + str(code) + '\n') print test + '\033[91m' + " FAIL" + '\033[0m' raise convert_to_BuildError(code)
def RunUnitTest(env, target, source, timeout=60): if env["ENV"].has_key("BUILD_ONLY"): return import subprocess test = str(source[0].abspath) logfile = open(target[0].abspath, "w") # env['_venv'] = {target: venv} tgt = target[0].name if "_venv" in env and tgt in env["_venv"] and env["_venv"][tgt]: cmd = ["/bin/bash", "-c", "source %s/bin/activate && %s" % (env[env["_venv"][tgt]]._path, test)] else: cmd = [test] ShEnv = { env["ENV_SHLIB_PATH"]: "build/lib", "DB_ITERATION_TO_YIELD": "1", "PATH": os.environ["PATH"], "USER": os.environ["USER"], "TOP_OBJECT_PATH": env["TOP"][1:], } heap_check = True try: # Skip HEAPCHECK in CentOS 6.4 subprocess.check_call('grep -q "CentOS release 6.4" /etc/issue 2>/dev/null', shell=True) heap_check = False except: pass if heap_check or env["ENV"].has_key("HEAPCHECK"): ShEnv["HEAPCHECK"] = "normal" ShEnv["PPROF_PATH"] = "build/bin/pprof" # Fix for frequent crash in gperftools ListerThread during exit # https://code.google.com/p/gperftools/issues/detail?id=497 ShEnv["LD_BIND_NOW"] = "1" proc = subprocess.Popen(cmd, stdout=logfile, stderr=logfile, env=ShEnv) # 60 second timeout for i in range(timeout): code = proc.poll() if not code is None: break time.sleep(1) if code is None: proc.kill() logfile.write("[ TIMEOUT ] ") print test + "\033[91m" + " TIMEOUT" + "\033[0m" return if code == 0: print test + "\033[94m" + " PASS" + "\033[0m" else: logfile.write("[ FAILED ] ") if code < 0: logfile.write("Terminated by signal: " + str(-code) + "\n") else: logfile.write("Program returned " + str(code) + "\n") print test + "\033[91m" + " FAIL" + "\033[0m" raise convert_to_BuildError(code)