Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
7515060
Update LLVM reference
CaseyCarter Jul 26, 2020
46f7b77
Merge branch 'master' of https://github.com/microsoft/STL into HEAD
cbezault Oct 16, 2020
d4ff68b
Avoid relying on upstream libcxx lit.cfg
cbezault Oct 16, 2020
f62ad74
Skip bogus failing tests
CaseyCarter Oct 19, 2020
7a859cd
Apply suggestions from code review
CaseyCarter Oct 19, 2020
777d49b
Update LLVM reference to latest
cbezault Oct 19, 2020
5d3ee9a
Update atomic_init per P0883R3
CaseyCarter Oct 19, 2020
e46a162
Update LLVM reference once again
CaseyCarter Oct 20, 2020
40b5aac
Fix mis-formatted line in expected_results.txt
CaseyCarter Oct 20, 2020
16c00b2
Fix bad separators in libcxx/expected_results
CaseyCarter Oct 20, 2020
c72c9fd
Let's rewrite the test harness
cbezault Oct 23, 2020
0a379b4
Fix merge conflicts
cbezault Oct 23, 2020
8b3708f
Get past file validation
cbezault Oct 23, 2020
352715d
That's what I get for not testing x86
cbezault Oct 23, 2020
9bb228a
Undo unwanted changes to submodules fixup tests which embed /c flag
cbezault Oct 23, 2020
428a2fc
resolve merge conflict
cbezault Oct 23, 2020
0b5cdaf
Resolves GH-1382
cbezault Oct 23, 2020
1843c30
Merge branch 'master' of https://github.com/Microsoft/STL
cbezault Oct 23, 2020
1d3cc67
cleanup the new custom format
cbezault Oct 23, 2020
d6eab20
Fix broken custom format
cbezault Oct 23, 2020
f5d374c
Respect tests getting marked as unsupported
cbezault Oct 23, 2020
c332008
Fix .fail tests
cbezault Oct 23, 2020
d0cb477
STL_EDG_DROP at least does something now + other cleanups
cbezault Oct 23, 2020
9f400b0
Make handling the intellisense response file its own step type
cbezault Oct 23, 2020
dd9a2a2
Make all compile-only tests compile only
cbezault Oct 23, 2020
331017e
Actually find tests with new suffix
cbezault Oct 23, 2020
74660fd
Update format.py
cbezault Oct 29, 2020
5116e2c
Merge with master
cbezault Oct 31, 2020
82e8f41
Merge branch 'master' of github.com:cbezault/STL
cbezault Oct 31, 2020
be7e4a4
Fix a bug that STL found
cbezault Nov 1, 2020
bad25da
Rebasing kernel harness on new test infrastructure
Nov 1, 2020
2fab494
Code review feedback.
StephanTLavavej Nov 2, 2020
73e08c6
Fix issue with expected results file. Integrate @ben-craig's suggestions
cbezault Nov 2, 2020
b91bb8b
It might be deprecated but pickling a tuple is faster than pickling a…
cbezault Nov 2, 2020
bf2381a
Resolve merge conflict
cbezault Nov 2, 2020
28f6864
clang format and some other small cleanups
cbezault Nov 2, 2020
54fa098
Update tests/utils/stl/test/format.py
cbezault Nov 3, 2020
0a7194c
Update tests/utils/stl/test/tests.py
cbezault Nov 3, 2020
25d73d5
Change `/analyze` to `/analyze:autolog-`.
StephanTLavavej Nov 3, 2020
691674b
Merge branch 'master' of github.com:cbezault/STL into kernel
cbezault Nov 3, 2020
2443db6
Light up kernel tests in CI
cbezault Nov 3, 2020
32377ab
clang-format
cbezault Nov 3, 2020
f0c62c3
Make validate happy
cbezault Nov 3, 2020
19b9294
Merge branch 'master' of https://github.com/Microsoft/STL
cbezault Nov 5, 2020
6887ca0
Get new test format to work with sharding
cbezault Nov 5, 2020
4d34a2d
Merge with origin changes
cbezault Nov 5, 2020
4e51118
Update tests/utils/stl/test/format.py
cbezault Nov 5, 2020
ac12e3c
Update tests/utils/stl/test/tests.py
cbezault Nov 5, 2020
7417354
We don't need to set this internal variable
cbezault Nov 5, 2020
227efe0
Update tests/utils/stl/test/tests.py
cbezault Nov 5, 2020
3725d6d
Update tests/utils/stl/test/tests.py
cbezault Nov 5, 2020
ad8a003
first kernel test
Nov 13, 2020
721cb3f
Point to the WDK
cbezault Dec 5, 2020
f7591e3
Merge master
cbezault Dec 5, 2020
51acb66
Fix line endings
cbezault Dec 5, 2020
5032e50
Merge pull request #10 from ben-craig/envlst2
cbezault Dec 5, 2020
4640507
clang-format
cbezault Dec 5, 2020
33319b4
Suppress 5040 in the WDK
cbezault Dec 5, 2020
dc58334
Make everything more verbose (maybe)
cbezault Dec 7, 2020
e910d81
Add a linking pragma
cbezault Dec 7, 2020
4f3b0fa
Handle calling convention differences
Dec 18, 2020
f041be3
Update tests.py
cbezault Dec 21, 2020
593f49a
Merge pull request #11 from ben-craig/kernel3
cbezault Dec 21, 2020
6f78416
clang-format
cbezault Dec 21, 2020
db798ef
Always compile kernel tests, but only run on amd64
Dec 23, 2020
3886633
Update format.py
cbezault Jan 4, 2021
bd9f7e4
Merge pull request #12 from ben-craig/kernel4
cbezault Jan 4, 2021
ba553ad
Update format.py
cbezault Jan 4, 2021
e31ce62
Merge branch 'main' into kernel
StephanTLavavej Feb 14, 2021
99e3d46
Define CMAKE_CXX_FLAGS and STL_IS_KERNEL on separate lines.
StephanTLavavej Feb 14, 2021
aca1692
Merge branch 'main' into local_kernel
ben-craig May 16, 2021
f44db64
STL review comments
ben-craig May 16, 2021
1454c77
Merge branch 'master' into kernel5
cbezault Jun 30, 2021
054d7fc
Merge pull request #13 from ben-craig/kernel5
cbezault Jun 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ if("${Boost_VERSION}" VERSION_LESS "${VCLIBS_MIN_BOOST_VERSION}")
endif()

