Don't copy CMake scripts to install folder
[junction.git] / samples / MapScalabilityTests / TestAllMaps.py
1 #!/usr/bin/env python
2 import os
3 import subprocess
4 import sys
5
6 # Default CMake command is just 'cmake' but you can override it by setting
7 # the CMAKE environment variable:
8 CMAKE = os.getenv('CMAKE', 'cmake')
9
10 ALL_MAPS = [
11     ('michael', 'junction/extra/impl/MapAdapter_CDS_Michael.h', ['-DJUNCTION_WITH_CDS=1', '-DTURF_WITH_EXCEPTIONS=1'], ['-i10000', '-c200']),
12     ('linear', 'junction/extra/impl/MapAdapter_Linear.h', [], ['-i10000', '-c200']),
13     ('leapfrog', 'junction/extra/impl/MapAdapter_LeapFrog.h', [], ['-i10000', '-c200']),
14     ('grampa', 'junction/extra/impl/MapAdapter_Grampa.h', [], ['-i10000', '-c200']),
15     ('stdmap', 'junction/extra/impl/MapAdapter_StdMap.h', [], ['-i10000', '-c10']),
16     ('folly', 'junction/extra/impl/MapAdapter_Folly.h', ['-DJUNCTION_WITH_FOLLY=1', '-DTURF_WITH_EXCEPTIONS=1'], ['-i2000', '-c1']),
17     ('nbds', 'junction/extra/impl/MapAdapter_NBDS.h', ['-DJUNCTION_WITH_NBDS=1'], ['-i10000', '-c200']),
18     ('tbb', 'junction/extra/impl/MapAdapter_TBB.h', ['-DJUNCTION_WITH_TBB=1'], ['-i10000', '-c200']),
19     ('tervel', 'junction/extra/impl/MapAdapter_Tervel.h', ['-DJUNCTION_WITH_TERVEL=1'], ['-i1000', '-c20']),
20     ('cuckoo', 'junction/extra/impl/MapAdapter_LibCuckoo.h', ['-DJUNCTION_WITH_LIBCUCKOO=1', '-DTURF_WITH_EXCEPTIONS=1'], ['-i5000', '-c20']),
21 ]
22
23 # Scan arguments for path to CMakeLists.txt and args to pass through.
24 passThroughArgs = []
25 pathArgs = []
26 for arg in sys.argv[1:]:
27     if arg.startswith('-'):
28         passThroughArgs.append(arg)
29     else:
30         pathArgs.append(arg)
31 if len(pathArgs) != 1:
32     sys.stderr.write('You must provide exactly one path argument.\n')
33     exit(1)
34
35 listFilePath = os.path.abspath(pathArgs[0])
36 for suffix, include, cmakeOpts, runtimeOpts in ALL_MAPS:
37     success = True
38     subdir = 'build-%s' % suffix
39     if not os.path.exists(subdir):
40         os.mkdir(subdir)
41     os.chdir(subdir)
42     print('Configuring in %s...' % subdir)
43     with open('junction_userconfig.h.in', 'w') as f:
44         f.write('#define JUNCTION_IMPL_MAPADAPTER_PATH "%s"\n' % include)
45     userConfigCMakePath = os.path.abspath('junction_userconfig.h.in')
46     if os.sep != '/':
47         userConfigCMakePath = userConfigCMakePath.replace(os.sep, '/')
48     if subprocess.call([CMAKE, listFilePath, '-DCMAKE_BUILD_TYPE=RelWithDebInfo', '-DCMAKE_INSTALL_PREFIX=TestAllMapsInstallFolder',
49                        '-DJUNCTION_USERCONFIG=%s' % userConfigCMakePath] + passThroughArgs + cmakeOpts) == 0:
50         subprocess.check_call([CMAKE, '--build', '.', '--target', 'install', '--config', 'RelWithDebInfo'])
51         print('Running in %s...' % subdir)
52         results = subprocess.check_output([os.path.join('TestAllMapsInstallFolder', 'bin', 'MapScalabilityTests')] + runtimeOpts)
53         with open('results.txt', 'wb') as f:
54             f.write(results)
55     os.chdir('..')