Diab: Add tests covering the Diab toolchains
Run the tests only if enabled explicitly by an undocumented cache entry. We will enable it on hosts known to have the toolchains. Closes: #26735
This commit is contained in:
parent
03d57336ab
commit
7624d0110b
@ -1369,3 +1369,7 @@ if(CMake_TEST_TICLANG_TOOLCHAINS)
|
|||||||
add_RunCMake_test(TIClang "-DCMake_TEST_TICLANG_TOOLCHAINS=${TOOLCHAINS}")
|
add_RunCMake_test(TIClang "-DCMake_TEST_TICLANG_TOOLCHAINS=${TOOLCHAINS}")
|
||||||
set_property(TEST RunCMake.TIClang APPEND PROPERTY LABELS "TIClang")
|
set_property(TEST RunCMake.TIClang APPEND PROPERTY LABELS "TIClang")
|
||||||
endif()
|
endif()
|
||||||
|
if(CMake_TEST_Diab_TOOLCHAINS)
|
||||||
|
add_RunCMake_test(Diab -DCMake_TEST_Diab_TOOLCHAINS=${CMake_TEST_Diab_TOOLCHAINS})
|
||||||
|
set_property(TEST RunCMake.Diab APPEND PROPERTY LABELS "Diab")
|
||||||
|
endif()
|
||||||
|
3
Tests/RunCMake/Diab/CMakeLists.txt
Normal file
3
Tests/RunCMake/Diab/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
cmake_minimum_required(VERSION 4.0)
|
||||||
|
project(${RunCMake_TEST} NONE)
|
||||||
|
include(${RunCMake_TEST}.cmake)
|
42
Tests/RunCMake/Diab/RunCMakeTest.cmake
Normal file
42
Tests/RunCMake/Diab/RunCMakeTest.cmake
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
include(RunCMake)
|
||||||
|
|
||||||
|
# Locate Diab toolchain
|
||||||
|
if(RunCMake_GENERATOR MATCHES "Makefile|Ninja")
|
||||||
|
file(GLOB _diab_toolchains
|
||||||
|
"${CMake_TEST_Diab_TOOLCHAINS}/*/*/bin/dcc*" )
|
||||||
|
if(_diab_toolchains STREQUAL "")
|
||||||
|
message(FATAL_ERROR "Could not find any Diab toolchains at: ${CMake_TEST_Diab_TOOLCHAINS}.")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
function(run_toolchain case)
|
||||||
|
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build)
|
||||||
|
run_cmake_with_options(${case} ${ARGN})
|
||||||
|
set(RunCMake_TEST_NO_CLEAN 1)
|
||||||
|
run_cmake_command(${case}-build ${CMAKE_COMMAND} --build .)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
|
foreach(_diab_toolchain IN LISTS _diab_toolchains)
|
||||||
|
message(STATUS "Found Diab toolchain: ${_diab_toolchain}")
|
||||||
|
cmake_path(GET _diab_toolchain PARENT_PATH BIN_DIR)
|
||||||
|
set(c_comp ${BIN_DIR}/dcc)
|
||||||
|
set(cxx_comp ${BIN_DIR}/dplus)
|
||||||
|
|
||||||
|
# Create an executable from .c sources only.
|
||||||
|
run_toolchain(diab-c
|
||||||
|
-DCMAKE_C_COMPILER=${c_comp}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Create an executale from .c and .cxx sources.
|
||||||
|
run_toolchain(diab-cxx
|
||||||
|
-DCMAKE_C_COMPILER=${c_comp}
|
||||||
|
-DCMAKE_CXX_COMPILER=${cxx_comp}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Create an executable from mixed, c, cxx and assembly.
|
||||||
|
run_toolchain(diab-asm
|
||||||
|
-DCMAKE_C_COMPILER=${c_comp}
|
||||||
|
-DCMAKE_CXX_COMPILER=${cxx_comp}
|
||||||
|
)
|
||||||
|
endforeach()
|
2
Tests/RunCMake/Diab/diab-asm.cmake
Normal file
2
Tests/RunCMake/Diab/diab-asm.cmake
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
enable_language(ASM)
|
||||||
|
add_executable(exec-asm module.s)
|
2
Tests/RunCMake/Diab/diab-c.cmake
Normal file
2
Tests/RunCMake/Diab/diab-c.cmake
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
enable_language(C)
|
||||||
|
add_executable(exec-c module.c)
|
2
Tests/RunCMake/Diab/diab-cxx.cmake
Normal file
2
Tests/RunCMake/Diab/diab-cxx.cmake
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
enable_language(CXX)
|
||||||
|
add_executable(exec-cxx module.cxx)
|
7
Tests/RunCMake/Diab/diab-lib.cmake
Normal file
7
Tests/RunCMake/Diab/diab-lib.cmake
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
enable_language(C)
|
||||||
|
add_library(diab-test-lib libmod.c)
|
||||||
|
|
||||||
|
add_executable(exec-lib-c module.c)
|
||||||
|
target_compile_options(exec-lib-c)
|
||||||
|
target_compile_definitions(exec-lib-c PRIVATE __USE_LIBFUN)
|
||||||
|
target_link_libraries(exec-lib-c PRIVATE diab-test-lib)
|
4
Tests/RunCMake/Diab/libmod.c
Normal file
4
Tests/RunCMake/Diab/libmod.c
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
int diab_libfun()
|
||||||
|
{
|
||||||
|
return 42;
|
||||||
|
}
|
15
Tests/RunCMake/Diab/module.c
Normal file
15
Tests/RunCMake/Diab/module.c
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include "module.h"
|
||||||
|
#if defined(__USE_LIBFUN)
|
||||||
|
extern int diab_libfun();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int i;
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
#if defined(__USE_LIBFUN)
|
||||||
|
i = diab_libfun();
|
||||||
|
#else
|
||||||
|
i = INTERNAL;
|
||||||
|
#endif
|
||||||
|
return i;
|
||||||
|
}
|
7
Tests/RunCMake/Diab/module.cxx
Normal file
7
Tests/RunCMake/Diab/module.cxx
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#include "module.h"
|
||||||
|
int i;
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
i = INTERNAL;
|
||||||
|
return i;
|
||||||
|
}
|
12
Tests/RunCMake/Diab/module.h
Normal file
12
Tests/RunCMake/Diab/module.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#ifndef __MODULE_H__
|
||||||
|
#define __MODULE_H__
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
# define INTERNAL 64
|
||||||
|
#elif !defined(__cplusplus)
|
||||||
|
# define INTERNAL 32
|
||||||
|
#else
|
||||||
|
# error "Unable to determine INTERNAL symbol."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __MODULE_H__ */
|
10
Tests/RunCMake/Diab/module.s
Normal file
10
Tests/RunCMake/Diab/module.s
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
; module.s: assembly "main" function returns 32.
|
||||||
|
;
|
||||||
|
.name "module.s"
|
||||||
|
.text
|
||||||
|
.align 2
|
||||||
|
|
||||||
|
.globl main
|
||||||
|
main:
|
||||||
|
diab.li r3,32
|
||||||
|
blr
|
Loading…
Reference in New Issue
Block a user