option(BUILD_TESTING "Enable testing" ON)
option(STL_IS_KERNEL "Enable kernel testing" OFF)
set(VCLIBS_SUFFIX "_oss" CACHE STRING "suffix for built DLL names to avoid conflicts with distributed DLLs")

if(NOT DEFINED VCLIBS_TARGET_ARCHITECTURE)
Expand Down
6 changes: 5 additions & 1 deletion azure-devops/cmake-configure-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ steps:
-DCMAKE_CXX_COMPILER=cl ^
-DCMAKE_BUILD_TYPE=Release ^
-DLIT_FLAGS=$(litFlags) ^
-DCMAKE_CXX_FLAGS=/analyze:autolog- ^
-DCMAKE_CXX_FLAGS="/analyze:autolog-" ^
-DSTL_IS_KERNEL=ON ^
-DWDK_INCLUDE_DIRECTORY="C:/Program Files (x86)/Windows Kits/10/Include/10.0.19041.0" ^
-DWDK_LIB_DIRECTORY="C:/Program Files (x86)/Windows Kits/10/Lib/10.0.19041.0" ^
-DWDK_BIN_DIRECTORY="C:/Program Files (x86)/Windows Kits/10/bin/10.0.19041.0" ^
-S $(Build.SourcesDirectory) -B $(${{ parameters.buildOutputLocationVar }})
displayName: 'Configure the STL'
timeoutInMinutes: 2
Expand Down
2 changes: 1 addition & 1 deletion azure-devops/cross-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
fixedFlags: '--timeout=240;--shuffle'
parallelismFlag: '-j$(testParallelism)'
xmlOutputFlag: '--xunit-xml-output=$(${{ parameters.buildOutputLocationVar }})/test-results.xml'
shardFlags: '--num-shards=$(System.TotalJobsInPhase);--run-shard=$(System.JobPositionInPhase)'
shardFlags: '-vv;--num-shards=$(System.TotalJobsInPhase);--run-shard=$(System.JobPositionInPhase)'
litFlags: '$(fixedFlags);$(parallelismFlag);$(xmlOutputFlag);$(shardFlags)'
strategy:
parallel: ${{ parameters.numShards }}
Expand Down
2 changes: 1 addition & 1 deletion azure-devops/native-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fixedFlags: '--timeout=240;--shuffle'
parallelismFlag: '-j$(testParallelism)'
xmlOutputFlag: '--xunit-xml-output=$(${{ parameters.buildOutputLocationVar }})/test-results.xml'
shardFlags: '--num-shards=$(System.TotalJobsInPhase);--run-shard=$(System.JobPositionInPhase)'
shardFlags: '-vv;--num-shards=$(System.TotalJobsInPhase);--run-shard=$(System.JobPositionInPhase)'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is -vv necessary/useful, or is it a relic of development?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this one is useful. Without this, CI failures tell you which tests failed, but give very little output from the failing test. But it's hard for me to verify that since this is in the CI machinery.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say this is useful since upstream broke our ability to write nice output to the xml test results.

