From a7bcac6a7ffd05784e46aa3368ec50fd31754b92 Mon Sep 17 00:00:00 2001 From: Andreas Fuchs Date: Thu, 29 Mar 2018 10:13:06 +0200 Subject: [PATCH] Build: Add meson build system This adds meson build files. Signed-off-by: Andreas Fuchs --- .travis.yml | 42 +++++-- INSTALL.md | 15 +++ meson.build | 259 +++++++++++++++++++++++++++++++++++++++++ meson_options.txt | 12 ++ src/meson.build | 291 ++++++++++++++++++++++++++++++++++++++++++++++ test/meson.build | 177 ++++++++++++++++++++++++++++ 6 files changed, 786 insertions(+), 10 deletions(-) create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 src/meson.build create mode 100644 test/meson.build diff --git a/.travis.yml b/.travis.yml index 7c5a67e1f7..9d91abd53e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,17 +7,21 @@ sudo: false dist: trusty env: + matrix: + - MESON=false + - MESON=true global: - # COVERITY_SCAN_TOKEN - - secure: "ZD0KxBhO/CaSE/TOkW+H5nsBbaMolbIPv5DgctcjA1BlTckgc5lK4m+7BIR1Fft6gaeeLOoCY3qUm4kW++Bqk2bTsrx/HvrmVmrzMO572jA74x4E+5lynUnRVaAgBg7cVBcB0hZcUurx8FifNBbgnWlxT/nDWttVnglkz400GCE9/zy+VTJWqt4QAB+6qeKPiG3vRthQdWcHstBI8IIAbvp4rhSUajBBQeZ5ro5RPGNy+iHen+t6tyJmbjiP0Y4qjkKGbfwXHnsseEcuSJQuxSkQ9MWK6t93BFXFSPw5MjHIApMn+4CjRp2JMoVTVfe5fFeZEHxVUmAzy+e5eIeftrUtUlCI293UuxZnw/vpJczn3BWunlhhjqjsCwVeknzGHxlaT+ck8Et1Mdl/3nY/E9dt47/NOzXY2xrAz59GYsdKvvsPoCGgNlAub03Vl0W24I1kjppsmN/zFwazHGqoxIBTwrDOQUmZvPfXA3jAUozrfAdT3YjnRcCG7bbQmacFApqfUm/bqMgapAgozjjxpuBrO1wQSUjjH6NANZsP2Gpk0eAl7FOlBzbVgKPxCQozWCjpKOj3HMnXX458ZQWsboG5J00wwjw9DRNRCkeexLdi832L/BPhUY5JgRlTqqyKr9cr69DvogBF/pLytpSCciF6t9NqqGZYbBomXJLaG84=" - # COVERALLS_REPO_TOKEN - - secure: "BJUO7GJjP+WgMgSwTTteuc2KKum7Na++92pCLDa3hAzwZZ2OA+MbR9Zd25Yp0kT1K7bIPGDVdg0RksMI9P+Lbun3pajqLWfJpXrAF5IywllQx7bT4x1KeJridJeDnHZVSobTn4oAaGl5JrtpGgXAOjzpgLl1ljP0STyZUF+kC4RSK4Wt2DdT2acj5B8PT6cqR3btfStWgWKlm8t2nOFDGxTCbI4YIwcfgFhOG/ATx7Uc/z08MBI3z7lezy0nBt1/o2gDPZVb4Pa5A390P6Gv0g6mFu1te+P2IFmrWR6mF2Jh5GiJFWR7935rX5d2HxCkCNO7uEmncM4WeDk5PE9+TIcg7T2d9G1JR762aLMvNtUcmlfa6JX/EvveZK47ThwAictwvlD3tgfDy1E7Wdb1O6PtLsUIXRx50UocqBMeSQvOfR1330FuF/td9VGNFqxKW0wDWVIyl8QMK+p7t0aE+2py2Hb3IYVQEk98aWnffvEFeYfNPBywOiVD7trsTFEXKusVypAWDF3kvOmNuetL6ADfPnIfzvPw6DxQzwsxPUo0ahM2C2pzY/MavSlDM8+Q/EZiLkw9g39IgxjDsExD2EEu8U9jyz8iSmbKsrK6Z4L3BWO6a0gFakBAfWR1Rsb15UfVPYlJgPwtAdbgQ65ElgVeyTdkDCuE64iby2nZeP4=" - # run coverity scan on gcc build to keep from DOSing coverity - - coverity_scan_run_condition='"$CC" = gcc' - - PKG_CONFIG_PATH="$(pwd)/cmocka/lib/pkgconfig:/usr/lib/pkgconfig" - - LD_LIBRARY_PATH="$(pwd)/cmocka/lib:/usr/lib" - - CMOCKA_CFLAGS="-I$(pwd)/cmocka/include -I/usr/include" - - CMOCKA_LIBS="-L$(pwd)/cmocka/lib -lcmocka" + # COVERITY_SCAN_TOKEN + - secure: "ZD0KxBhO/CaSE/TOkW+H5nsBbaMolbIPv5DgctcjA1BlTckgc5lK4m+7BIR1Fft6gaeeLOoCY3qUm4kW++Bqk2bTsrx/HvrmVmrzMO572jA74x4E+5lynUnRVaAgBg7cVBcB0hZcUurx8FifNBbgnWlxT/nDWttVnglkz400GCE9/zy+VTJWqt4QAB+6qeKPiG3vRthQdWcHstBI8IIAbvp4rhSUajBBQeZ5ro5RPGNy+iHen+t6tyJmbjiP0Y4qjkKGbfwXHnsseEcuSJQuxSkQ9MWK6t93BFXFSPw5MjHIApMn+4CjRp2JMoVTVfe5fFeZEHxVUmAzy+e5eIeftrUtUlCI293UuxZnw/vpJczn3BWunlhhjqjsCwVeknzGHxlaT+ck8Et1Mdl/3nY/E9dt47/NOzXY2xrAz59GYsdKvvsPoCGgNlAub03Vl0W24I1kjppsmN/zFwazHGqoxIBTwrDOQUmZvPfXA3jAUozrfAdT3YjnRcCG7bbQmacFApqfUm/bqMgapAgozjjxpuBrO1wQSUjjH6NANZsP2Gpk0eAl7FOlBzbVgKPxCQozWCjpKOj3HMnXX458ZQWsboG5J00wwjw9DRNRCkeexLdi832L/BPhUY5JgRlTqqyKr9cr69DvogBF/pLytpSCciF6t9NqqGZYbBomXJLaG84=" + # COVERALLS_REPO_TOKEN + - secure: "BJUO7GJjP+WgMgSwTTteuc2KKum7Na++92pCLDa3hAzwZZ2OA+MbR9Zd25Yp0kT1K7bIPGDVdg0RksMI9P+Lbun3pajqLWfJpXrAF5IywllQx7bT4x1KeJridJeDnHZVSobTn4oAaGl5JrtpGgXAOjzpgLl1ljP0STyZUF+kC4RSK4Wt2DdT2acj5B8PT6cqR3btfStWgWKlm8t2nOFDGxTCbI4YIwcfgFhOG/ATx7Uc/z08MBI3z7lezy0nBt1/o2gDPZVb4Pa5A390P6Gv0g6mFu1te+P2IFmrWR6mF2Jh5GiJFWR7935rX5d2HxCkCNO7uEmncM4WeDk5PE9+TIcg7T2d9G1JR762aLMvNtUcmlfa6JX/EvveZK47ThwAictwvlD3tgfDy1E7Wdb1O6PtLsUIXRx50UocqBMeSQvOfR1330FuF/td9VGNFqxKW0wDWVIyl8QMK+p7t0aE+2py2Hb3IYVQEk98aWnffvEFeYfNPBywOiVD7trsTFEXKusVypAWDF3kvOmNuetL6ADfPnIfzvPw6DxQzwsxPUo0ahM2C2pzY/MavSlDM8+Q/EZiLkw9g39IgxjDsExD2EEu8U9jyz8iSmbKsrK6Z4L3BWO6a0gFakBAfWR1Rsb15UfVPYlJgPwtAdbgQ65ElgVeyTdkDCuE64iby2nZeP4=" + # run coverity scan on gcc build to keep from DOSing coverity + - coverity_scan_run_condition='"$CC" = gcc' + - PKG_CONFIG_PATH="$(pwd)/cmocka/lib/pkgconfig:/usr/lib/pkgconfig" + - LD_LIBRARY_PATH="$(pwd)/cmocka/lib:/usr/lib" + - CMOCKA_CFLAGS="-I$(pwd)/cmocka/include -I/usr/include" + - CMOCKA_LIBS="-L$(pwd)/cmocka/lib -lcmocka" + - PATH="$(pwd):$PATH" addons: apt: @@ -30,6 +34,7 @@ addons: - lcov - libssl-dev - uthash-dev + - python3-pip coverity_scan: project: name: "01org/TPM2.0-TSS" @@ -61,11 +66,28 @@ install: - tar xJf autoconf-archive-2017.09.28.tar.xz - cp autoconf-archive-2017.09.28/m4/ax_code_coverage.m4 m4/ - pip install --user cpp-coveralls +# Trusty's python version is 3.4.x. Meson 0.45++ require python 3.5++ + - pip3 install --user meson==0.44.1 +# Trusty's ninja is too old + - wget https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip + - sha256sum ninja-linux.zip | grep -q d2fea9ff33b3ef353161ed906f260d565ca55b8ca0568fa07b1d2cab90a84a07 + - unzip ninja-linux.zip before_script: - ./bootstrap script: +# if we are building with meson, only the next 5 lines are executed + - test "$MESON" != "true" || meson builddir -Dtests=true -Dsimulatorbin=$(pwd)/ibmtpm/src/tpm_server + - test "$MESON" != "true" || pushd builddir + - test "$MESON" != "true" || cat meson-logs/meson-log.txt + - test "$MESON" != "true" || meson configure + - test "$MESON" != "true" || ninja + - test "$MESON" != "true" || meson test --setup=sim + - test "$MESON" != "true" || cat meson-logs/testlog-int-log-compiler.sh.txt + - test "$MESON" != "true" || ninja dist || exit 1 + - test "$MESON" != "true" || popd + - test "$MESON" != "true" || exit 0 # short-circuit normal build if we've already done a coverity scan - | if [ "${COVERITY_SCAN_BRANCH}" == 1 ]; then diff --git a/INSTALL.md b/INSTALL.md index 083149674a..363b548c3d 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -123,6 +123,21 @@ $ docker rm temp tpm2-tss is now in your working directory and contains all the built files. +## Building with meson + +The project now contains initial meson.build files. These are currently +experimental but shall be actively supported in the future. +To build using meson, please run +``` +mkdir builddir installdir +meson builddir -Dtests=true -Dsimulatorbin=$PWD/../tpm_server +cd builddir +meson configure +ninja +meson test --setup=sim +ninja install +``` + ## Doxygen Documentation To build Doxygen documentation files, first install package Doxygen. diff --git a/meson.build b/meson.build new file mode 100644 index 0000000000..0550103367 --- /dev/null +++ b/meson.build @@ -0,0 +1,259 @@ +project('tpm2-tss', 'c', + version : '2.0.0-dev', + license : 'BSD 2-clause', + meson_version : '>= 0.41', + default_options : [ + 'c_std=c99', + 'werror=true', + 'b_lundef=true' + ] ) + +################################################################################ + +subdir('src') +subdir('test') + +################################################################################ + +tctidefault_c_args = [] +if get_option('tctidefaultmodule') != '' + tctidefault_c_args += [ '-DESYS_TCTI_DEFAULT_MODULE='+get_option('tctidefaultmodule') ] +endif +if get_option('tctidefaultconfig') != '' + tctidefault_c_args += [ '-DESYS_TCTI_DEFAULT_CONFIG='+get_option('tctidefaultconfig') ] +endif + +maxloglevel = get_option('maxloglevel').to_lower() +if maxloglevel == 'trace' + add_project_arguments('-DMAXLOGLEVEL=6', language : 'c') +elif maxloglevel == 'debug' + add_project_arguments('-DMAXLOGLEVEL=5', language : 'c') +elif maxloglevel == 'info' + add_project_arguments('-DMAXLOGLEVEL=4', language : 'c') +elif maxloglevel == 'warning' + add_project_arguments('-DMAXLOGLEVEL=3', language : 'c') +elif maxloglevel == 'error' + add_project_arguments('-DMAXLOGLEVEL=2', language : 'c') +elif maxloglevel == 'none' + add_project_arguments('-DMAXLOGLEVEL=0', language : 'c') +else + error('No maxloglevel set.') +endif + +################################################################################ + +cc = meson.get_compiler('c') +foreach arg : ['-Wall', + '-Wextra', + '-fstack-protector', + '-fstack-protector-strong', + '-fstack-protector-all', + '-fPIE' ] + if cc.has_argument(arg) + add_project_arguments(arg, language : 'c') + endif +endforeach + +add_project_arguments('-D_DEFAULT_SOURCE', + '-D_BSD_SOURCE', + '-D_POSIX_SOURCE', + language : 'c') + +################################################################################ + +libdl = cc.find_library('dl') +libgcrypt = cc.find_library('gcrypt') +liburiparser = dependency('liburiparser') +libcrypto = dependency('libcrypto') + +################################################################################ + +tss2_headers = files(''' + include/tss2/tss2_common.h + include/tss2/tss2_esys.h + include/tss2/tss2_mu.h + include/tss2/tss2_sys.h + include/tss2/tss2_tcti.h + include/tss2/tss2_tcti_device.h + include/tss2/tss2_tcti_mssim.h + include/tss2/tss2_tpm2_types.h'''.split()) + +install_headers(tss2_headers, subdir: 'tss2') + +################################################################################ + +incdirs = include_directories('include/tss2', 'src', 'src/util') + +libutil = static_library('util', util_sources, + include_directories : incdirs, install : false) + +libmu = shared_library('tss2-mu', mu_sources, + include_directories : incdirs, + link_whole : libutil, + install : true) + +libdevice = shared_library('tss2-tcti-device', device_sources, + include_directories : incdirs, + link_with : libmu, + install : true) + +libmssim = shared_library('tss2-tcti-mssim', mssim_sources, + include_directories : incdirs, + link_with : libmu, + dependencies : liburiparser, + install : true) + +libsys = shared_library('tss2-sys', sys_sources, + include_directories : [ incdirs, + include_directories('src/tss2-sys') ], + link_with : libmu, + install : true) + +libesys = shared_library('tss2-esys', esys_sources, + include_directories : [ incdirs, + include_directories('src/tss2-sys', + 'src/tss2-esys') ], + c_args: tctidefault_c_args, + link_with : [ libdevice, libmssim, libmu, libsys ], + dependencies : [ libgcrypt, libdl ], + install : true) + +################################################################################ + +docdir = join_paths(get_option('datadir'), 'doc', meson.project_name()) + +install_data('CHANGELOG.md', + 'CONTRIBUTING.md', + 'INSTALL.md', + 'README.md', + 'RELEASE.md', + 'LICENSE', + 'MAINTAINERS', + 'doc/archandlayout.md', + 'doc/arch.md', + 'doc/coding_standard_c.md', + 'doc/logging.md', + 'doc/TSS block diagram.png', + install_dir : docdir) + +cdata = configuration_data() +cdata.set('VERSION', meson.project_version()) +cdata.set('PACKAGE_NAME', meson.project_name()) +cdata.set('TOP_SRCDIR', meson.source_root()) +cdata.set('TOP_BUILDDIR', meson.build_root()) + +man_pages = [] +foreach m: ['tss2-tcti-device.7', + 'Tss2_Tcti_Device_Init.3', + 'tss2-tcti-mssim.7', + 'Tss2_Tcti_Mssim_Init.3'] + man_pages += configure_file(input: 'man/'+m+'.in', + output: m, + configuration: cdata) +endforeach + +man = custom_target('man', + output : 'man', + input : man_pages, + command : ['echo']) + +if get_option('doxygen-docs') + doxygen = find_program('doxygen', required : false) + + doxyfile = configure_file(input: 'doc/Doxyfile.in', + output: 'Doxyfile', + configuration: cdata, + install: false) + + html_target = custom_target('doxygen-docs', + build_always: true, + input: doxyfile, + output: 'html', + command: [doxygen, doxyfile], + install: true, + install_dir: docdir) +endif + +################################################################################ + +if get_option('tests') + +cmocka = dependency('cmocka') +libuthash = cc.find_library('ut') + +test_c_args = [ '-Wno-unused-parameter', + '-Wno-missing-field-initializers', + '-Wno-missing-braces' ] + +libtestutil = static_library('testutil', testutil_sources, + include_directories : [ incdirs, + include_directories('src/tss2-sys', + 'src/tss2-esys') ], + c_args : test_c_args, + link_with : [ libdevice, libmssim, libmu, libsys ], + dependencies: [ libcrypto ]) + +foreach t: tests_unit +test(t[0], executable(t[0].underscorify(), + [ t[0]+'.c' ] + t[1], + include_directories : [ incdirs, + include_directories('src/tss2-sys'), + include_directories('src/tss2-esys') ], + c_args : t[2] + test_c_args, + link_with : [ libmu, libsys, libesys, libdevice, libmssim ], + link_whole : [ libutil, libtestutil ], + link_args : t[3], + dependencies: [ cmocka, liburiparser ] )) +endforeach + +testhelperstartup = executable('test/helper/tpm_startup', + 'test/helper/tpm_startup.c', + include_directories : [ incdirs, + include_directories('src/tss2-sys'), + include_directories('test/integration') ], + c_args: test_c_args, + link_with : [ libmu, libsys, libmssim ], + link_whole : [ libutil, libtestutil ], + dependencies: [ cmocka, liburiparser ] ) + +testhelperstartup = executable('test/helper/tpm_transientempty', + 'test/helper/tpm_transientempty.c', + include_directories : [ incdirs, + include_directories('src/tss2-sys'), + include_directories('test/integration') ], + c_args: test_c_args, + link_with : [ libmu, libsys, libmssim ], + link_whole : [ libutil, libtestutil ], + dependencies: [ cmocka, liburiparser ] ) + +testharness = find_program('script/int-log-compiler.sh') + +simulatorbin = get_option('simulatorbin') +if simulatorbin != '' + tpmsim = find_program(simulatorbin) + add_test_setup('sim', + exe_wrapper: [ testharness, '--simulator-bin='+tpmsim.path() ]) +endif + +foreach t: tests_integration + tsrc = t[1] + if (t[1] == []) + tsrc += [ t[0]+'.c' ] + if (t[0].startswith('test/integration/esys-')) + tsrc += ['test/integration/main-esapi.c'] + elif (t[0].startswith('test/integration/')) + tsrc += ['test/integration/main.c'] + endif + endif + test(t[0], executable(t[0].underscorify(), tsrc, + include_directories : [ incdirs, + include_directories('src/tss2-sys'), + include_directories('src/tss2-esys') ], + c_args : t[2] + test_c_args, + link_with : [ libmu, libsys, libesys, libdevice, libmssim ], + link_whole : [ libutil, libtestutil ], + link_args : t[3], + dependencies: [ libcrypto, libuthash ] ) ) +endforeach + +endif #tests diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000000..bb1abb0651 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,12 @@ +option('tctidefaultmodule', type : 'string', value : '', + description : 'The default TCTI module for ESAPI.') +option('tctidefaultconfig', type : 'string', value : '', + description : 'The default tcti modules configuration.') +option('maxloglevel', type : 'string', value : 'trace', + description : 'sets the maximum log level (trace, debug, info, warning, error or none).') +option('tests', type : 'boolean', value : false, + description : 'Enable compilation of tests.') +option('simulatorbin', type : 'string', value : '', + description : 'Set the simulator executable for tests (use meson test --setup=sim).') +option('doxygen-docs', type : 'boolean', value : false, + description : 'Enable doxygen documentation.') diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000000..29b2289e97 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,291 @@ +util_sources = files(''' + util/io.c + util/log.c + util/io.h + util/log.h + util/tpm2b.h + util/tss2_endian.h +'''.split()) + +mu_sources = files(''' + tss2-mu/base-types.c + tss2-mu/tpm2b-types.c + tss2-mu/tpma-types.c + tss2-mu/tpml-types.c + tss2-mu/tpms-types.c + tss2-mu/tpmt-types.c + tss2-mu/tpmu-types.c +'''.split()) + +device_sources = files(['tss2-tcti/tcti-device.c', + 'tss2-tcti/tcti-device.h', + 'tss2-tcti/tcti-common.c', + 'tss2-tcti/tcti-common.h']) + +mssim_sources = files(['tss2-tcti/tcti-mssim.c', + 'tss2-tcti/tcti-mssim.h', + 'tss2-tcti/tcti-common.c', + 'tss2-tcti/tcti-common.h']) + +sys_sources = files(''' + tss2-sys/api/Tss2_Sys_AC_GetCapability.c + tss2-sys/api/Tss2_Sys_AC_Send.c + tss2-sys/api/Tss2_Sys_ActivateCredential.c + tss2-sys/api/Tss2_Sys_Certify.c + tss2-sys/api/Tss2_Sys_CertifyCreation.c + tss2-sys/api/Tss2_Sys_ChangeEPS.c + tss2-sys/api/Tss2_Sys_ChangePPS.c + tss2-sys/api/Tss2_Sys_Clear.c + tss2-sys/api/Tss2_Sys_ClearControl.c + tss2-sys/api/Tss2_Sys_ClockRateAdjust.c + tss2-sys/api/Tss2_Sys_ClockSet.c + tss2-sys/api/Tss2_Sys_Commit.c + tss2-sys/api/Tss2_Sys_ContextLoad.c + tss2-sys/api/Tss2_Sys_ContextSave.c + tss2-sys/api/Tss2_Sys_Create.c + tss2-sys/api/Tss2_Sys_CreateLoaded.c + tss2-sys/api/Tss2_Sys_CreatePrimary.c + tss2-sys/api/Tss2_Sys_DictionaryAttackLockReset.c + tss2-sys/api/Tss2_Sys_DictionaryAttackParameters.c + tss2-sys/api/Tss2_Sys_Duplicate.c + tss2-sys/api/Tss2_Sys_ECC_Parameters.c + tss2-sys/api/Tss2_Sys_ECDH_KeyGen.c + tss2-sys/api/Tss2_Sys_ECDH_ZGen.c + tss2-sys/api/Tss2_Sys_EC_Ephemeral.c + tss2-sys/api/Tss2_Sys_EncryptDecrypt.c + tss2-sys/api/Tss2_Sys_EncryptDecrypt2.c + tss2-sys/api/Tss2_Sys_EventSequenceComplete.c + tss2-sys/api/Tss2_Sys_EvictControl.c + tss2-sys/api/Tss2_Sys_Execute.c + tss2-sys/api/Tss2_Sys_FieldUpgradeData.c + tss2-sys/api/Tss2_Sys_FieldUpgradeStart.c + tss2-sys/api/Tss2_Sys_Finalize.c + tss2-sys/api/Tss2_Sys_FirmwareRead.c + tss2-sys/api/Tss2_Sys_FlushContext.c + tss2-sys/api/Tss2_Sys_GetCapability.c + tss2-sys/api/Tss2_Sys_GetCommandAuditDigest.c + tss2-sys/api/Tss2_Sys_GetCommandCode.c + tss2-sys/api/Tss2_Sys_GetContextSize.c + tss2-sys/api/Tss2_Sys_GetCpBuffer.c + tss2-sys/api/Tss2_Sys_GetDecryptParam.c + tss2-sys/api/Tss2_Sys_GetEncryptParam.c + tss2-sys/api/Tss2_Sys_GetRandom.c + tss2-sys/api/Tss2_Sys_GetRpBuffer.c + tss2-sys/api/Tss2_Sys_GetRspAuths.c + tss2-sys/api/Tss2_Sys_GetSessionAuditDigest.c + tss2-sys/api/Tss2_Sys_GetTctiContext.c + tss2-sys/api/Tss2_Sys_GetTestResult.c + tss2-sys/api/Tss2_Sys_GetTime.c + tss2-sys/api/Tss2_Sys_HMAC.c + tss2-sys/api/Tss2_Sys_HMAC_Start.c + tss2-sys/api/Tss2_Sys_Hash.c + tss2-sys/api/Tss2_Sys_HashSequenceStart.c + tss2-sys/api/Tss2_Sys_HierarchyChangeAuth.c + tss2-sys/api/Tss2_Sys_HierarchyControl.c + tss2-sys/api/Tss2_Sys_Import.c + tss2-sys/api/Tss2_Sys_IncrementalSelfTest.c + tss2-sys/api/Tss2_Sys_Initialize.c + tss2-sys/api/Tss2_Sys_Load.c + tss2-sys/api/Tss2_Sys_LoadExternal.c + tss2-sys/api/Tss2_Sys_MakeCredential.c + tss2-sys/api/Tss2_Sys_NV_Certify.c + tss2-sys/api/Tss2_Sys_NV_ChangeAuth.c + tss2-sys/api/Tss2_Sys_NV_DefineSpace.c + tss2-sys/api/Tss2_Sys_NV_Extend.c + tss2-sys/api/Tss2_Sys_NV_GlobalWriteLock.c + tss2-sys/api/Tss2_Sys_NV_Increment.c + tss2-sys/api/Tss2_Sys_NV_Read.c + tss2-sys/api/Tss2_Sys_NV_ReadLock.c + tss2-sys/api/Tss2_Sys_NV_ReadPublic.c + tss2-sys/api/Tss2_Sys_NV_SetBits.c + tss2-sys/api/Tss2_Sys_NV_UndefineSpace.c + tss2-sys/api/Tss2_Sys_NV_UndefineSpaceSpecial.c + tss2-sys/api/Tss2_Sys_NV_Write.c + tss2-sys/api/Tss2_Sys_NV_WriteLock.c + tss2-sys/api/Tss2_Sys_ObjectChangeAuth.c + tss2-sys/api/Tss2_Sys_PCR_Allocate.c + tss2-sys/api/Tss2_Sys_PCR_Event.c + tss2-sys/api/Tss2_Sys_PCR_Extend.c + tss2-sys/api/Tss2_Sys_PCR_Read.c + tss2-sys/api/Tss2_Sys_PCR_Reset.c + tss2-sys/api/Tss2_Sys_PCR_SetAuthPolicy.c + tss2-sys/api/Tss2_Sys_PCR_SetAuthValue.c + tss2-sys/api/Tss2_Sys_PP_Commands.c + tss2-sys/api/Tss2_Sys_PolicyAuthValue.c + tss2-sys/api/Tss2_Sys_PolicyAuthorize.c + tss2-sys/api/Tss2_Sys_PolicyAuthorizeNV.c + tss2-sys/api/Tss2_Sys_PolicyCommandCode.c + tss2-sys/api/Tss2_Sys_PolicyCounterTimer.c + tss2-sys/api/Tss2_Sys_PolicyCpHash.c + tss2-sys/api/Tss2_Sys_PolicyDuplicationSelect.c + tss2-sys/api/Tss2_Sys_PolicyGetDigest.c + tss2-sys/api/Tss2_Sys_PolicyLocality.c + tss2-sys/api/Tss2_Sys_PolicyNV.c + tss2-sys/api/Tss2_Sys_PolicyNameHash.c + tss2-sys/api/Tss2_Sys_PolicyNvWritten.c + tss2-sys/api/Tss2_Sys_PolicyOR.c + tss2-sys/api/Tss2_Sys_PolicyPCR.c + tss2-sys/api/Tss2_Sys_PolicyPassword.c + tss2-sys/api/Tss2_Sys_PolicyPhysicalPresence.c + tss2-sys/api/Tss2_Sys_PolicyRestart.c + tss2-sys/api/Tss2_Sys_PolicySecret.c + tss2-sys/api/Tss2_Sys_PolicySigned.c + tss2-sys/api/Tss2_Sys_PolicyTemplate.c + tss2-sys/api/Tss2_Sys_PolicyTicket.c + tss2-sys/api/Tss2_Sys_Policy_AC_SendSelect.c + tss2-sys/api/Tss2_Sys_Quote.c + tss2-sys/api/Tss2_Sys_RSA_Decrypt.c + tss2-sys/api/Tss2_Sys_RSA_Encrypt.c + tss2-sys/api/Tss2_Sys_ReadClock.c + tss2-sys/api/Tss2_Sys_ReadPublic.c + tss2-sys/api/Tss2_Sys_Rewrap.c + tss2-sys/api/Tss2_Sys_SelfTest.c + tss2-sys/api/Tss2_Sys_SequenceComplete.c + tss2-sys/api/Tss2_Sys_SequenceUpdate.c + tss2-sys/api/Tss2_Sys_SetAlgorithmSet.c + tss2-sys/api/Tss2_Sys_SetCmdAuths.c + tss2-sys/api/Tss2_Sys_SetCommandCodeAuditStatus.c + tss2-sys/api/Tss2_Sys_SetDecryptParam.c + tss2-sys/api/Tss2_Sys_SetEncryptParam.c + tss2-sys/api/Tss2_Sys_SetPrimaryPolicy.c + tss2-sys/api/Tss2_Sys_Shutdown.c + tss2-sys/api/Tss2_Sys_Sign.c + tss2-sys/api/Tss2_Sys_StartAuthSession.c + tss2-sys/api/Tss2_Sys_Startup.c + tss2-sys/api/Tss2_Sys_StirRandom.c + tss2-sys/api/Tss2_Sys_TestParms.c + tss2-sys/api/Tss2_Sys_Unseal.c + tss2-sys/api/Tss2_Sys_Vendor_TCG_Test.c + tss2-sys/api/Tss2_Sys_VerifySignature.c + tss2-sys/api/Tss2_Sys_ZGen_2Phase.c + tss2-sys/sysapi_util.c + tss2-sys/sysapi_util.h +'''.split()) + +esys_sources = files(''' + tss2-esys/esys_crypto.h + tss2-esys/esys_int.h + tss2-esys/esys_iutil.h + tss2-esys/esys_mu.h + tss2-esys/esys_tcti_default.h + tss2-esys/esys_types.h + tss2-esys/api/Esys_ActivateCredential.c + tss2-esys/api/Esys_Certify.c + tss2-esys/api/Esys_CertifyCreation.c + tss2-esys/api/Esys_ChangeEPS.c + tss2-esys/api/Esys_ChangePPS.c + tss2-esys/api/Esys_Clear.c + tss2-esys/api/Esys_ClearControl.c + tss2-esys/api/Esys_ClockRateAdjust.c + tss2-esys/api/Esys_ClockSet.c + tss2-esys/api/Esys_Commit.c + tss2-esys/api/Esys_ContextLoad.c + tss2-esys/api/Esys_ContextSave.c + tss2-esys/api/Esys_Create.c + tss2-esys/api/Esys_CreateLoaded.c + tss2-esys/api/Esys_CreatePrimary.c + tss2-esys/api/Esys_DictionaryAttackLockReset.c + tss2-esys/api/Esys_DictionaryAttackParameters.c + tss2-esys/api/Esys_Duplicate.c + tss2-esys/api/Esys_ECC_Parameters.c + tss2-esys/api/Esys_ECDH_KeyGen.c + tss2-esys/api/Esys_ECDH_ZGen.c + tss2-esys/api/Esys_EC_Ephemeral.c + tss2-esys/api/Esys_EncryptDecrypt.c + tss2-esys/api/Esys_EncryptDecrypt2.c + tss2-esys/api/Esys_EventSequenceComplete.c + tss2-esys/api/Esys_EvictControl.c + tss2-esys/api/Esys_FieldUpgradeData.c + tss2-esys/api/Esys_FieldUpgradeStart.c + tss2-esys/api/Esys_FirmwareRead.c + tss2-esys/api/Esys_FlushContext.c + tss2-esys/api/Esys_GetCapability.c + tss2-esys/api/Esys_GetCommandAuditDigest.c + tss2-esys/api/Esys_GetRandom.c + tss2-esys/api/Esys_GetSessionAuditDigest.c + tss2-esys/api/Esys_GetTestResult.c + tss2-esys/api/Esys_GetTime.c + tss2-esys/api/Esys_HMAC.c + tss2-esys/api/Esys_HMAC_Start.c + tss2-esys/api/Esys_Hash.c + tss2-esys/api/Esys_HashSequenceStart.c + tss2-esys/api/Esys_HierarchyChangeAuth.c + tss2-esys/api/Esys_HierarchyControl.c + tss2-esys/api/Esys_Import.c + tss2-esys/api/Esys_IncrementalSelfTest.c + tss2-esys/api/Esys_Load.c + tss2-esys/api/Esys_LoadExternal.c + tss2-esys/api/Esys_MakeCredential.c + tss2-esys/api/Esys_NV_Certify.c + tss2-esys/api/Esys_NV_ChangeAuth.c + tss2-esys/api/Esys_NV_DefineSpace.c + tss2-esys/api/Esys_NV_Extend.c + tss2-esys/api/Esys_NV_GlobalWriteLock.c + tss2-esys/api/Esys_NV_Increment.c + tss2-esys/api/Esys_NV_Read.c + tss2-esys/api/Esys_NV_ReadLock.c + tss2-esys/api/Esys_NV_ReadPublic.c + tss2-esys/api/Esys_NV_SetBits.c + tss2-esys/api/Esys_NV_UndefineSpace.c + tss2-esys/api/Esys_NV_UndefineSpaceSpecial.c + tss2-esys/api/Esys_NV_Write.c + tss2-esys/api/Esys_NV_WriteLock.c + tss2-esys/api/Esys_ObjectChangeAuth.c + tss2-esys/api/Esys_PCR_Allocate.c + tss2-esys/api/Esys_PCR_Event.c + tss2-esys/api/Esys_PCR_Extend.c + tss2-esys/api/Esys_PCR_Read.c + tss2-esys/api/Esys_PCR_Reset.c + tss2-esys/api/Esys_PCR_SetAuthPolicy.c + tss2-esys/api/Esys_PCR_SetAuthValue.c + tss2-esys/api/Esys_PP_Commands.c + tss2-esys/api/Esys_PolicyAuthValue.c + tss2-esys/api/Esys_PolicyAuthorize.c + tss2-esys/api/Esys_PolicyAuthorizeNV.c + tss2-esys/api/Esys_PolicyCommandCode.c + tss2-esys/api/Esys_PolicyCounterTimer.c + tss2-esys/api/Esys_PolicyCpHash.c + tss2-esys/api/Esys_PolicyDuplicationSelect.c + tss2-esys/api/Esys_PolicyGetDigest.c + tss2-esys/api/Esys_PolicyLocality.c + tss2-esys/api/Esys_PolicyNV.c + tss2-esys/api/Esys_PolicyNameHash.c + tss2-esys/api/Esys_PolicyNvWritten.c + tss2-esys/api/Esys_PolicyOR.c + tss2-esys/api/Esys_PolicyPCR.c + tss2-esys/api/Esys_PolicyPassword.c + tss2-esys/api/Esys_PolicyPhysicalPresence.c + tss2-esys/api/Esys_PolicyRestart.c + tss2-esys/api/Esys_PolicySecret.c + tss2-esys/api/Esys_PolicySigned.c + tss2-esys/api/Esys_PolicyTemplate.c + tss2-esys/api/Esys_PolicyTicket.c + tss2-esys/api/Esys_Quote.c + tss2-esys/api/Esys_RSA_Decrypt.c + tss2-esys/api/Esys_RSA_Encrypt.c + tss2-esys/api/Esys_ReadClock.c + tss2-esys/api/Esys_ReadPublic.c + tss2-esys/api/Esys_Rewrap.c + tss2-esys/api/Esys_SelfTest.c + tss2-esys/api/Esys_SequenceComplete.c + tss2-esys/api/Esys_SequenceUpdate.c + tss2-esys/api/Esys_SetAlgorithmSet.c + tss2-esys/api/Esys_SetCommandCodeAuditStatus.c + tss2-esys/api/Esys_SetPrimaryPolicy.c + tss2-esys/api/Esys_Shutdown.c + tss2-esys/api/Esys_Sign.c + tss2-esys/api/Esys_StartAuthSession.c + tss2-esys/api/Esys_Startup.c + tss2-esys/api/Esys_StirRandom.c + tss2-esys/api/Esys_TestParms.c + tss2-esys/api/Esys_Unseal.c + tss2-esys/api/Esys_Vendor_TCG_Test.c + tss2-esys/api/Esys_VerifySignature.c + tss2-esys/api/Esys_ZGen_2Phase.c + tss2-esys/esys_context.c + tss2-esys/esys_crypto.c + tss2-esys/esys_iutil.c + tss2-esys/esys_mu.c + tss2-esys/esys_tcti_default.c + tss2-esys/esys_tr.c +'''.split()) diff --git a/test/meson.build b/test/meson.build new file mode 100644 index 0000000000..a09ac3bac2 --- /dev/null +++ b/test/meson.build @@ -0,0 +1,177 @@ +testutil_sources = files(''' + integration/context-util.c integration/context-util.h + integration/sapi-util.c integration/sapi-util.h + integration/session-util.c integration/session-util.h + integration/test-options.c integration/test-options.h + integration/entity-util.c integration/test.h'''.split()) + +# Structure is a list of quadruples as follows: +# Name, sources, c_args, link_args +# If sources is empty, then name + '.c' is used as sources +tests_unit = [ + [ 'test/unit/CommonPreparePrologue', [], [], [] ], + [ 'test/unit/CopyCommandHeader', [], [], [] ], + [ 'test/unit/GetNumHandles', [], [], [] ], + [ 'test/unit/UINT8-marshal', [], [], [] ], + [ 'test/unit/UINT16-marshal', [], [], [] ], + [ 'test/unit/UINT32-marshal', [], [], [] ], + [ 'test/unit/UINT64-marshal', [], [], [] ], + [ 'test/unit/TPMA-marshal', [], [], [] ], + [ 'test/unit/TPM2B-marshal', [], [], [] ], + [ 'test/unit/TPMS-marshal', [], [], [] ], + [ 'test/unit/TPML-marshal', [], [], [] ], + [ 'test/unit/TPMT-marshal', [], [], [] ], + [ 'test/unit/TPMU-marshal', [], [], [] ], + [ 'test/unit/esys-context-null', [], [], [] ], + [ 'test/unit/esys-resubmissions', [], [], [] ], + [ 'test/unit/esys-sequence-finish', [], [], [] ], + [ 'test/unit/io', [], [], + [ '-Wl,--wrap=connect', '-Wl,--wrap=socket', '-Wl,-wrap=read', + '-Wl,-wrap=write' ] ], + [ 'test/unit/tcti-device', + ['src/tss2-tcti/tcti-device.c', 'src/tss2-tcti/tcti-device.h', + 'src/tss2-tcti/tcti-common.c', 'src/tss2-tcti/tcti-common.h'], + [], + [ '-Wl,--wrap=read', '-Wl,-wrap=write' ] ], + [ 'test/unit/tcti-mssim', + [ 'src/tss2-tcti/tcti-mssim.c', 'src/tss2-tcti/tcti-mssim.h', + 'src/tss2-tcti/tcti-common.c','src/tss2-tcti/tcti-common.h' ], + [], + [ '-Wl,--wrap=connect', '-Wl,--wrap=read', + '-Wl,--wrap=select', '-Wl,-wrap=write' ] ], + [ 'test/unit/esys-default-tcti', + [ 'test/unit/esys-default-tcti.c', 'src/tss2-esys/esys_tcti_default.c', + 'src/tss2-esys/esys_tcti_default.h' ], + [], + [ '-Wl,--wrap=dlopen', '-Wl,-wrap=dlclose', '-Wl,-wrap=dlsym', + '-Wl,--wrap=Tss2_Tcti_Device_Init', + '-Wl,--wrap=Tss2_Tcti_Mssim_Init' ] ], + [ 'test/unit/esys-tcti-rcs', [], [], [] ], + [ 'test/unit/esys-tpm-rcs', [], [], [] ], +] + + +# Structure is a list of quadruples as follows: +# Name, sources, c_args, link_args +# If sources is empty, then name + '.c' is used as sources +tests_integration = [ + [ 'test/tpmclient/tpmclient.int', + [ 'test/tpmclient/DecryptEncrypt.c', 'test/integration/main.c', + 'test/tpmclient/tpmclient.int.c' ], [ '-U_FORTIFY_SOURCE' ], [] ], + [ 'test/integration/asymmetric-encrypt-decrypt.int', [], [], [] ], + [ 'test/integration/create-primary-rsa-2048-aes-128-cfb.int', [], [], [] ], + [ 'test/integration/create-keyedhash-sha1-hmac.int', [], [], [] ], + [ 'test/integration/encrypt-decrypt.int', [], [], [] ], + [ 'test/integration/encrypt-decrypt-2.int', [], [], [] ], + [ 'test/integration/evict-ctrl.int', [], [], [] ], + [ 'test/integration/get-random.int', [], [], [] ], + [ 'test/integration/hierarchy-change-auth.int', [], [], [] ], + [ 'test/integration/abi-version.int', [], [], [] ], + [ 'test/integration/pcr-extension.int', [], [], [] ], + [ 'test/integration/self-test.int', [], [], [] ], + [ 'test/integration/start-auth-session.int', [], [], [] ], + [ 'test/integration/sys-initialize.int', [], [], [] ], + [ 'test/integration/tpm-properties.int', [], [], [] ], + [ 'test/integration/system-api.int', [], [], [] ], + [ 'test/integration/policy-template.int', [], [], [] ], + [ 'test/integration/create-loaded.int', [], [], [] ], + [ 'test/integration/policy-authorizeNV.int', [], [], [] ], + [ 'test/integration/command-cancel.int', [], [], [] ], + + [ 'test/integration/esys-audit.int', [], [], [] ], + [ 'test/integration/esys-certify-creation.int', [], [], [] ], + [ 'test/integration/esys-certify.int', [], [], [] ], + [ 'test/integration/esys-change-eps.int', [], [], [] ], + [ 'test/integration/esys-clear-control.int', [], [], [] ], + [ 'test/integration/esys-clear.int', [], [], [] ], + [ 'test/integration/esys-clockset.int', [], [], [] ], + [ 'test/integration/esys-commit.int', [], [], [] ], + [ 'test/integration/esys-create-fail.int', [], [], [] ], + [ 'test/integration/esys-createloaded.int', [], [], [] ], + [ 'test/integration/esys-create-password-auth.int', [], [], [] ], + [ 'test/integration/esys-create-primary-hmac.int', [], [], [] ], + [ 'test/integration/esys-duplicate.int', [], [], [] ], + [ 'test/integration/esys-ecc-parameters.int', [], [], [] ], + [ 'test/integration/esys-ecdh-keygen.int', [], [], [] ], + [ 'test/integration/esys-ecdh-zgen.int', [], [], [] ], + [ 'test/integration/esys-encrypt-decrypt.int', [], [], [] ], + [ 'test/integration/esys-event-sequence-complete.int', [], [], [] ], + [ 'test/integration/esys-evict-control-serialization.int', [], [], [] ], + [ 'test/integration/esys-field-upgrade.int', [], [], [] ], + [ 'test/integration/esys-firmware-read.int', [], [], [] ], + [ 'test/integration/esys-get-capability.int', [], [], [] ], + [ 'test/integration/esys-get-random.int', [], [], [] ], + [ 'test/integration/esys-get-time.int', [], [], [] ], + [ 'test/integration/esys-hashsequencestart.int', [], [], [] ], + [ 'test/integration/esys-hierarchychangeauth.int', [], [], [] ], + [ 'test/integration/esys-hierarchy-control.int', [], [], [] ], + [ 'test/integration/esys-hmacsequencestart.int', [], [], [] ], + [ 'test/integration/esys-import.int', [], [], [] ], + [ 'test/integration/esys-lock.int', [], [], [] ], + [ 'test/integration/esys-make-credential.int', [], [], [] ], + [ 'test/integration/esys-nv-certify.int', [], [], [] ], + [ 'test/integration/esys-nv-ram-counter.int', [], [], [] ], + [ 'test/integration/esys-nv-ram-extend-index.int', [], [], [] ], + [ 'test/integration/esys-nv-ram-ordinary-index.int', [], [], [] ], + [ 'test/integration/esys-nv-ram-set-bits.int', [], [], [] ], + [ 'test/integration/esys-object-changeauth.int', [], [], [] ], + [ 'test/integration/esys-pcr-auth-value.int', [], [], [] ], + [ 'test/integration/esys-pcr-basic.int', [], [], [] ], + [ 'test/integration/esys-policy-authorize.int', [], [], [] ], + [ 'test/integration/esys-policy-nv-changeauth.int', [], [], [] ], + [ 'test/integration/esys-policy-nv-undefine-special.int', [], [], [] ], + [ 'test/integration/esys-policy-password.int', [], [], [] ], + [ 'test/integration/esys-policy-regression.int', [], [], [] ], + [ 'test/integration/esys-policy-ticket.int', [], [], [] ], + [ 'test/integration/esys-pp-commands.int', [], [], [] ], + [ 'test/integration/esys-quote.int', [], [], [] ], + [ 'test/integration/esys-rsa-encrypt-decrypt.int', [], [], [] ], + [ 'test/integration/esys-save-and-load-context.int', [], [], [] ], + [ 'test/integration/esys-set-algorithm-set.int', [], [], [] ], + [ 'test/integration/esys-stir-random.int', [], [], [] ], + [ 'test/integration/esys-testparms.int', [], [], [] ], + [ 'test/integration/esys-tpm-tests.int', [], [], [] ], + [ 'test/integration/esys-tr-fromTpmPublic-key.int', [], [], [] ], + [ 'test/integration/esys-tr-fromTpmPublic-nv.int', [], [], [] ], + [ 'test/integration/esys-tr-getName-hierarchy.int', [], [], [] ], + [ 'test/integration/esys-unseal-password-auth.int', [], [], [] ], + [ 'test/integration/esys-verify-signature.int', [], [], [] ], + [ 'test/integration/esys-zgen-2phase.int', [], [], [] ], + + [ 'test/integration/esys-create-session-auth-param.int', + [ 'test/integration/esys-create-session-auth.int.c', + 'test/integration/main-esapi.c' ], ['-DTEST_AES_ENCRYPTION'], [] ], + [ 'test/integration/esys-create-session-auth-xor.int', + [ 'test/integration/esys-create-session-auth.int.c', + 'test/integration/main-esapi.c' ], ['-DTEST_XOR_OBFUSCATION'], [] ], + [ 'test/integration/esys-create-primary-ecc-hmac.int', + [ 'test/integration/esys-create-primary-hmac.int.c', + 'test/integration/main-esapi.c' ], [ '-DTEST_ECC' ], [] ], + [ 'test/integration/esys-clear-session.int', + [ 'test/integration/esys-clear.int.c', + 'test/integration/main-esapi.c' ], [ '-DTEST_SESSION' ], [] ], + [ 'test/integration/esys-clockset-session.int', + [ 'test/integration/esys-clockset.int.c', + 'test/integration/main-esapi.c' ], [ '-DTEST_SESSION' ], [] ], + [ 'test/integration/esys-createloaded-session.int', + [ 'test/integration/esys-createloaded.int.c', + 'test/integration/main-esapi.c' ], [ '-DTEST_SESSION' ], [] ], + [ 'test/integration/esys-hashsequencestart-session.int', + [ 'test/integration/esys-hashsequencestart.int.c', + 'test/integration/main-esapi.c' ], [ '-DTEST_SESSION' ], [] ], + [ 'test/integration/esys-hmacsequencestart-session.int', + [ 'test/integration/esys-hmacsequencestart.int.c', + 'test/integration/main-esapi.c' ], [ '-DTEST_SESSION' ], [] ], + [ 'test/integration/esys-make-credential-session.int', + [ 'test/integration/esys-make-credential.int.c', + 'test/integration/main-esapi.c' ], [ '-DTEST_SESSION' ], [] ], + [ 'test/integration/esys-nv-ram-counter-session.int', + [ 'test/integration/esys-nv-ram-counter.int.c', + 'test/integration/main-esapi.c' ], [ '-DTEST_SESSION' ], [] ], + [ 'test/integration/esys-nv-ram-extend-index-session.int', + [ 'test/integration/esys-nv-ram-extend-index.int.c', + 'test/integration/main-esapi.c' ], [ '-DTEST_SESSION' ], [] ], + [ 'test/integration/esys-nv-ram-set-bits-session.int', + [ 'test/integration/esys-nv-ram-set-bits.int.c', + 'test/integration/main-esapi.c' ], [ '-DTEST_SESSION' ], [] ], +]