BLD: `ctest` port

This commit is contained in:
Mateusz Sokół 2024-07-26 13:10:17 +00:00
parent 3bc55f15f0
commit 1799f60893
4 changed files with 107 additions and 4 deletions

71
ctest/meson.build Normal file
View File

@ -0,0 +1,71 @@
testl1_src = ['c_?blat1.f', 'c_?blas1.c']
testl2_src = ['c_?blat2.f', 'c_?blas2.c', 'c_?2chke.c', 'auxiliary.c', 'constant.c', 'c_xerbla.c']
testl3_src = ['c_?blat3.f', 'c_?blas3.c', 'c_?3chke.c', 'auxiliary.c', 'constant.c', 'c_xerbla.c']
testl3_3m_src = ['c_?blat3_3m.f', 'c_?blas3_3m.c', 'c_?3chke_3m.c', 'auxiliary.c', 'constant.c', 'c_xerbla.c']
_test_input_array = {
'l1': {
'base': 'x?blat1',
'has_dat': false,
'types': ['s', 'd', 'c', 'z'],
'sources': testl1_src,
},
'l2': {
'base': 'x?cblat2',
'has_dat': true,
'types': ['s', 'd', 'c', 'z'],
'sources': testl2_src,
'input_file': '?in2',
},
'l3': {
'base': 'x?cblat3',
'has_dat': true,
'types': ['s', 'd', 'c', 'z'],
'sources': testl3_src,
'input_file': '?in3',
},
'l3_3m': {
'base': 'x?cblat3_3m',
'has_dat': true,
'types': ['c', 'z'],
'sources': testl3_3m_src,
'input_file': '?in3_3m',
},
}
_test_runner = executable('test_runner', sources: ['test_runner.c'], install: false)
foreach lvl : ['l1', 'l2', 'l3', 'l3_3m']
details = _test_input_array[lvl]
foreach type : details['types']
op_name = details['base'].replace('?', type)
mapped_sources = []
foreach source : details['sources']
mapped_sources += source.replace('?', type)
endforeach
executable(
op_name,
sources: mapped_sources + [config_h],
link_with: [_openblas],
dependencies: [dependency('threads')],
include_directories: include_directories('..'),
c_args: ['-I..', '-I.', '-DADD_', '-DCBLAS'],
)
_args = [f'./@op_name@']
if details.has_key('input_file')
_args += [meson.current_source_dir() / details['input_file'].replace('?', type)]
endif
test(
op_name,
_test_runner,
args: _args,
workdir: meson.current_build_dir(),
) # TODO: add OPENBLAS_NUM_THREADS=2
endforeach
endforeach

25
ctest/test_runner.c Normal file
View File

@ -0,0 +1,25 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[]) {
if (argc != 2 && argc != 3) {
fprintf(stderr, "Usage: %s <executable> <optional_input_file>\n", argv[0]);
return EXIT_FAILURE;
}
char command[1024];
if (argc == 2) {
snprintf(command, sizeof(command), "%s", argv[1]);
} else {
snprintf(command, sizeof(command), "%s < %s", argv[1], argv[2]);
}
int result = system(command);
if (result != 0) {
fprintf(stderr, "Error: Command '%s' failed with return code %d.\n", command, result);
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}

View File

@ -385,18 +385,24 @@ base_kops = [
},
{ 'base': '?geru',
'modes': {
'c': {'exts': {'_k': {'dir': 'generic', 'kernel': 'zger.c'}}},
'z': {'exts': {'_k': {'dir': 'generic', 'kernel': 'zger.c'}}},
'c': {'exts': {'_k': {'dir': 'generic', 'kernel': 'zger.c', 'addl': ['-UDOUBLE', '-DCOMPLEX', '-UCONJ']}}},
'z': {'exts': {'_k': {'dir': 'generic', 'kernel': 'zger.c', 'addl': ['-DDOUBLE', '-DCOMPLEX', '-UCONJ']}}},
# 'x': {'exts': {'_k': {'dir': 'generic', 'kernel': 'zger.c'}}},
},
},
{ 'base': '?gerc',
'modes': {
'c': {'exts': {'_k': {'dir': 'generic', 'kernel': 'zger.c'}}},
'z': {'exts': {'_k': {'dir': 'generic', 'kernel': 'zger.c'}}},
'c': {'exts': {'_k': {'dir': 'generic', 'kernel': 'zger.c', 'addl': ['-UDOUBLE', '-DCOMPLEX', '-DCONJ']}}},
'z': {'exts': {'_k': {'dir': 'generic', 'kernel': 'zger.c', 'addl': ['-DDOUBLE', '-DCOMPLEX', '-DCONJ']}}},
# 'x': {'exts': {'_k': {'dir': 'generic', 'kernel': 'zger.c'}}},
},
},
{ 'base': '?gerv',
'modes': {
'c': {'exts': {'_k': {'dir': 'generic', 'kernel': 'zger.c', 'addl': ['-UDOUBLE', '-DCOMPLEX', '-UCONJ', '-DXCONJ']}}},
'z': {'exts': {'_k': {'dir': 'generic', 'kernel': 'zger.c', 'addl': ['-DDOUBLE', '-DCOMPLEX', '-UCONJ', '-DXCONJ']}}},
},
},
{ 'base': '?hemv',
'modes': {
'c': {

View File

@ -553,5 +553,6 @@ pkg.generate(_openblas,
if build_testing
subdir('test')
subdir('ctest')
subdir('utest')
endif