litFlags: '$(fixedFlags);$(parallelismFlag);$(xmlOutputFlag);$(shardFlags)'
strategy:
parallel: ${{ parameters.numShards }}
Expand Down
153 changes: 153 additions & 0 deletions stl/inc/ranges
Original file line number Diff line number Diff line change
Expand Up @@ -2489,6 +2489,49 @@ namespace ranges {
};

inline constexpr _Drop_fn drop;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like some ranges changes snuck in by accident?

// VARIABLE views::counted
class _Counted_fn {
private:
enum class _St { _Span, _Subrange, _Subrange_counted };

template <class _It>
_NODISCARD static _CONSTEVAL _Choice_t<_St> _Choose() noexcept {
_STL_INTERNAL_STATIC_ASSERT(input_or_output_iterator<_It>);
if constexpr (contiguous_iterator<_It>) {
return {_St::_Span, noexcept(span{_STD to_address(_STD declval<_It>()), iter_difference_t<_It>{}})};
} else if constexpr (random_access_iterator<_It>) {
return {_St::_Subrange,
noexcept(subrange{_STD declval<_It>(), _STD declval<_It>() + iter_difference_t<_It>{}})};
} else {
return {_St::_Subrange_counted,
noexcept(subrange{
counted_iterator{_STD declval<_It>(), iter_difference_t<_It>{}}, default_sentinel})};
}
}

template <class _It>
static constexpr _Choice_t<_St> _Choice = _Choose<_It>();

public:
// clang-format off
template <class _It>
requires input_or_output_iterator<decay_t<_It>>
_NODISCARD constexpr auto operator()(_It&& _First, const iter_difference_t<decay_t<_It>> _Count) const
noexcept(_Choice<decay_t<_It>>._No_throw) {
// clang-format on
_STL_ASSERT(_Count >= 0, "The size passed to views::counted must be non-negative");
if constexpr (_Choice<decay_t<_It>>._Strategy == _St::_Span) {
return span{_STD to_address(_STD forward<_It>(_First)), static_cast<size_t>(_Count)};
} else if constexpr (_Choice<decay_t<_It>>._Strategy == _St::_Subrange) {
return subrange{_First, _First + _Count};
} else if constexpr (_Choice<decay_t<_It>>._Strategy == _St::_Subrange_counted) {
return subrange{counted_iterator{_STD forward<_It>(_First), _Count}, default_sentinel};
}
}
};

inline constexpr _Counted_fn counted;
} // namespace views

// CLASS TEMPLATE ranges::drop_while_view
Expand Down Expand Up @@ -4088,6 +4131,116 @@ namespace ranges {
inline constexpr auto keys = elements<0>;
inline constexpr auto values = elements<1>;
} // namespace views

