add test cases

pull/13703/head
unknown 3 months ago committed by Dylan Baker
parent 527752a588
commit 63cea2ae22
  1. 30
      test cases/windows/23 diasdk/dia_registered.cpp
  2. 13
      test cases/windows/23 diasdk/meson.build
  3. 3
      test cases/windows/24 diasdk copy dll/config.h.in
  4. 32
      test cases/windows/24 diasdk copy dll/dia_from_dll.cpp
  5. 21
      test cases/windows/24 diasdk copy dll/meson.build

@ -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;
}
}

@ -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])

@ -0,0 +1,3 @@
#pragma once
#define MSDIA_DLL_NAME L"@msdia_dll_name@"

@ -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;
}
}

@ -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])
Loading…
Cancel
Save