# (C) Copyright 2020-2023 Intel Corporation.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
"""Unit tests"""

import os

TEST_SRC = ['test_gurt.c', 'test_gurt_telem_producer.c']


def scons():
    """Scons function"""
    if GetOption('help'):
        return

    Import('env', 'gurt_targets')

    test_env = env.Clone()
    test_env.require('mercury', 'uuid')
    test_env.AppendUnique(LIBS=['pthread', 'cmocka', 'm'])
    test_env.AppendUnique(CXXFLAGS=['-std=c++0x'])
    tests = []

    for test in TEST_SRC:
        flags = []
        testobj = test_env.Object(test)
        testname = os.path.splitext(test)[0]
        testprog = test_env.d_test_program(target=testname,
                                           source=testobj + gurt_targets,
                                           LIBS=test_env["LIBS"] + ['yaml'],
                                           LINKFLAGS=flags)
        tests.append(testprog)

    Default(tests)


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