// CLASS TEMPLATE ranges::common_view
// clang-format off
template <view _Vw>
requires (!common_range<_Vw> && copyable<iterator_t<_Vw>>)
class common_view : public view_interface<common_view<_Vw>> {
// clang-format on
private:
/* [[no_unique_address]] */ _Vw _Base{};

public:
common_view() = default;
constexpr explicit common_view(_Vw _Base_) noexcept(is_nothrow_move_constructible_v<_Vw>) // strengthened
: _Base(_STD move(_Base_)) {}
// converting constructor template omitted per LWG-3405

_NODISCARD constexpr _Vw base() const& noexcept(
is_nothrow_copy_constructible_v<_Vw>) /* strengthened */ requires copy_constructible<_Vw> {
return _Base;
}
_NODISCARD constexpr _Vw base() && noexcept(is_nothrow_move_constructible_v<_Vw>) /* strengthened */ {
return _STD move(_Base);
}

_NODISCARD constexpr auto begin() noexcept(
noexcept(_RANGES begin(_Base)) && is_nothrow_move_constructible_v<iterator_t<_Vw>>) /* strengthened */ {
if constexpr (random_access_range<_Vw> && sized_range<_Vw>) {
return _RANGES begin(_Base);
} else {
return common_iterator<iterator_t<_Vw>, sentinel_t<_Vw>>{_RANGES begin(_Base)};
}
}

_NODISCARD constexpr auto begin() const noexcept(
noexcept(_RANGES begin(_Base))
&& is_nothrow_move_constructible_v<iterator_t<const _Vw>>) /* strengthened */ requires range<const _Vw> {
if constexpr (random_access_range<const _Vw> && sized_range<const _Vw>) {
return _RANGES begin(_Base);
} else {
return common_iterator<iterator_t<const _Vw>, sentinel_t<const _Vw>>{_RANGES begin(_Base)};
}
}

_NODISCARD constexpr auto end() {
if constexpr (random_access_range<_Vw> && sized_range<_Vw>) {
return _RANGES begin(_Base) + _RANGES size(_Base);
} else {
return common_iterator<iterator_t<_Vw>, sentinel_t<_Vw>>{_RANGES end(_Base)};
}
}

_NODISCARD constexpr auto end() const requires range<const _Vw> {
if constexpr (random_access_range<const _Vw> && sized_range<const _Vw>) {
return _RANGES begin(_Base) + _RANGES size(_Base);
} else {
return common_iterator<iterator_t<const _Vw>, sentinel_t<const _Vw>>{_RANGES end(_Base)};
}
}

_NODISCARD constexpr auto size() noexcept(
noexcept(_RANGES size(_Base))) /* strengthened */ requires sized_range<_Vw> {
return _RANGES size(_Base);
}
_NODISCARD constexpr auto size() const
noexcept(noexcept(_RANGES size(_Base))) /* strengthened */ requires sized_range<const _Vw> {
return _RANGES size(_Base);
}
};

template <class _Rng>
common_view(_Rng &&) -> common_view<views::all_t<_Rng>>;

namespace views {
// VARIABLE views::common
class _Common_fn : public _Pipe::_Base<_Common_fn> {
private:
enum class _St { _None, _All, _Common };

template <class _Rng>
_NODISCARD static _CONSTEVAL _Choice_t<_St> _Choose() noexcept {
if constexpr (common_range<_Rng>) {
return {_St::_All, noexcept(views::all(_STD declval<_Rng>()))};
} else if constexpr (copyable<iterator_t<_Rng>>) {
return {_St::_Common, noexcept(common_view{_STD declval<_Rng>()})};
} else {
return {_St::_None};
}
}

template <class _Rng>
static constexpr _Choice_t<_St> _Choice = _Choose<_Rng>();

public:
// clang-format off
template <viewable_range _Rng>
requires (_Choice<_Rng>._Strategy != _St::_None)
_NODISCARD constexpr auto operator()(_Rng&& _Range) const noexcept(_Choice<_Rng>._No_throw) {
// clang-format on
if constexpr (_Choice<_Rng>._Strategy == _St::_All) {
return views::all(_STD forward<_Rng>(_Range));
} else if constexpr (_Choice<_Rng>._Strategy == _St::_Common) {
return common_view{_STD forward<_Rng>(_Range)};
} else {
static_assert(_Always_false<_Rng>, "Should be unreachable");
}
}
};

inline constexpr _Common_fn common;
} // namespace views
} // namespace ranges

namespace views = ranges::views;
Expand Down
3 changes: 3 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ option(TESTS_BUILD_ONLY "Only run the build steps of tests" OFF)
add_subdirectory(libcxx)
add_subdirectory(std)
add_subdirectory(tr1)
if(STL_IS_KERNEL)
add_subdirectory(utils/kernel)
endif()

# Add the stl-lit subdirectory last so all the test directories have had a
# chance to add to the config map and test directory global properties.
Expand Down
7 changes: 7 additions & 0 deletions tests/libcxx/lit.site.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ lit_config.cxx_runtime = '@CMAKE_RUNTIME_OUTPUT_DIRECTORY@'
lit_config.target_arch = '@VCLIBS_TARGET_ARCHITECTURE@'
lit_config.build_only = '@TESTS_BUILD_ONLY@'.lower() in ['1', 'true', 'on']

