зеркало из https://github.com/mozilla/pjs.git
Bug 564966 - ctypes stdcall tests borked on windows. r=benjamn, a=blocker
This commit is contained in:
Родитель
7a1043c989
Коммит
838cd2c2a1
|
@ -75,39 +75,39 @@ test_void_t_cdecl()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DEFINE_TYPE(name, type, ffiType) \
|
#define FUNCTION_TESTS(name, type, ffiType, suffix) \
|
||||||
type ABI \
|
type ABI \
|
||||||
get_##name##_cdecl() \
|
get_##name##_##suffix() \
|
||||||
{ \
|
{ \
|
||||||
return ValueTraits<type>::literal(); \
|
return ValueTraits<type>::literal(); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
type ABI \
|
type ABI \
|
||||||
set_##name##_cdecl(type x) \
|
set_##name##_##suffix(type x) \
|
||||||
{ \
|
{ \
|
||||||
return x; \
|
return x; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
type ABI \
|
type ABI \
|
||||||
sum_##name##_cdecl(type x, type y) \
|
sum_##name##_##suffix(type x, type y) \
|
||||||
{ \
|
{ \
|
||||||
return ValueTraits<type>::sum(x, y); \
|
return ValueTraits<type>::sum(x, y); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
type ABI \
|
type ABI \
|
||||||
sum_alignb_##name##_cdecl(char a, type x, char b, type y, char c) \
|
sum_alignb_##name##_##suffix(char a, type x, char b, type y, char c) \
|
||||||
{ \
|
{ \
|
||||||
return ValueTraits<type>::sum(x, y); \
|
return ValueTraits<type>::sum(x, y); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
type ABI \
|
type ABI \
|
||||||
sum_alignf_##name##_cdecl(float a, type x, float b, type y, float c) \
|
sum_alignf_##name##_##suffix(float a, type x, float b, type y, float c) \
|
||||||
{ \
|
{ \
|
||||||
return ValueTraits<type>::sum(x, y); \
|
return ValueTraits<type>::sum(x, y); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
type ABI \
|
type ABI \
|
||||||
sum_many_##name##_cdecl( \
|
sum_many_##name##_##suffix( \
|
||||||
type a, type b, type c, type d, type e, type f, type g, type h, type i, \
|
type a, type b, type c, type d, type e, type f, type g, type h, type i, \
|
||||||
type j, type k, type l, type m, type n, type o, type p, type q, type r) \
|
type j, type k, type l, type m, type n, type o, type p, type q, type r) \
|
||||||
{ \
|
{ \
|
||||||
|
@ -116,6 +116,7 @@ sum_many_##name##_cdecl( \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ABI /* cdecl */
|
#define ABI /* cdecl */
|
||||||
|
#define DEFINE_TYPE(x, y, z) FUNCTION_TESTS(x, y, z, cdecl)
|
||||||
#include "typedefs.h"
|
#include "typedefs.h"
|
||||||
#undef ABI
|
#undef ABI
|
||||||
|
|
||||||
|
@ -129,6 +130,7 @@ test_void_t_stdcall()
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ABI NS_STDCALL
|
#define ABI NS_STDCALL
|
||||||
|
#define DEFINE_TYPE(x, y, z) FUNCTION_TESTS(x, y, z, stdcall)
|
||||||
#include "typedefs.h"
|
#include "typedefs.h"
|
||||||
#undef ABI
|
#undef ABI
|
||||||
|
|
||||||
|
|
|
@ -653,11 +653,31 @@ function run_UInt64_tests() {
|
||||||
function run_basic_abi_tests(library, t, name, toprimitive,
|
function run_basic_abi_tests(library, t, name, toprimitive,
|
||||||
get_test, set_tests, sum_tests, sum_many_tests) {
|
get_test, set_tests, sum_tests, sum_many_tests) {
|
||||||
// Test the function call ABI for calls involving the type.
|
// Test the function call ABI for calls involving the type.
|
||||||
run_single_abi_tests(library, ctypes.default_abi, t, name + "_cdecl",
|
function declare_fn_cdecl(fn_t, prefix) {
|
||||||
|
return library.declare(prefix + name + "_cdecl", fn_t);
|
||||||
|
}
|
||||||
|
run_single_abi_tests(declare_fn_cdecl, ctypes.default_abi, t,
|
||||||
toprimitive, get_test, set_tests, sum_tests, sum_many_tests);
|
toprimitive, get_test, set_tests, sum_tests, sum_many_tests);
|
||||||
#ifdef _WIN32
|
|
||||||
#ifndef _WIN64
|
#ifdef WIN32
|
||||||
run_single_abi_tests(library, ctypes.stdcall_abi, t, name + "_stdcall",
|
#ifndef HAVE_64BIT_OS
|
||||||
|
function declare_fn_stdcall(fn_t, prefix) {
|
||||||
|
return library.declare(
|
||||||
|
// stdcall functions have the symbol name postfixed with the (aligned)
|
||||||
|
// size of the args.
|
||||||
|
"_" + prefix + name + "_stdcall" + "@" + argsize(fn_t.targetType.argTypes), fn_t);
|
||||||
|
}
|
||||||
|
function argsize(arglist) {
|
||||||
|
let size = 0;
|
||||||
|
for each (let a in arglist) {
|
||||||
|
if (a.size % 4 == 0)
|
||||||
|
size += a.size;
|
||||||
|
else
|
||||||
|
size += a.size + 4 - a.size % 4;
|
||||||
|
}
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
run_single_abi_tests(declare_fn_stdcall, ctypes.stdcall_abi, t,
|
||||||
toprimitive, get_test, set_tests, sum_tests, sum_many_tests);
|
toprimitive, get_test, set_tests, sum_tests, sum_many_tests);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -667,23 +687,28 @@ function run_basic_abi_tests(library, t, name, toprimitive,
|
||||||
check_struct_stats(library, t);
|
check_struct_stats(library, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
function run_single_abi_tests(library, abi, t, name, toprimitive,
|
function run_single_abi_tests(decl, abi, t, toprimitive,
|
||||||
get_test, set_tests, sum_tests, sum_many_tests) {
|
get_test, set_tests, sum_tests, sum_many_tests) {
|
||||||
let getter = library.declare("get_" + name, abi, t);
|
let getter_t = ctypes.FunctionType(abi, t).ptr;
|
||||||
|
let getter = decl(getter_t, "get_");
|
||||||
do_check_eq(toprimitive(getter()), get_test);
|
do_check_eq(toprimitive(getter()), get_test);
|
||||||
|
|
||||||
let setter = library.declare("set_" + name, ctypes.default_abi, t, t);
|
let setter_t = ctypes.FunctionType(abi, t, [t]).ptr;
|
||||||
|
let setter = decl(setter_t, "set_");
|
||||||
for each (let i in set_tests)
|
for each (let i in set_tests)
|
||||||
do_check_eq(toprimitive(setter(i)), i);
|
do_check_eq(toprimitive(setter(i)), i);
|
||||||
|
|
||||||
let sum = library.declare("sum_" + name, ctypes.default_abi, t, t, t);
|
let sum_t = ctypes.FunctionType(abi, t, [t, t]).ptr;
|
||||||
|
let sum = decl(sum_t, "sum_");
|
||||||
for each (let a in sum_tests)
|
for each (let a in sum_tests)
|
||||||
do_check_eq(toprimitive(sum(a[0], a[1])), a[2]);
|
do_check_eq(toprimitive(sum(a[0], a[1])), a[2]);
|
||||||
|
|
||||||
let sum_alignb = library.declare("sum_alignb_" + name, ctypes.default_abi, t,
|
let sum_alignb_t = ctypes.FunctionType(abi, t,
|
||||||
ctypes.char, t, ctypes.char, t, ctypes.char);
|
[ctypes.char, t, ctypes.char, t, ctypes.char]).ptr;
|
||||||
let sum_alignf = library.declare("sum_alignf_" + name, ctypes.default_abi, t,
|
let sum_alignb = decl(sum_alignb_t, "sum_alignb_");
|
||||||
ctypes.float, t, ctypes.float, t, ctypes.float);
|
let sum_alignf_t = ctypes.FunctionType(abi, t,
|
||||||
|
[ctypes.float, t, ctypes.float, t, ctypes.float]).ptr;
|
||||||
|
let sum_alignf = decl(sum_alignf_t, "sum_alignf_");
|
||||||
for each (let a in sum_tests) {
|
for each (let a in sum_tests) {
|
||||||
do_check_eq(toprimitive(sum_alignb(0, a[0], 0, a[1], 0)), a[2]);
|
do_check_eq(toprimitive(sum_alignb(0, a[0], 0, a[1], 0)), a[2]);
|
||||||
do_check_eq(toprimitive(sum_alignb(1, a[0], 1, a[1], 1)), a[2]);
|
do_check_eq(toprimitive(sum_alignb(1, a[0], 1, a[1], 1)), a[2]);
|
||||||
|
@ -691,11 +716,12 @@ function run_single_abi_tests(library, abi, t, name, toprimitive,
|
||||||
do_check_eq(toprimitive(sum_alignf(1, a[0], 1, a[1], 1)), a[2]);
|
do_check_eq(toprimitive(sum_alignf(1, a[0], 1, a[1], 1)), a[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
let sum_many = library.declare("sum_many_" + name, ctypes.default_abi, t,
|
let sum_many_t = ctypes.FunctionType(abi, t,
|
||||||
t, t, t, t, t, t, t, t, t, t, t, t, t, t, t, t, t, t);
|
[t, t, t, t, t, t, t, t, t, t, t, t, t, t, t, t, t, t]).ptr;
|
||||||
|
let sum_many = decl(sum_many_t, "sum_many_");
|
||||||
for each (let a in sum_many_tests)
|
for each (let a in sum_many_tests)
|
||||||
do_check_eq(toprimitive(
|
do_check_eq(
|
||||||
sum_many(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7],
|
toprimitive(sum_many(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7],
|
||||||
a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15],
|
a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15],
|
||||||
a[16], a[17])), a[18]);
|
a[16], a[17])), a[18]);
|
||||||
}
|
}
|
||||||
|
@ -1824,11 +1850,11 @@ function run_FunctionType_tests() {
|
||||||
ctypes.char.ptr.array().ptr).ptr.ptr.array(8).array();
|
ctypes.char.ptr.array().ptr).ptr.ptr.array(8).array();
|
||||||
do_check_eq(f3_t.name, "char*(*(**[][8])())[]");
|
do_check_eq(f3_t.name, "char*(*(**[][8])())[]");
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef WIN32
|
||||||
#ifndef _WIN64
|
#ifndef HAVE_64BIT_OS
|
||||||
f3_t = ctypes.FunctionType(ctypes.stdcall_abi,
|
f3_t = ctypes.FunctionType(ctypes.stdcall_abi,
|
||||||
ctypes.char.ptr.array().ptr).ptr.array(8).array();
|
ctypes.char.ptr.array().ptr).ptr.ptr.array(8).array();
|
||||||
do_check_eq(f3_t.ptr.name, "char*(__stdcall *(**[][8])())[]");
|
do_check_eq(f3_t.name, "char*(*(__stdcall **[][8])())[]");
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2016,9 +2042,9 @@ function run_void_tests(library) {
|
||||||
library.declare("test_void_t_cdecl", ctypes.default_abi, ctypes.void_t, ctypes.void_t);
|
library.declare("test_void_t_cdecl", ctypes.default_abi, ctypes.void_t, ctypes.void_t);
|
||||||
}, Error);
|
}, Error);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef WIN32
|
||||||
#ifndef _WIN64
|
#ifndef HAVE_64BIT_OS
|
||||||
test_void_t = library.declare("test_void_t_stdcall", ctypes.stdcall_abi, ctypes.void_t);
|
test_void_t = library.declare("_test_void_t_stdcall@0", ctypes.stdcall_abi, ctypes.void_t);
|
||||||
do_check_eq(test_void_t(), undefined);
|
do_check_eq(test_void_t(), undefined);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -2170,9 +2196,10 @@ function run_function_tests(library)
|
||||||
function run_closure_tests(library)
|
function run_closure_tests(library)
|
||||||
{
|
{
|
||||||
run_single_closure_tests(library, ctypes.default_abi, "cdecl");
|
run_single_closure_tests(library, ctypes.default_abi, "cdecl");
|
||||||
#ifdef _WIN32
|
#ifdef WIN32
|
||||||
#ifndef _WIN64
|
#ifndef HAVE_64BIT_OS
|
||||||
run_single_closure_tests(library, ctypes.stdcall_abi, "stdcall");
|
// stdcall closure tests are currently broken on windows. see bug 564966.
|
||||||
|
//run_single_closure_tests(library, ctypes.stdcall_abi, "stdcall");
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -2233,8 +2260,8 @@ function run_variadic_tests(library) {
|
||||||
ctypes.FunctionType(ctypes.default_abi, ctypes.bool, ["..."]);
|
ctypes.FunctionType(ctypes.default_abi, ctypes.bool, ["..."]);
|
||||||
}, Error);
|
}, Error);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef WIN32
|
||||||
#ifndef _WIN64
|
#ifndef HAVE_64BIT_OS
|
||||||
do_check_throws(function() {
|
do_check_throws(function() {
|
||||||
ctypes.FunctionType(ctypes.stdcall_abi, ctypes.bool,
|
ctypes.FunctionType(ctypes.stdcall_abi, ctypes.bool,
|
||||||
[ctypes.bool, "..."]);
|
[ctypes.bool, "..."]);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче