###################################################################
# Copyright 2018, 2020, 2022, 2025 NXP
# SPDX-License-Identifier: BSD-3-Clause

"""
Copyright 2015 Freescale Semiconductor, Inc.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of Freescale Semiconductor nor the names of its
      contributors may be used to endorse or promote products derived from
      this software without specific prior written permission.

This software is provided by Freescale Semiconductor "as is" and any
express or implied warranties, including, but not limited to, the implied
warranties of merchantability and fitness for a particular purpose are
disclaimed. In no event shall Freescale Semiconductor be liable for any
direct, indirect, incidental, special, exemplary, or consequential damages
(including, but not limited to, procurement of substitute goods or services;
loss of use, data, or profits; or business interruption) however caused and
on any theory of liability, whether in contract, strict liability, or tort
(including negligence or otherwise) arising in any way out of the use of
this software, even if advised of the possibility of such damage.
"""

###################################################################
######### Parameters
###################################################################

# Script that used to initialize target
_INIT_SCRIPT = "C:/Radu_work/S32DS_GTA_REPO/debug_ng/GTA/components/init_scripts/s32r45/s32r45_generic_bareboard_all_cores.py"                


_TEST_ELF = "C:/Radu_work/LAX/S32DS_projs/LAX_lib_testerO3O3_82_87_time/LAX_lib_tester/project/CW_LAX_lib_tester/Debug/CW_LAX_lib_tester.eld"
#_TEST_ELF = "C:/Radu_work/LAX/S32DS_projs/LAX_lib_testerO0O0_82_87_time/LAX_lib_tester/project/CW_LAX_lib_tester/Debug/CW_LAX_lib_tester.eld"
#_TEST_ELF = "C:/Radu_work/LAX/S32DS_projs/LAX_lib_testerO0O0_82_87/LAX_lib_tester/project/CW_LAX_lib_tester/Debug/CW_LAX_lib_tester.eld"

_TEST_DIRECTORY = "C:/Radu_work/LAX/S32DS_projs/LAX_lib_testerO0O0_82_87/LAX_lib_tester/vector/dev"

###################################################################
######### Start RSDK Test Services
###################################################################
import sys
import os

#compute gdb_extensions absolute path
DDR_EXT_INSTALL_DIR = ''.join([os.path.dirname(os.path.realpath(__file__)), '/'])
GDB_EXT_INSTALL_DIR =''.join([DDR_EXT_INSTALL_DIR, '../'])

#add gdb_extensions to system path
sys.path.insert(0, GDB_EXT_INSTALL_DIR)

from rsdk_test.gdbcommands.commands import create_test_command
from rsdk_test.gdbcommands.commands import start_rsdk_test

def rsdk_test():
    
    
    init_script = '--init "%s"' % _INIT_SCRIPT

    test_dir = '-d %s' % _TEST_DIRECTORY
    
    test_elf = '-e %s' % _TEST_ELF

    argument = ' '.join([init_script, test_dir, test_elf])
    start_rsdk_test(argument)
    
def rsdk_create_command():
    
    create_test_command()
