Add tests for the autoimport feature
This commit is contained in:
1 parent
5f12b33177
commit
37f8ba8516
5 files changed
+103
-3
No files matched your search
+7
-1
@@ -52,13 +52,19 @@ RUN ./build-mingw-w64-libraries.sh $TOOLCHAIN_PREFIX
|
||||
# Build C test applications
|
||||
ENV PATH=$TOOLCHAIN_PREFIX/bin:$PATH
|
||||
|
||||
COPY test/*.c ./test/
|
||||
COPY test/*.c test/*.h ./test/
|
||||
RUN cd test && \
|
||||
for arch in $TOOLCHAIN_ARCHS; do \
|
||||
mkdir -p $arch && \
|
||||
for test in hello hello-tls crt-test setjmp; do \
|
||||
$arch-w64-mingw32-clang $test.c -o $arch/$test.exe || exit 1; \
|
||||
done; \
|
||||
for test in autoimport-lib; do \
|
||||
$arch-w64-mingw32-clang $test.c -shared -o $arch/$test.dll -Wl,--out-implib,$arch/lib$test.dll.a || exit 1; \
|
||||
done; \
|
||||
for test in autoimport-main; do \
|
||||
$arch-w64-mingw32-clang $test.c -o $arch/$test.exe -L$arch -l${test%-main}-lib || exit 1; \
|
||||
done; \
|
||||
done
|
||||
|
||||
# Build libunwind/libcxxabi/libcxx
|
||||
|
||||
+10
-2
@@ -13,6 +13,8 @@ export PATH=$PREFIX/bin:$PATH
|
||||
|
||||
cd test
|
||||
TESTS_C="hello hello-tls crt-test setjmp"
|
||||
TESTS_C_DLL="autoimport-lib"
|
||||
TESTS_C_LINK_DLL="autoimport-main"
|
||||
TESTS_C_NO_BUILTIN="crt-test"
|
||||
TESTS_CPP="hello-cpp hello-exception tlstest-main"
|
||||
TESTS_CPP_DLL="tlstest-lib"
|
||||
@@ -22,6 +24,12 @@ for arch in $ARCHS; do
|
||||
for test in $TESTS_C; do
|
||||
$arch-w64-mingw32-clang $test.c -o $arch/$test.exe
|
||||
done
|
||||
for test in $TESTS_C_DLL; do
|
||||
$arch-w64-mingw32-clang $test.c -shared -o $arch/$test.dll -Wl,--out-implib,$arch/lib$test.dll.a
|
||||
done
|
||||
for test in $TESTS_C_LINK_DLL; do
|
||||
$arch-w64-mingw32-clang $test.c -o $arch/$test.exe -L$arch -l${test%-main}-lib
|
||||
done
|
||||
TESTS_EXTRA=""
|
||||
for test in $TESTS_C_NO_BUILTIN; do
|
||||
$arch-w64-mingw32-clang $test.c -o $arch/$test-no-builtin.exe -fno-builtin
|
||||
@@ -36,7 +44,7 @@ for arch in $ARCHS; do
|
||||
for test in $TESTS_SSP; do
|
||||
$arch-w64-mingw32-clang $test.c -o $arch/$test.exe -fstack-protector-strong
|
||||
done
|
||||
DLL="$TESTS_CPP_DLL"
|
||||
DLL="$TESTS_C_DLL $TESTS_CPP_DLL"
|
||||
case $arch in
|
||||
i686|x86_64)
|
||||
RUN=wine
|
||||
@@ -57,7 +65,7 @@ for arch in $ARCHS; do
|
||||
$COPY $i.dll
|
||||
done
|
||||
fi
|
||||
for test in $TESTS_C $TESTS_CPP $TESTS_EXTRA $TESTS_SSP; do
|
||||
for test in $TESTS_C $TESTS_C_LINK_DLL $TESTS_CPP $TESTS_EXTRA $TESTS_SSP; do
|
||||
file=$test.exe
|
||||
if [ -n "$COPY" ]; then
|
||||
$COPY $file
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Martin Storsjo
|
||||
*
|
||||
* 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 "autoimport-lib.h"
|
||||
|
||||
int var;
|
||||
|
||||
int getVar(void) {
|
||||
return var;
|
||||
}
|
||||
|
||||
void setVar(int val) {
|
||||
var = val;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Martin Storsjo
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef AUTOIMPORT_LIB_H
|
||||
#define AUTOIMPORT_LIB_H
|
||||
|
||||
extern int var;
|
||||
int getVar(void);
|
||||
void setVar(int val);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Martin Storsjo
|
||||
*
|
||||
* 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 "autoimport-lib.h"
|
||||
|
||||
int *ptr = &var;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
setVar(42);
|
||||
if (var != 42) return 1;
|
||||
var++;
|
||||
if (getVar() != 43) return 1;
|
||||
(*ptr)++;
|
||||
if (getVar() != 44) return 1;
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user