![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /usr/share/emscripten/tests/fuzz/ |
Upload File : |
#! /usr/bin/python ''' Usage: creduce ./creduce_tester.py newfail1.c ''' import os, sys from subprocess import Popen, PIPE, STDOUT sys.path += [os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'tools')] import shared, jsrun # creduce will only pass the filename of the C file as the first arg, so other # configuration options will have to be hardcoded. CSMITH_CFLAGS = ['-I', os.path.join(os.environ['CSMITH_PATH'], 'runtime')] ENGINE = shared.JS_ENGINES[0] EMCC_ARGS = ['-O2', '-s', 'ASM_JS=1', '-s', 'PRECISE_I64_MATH=1', '-s', 'PRECISE_I32_MUL=1'] filename = sys.argv[1] obj_filename = os.path.splitext(filename)[0] js_filename = obj_filename + '.js' print 'testing file', filename try: print '2) Compile natively' shared.check_execute([shared.CLANG_CC, '-O2', filename, '-o', obj_filename] + CSMITH_CFLAGS) print '3) Run natively' correct = jsrun.timeout_run(Popen([obj_filename], stdout=PIPE, stderr=PIPE), 3) except Exception, e: print 'Failed or infinite looping in native, skipping', e sys.exit(1) # boring print '4) Compile JS-ly and compare' def try_js(args): shared.check_execute([shared.PYTHON, shared.EMCC] + EMCC_ARGS + CSMITH_CFLAGS + args + [filename, '-o', js_filename]) js = shared.run_js(js_filename, stderr=PIPE, engine=ENGINE) assert correct == js # Try normally, then try unaligned because csmith does generate nonportable code that requires x86 alignment # If you are sure that alignment is not the cause, disable it for a faster reduction for args in [[]]: try: try_js(args) break except Exception, e: pass else: sys.exit(0) sys.exit(1) # boring