def test_echo(): if not os.path.exists('/bin/echo'): py.test.skip("there is no /bin/echo") returncode, stdout, stderr = run_subprocess('/bin/echo', 'FooBar') assert returncode == 0 assert stdout == 'FooBar\n' assert stderr == ''
def test_cat_fail(): if not os.path.exists('/bin/cat'): py.test.skip("there is no /bin/cat") returncode, stdout, stderr = run_subprocess('/bin/cat', 'no/such/filename') assert returncode == 1 assert stdout == '' assert 'no/such/filename' in stderr
def test_false(): if not os.path.exists('/bin/false'): py.test.skip("there is no /bin/false") returncode, stdout, stderr = run_subprocess('/bin/false', []) assert returncode == 1 assert stdout == '' assert stderr == ''
def gen_makefile(self, targetdir, exe_name=None): cfiles = [self.c_source_filename] + self.extrafiles if exe_name is not None: exe_name = targetdir.join(exe_name) mk = self.translator.platform.gen_makefile( cfiles, self.eci, path=targetdir, exe_name=exe_name, shared=self.config.translation.shared) if self.has_profopt(): profopt = self.config.translation.profopt mk.definition('ABS_TARGET', '$(shell python -c "import sys,os; print os.path.abspath(sys.argv[1])" $(TARGET))') mk.definition('DEFAULT_TARGET', 'profopt') mk.definition('PROFOPT', profopt) rules = [ ('clean', '', 'rm -f $(OBJECTS) $(TARGET) $(GCMAPFILES) $(ASMFILES) *.gc?? ../module_cache/*.gc??'), ('clean_noprof', '', 'rm -f $(OBJECTS) $(TARGET) $(GCMAPFILES) $(ASMFILES)'), ('debug', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT" debug_target'), ('debug_exc', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT -DDO_LOG_EXC" debug_target'), ('debug_mem', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT -DTRIVIAL_MALLOC_DEBUG" debug_target'), ('no_obmalloc', '', '$(MAKE) CFLAGS="-g -O2 -DRPY_ASSERT -DNO_OBMALLOC" $(TARGET)'), ('linuxmemchk', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT -DLINUXMEMCHK" debug_target'), ('llsafer', '', '$(MAKE) CFLAGS="-O2 -DRPY_LL_ASSERT" $(TARGET)'), ('lldebug', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT -DRPY_LL_ASSERT" debug_target'), ('profile', '', '$(MAKE) CFLAGS="-g -O1 -pg $(CFLAGS) -fno-omit-frame-pointer" LDFLAGS="-pg $(LDFLAGS)" $(TARGET)'), ] if self.has_profopt(): rules.append( ('profopt', '', [ '$(MAKENOPROF)', '$(MAKE) CFLAGS="-fprofile-generate $(CFLAGS)" LDFLAGS="-fprofile-generate $(LDFLAGS)" $(TARGET)', 'cd $(PYPYDIR)/translator/goal && $(ABS_TARGET) $(PROFOPT)', '$(MAKE) clean_noprof', '$(MAKE) CFLAGS="-fprofile-use $(CFLAGS)" LDFLAGS="-fprofile-use $(LDFLAGS)" $(TARGET)'])) for rule in rules: mk.rule(*rule) if self.config.translation.gcrootfinder == 'asmgcc': trackgcfiles = [cfile[:cfile.rfind('.')] for cfile in mk.cfiles] if self.translator.platform.name == 'msvc': trackgcfiles = [f for f in trackgcfiles if f.startswith(('implement', 'testing', '../module_cache/module'))] sfiles = ['%s.s' % (c,) for c in trackgcfiles] lblsfiles = ['%s.lbl.s' % (c,) for c in trackgcfiles] gcmapfiles = ['%s.gcmap' % (c,) for c in trackgcfiles] mk.definition('ASMFILES', sfiles) mk.definition('ASMLBLFILES', lblsfiles) mk.definition('GCMAPFILES', gcmapfiles) if sys.platform == 'win32': mk.definition('DEBUGFLAGS', '/MD /Zi') else: mk.definition('DEBUGFLAGS', '-O2 -fomit-frame-pointer -g') if self.config.translation.shared: mk.definition('PYPY_MAIN_FUNCTION', "pypy_main_startup") else: mk.definition('PYPY_MAIN_FUNCTION', "main") if sys.platform == 'win32': python = sys.executable.replace('\\', '/') + ' ' else: python = sys.executable + ' ' # Is there a command 'python' that runs python 2.5-2.7? # If there is, then we can use it instead of sys.executable returncode, stdout, stderr = runsubprocess.run_subprocess( "python", "-V") if (stdout.startswith('Python 2.') or stderr.startswith('Python 2.')): python = 'python ' if self.translator.platform.name == 'msvc': lblofiles = [] for cfile in mk.cfiles: f = cfile[:cfile.rfind('.')] if f in trackgcfiles: ofile = '%s.lbl.obj' % (f,) else: ofile = '%s.obj' % (f,) lblofiles.append(ofile) mk.definition('ASMLBLOBJFILES', lblofiles) mk.definition('OBJECTS', 'gcmaptable.obj $(ASMLBLOBJFILES)') # /Oi (enable intrinsics) and /Ob1 (some inlining) are mandatory # even in debug builds mk.definition('ASM_CFLAGS', '$(CFLAGS) $(CFLAGSEXTRA) /Oi /Ob1') mk.rule('.SUFFIXES', '.s', []) mk.rule('.s.obj', '', 'cmd /c $(MASM) /nologo /Cx /Cp /Zm /coff /Fo$@ /c $< $(INCLUDEDIRS)') mk.rule('.c.gcmap', '', ['$(CC) /nologo $(ASM_CFLAGS) /c /FAs /Fa$*.s $< $(INCLUDEDIRS)', 'cmd /c ' + python + '$(PYPYDIR)/translator/c/gcc/trackgcroot.py -fmsvc -t $*.s > $@'] ) mk.rule('gcmaptable.c', '$(GCMAPFILES)', 'cmd /c ' + python + '$(PYPYDIR)/translator/c/gcc/trackgcroot.py -fmsvc $(GCMAPFILES) > $@') else: mk.definition('OBJECTS', '$(ASMLBLFILES) gcmaptable.s') mk.rule('%.s', '%.c', '$(CC) $(CFLAGS) $(CFLAGSEXTRA) -frandom-seed=$< -o $@ -S $< $(INCLUDEDIRS)') mk.rule('%.lbl.s %.gcmap', '%.s', [python + '$(PYPYDIR)/translator/c/gcc/trackgcroot.py ' '-t $< > $*.gctmp', 'mv $*.gctmp $*.gcmap']) mk.rule('gcmaptable.s', '$(GCMAPFILES)', [python + '$(PYPYDIR)/translator/c/gcc/trackgcroot.py ' '$(GCMAPFILES) > [email protected]', 'mv [email protected] $@']) mk.rule('.PRECIOUS', '%.s', "# don't remove .s files if Ctrl-C'ed") else: if sys.platform == 'win32': mk.definition('DEBUGFLAGS', '/MD /Zi') else: mk.definition('DEBUGFLAGS', '-O1 -g') if sys.platform == 'win32': mk.rule('debug_target', 'debugmode_$(DEFAULT_TARGET)', 'rem') else: mk.rule('debug_target', '$(TARGET)', '#') mk.write() #self.translator.platform, # , # self.eci, profbased=self.getprofbased() self.executable_name = mk.exe_name