Skip to content
Snippets Groups Projects
meson.build 4.46 KiB
Newer Older
  • Learn to ignore specific revisions
  • cc = meson.get_compiler('c')
    
    liburcu_memb = option_urcu ? cc.find_library('urcu-memb') : disabler()
    liburcu_cds = option_urcu ? cc.find_library('urcu-cds') : disabler()
    
    # TODO: Parallel tests should be run without io_uring compiled
    # into emper, to avoid running into `ulimit -l`.
    
    tests = [
    	{
    		'source': files('SimpleFibTest.cpp'),
    		'name': 'SimpleFibTest',
    		'description': 'Simple test',
    	},
    
    	{
    		'source': files('SimplestFibTest.cpp'),
    		'name': 'SimplestFibTest',
    		'description': 'Simplest fib test',
    		'test_suite': 'smoke',
    		'is_parallel': true,
    	},
    
    	{
    		'source': files('RuntimeDestroyTest.cpp'),
    		'name': 'RuntimeDestroyTest',
    		'description': 'Test runtime destruction',
    		'test_suite': 'smoke',
    		'is_parallel': true,
    	},
    
    	{
    		'source': files('c_api_test.c'),
    		'name': 'c_api_test',
    		'description': 'Test EMPER\'s C API',
    	},
    
    	{
    		'source': files('CppApiTest.cpp'),
    		'name': 'CppApiTest',
    		'description': 'Test EMPER\'s C++ API',
    	},
    
    	{
    		'source': files('YieldToAnywhereTest.cpp'),
    		'name': 'YieldToAnywhereTest',
    		'description': 'Test emper::yieldToAnywhere',
    		'test_runner': 'emper',
    	},
    
    	{
    		'source': files('ReuseBpsTest.cpp'),
    		'name': 'ReuseBpsTest',
    		'description': 'Test resetting of BPSs',
    		'test_runner': 'emper',
    	},
    
    	{
    		'source': files('SimpleActorTest.cpp'),
    		'name': 'SimpleActorTest',
    		'description': 'Simple Actor Test',
    	},
    
    	{
    		'source': files('AlarmActorTest.cpp'),
    		'name': 'AlarmActorTest',
    		'description': 'Use an Actor to unblock fibers using BPS',
    	},
    
    	{
    		'source': files('UnblockOnMainActorTest.cpp'),
    		'name': 'UnblockOnMainActorTest',
    		'description': 'Slight modification of AlarmActorTest using the main thread to signal BPS',
    	},
    
    	{
    		'source': files('SimpleLawsTest.cpp'),
    		'name': 'SimpleLawsTest',
    		'description': 'Simple LAWS scheduling strategy test',
    	},
    
    	{
    		'source': files('SimpleUrcuTest.cpp'),
    		'name': 'SimpleUrcuTest',
    		'description': 'Simple userspace-rcu hash table test',
    		'dependencies': [liburcu_memb, liburcu_cds]
    	},
    
    	{
    		'source': files('SignalPrivateSemaphoreFromAnywhereTest.cpp'),
    		'name': 'SignalPrivateSemaphoreFromAnywhereTest',
    		'description': 'Simple test for PrivateSemaphore:signalFromAnywhere()',
    		'test_suite': 'smoke',
    		'is_parallel': true,
    		'test_runner': 'emper',
    	},
    
    	{
    		'source': files('TellActorFromAnywhereTest.cpp'),
    		'name': 'TellActorFromAnywhereTest',
    		'description': 'Simple test for Actor:tellFromAnywhere()',
    		'test_suite': 'smoke',
    		'is_parallel': true,
    		'test_runner': 'emper',
    	},
    ]
    
    subdir('io')
    subdir('lib')
    
    test_env = environment(
      {
    	# Set glibc's MALLOC_PERTURB to 1. This means that newly allocated
    	# memory will be initialized with 0x01, and that free'ed memory
    	# will be set to 0xFE (I think).
    	'MALLOC_PERTURB_': '1',
      }
    )
    
    subdir('test-runner')
    
    
    io_uring_enabled = get_option('io')
    
    parallel_ok = (not io_uring_enabled)
    
    
    # Meson integration for GTest and GMock
    # See https://mesonbuild.com/Dependencies.html#gtest-and-gmock
    
    gtest_dep = dependency('gtest', main: true, required: false)
    # If gtest is not available on the system use the meson wrap provided
    # by WrapDB and build it ourself
    if not gtest_dep.found()
    	gtest_sp = subproject('gtest')
    	gtest_dep = gtest_sp.get_variable('gtest_main_dep')
    endif
    
    fs = import('fs')
    
    foreach test_dict : tests
      # The test_name is the name of the source file without the file suffix'.
      source = test_dict['source'][0]
      # Currently fs does not support files() objects
      # https://github.com/mesonbuild/meson/issues/8608
      # TODO: Use meson fs (filesystem) module once this is solved an in buster-backports
      test_name = test_dict['name']
    
      test_deps = [thread_dep, test_fixtures]
    
    
      if test_dict.get('gtest', false)
        test_deps += gtest_dep
      endif
    
    
      if test_dict.has_key('dependencies')
    
      	test_deps += test_dict['dependencies']
    
      if test_dict.has_key('test_runner')
    	test_deps += test_runners[test_dict['test_runner']]
    
      test_exe = executable(test_name,
    						source,
    						include_directories: emper_all_include,
    
    						c_args: undef_ndebug,
    						cpp_args: undef_ndebug,
    
    						dependencies: [emper_full_dep] + test_deps,
    
      test_is_parallel = test_dict.get('is_parallel', false)
    
    
    	   is_parallel: test_is_parallel and parallel_ok,
    
    	   suite: test_dict.get('test_suite', 'all'),
    
    	   timeout: test_dict.get('timeout', 180),
    	   args: test_dict.get('args', []),
    	   should_fail: test_dict.get('should_fail', false),