Project Euler Solutions
Functions | Variables
c.test_euler Namespace Reference

Functions

def cleanup ()
 
def v_compiler (request)
 
def compiler (request)
 
def key (request)
 
def c_file (request)
 
def test_compiler_macros (compiler)
 
def test_deterministic_build (c_file, compiler)
 
def test_bcd_int (benchmark, compiler)
 
def test_is_prime (benchmark, compiler)
 
def test_problem (benchmark, key, compiler)
 
def test_valgrind (c_file, v_compiler)
 
def test_pahole (c_file, v_compiler)
 

Variables

 C_FOLDER = Path(__file__).parent
 
 BUILD_FOLDER = C_FOLDER.joinpath('build', 'test-run-{}'.format(uuid4()))
 
dictionary answers
 
string IN_WINDOWS = 'Windows'
 
string IN_OSX = 'Darwin'
 
 IN_TERMUX = bool(which('termux-setup-storage'))
 
tuple IN_LINUX = (not IN_TERMUX)and(system() == 'Linux')
 
 _raw_NO_SLOW = environ.get('NO_SLOW')
 
 _parsed_NO_SLOW = _raw_NO_SLOW
 
 _raw_ONLY_SLOW = environ.get('ONLY_SLOW')
 
 _parsed_ONLY_SLOW = _raw_ONLY_SLOW
 
 _raw_NO_OPTIONAL_TESTS = environ.get('NO_OPTIONAL_TESTS')
 
 _parsed_NO_OPTIONAL_TESTS = _raw_NO_OPTIONAL_TESTS
 
tuple NO_SLOW = ((IN_TERMUX and _parsed_NO_SLOW is None) or _parsed_NO_SLOW)andnot_parsed_ONLY_SLOW
 
 ONLY_SLOW = _parsed_ONLY_SLOWandnot_parsed_NO_SLOW
 
tuple NO_OPTIONAL_TESTS = (_parsed_NO_OPTIONAL_TESTS is None and ONLY_SLOW)or_parsed_NO_OPTIONAL_TESTS
 
 EXE_EXT = processor()
 
 GCC_BINARY = environ.get('GCC_OVERRIDE', 'gcc')
 
 AOCC_BINARY = environ.get('AOCC_OVERRIDE', 'clang')
 
list valgrind_compilers = [x for x in compilers if x != 'CL']
 
 COMPILER_LEN = len(max(compilers, key=len))
 
 V_COMPILER_LEN = len(max(valgrind_compilers or [''], key=len))
 
 parents
 
 True
 
 exist_ok
 
bool CL_NO_64 = False
 
 OBJ_FOLDER = BUILD_FOLDER.joinpath('objects')
 
 _test_file = BUILD_FOLDER.parent.joinpath('{}.c'.format(uuid4()))
 
 _test_exe = str(BUILD_FOLDER.joinpath('test_cl_64_support-{}.out'.format(uuid4())))
 
bool GCC_NO_64 = False
 
string CLANG_LINK_MATH = ''
 
string CLANG_ARCH = '-march=native'
 
string SOURCE_TEMPLATE = "{}{}p{{:0>4}}.c"
 
string EXE_TEMPLATE = "{}{}p{{:0>4}}.{{}}.{}"
 
tuple GCC_TEMPLATE
 
tuple CLANG_TEMPLATE = ("{} {{}} -O3 {} {} -Wall -Werror -Wno-initializer-overrides -std=gnu11 {} -o {{}}")
 
dictionary templates
 
dictionary debug_templates
 
 valgrind_test_exe_name = EXE_TEMPLATE.format('valgrind-check-{}'.format(uuid4()), valgrind_compilers[0])
 
 VALGRIND_ERR_LIST = notrun(['valgrind', '-s', valgrind_test_exe_name], cwd=BUILD_FOLDER).returncode
 

Function Documentation

def c.test_euler.c_file (   request)
def c.test_euler.cleanup ( )
def c.test_euler.compiler (   request)
def c.test_euler.key (   request)
def c.test_euler.test_bcd_int (   benchmark,
  compiler 
)
def c.test_euler.test_compiler_macros (   compiler)
def c.test_euler.test_deterministic_build (   c_file,
  compiler 
)
def c.test_euler.test_is_prime (   benchmark,
  compiler 
)
def c.test_euler.test_pahole (   c_file,
  v_compiler 
)
def c.test_euler.test_problem (   benchmark,
  key,
  compiler 
)
def c.test_euler.test_valgrind (   c_file,
  v_compiler 
)
def c.test_euler.v_compiler (   request)

Variable Documentation

