Now a single test suite with 89 tests, instead of 89 test suites with 1 test each

Added dummy implementations of sanity checks for compilers/architectures I didn't write them for yet. Long story short: now compiles and runs with Visual C++, both x86 and x64
Added copyright/license header

svn path=/trunk/; revision=38339
This commit is contained in:
KJK::Hyperion 2008-12-24 23:22:04 +00:00
parent d785178de6
commit 456b1c9e58
2 changed files with 186 additions and 132 deletions

View file

@ -1,3 +1,25 @@
/*
Copyright (c) 2008 KJK::Hyperion
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <stddef.h> #include <stddef.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -42,12 +64,7 @@ extern void set_positive(int *);
static int call_test(int (*)(void)); static int call_test(int (*)(void));
#define DEFINE_TEST(NAME_) \ #define DEFINE_TEST(NAME_) static int test_ ## NAME_(void)
static int test_ ## NAME_(void); \
\
static void NAME_(void) { ok(call_test(test_ ## NAME_), "test failed\n"); } \
\
static int test_ ## NAME_(void)
/* Empty statements *///{{{ /* Empty statements *///{{{
DEFINE_TEST(empty_1) DEFINE_TEST(empty_1)
@ -2240,11 +2257,95 @@ DEFINE_TEST(abnorm_8)
// TODO // TODO
//}}} //}}}
static
LONG WINAPI unhandled_exception(PEXCEPTION_POINTERS ExceptionInfo)
{
ok(0, "unhandled exception %08lX thrown from %p\n", ExceptionInfo->ExceptionRecord->ExceptionCode, ExceptionInfo->ExceptionRecord->ExceptionAddress);
return EXCEPTION_CONTINUE_SEARCH;
}
#if defined(_M_IX86)
struct volatile_context
{
void * esp;
void * ebp;
void * ebx;
void * esi;
void * edi;
};
#else
struct volatile_context
{
int _ignore;
};
#endif
static
DECLSPEC_NOINLINE
int sanity_check(int ret, struct volatile_context * before, struct volatile_context * after)
{
if(ret && memcmp(before, after, sizeof(before)))
ok(0, "volatile context corrupted\n");
return ret;
}
static
DECLSPEC_NOINLINE
int call_test(int (* func)(void))
{
static int ret;
static struct volatile_context before, after;
static LPTOP_LEVEL_EXCEPTION_FILTER prev_unhandled_exception;
prev_unhandled_exception = SetUnhandledExceptionFilter(&unhandled_exception);
#if defined(__GNUC__) && defined(__i386__)
__asm__ __volatile__
(
"mov %%esp, 0x00 + %c[before]\n"
"mov %%ebp, 0x04 + %c[before]\n"
"mov %%ebx, 0x08 + %c[before]\n"
"mov %%esi, 0x0c + %c[before]\n"
"mov %%edi, 0x10 + %c[before]\n"
"call *%[test]\n"
"mov %%esp, 0x00 + %c[after]\n"
"mov %%ebp, 0x04 + %c[after]\n"
"mov %%ebx, 0x08 + %c[after]\n"
"mov %%esi, 0x0c + %c[after]\n"
"mov %%edi, 0x10 + %c[after]\n"
"push %[after]\n"
"push %[before]\n"
"push %[ret]\n"
"call %c[sanity_check]\n"
"pop %%ecx\n"
"pop %%ecx\n"
"pop %%ecx\n" :
[ret] "=a" (ret) :
[test] "r" (func), [before] "i" (&before), [after] "i" (&after), [sanity_check] "i" (&sanity_check) :
"ebx", "ecx", "edx", "esi", "edi", "flags", "memory"
);
#else
ret = func();
#endif
SetUnhandledExceptionFilter(prev_unhandled_exception);
return ret;
}
#define USE_TEST_NAME_(NAME_) # NAME_ #define USE_TEST_NAME_(NAME_) # NAME_
#define USE_TEST_NAME(NAME_) USE_TEST_NAME_(NAME_) #define USE_TEST_NAME(NAME_) USE_TEST_NAME_(NAME_)
#define USE_TEST(NAME_) { USE_TEST_NAME(NAME_), NAME_ } #define USE_TEST(NAME_) { USE_TEST_NAME(test_ ## NAME_), test_ ## NAME_ }
const struct test winetest_testlist[] = struct subtest
{
const char * name;
int (* func)(void);
};
void testsuite_syntax(void)
{
const struct subtest testsuite[] =
{ {
USE_TEST(empty_1), USE_TEST(empty_1),
USE_TEST(empty_2), USE_TEST(empty_2),
@ -2351,86 +2452,17 @@ const struct test winetest_testlist[] =
USE_TEST(abnorm_6), USE_TEST(abnorm_6),
USE_TEST(abnorm_7), USE_TEST(abnorm_7),
USE_TEST(abnorm_8), USE_TEST(abnorm_8),
};
size_t i;
for(i = 0; i < sizeof(testsuite) / sizeof(testsuite[0]); ++ i)
ok(call_test(testsuite[i].func), "%s failed\n", testsuite[i].name);
}
const struct test winetest_testlist[] = {
{ "pseh2_syntax", testsuite_syntax },
{ 0, 0 } { 0, 0 }
}; };
static
LONG WINAPI unhandled_exception(PEXCEPTION_POINTERS ExceptionInfo)
{
ok(0, "unhandled exception %08lX thrown from %p\n", ExceptionInfo->ExceptionRecord->ExceptionCode, ExceptionInfo->ExceptionRecord->ExceptionAddress);
return EXCEPTION_CONTINUE_SEARCH;
}
#if defined(_M_IX86)
struct volatile_context
{
void * esp;
void * ebp;
void * ebx;
void * esi;
void * edi;
};
#else
#error TODO
#endif
#if defined(__GNUC__)
static
__attribute__((noinline))
int sanity_check(int ret, struct volatile_context * before, struct volatile_context * after)
{
if(ret && memcmp(before, after, sizeof(before)))
ok(0, "volatile context corrupted\n");
return ret;
}
static
__attribute__((noinline))
int call_test(int (* func)(void))
{
static int ret;
static LPTOP_LEVEL_EXCEPTION_FILTER prev_unhandled_exception;
prev_unhandled_exception = SetUnhandledExceptionFilter(&unhandled_exception);
#if defined(__i386__)
static struct volatile_context before, after;
__asm__ __volatile__
(
"mov %%esp, 0x00 + %c[before]\n"
"mov %%ebp, 0x04 + %c[before]\n"
"mov %%ebx, 0x08 + %c[before]\n"
"mov %%esi, 0x0c + %c[before]\n"
"mov %%edi, 0x10 + %c[before]\n"
"call *%[test]\n"
"mov %%esp, 0x00 + %c[after]\n"
"mov %%ebp, 0x04 + %c[after]\n"
"mov %%ebx, 0x08 + %c[after]\n"
"mov %%esi, 0x0c + %c[after]\n"
"mov %%edi, 0x10 + %c[after]\n"
"push %[after]\n"
"push %[before]\n"
"push %[ret]\n"
"call %c[sanity_check]\n"
"pop %%ecx\n"
"pop %%ecx\n"
"pop %%ecx\n" :
[ret] "=a" (ret) :
[test] "r" (func), [before] "i" (&before), [after] "i" (&after), [sanity_check] "i" (&sanity_check) :
"ebx", "ecx", "edx", "esi", "edi", "flags", "memory"
);
#else
#error TODO
#endif
SetUnhandledExceptionFilter(prev_unhandled_exception);
return ret;
}
#else
#error TODO
#endif
/* EOF */ /* EOF */

View file

@ -1,3 +1,25 @@
/*
Copyright (c) 2008 KJK::Hyperion
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
extern extern
int return_arg(int arg) int return_arg(int arg)
{ {