rlib/test/test_clibffi.py::TestCLibffi::()::test_variadic_args
self = <rpython.rlib.test.test_clibffi.TestCLibffi object at 0x0000023bba022100>
def test_variadic_args(self):
from rpython.translator.tool.cbuild import ExternalCompilationInfo
from rpython.translator.platform import platform
from rpython.tool.udir import udir
c_file = udir.ensure("test_libffi", dir=1).join("xlib.c")
c_file.write(py.code.Source('''
#include "src/precommondefs.h"
#include <stdarg.h>
#include <stdio.h>
RPY_EXPORTED
Signed fun(Signed n, ...) {
va_list ptr;
int sum = 0;
printf("n: %ld\\n", n);
va_start(ptr, n);
for (int i = 0; i < n; i++) {
Signed foo = va_arg(ptr, Signed);
sum += foo;
printf("Arg %d: %ld\\n", i, foo);
}
va_end(ptr);
return sum;
}
'''))
eci = ExternalCompilationInfo(include_dirs=[cdir])
lib_name = str(platform.compile([c_file], eci, 'x4', standalone=False))
> lib = CDLL(lib_name)
rlib\test\test_clibffi.py:442:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
rlib\clibffi.py:702: in __init__
self.lib = dlopen(libname, mode)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
name = 'd:\\systemtemp\\pytest\\usession-main-805\\test_libffi\\x4.dll'
mode = -1
def dlopen(name, mode=-1):
# mode is unused on windows, but a consistant signature
if not name:
raise DLOpenError("cannot use None")
with rffi.scoped_utf82wcharp(name, codepoints_in_utf8(name)) as buf:
res = rwin32.LoadLibraryW(buf)
if not res:
err = rwin32.GetLastError_saved()
ustr, lgt = rwin32.FormatErrorW(err)
> raise DLOpenError(ustr)
E DLOpenError: 'Teseiidmdl ol o efud\xf2\xa0\x80\x8d\x00\xee\x95\xa0\xe1\xa0\xbb\x01\x00\xe7\xab\x90\xc8\xbb\xe3\xbe\xa8\xe7\xbf\xba \x0e\x01\x00\x00\x00\xe3\xbe\xa8\xe7\xbf\xba\xe7\xab\x90\xc8\xbb'
rlib\rdynload.py:242: DLOpenError
builder: rpython-win-x86-64 build #399
test: rlib/test/test_clibffi/py/TestCLibffi/()/test_variadic_args