c.test_euler._parsed_NO_OPTIONAL_TESTS = _raw_NO_OPTIONAL_TESTS
private
c.test_euler._parsed_NO_SLOW = _raw_NO_SLOW
private
c.test_euler._parsed_ONLY_SLOW = _raw_ONLY_SLOW
private
c.test_euler._raw_NO_OPTIONAL_TESTS = environ.get('NO_OPTIONAL_TESTS')
private
c.test_euler._raw_NO_SLOW = environ.get('NO_SLOW')
private
c.test_euler._raw_ONLY_SLOW = environ.get('ONLY_SLOW')
private
c.test_euler._test_exe = str(BUILD_FOLDER.joinpath('test_cl_64_support-{}.out'.format(uuid4())))
private
c.test_euler._test_file = BUILD_FOLDER.parent.joinpath('{}.c'.format(uuid4()))
private
dictionary c.test_euler.answers
Initial value:
1 = {
2  1: 233168,
3  2: 4613732,
4  3: 6857,
5  4: 906609,
6  5: 232792560,
7  6: 25164150,
8  7: 104743,
9  8: 23514624000,
10  9: 31875000,
11  10: 142913828922,
12  11: 70600674,
13  13: 5537376230,
14  14: 837799,
15  15: 137846528820,
16  16: 1366,
17  20: 648,
18  25: 4782,
19  30: 443839,
20  34: 40730,
21  76: 190569291,
22 }
c.test_euler.AOCC_BINARY = environ.get('AOCC_OVERRIDE', 'clang')
c.test_euler.BUILD_FOLDER = C_FOLDER.joinpath('build', 'test-run-{}'.format(uuid4()))
c.test_euler.C_FOLDER = Path(__file__).parent
c.test_euler.CL_NO_64 = False
string c.test_euler.CLANG_ARCH = '-march=native'
string c.test_euler.CLANG_LINK_MATH = ''
tuple c.test_euler.CLANG_TEMPLATE = ("{} {{}} -O3 {} {} -Wall -Werror -Wno-initializer-overrides -std=gnu11 {} -o {{}}")
c.test_euler.COMPILER_LEN = len(max(compilers, key=len))
dictionary c.test_euler.debug_templates
Initial value:
1 = {
2  'GCC': GCC_TEMPLATE.format(GCC_BINARY, '-g'),
3  'CLANG': CLANG_TEMPLATE.format('clang', CLANG_LINK_MATH, CLANG_ARCH, '-DAMD_COMPILER=0 -g'),
4  # CL would go here if I thought it worked with gdb/valgrind
5  'ICC': GCC_TEMPLATE.format('icc', '-g'),
6  'AOCC': CLANG_TEMPLATE.format(AOCC_BINARY, CLANG_LINK_MATH, CLANG_ARCH, '-DAMD_COMPILER=1 -g'),
7 }
string c.test_euler.EXE_EXT = processor()
string c.test_euler.EXE_TEMPLATE = "{}{}p{{:0>4}}.{{}}.{}"
c.test_euler.exist_ok
c.test_euler.GCC_BINARY = environ.get('GCC_OVERRIDE', 'gcc')
c.test_euler.GCC_NO_64 = False
tuple c.test_euler.GCC_TEMPLATE
Initial value:
1 = ("{} {{}} -O3 {} -lm -Wall -Werror -Wno-error=format=* -Wno-error=format-extra-args -std=gnu11 "
2  "-Wno-initializer-overrides -march=native -flto -fwhole-program -o {{}}")
tuple c.test_euler.IN_LINUX = (not IN_TERMUX)and(system() == 'Linux')
string c.test_euler.IN_OSX = 'Darwin'
c.test_euler.IN_TERMUX = bool(which('termux-setup-storage'))
string c.test_euler.IN_WINDOWS = 'Windows'
tuple c.test_euler.NO_OPTIONAL_TESTS = (_parsed_NO_OPTIONAL_TESTS is None and ONLY_SLOW)or_parsed_NO_OPTIONAL_TESTS
tuple c.test_euler.NO_SLOW = ((IN_TERMUX and _parsed_NO_SLOW is None) or _parsed_NO_SLOW)andnot_parsed_ONLY_SLOW
c.test_euler.OBJ_FOLDER = BUILD_FOLDER.joinpath('objects')
c.test_euler.ONLY_SLOW = _parsed_ONLY_SLOWandnot_parsed_NO_SLOW
c.test_euler.parents
string c.test_euler.SOURCE_TEMPLATE = "{}{}p{{:0>4}}.c"
dictionary c.test_euler.templates
Initial value:
1 = {
2  'GCC': GCC_TEMPLATE.format(GCC_BINARY, ''),
3  'CLANG': CLANG_TEMPLATE.format('clang', CLANG_LINK_MATH, CLANG_ARCH, '-DAMD_COMPILER=0'),
4  'CL': "cl -Fe:{{1}} -Fo{}\\ -O2 -GL -GF -Brepro -WX -W3 -TC {{0}}".format(BUILD_FOLDER.joinpath('objects')),
5  'ICC': GCC_TEMPLATE.format('icc', ''),
6  'AOCC': CLANG_TEMPLATE.format(AOCC_BINARY, CLANG_LINK_MATH, CLANG_ARCH, '-DAMD_COMPILER=1'),
7 }
c.test_euler.True
c.test_euler.V_COMPILER_LEN = len(max(valgrind_compilers or [''], key=len))
list c.test_euler.valgrind_compilers = [x for x in compilers if x != 'CL']
c.test_euler.VALGRIND_ERR_LIST = notrun(['valgrind', '-s', valgrind_test_exe_name], cwd=BUILD_FOLDER).returncode
c.test_euler.valgrind_test_exe_name = EXE_TEMPLATE.format('valgrind-check-{}'.format(uuid4()), valgrind_compilers[0])