tests: add a test to make sure compiling forbidden UWP APIs fails

When building for UWP and works otherwise
This commit is contained in:
Steve Lhomme authored and Martin Storsjö committed 2019-04-18 12:23:28 +03:00
1 parent 591a5c2ddc
commit 707fda6348
2 files changed
+50

No files matched your search

+24
View File
@@ -38,6 +38,7 @@ TESTS_CPP_DLL="tlstest-lib"
TESTS_SSP="stacksmash" TESTS_SSP="stacksmash"
TESTS_ASAN="stacksmash" TESTS_ASAN="stacksmash"
TESTS_UBSAN="ubsan" TESTS_UBSAN="ubsan"
TESTS_UWP="uwp-error"
for arch in $ARCHS; do for arch in $ARCHS; do
case $arch in case $arch in
i686|x86_64) i686|x86_64)
@@ -92,6 +93,29 @@ for arch in $ARCHS; do
for test in $TESTS_SSP; do for test in $TESTS_SSP; do
$arch-w64-$target_os-clang $test.c -o $TEST_DIR/$test.exe -fstack-protector-strong $arch-w64-$target_os-clang $test.c -o $TEST_DIR/$test.exe -fstack-protector-strong
done done
for test in $TESTS_UWP; do
set +e
# compilation should fail for UWP and WinRT
$arch-w64-$target_os-clang $test.c -o $TEST_DIR/$test.exe -Wimplicit-function-declaration -Werror
UWP_ERROR=$?
set -e
case $target_os in
mingw32uwp)
if [ $UWP_ERROR -eq 0 ]; then
echo "UWP compilation should have failed for test $test!"
exit 1
fi
;;
*)
if [ $UWP_ERROR -eq 0 ]; then
TESTS_EXTRA="$TESTS_EXTRA $test"
else
echo "$test failed to compile for non-UWP target!"
exit 1
fi
;;
esac
done
for test in $TESTS_ASAN; do for test in $TESTS_ASAN; do
case $arch in case $arch in
# Sanitizers on windows only support x86. # Sanitizers on windows only support x86.
+26
View File
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2019 Steve Lhomme
*
* This file is part of llvm-mingw.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <windows.h>
#include <stdio.h>
int main(int argc, char *argv[]) {
UINT res = GetOEMCP();
fprintf(stderr, "Windows OEM CP is %u\n", res);
return 0;
}