lit_config.is_kernel = '@STL_IS_KERNEL@'.lower() in ['1', 'true', 'on']
if lit_config.is_kernel:
lit_config.wdk_include = "@WDK_INCLUDE_DIRECTORY@"
lit_config.wdk_lib = "@WDK_LIB_DIRECTORY@"
lit_config.wdk_bin = "@WDK_BIN_DIRECTORY@"
lit_config.utils_dir = "@STL_TEST_UTILS_DIR@"

# Add parameters and features to the config
stl.test.config.configure(
stl.test.params.getDefaultParameters(config, lit_config),
Expand Down
7 changes: 7 additions & 0 deletions tests/std/lit.site.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ lit_config.cxx_runtime = '@CMAKE_RUNTIME_OUTPUT_DIRECTORY@'
lit_config.target_arch = '@VCLIBS_TARGET_ARCHITECTURE@'
lit_config.build_only = '@TESTS_BUILD_ONLY@'.lower() in ['1', 'true', 'on']

lit_config.is_kernel = '@STL_IS_KERNEL@'.lower() in ['1', 'true', 'on']
if lit_config.is_kernel:
lit_config.wdk_include = "@WDK_INCLUDE_DIRECTORY@"
lit_config.wdk_lib = "@WDK_LIB_DIRECTORY@"
lit_config.wdk_bin = "@WDK_BIN_DIRECTORY@"
lit_config.utils_dir = "@STL_TEST_UTILS_DIR@"

# Add parameters and features to the config
stl.test.config.configure(
stl.test.params.getDefaultParameters(config, lit_config),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

RUNALL_INCLUDE ..\impure_matrix.lst
RUNALL_INCLUDE ..\kernel.lst
14 changes: 13 additions & 1 deletion tests/std/tests/Dev11_0863628_atomic_compare_exchange/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <string.h>
#include <type_traits>


using namespace std;

#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
Expand Down Expand Up @@ -503,12 +502,25 @@ void test_layout_paranoia() {
assert(b[2] == 3);
}

#ifdef _KERNEL_MODE

#define assert_bitwise_identical(MSG, LHS, RHS) \
{ \
double lhs = LHS; \
double rhs = RHS; \
if (memcmp(&lhs, &rhs, sizeof(lhs)) != 0) { \
assert(!MSG); \
} \
}

#else // _KERNEL_MODE
void assert_bitwise_identical(const char* const msg, const double lhs, const double rhs) {
if (memcmp(&lhs, &rhs, sizeof(lhs)) != 0) {
printf("counterexample found in %s: %a and %a\n", msg, lhs, rhs);
abort();
}
}
#endif // _KERNEL_MODE

void test_double_identical_results() {
#if _HAS_CXX20
Expand Down
3 changes: 3 additions & 0 deletions tests/std/tests/P0896R4_views_common/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,9 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) {
}

// Validate common_view::base() && (NB: do this last since it leaves r moved-from)
#if !defined(__clang__) && !defined(__EDG__) // TRANSITION, DevCom-1159442
(void) 42;
#endif // TRANSITION, DevCom-1159442
same_as<V> auto b2 = move(r).base();
static_assert(noexcept(move(r).base()) == is_nothrow_move_constructible_v<V>);
if (!is_empty) {
Expand Down
4 changes: 4 additions & 0 deletions tests/std/tests/kernel.lst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

PM_CL="/kernel /Zc:preprocessor /std:c++latest /w14640 /Zc:threadSafeInit- /DNO_TEST_ENVIRONMENT_PREPARER" PM_LINK="/IGNORE:4210 /subsystem:native /nodefaultlib stl_kernel.lib BufferOverflowFastFailK.lib ntoskrnl.lib hal.lib wmilib.lib Ntstrsafe.lib libcpmt.lib libcmt.lib"
7 changes: 7 additions & 0 deletions tests/tr1/lit.site.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ lit_config.cxx_runtime = '@CMAKE_RUNTIME_OUTPUT_DIRECTORY@'
lit_config.target_arch = '@VCLIBS_TARGET_ARCHITECTURE@'
lit_config.build_only = '@TESTS_BUILD_ONLY@'.lower() in ['1', 'true', 'on']

lit_config.is_kernel = '@STL_IS_KERNEL@'.lower() in ['1', 'true', 'on']
if lit_config.is_kernel:
lit_config.wdk_include = "@WDK_INCLUDE_DIRECTORY@"
lit_config.wdk_lib = "@WDK_LIB_DIRECTORY@"
lit_config.wdk_bin = "@WDK_BIN_DIRECTORY@"
lit_config.utils_dir = "@STL_TEST_UTILS_DIR@"

# Add parameters and features to the config
stl.test.config.configure(
stl.test.params.getDefaultParameters(config, lit_config),
Expand Down
52 changes: 52 additions & 0 deletions tests/utils/kernel/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

set(STL_KERNEL_LOADER_SOURCES
${CMAKE_CURRENT_LIST_DIR}/src/stl_kernel_loader/testapp.cpp
${CMAKE_CURRENT_LIST_DIR}/src/stl_kernel_loader/install.cpp
)

set(STL_KERNEL_SOURCES
${CMAKE_CURRENT_LIST_DIR}/src/stl_kernel/doAssert.cpp
${CMAKE_CURRENT_LIST_DIR}/src/stl_kernel/stl_kernel.cpp
)

add_library(stl_kernel STATIC ${STL_KERNEL_SOURCES})
set_target_properties(stl_kernel PROPERTIES LINKER_LANGUAGE CXX)
target_compile_definitions(stl_kernel PRIVATE "__STL_IS_KERNEL")

# ${WDK_INCLUDE_DIRECTORY}/km/crt isn't in the files under test include paths.
# doAssert.cpp wants to use RtlStringCbPrintfExA, and that requires pulling in
# km/crt. If we don't pull in km/crt here, we erroneously pull in user mode
# crt headers, and that gets us linker errors dealing with missing user mode
# symbols in this kernel mode binary.
target_include_directories(stl_kernel PRIVATE
${CMAKE_CURRENT_LIST_DIR}/inc
${WDK_INCLUDE_DIRECTORY}/km
${WDK_INCLUDE_DIRECTORY}/km/crt
${WDK_INCLUDE_DIRECTORY}/shared
)

# TRANSITION, WDK needs to suppress C5040
if(VCLIBS_TARGET_ARCHITECTURE STREQUAL "x86")
set(STL_KERNEL_CALLING_CONVENTION "/Gz")
else()
set(STL_KERNEL_CALLING_CONVENTION "")
endif()

target_compile_options(stl_kernel PRIVATE /kernel /wd5040 ${STL_KERNEL_CALLING_CONVENTION})

add_executable(stl_kernel_loader ${STL_KERNEL_LOADER_SOURCES})
target_include_directories(stl_kernel_loader PRIVATE
${CMAKE_CURRENT_LIST_DIR}/inc
${WDK_INCLUDE_DIRECTORY}/ucrt
${WDK_INCLUDE_DIRECTORY}/um
${WDK_INCLUDE_DIRECTORY}/shared
)
target_compile_options(stl_kernel_loader PRIVATE /EHsc)
target_link_libraries(stl_kernel_loader PRIVATE
msvcrt.lib
kernel32.lib
ucrt.lib
AdvApi32.lib
)
29 changes: 29 additions & 0 deletions tests/utils/kernel/generateMsvcCert.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

param([string]$out="MsvcStlTestingCert.pfx",[string]$pass="placeholderPassword")

$ErrorActionPreference = 'Stop'
# Clean up old certificates
Get-ChildItem cert:\localmachine\My |
Where-Object { $_.Subject -eq 'CN=MsvcStlTestingCert' } |
Remove-Item

Get-ChildItem cert:\localmachine\root |
Where-Object { $_.Subject -eq 'CN=MsvcStlTestingCert' } |
Remove-Item

Get-ChildItem cert:\localmachine\trustedpublisher |
Where-Object { $_.Subject -eq 'CN=MsvcStlTestingCert' } |
Remove-Item

# Make the new cert
$cert = New-SelfSignedCertificate -Type CodeSigningCert -DnsName "MsvcStlTestingCert" `
-certstorelocation cert:\localmachine\my -NotAfter (Get-Date).AddDays(2)
$path = 'cert:\localMachine\my\' + $cert.thumbprint
$pwd = ConvertTo-SecureString -String $pass -Force -AsPlainText
Export-PfxCertificate -cert $path -FilePath $out -Password $pwd

# install the cert so that we can load our drivers
Import-PfxCertificate -FilePath $out -CertStoreLocation cert:\localmachine\root -Password $pwd
Import-PfxCertificate -FilePath $out -CertStoreLocation cert:\localmachine\trustedpublisher -Password $pwd
4 changes: 4 additions & 0 deletions tests/utils/kernel/inc/assert.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <cassert>
Loading