def assertSaneJsBinary(cacheF): ''' If the cache folder is present, check that the js binary is working properly. ''' if os.path.isdir(cacheF): fList = os.listdir(cacheF) if 'build' in fList: if INCOMPLETE_NOTE in fList: print cacheF + ' has subdirectories: ' + str(fList) raise Exception( 'Downloaded binaries and incompleteBuild.txt should not both be ' + 'present together in this directory.') assert os.path.isdir( sps.normExpUserPath(os.path.join(cacheF, 'build', 'download'))) assert os.path.isdir( sps.normExpUserPath(os.path.join(cacheF, 'build', 'dist'))) assert os.path.isfile( sps.normExpUserPath( os.path.join(cacheF, 'build', 'dist', 'js' + ('.exe' if sps.isWin else '')))) try: shellPath = getTboxJsBinPath(cacheF) # Ensure we don't fail because the shell lacks u+x if not os.access(shellPath, os.X_OK): os.chmod(shellPath, stat.S_IXUSR) # tbpl binaries are always: # * run without Valgrind (they are not compiled with --enable-valgrind) retCode = inspectShell.testBinary(shellPath, ['-e', '42'], False)[1] # Exit code -1073741515 on Windows shows up when a required DLL is not present. # This was testable at the time of writing, see bug 953314. isDllNotPresentWinStartupError = (sps.isWin and retCode == -1073741515) # We should have another condition here for non-Windows platforms but we do not yet # have a situation where we can test broken treeherder js shells on those platforms. if isDllNotPresentWinStartupError: raise Exception( 'Shell startup error - a .dll file is probably not present.' ) elif retCode != 0: raise Exception('Non-zero return code: ' + str(retCode)) return True # Binary is working correctly except (OSError, IOError): raise Exception('Cache folder ' + cacheF + ' is corrupt, please delete it ' + 'and try again.') elif INCOMPLETE_NOTE in fList: return True else: raise Exception( 'Neither build/ nor INCOMPLETE_NOTE were found in the cache folder.' ) else: raise Exception('Cache folder ' + cacheF + ' is not found.')
def inner(shellFilename, _hgHash): (stdoutStderr, exitCode) = inspectShell.testBinary(shellFilename, options.paramList, options.buildOptions.runWithVg) if (stdoutStderr.find(options.output) != -1) and (options.output != ''): return ('bad', 'Specified-bad output') elif options.watchExitCode is not None and exitCode == options.watchExitCode: return ('bad', 'Specified-bad exit code ' + str(exitCode)) elif options.watchExitCode is None and 129 <= exitCode <= 159: return ('bad', 'High exit code ' + str(exitCode)) elif exitCode < 0: # On Unix-based systems, the exit code for signals is negative, so we check if # 128 + abs(exitCode) meets our specified signal exit code. if options.watchExitCode is not None and 128 - exitCode == options.watchExitCode: return ( "bad", "Specified-bad exit code %s (after converting to signal)" % exitCode) elif (stdoutStderr.find(options.output) == -1) and (options.output != ''): return ('good', 'Bad output, but not the specified one') elif options.watchExitCode is not None and 128 - exitCode != options.watchExitCode: return ('good', 'Negative exit code, but not the specified one') return ('bad', 'Negative exit code ' + str(exitCode)) elif exitCode == 0: return ('good', 'Exit code 0') elif (exitCode == 1 or exitCode == 2) and (options.output != '') and \ (stdoutStderr.find('usage: js [') != -1 or stdoutStderr.find('Error: Short option followed by junk') != -1 or stdoutStderr.find('Error: Invalid long option:') != -1 or stdoutStderr.find('Error: Invalid short option:') != -1): return ( "good", "Exit code 1 or 2 - js shell quits because it does not support a given CLI parameter" ) elif 3 <= exitCode <= 6: return ('good', 'Acceptable exit code ' + str(exitCode)) elif options.watchExitCode is not None: return ('good', 'Unknown exit code ' + str(exitCode) + ', but not the specified one') return ('bad', 'Unknown exit code ' + str(exitCode))
def assertSaneJsBinary(cacheF): ''' If the cache folder is present, check that the js binary is working properly. ''' if os.path.isdir(cacheF): fList = os.listdir(cacheF) if 'build' in fList: if INCOMPLETE_NOTE in fList: print cacheF + ' has subdirectories: ' + str(fList) raise Exception('Downloaded binaries and incompleteBuild.txt should not both be ' + 'present together in this directory.') assert os.path.isdir(sps.normExpUserPath(os.path.join(cacheF, 'build', 'download'))) assert os.path.isdir(sps.normExpUserPath(os.path.join(cacheF, 'build', 'dist'))) assert os.path.isfile(sps.normExpUserPath(os.path.join(cacheF, 'build', 'dist', 'js' + ('.exe' if sps.isWin else '')))) try: shellPath = getTboxJsBinPath(cacheF) # Ensure we don't fail because the shell lacks u+x if not os.access(shellPath, os.X_OK): os.chmod(shellPath, stat.S_IXUSR) # tbpl binaries are always: # * run without Valgrind (they are not compiled with --enable-valgrind) retCode = inspectShell.testBinary(shellPath, ['-e', '42'], False)[1] # Exit code -1073741515 on Windows shows up when a required DLL is not present. # This was testable at the time of writing, see bug 953314. isDllNotPresentWinStartupError = (sps.isWin and retCode == -1073741515) # We should have another condition here for non-Windows platforms but we do not yet # have a situation where we can test broken treeherder js shells on those platforms. if isDllNotPresentWinStartupError: raise Exception('Shell startup error - a .dll file is probably not present.') elif retCode != 0: raise Exception('Non-zero return code: ' + str(retCode)) return True # Binary is working correctly except (OSError, IOError): raise Exception('Cache folder ' + cacheF + ' is corrupt, please delete it ' + 'and try again.') elif INCOMPLETE_NOTE in fList: return True else: raise Exception('Neither build/ nor INCOMPLETE_NOTE were found in the cache folder.') else: raise Exception('Cache folder ' + cacheF + ' is not found.')
def inner(shellFilename, _hgHash): (stdoutStderr, exitCode) = inspectShell.testBinary(shellFilename, options.paramList, options.buildOptions.runWithVg) if (stdoutStderr.find(options.output) != -1) and (options.output != ''): return ('bad', 'Specified-bad output') elif options.watchExitCode is not None and exitCode == options.watchExitCode: return ('bad', 'Specified-bad exit code ' + str(exitCode)) elif options.watchExitCode is None and 129 <= exitCode <= 159: return ('bad', 'High exit code ' + str(exitCode)) elif exitCode < 0: # On Unix-based systems, the exit code for signals is negative, so we check if # 128 + abs(exitCode) meets our specified signal exit code. if options.watchExitCode is not None and 128 - exitCode == options.watchExitCode: return ('bad', 'Specified-bad exit code ' + str(exitCode) + ' (after converting to signal)') elif (stdoutStderr.find(options.output) == -1) and (options.output != ''): return ('good', 'Bad output, but not the specified one') elif options.watchExitCode is not None and 128 - exitCode != options.watchExitCode: return ('good', 'Negative exit code, but not the specified one') else: return ('bad', 'Negative exit code ' + str(exitCode)) elif exitCode == 0: return ('good', 'Exit code 0') elif (exitCode == 1 or exitCode == 2) and (options.output != '') and \ (stdoutStderr.find('usage: js [') != -1 or stdoutStderr.find('Error: Short option followed by junk') != -1 or stdoutStderr.find('Error: Invalid long option:') != -1 or stdoutStderr.find('Error: Invalid short option:') != -1): return ('good', 'Exit code 1 or 2 - js shell quits ' + 'because it does not support a given CLI parameter') elif 3 <= exitCode <= 6: return ('good', 'Acceptable exit code ' + str(exitCode)) elif options.watchExitCode is not None: return ('good', 'Unknown exit code ' + str(exitCode) + ', but not the specified one') else: return ('bad', 'Unknown exit code ' + str(exitCode))