diff options
author | unknown <vid512@gmail.com> | 2024-09-05 23:39:49 +0200 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2024-09-21 08:17:41 -0700 |
commit | 63cea2ae221a7134a71747a3813135ceb14c0a4b (patch) | |
tree | 199b549783a05d8cb38d8b858d35cf33d66b8ab5 | |
parent | 527752a58874cd82f87f3122efae9300dabe173f (diff) | |
download | meson-63cea2ae221a7134a71747a3813135ceb14c0a4b.zip meson-63cea2ae221a7134a71747a3813135ceb14c0a4b.tar.gz meson-63cea2ae221a7134a71747a3813135ceb14c0a4b.tar.bz2 |
add test cases
-rw-r--r-- | test cases/windows/23 diasdk/dia_registered.cpp | 30 | ||||
-rw-r--r-- | test cases/windows/23 diasdk/meson.build | 13 | ||||
-rw-r--r-- | test cases/windows/24 diasdk copy dll/config.h.in | 3 | ||||
-rw-r--r-- | test cases/windows/24 diasdk copy dll/dia_from_dll.cpp | 32 | ||||
-rw-r--r-- | test cases/windows/24 diasdk copy dll/meson.build | 21 |
5 files changed, 99 insertions, 0 deletions
diff --git a/test cases/windows/23 diasdk/dia_registered.cpp b/test cases/windows/23 diasdk/dia_registered.cpp new file mode 100644 index 0000000..cec4fb2 --- /dev/null +++ b/test cases/windows/23 diasdk/dia_registered.cpp @@ -0,0 +1,30 @@ +// Loads DIA SDK from system registry using CoCreateInstance(). +// The corresponding msdiaXXX.dll must be registered in system registry +// (eg. run `regsvr32.exe msdia140.dll` as administrator) + +#include <dia2.h> +#include <windows.h> +#include <stdexcept> +#include <iostream> + +int main() +{ + try { + + HRESULT hr = CoInitialize(NULL); + if (FAILED(hr)) + throw std::runtime_error("Failed to initialize COM library"); + + IDiaDataSource* datasrc; + hr = CoCreateInstance( CLSID_DiaSource, NULL, CLSCTX_INPROC_SERVER, __uuidof(IDiaDataSource), (void **)&datasrc); + if (FAILED(hr)) + throw std::runtime_error("Can't create IDiaDataSource. You must register msdia*.dll with regsvr32.exe."); + + std::cout << "DIA was successfully loaded\n"; + return 0; + + } catch (std::exception& err) { + std::cerr << err.what() << std::endl; + return 1; + } +} diff --git a/test cases/windows/23 diasdk/meson.build b/test cases/windows/23 diasdk/meson.build new file mode 100644 index 0000000..bb84778 --- /dev/null +++ b/test cases/windows/23 diasdk/meson.build @@ -0,0 +1,13 @@ +project('diatest', 'cpp') + +if host_machine.system() != 'windows' + error('MESON_SKIP_TEST: unsupported platform') +endif +cpp = meson.get_compiler('cpp', native: false) +is_msvc_clang = cpp.get_id() == 'clang' and cpp.get_define('_MSC_VER') != '' +if not ['msvc', 'clang-cl'].contains(cpp.get_id()) and not is_msvc_clang + error('MESON_SKIP_TEST: unsupported compiler') +endif + +dia = dependency('diasdk', required: true) +executable('dia_registered', ['dia_registered.cpp'], dependencies:[dia]) diff --git a/test cases/windows/24 diasdk copy dll/config.h.in b/test cases/windows/24 diasdk copy dll/config.h.in new file mode 100644 index 0000000..80d59c1 --- /dev/null +++ b/test cases/windows/24 diasdk copy dll/config.h.in @@ -0,0 +1,3 @@ +#pragma once + +#define MSDIA_DLL_NAME L"@msdia_dll_name@" diff --git a/test cases/windows/24 diasdk copy dll/dia_from_dll.cpp b/test cases/windows/24 diasdk copy dll/dia_from_dll.cpp new file mode 100644 index 0000000..5474717 --- /dev/null +++ b/test cases/windows/24 diasdk copy dll/dia_from_dll.cpp @@ -0,0 +1,32 @@ +// Loads msdiaXXX.dll from current directory using NoRegCoCreate. +// File name is set in config.h symbol MSDIA_DLL_NAME. + +#include <dia2.h> +#include <diacreate.h> +#include <windows.h> +#include <stdexcept> +#include <iostream> + +#include "config.h" + +int main() +{ + try { + + HRESULT hr = CoInitialize(NULL); + if (FAILED(hr)) + throw std::runtime_error("Failed to initialize COM library"); + + IDiaDataSource* datasrc; + hr = NoRegCoCreate(MSDIA_DLL_NAME, CLSID_DiaSource, __uuidof(IDiaDataSource), (void**)&datasrc); + if (FAILED(hr)) + throw std::runtime_error("Can't open DIA DLL"); + + std::cout << "DIA was successfully loaded\n"; + return 0; + + } catch (std::exception& err) { + std::cerr << err.what() << std::endl; + return 1; + } +} diff --git a/test cases/windows/24 diasdk copy dll/meson.build b/test cases/windows/24 diasdk copy dll/meson.build new file mode 100644 index 0000000..1a078b0 --- /dev/null +++ b/test cases/windows/24 diasdk copy dll/meson.build @@ -0,0 +1,21 @@ +project('diatest', 'cpp') + +if host_machine.system() != 'windows' + error('MESON_SKIP_TEST: unsupported platform') +endif +cpp = meson.get_compiler('cpp', native: false) +is_msvc_clang = cpp.get_id() == 'clang' and cpp.get_define('_MSC_VER') != '' +if not ['msvc', 'clang-cl'].contains(cpp.get_id()) and not is_msvc_clang + error('MESON_SKIP_TEST: unsupported compiler') +endif + +dia = dependency('diasdk', required: true) +dia_dll_name = dia.get_variable('dll') +fs = import('fs') +fs.copyfile( dia_dll_name ) + +conf = configuration_data() +conf.set('msdia_dll_name', fs.name(dia_dll_name)) +configure_file(input: 'config.h.in', output: 'config.h', configuration: conf) + +executable('dia_from_dll', ['dia_from_dll.cpp'], dependencies: [dia]) |