"""Build daos engine tests"""


def scons():
    """Execute build"""
    Import('denv', 'drpc_test_utils')

    unit_env = denv.Clone()
    unit_env.AppendUnique(OBJPREFIX='utest_')

    common_mock_ld_script = f"{Dir('.').srcnode()}/../../common/tests/common-mock-ld-opts"
    unit_env.AppendUnique(LINKFLAGS=[f'-Wl,@{common_mock_ld_script}'])

    Depends('drpc_progress_tests', common_mock_ld_script)
    unit_env.d_test_program('drpc_progress_tests',
                            ['drpc_progress_tests.c', drpc_test_utils, '../drpc_progress.c'],
                            LIBS=['daos_common', 'protobuf-c', 'gurt', 'cmocka'])

    Depends('drpc_handler_tests', common_mock_ld_script)
    unit_env.d_test_program('drpc_handler_tests',
                            ['drpc_handler_tests.c', drpc_test_utils, '../drpc_handler.c'],
                            LIBS=['daos_common', 'protobuf-c', 'gurt', 'cmocka'])

    Depends('drpc_listener_tests', common_mock_ld_script)
    unit_env.d_test_program('drpc_listener_tests',
                            ['drpc_listener_tests.c', drpc_test_utils, '../drpc_listener.c'],
                            LIBS=['daos_common', 'protobuf-c', 'gurt', 'cmocka'])

    Depends('drpc_client_tests', common_mock_ld_script)
    unit_env.d_test_program('drpc_client_tests',
                            ['drpc_client_tests.c', drpc_test_utils, '../drpc_client.c',
                             '../drpc_ras.c', '../srv.pb-c.c', '../event.pb-c.c'],
                            LIBS=['daos_common', 'protobuf-c', 'gurt', 'cmocka',
                                  'uuid', 'pthread', 'abt', 'cart'])


if __name__ == "SCons.Script":
    scons()
