Mercurial > pub > dyncall > dyncall
changeset 410:7608e34098b0
- cleanups, simplifications, some api clarification, ...
- test cases consistency:
* return status code depending on test results (for actual conformance tests, not stuff that is not an example or hack to check something, ..)
* platform init helper added for some
author | Tassilo Philipp |
---|---|
date | Tue, 05 Oct 2021 21:53:04 +0200 |
parents | 15698dc0cba3 |
children | 49bc10c99462 |
files | ChangeLog dyncallback/dyncall_alloc_wx.h test/Makefile.generic test/call_suite/main.c test/callback_plain/callback_plain.c test/callback_suite/Makefile.embedded test/callback_suite/Makefile.generic test/callback_suite/do_test.c test/callback_suite/main.c test/callback_suite/print.c test/callback_suite/print.h test/callf/main.c test/dynload_plain/dynload_plain.c test/ellipsis/main.cc test/resolve_self/main.c test/sign/sign.c test/suite/main.c test/suite2/main.cc test/suite2_x86win32fast/main.cc test/suite2_x86win32std/main.cc test/suite3/main.cc test/suite_floats/main.cc test/suite_x86win32fast/main.cc test/suite_x86win32std/main.cc test/syscall/syscall.c test/thunk/test_thunk.c |
diffstat | 26 files changed, 181 insertions(+), 248 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Sun Oct 03 19:41:41 2021 +0200 +++ b/ChangeLog Tue Oct 05 21:53:04 2021 +0200 @@ -14,6 +14,8 @@ buildsys: o windows/nmake based builds: output library name changes to follow conventions of the native platform and be in line with cmake based builds +tests: + o fixed status codes of some tests to actually depend on results (for consistency and automation) Version 1.2 (2021/01/23)
--- a/dyncallback/dyncall_alloc_wx.h Sun Oct 03 19:41:41 2021 +0200 +++ b/dyncallback/dyncall_alloc_wx.h Tue Oct 05 21:53:04 2021 +0200 @@ -6,7 +6,7 @@ Description: Allocate write/executable memory - Interface License: - Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>, + Copyright (c) 2007-2021 Daniel Adler <dadler@uni-goettingen.de>, Tassilo Philipp <tphilipp@potion-studios.com> Permission to use, copy, modify, and distribute this software for any @@ -35,6 +35,7 @@ extern "C" { #endif +// returns 0 on success DCerror dcAllocWX (DCsize size, void** p); DCerror dcInitExecWX(void* p, DCsize size); void dcFreeWX (void* p, DCsize size);
--- a/test/Makefile.generic Sun Oct 03 19:41:41 2021 +0200 +++ b/test/Makefile.generic Tue Oct 05 21:53:04 2021 +0200 @@ -74,11 +74,6 @@ callback_plain/callback_plain callback_suite/callback_suite -linux: - LDLIBS="-lm -ldl" ${MAKE} all -bsd: - LDLIBS="-lm" ${MAKE} all - pack: ${PACK} ${VPATH}/pack-tests.sh ${PACK}
--- a/test/call_suite/main.c Sun Oct 03 19:41:41 2021 +0200 +++ b/test/call_suite/main.c Tue Oct 05 21:53:04 2021 +0200 @@ -68,6 +68,6 @@ dcTest_deInitPlatform(); - return 0; + return !total; }
--- a/test/callback_plain/callback_plain.c Sun Oct 03 19:41:41 2021 +0200 +++ b/test/callback_plain/callback_plain.c Tue Oct 05 21:53:04 2021 +0200 @@ -6,7 +6,7 @@ Description: License: - Copyright (c) 2011-2018 Daniel Adler <dadler@uni-goettingen.de>, + Copyright (c) 2011-2021 Daniel Adler <dadler@uni-goettingen.de>, Tassilo Philipp <tphilipp@potion-studios.com> Permission to use, copy, modify, and distribute this software for any @@ -74,10 +74,11 @@ printf("successfully returned from callback\n"); printf("return value (should be 1234): %d\n", result); - printf("result: callback_plain: %s\n", (userdata == 6) && (result == 1234) ? "1" : "0"); + result = (userdata == 6) && (result == 1234); + printf("result: callback_plain: %d\n", result); dcTest_deInitPlatform(); - return 0; + return !result; }
--- a/test/callback_suite/Makefile.embedded Sun Oct 03 19:41:41 2021 +0200 +++ b/test/callback_suite/Makefile.embedded Tue Oct 05 21:53:04 2021 +0200 @@ -1,5 +1,5 @@ APP = callback_suite -OBJS = env.o handler.o sigstrings.o invokers.o do_test.o main.o print.o signature_utils.o +OBJS = env.o handler.o sigstrings.o invokers.o do_test.o main.o signature_utils.o SRCTOP = ../.. BLDTOP = ${SRCTOP}
--- a/test/callback_suite/Makefile.generic Sun Oct 03 19:41:41 2021 +0200 +++ b/test/callback_suite/Makefile.generic Tue Oct 05 21:53:04 2021 +0200 @@ -1,5 +1,5 @@ APP = callback_suite -OBJS = env.o handler.o sigstrings.o invokers.o do_test.o main.o print.o signature_utils.o +OBJS = env.o handler.o sigstrings.o invokers.o do_test.o main.o signature_utils.o SRCTOP = ${VPATH}/../.. BLDTOP = ../.. CFLAGS += -I${SRCTOP}/dyncall -I${SRCTOP}/dyncallback
--- a/test/callback_suite/do_test.c Sun Oct 03 19:41:41 2021 +0200 +++ b/test/callback_suite/do_test.c Tue Oct 05 21:53:04 2021 +0200 @@ -30,7 +30,6 @@ #include "sigstrings.h" #include "signature_utils.h" #include "env.h" -#include "print.h" #include "../common/platformInit.h" int CompareValues(char type, DCValue* a, DCValue* b) @@ -115,13 +114,13 @@ index = id - 1; signature = GetSignature(index); - PrintCaseInfo(id,signature); + printf("f%d(\t%s", id, signature); pcb = dcbNewCallback( signature, handler, (void*) signature ); assert(pcb != NULL); DoInvoke(index, (void*) pcb); result = Compare(signature); - PrintCaseResult(result); + printf(" :%d\n", result); dcbFreeCallback(pcb); return result; }
--- a/test/callback_suite/main.c Sun Oct 03 19:41:41 2021 +0200 +++ b/test/callback_suite/main.c Tue Oct 05 21:53:04 2021 +0200 @@ -6,7 +6,7 @@ Description: License: - Copyright (c) 2011-2018 Daniel Adler <dadler@uni-goettingen.de>, + Copyright (c) 2011-2021 Daniel Adler <dadler@uni-goettingen.de>, Tassilo Philipp <tphilipp@potion-studios.com> Permission to use, copy, modify, and distribute this software for any @@ -27,11 +27,25 @@ #include <stdlib.h> #include "_auto_config.h" #include "env.h" -#include "print.h" #include "../common/platformInit.h" #include "../common/platformInit.c" /* Impl. for functions only used in this translation unit */ +void PrintUsage(const char* appName) +{ + printf("usage:\n\ +%s [ -v ] [ from [to] ]\n\ +where\n\ + from, to: test range\n\ +options\n\ + -v verbose reports\n\ + -h help on usage\n\ +\n\ +", appName); +} + + + const char* appname = "unknown"; /* test one case, returns error code */ @@ -101,13 +115,13 @@ ncases = (to - from) + 1; - PrintHeader(); + printf("case\tsignat.\tresult\n"); TestRange(from, to); - totalResult = (totalErrorCodes[1] == ncases) ? 1 : 0; - PrintTotalResult(totalResult); + totalResult = (totalErrorCodes[1] == ncases); + printf("result: callback_suite: %d\n", totalResult); dcTest_deInitPlatform(); - return 0; + return !totalResult; }
--- a/test/callback_suite/print.c Sun Oct 03 19:41:41 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/* - - Package: dyncall - Library: test - File: test/callback_suite/print.c - Description: - License: - - Copyright (c) 2011-2018 Daniel Adler <dadler@uni-goettingen.de>, - Tassilo Philipp <tphilipp@potion-studios.com> - - Permission to use, copy, modify, and 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 "../common/platformInit.h" - -void PrintUsage(const char* appName) -{ - fprintf(stdout, "usage:\n\ -%s [ -v ] [ from [to] ]\n\ -where\n\ - from, to: test range\n\ -options\n\ - -v verbose reports\n\ - -h help on usage\n\ -\n\ -", appName); - fflush(stdout); -} - -void PrintHeader() -{ - fprintf(stdout, "case\tsignat.\tresult\n"); -} - -void PrintCaseInfo(int caseId, const char* signatureString) -{ - fprintf(stdout, "f%d(\t%s", caseId, signatureString); - fflush(stdout); -} - -void PrintCaseResult(int resultId) -{ - fprintf(stdout, " :%d\n", resultId); - fflush(stdout); -} - -void PrintTotalResult(int resultId) -{ - printf("result: callback_suite: %d\n", resultId); - fflush(stdout); -} -
--- a/test/callback_suite/print.h Sun Oct 03 19:41:41 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -/* - - Package: dyncall - Library: test - File: test/callback_suite/print.h - Description: - License: - - Copyright (c) 2011-2018 Daniel Adler <dadler@uni-goettingen.de>, - Tassilo Philipp <tphilipp@potion-studios.com> - - Permission to use, copy, modify, and 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. - -*/ - -void PrintUsage(const char* appname); -void PrintHeader(); -void PrintCaseInfo(int index, const char* signature); -void PrintCaseResult(int result); -void PrintTotalResult(int result);
--- a/test/callf/main.c Sun Oct 03 19:41:41 2021 +0200 +++ b/test/callf/main.c Tue Oct 05 21:53:04 2021 +0200 @@ -150,6 +150,6 @@ dcTest_deInitPlatform(); - return 0; + return !r; }
--- a/test/dynload_plain/dynload_plain.c Sun Oct 03 19:41:41 2021 +0200 +++ b/test/dynload_plain/dynload_plain.c Tue Oct 05 21:53:04 2021 +0200 @@ -6,7 +6,7 @@ Description: License: - Copyright (c) 2017-2018 Tassilo Philipp <tphilipp@potion-studios.com> + Copyright (c) 2017-2021 Tassilo Philipp <tphilipp@potion-studios.com> Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -25,6 +25,7 @@ #include "../../dynload/dynload.h" #include "../common/platformInit.h" +#include "../common/platformInit.c" /* Impl. for functions only used in this translation unit */ #include <string.h> #include <sys/stat.h> @@ -89,6 +90,8 @@ "C:\\Windows\\system32\\msvcrt.dll" }; + dcTest_initPlatform(); + /* use first matching path of hacky hardcoded list, above */ for(i=0; i<(sizeof(clibs)/sizeof(const char*)); ++i) { if(access(clibs[i], F_OK) != -1) { @@ -280,6 +283,9 @@ /* Check final score of right ones to see if all worked */ r = (r == 16 + cmp_inode); printf("result: dynload_plain: %d\n", r); + + dcTest_deInitPlatform(); + return !r; }
--- a/test/ellipsis/main.cc Sun Oct 03 19:41:41 2021 +0200 +++ b/test/ellipsis/main.cc Tue Oct 05 21:53:04 2021 +0200 @@ -6,7 +6,7 @@ Description: call (...) functions via dyncall library, targets are auto-generated License: - Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>, + Copyright (c) 2007-2021 Daniel Adler <dadler@uni-goettingen.de>, Tassilo Philipp <tphilipp@potion-studios.com> Permission to use, copy, modify, and distribute this software for any @@ -58,18 +58,18 @@ void init() { - for (int i = 0 ; i < NARGS ; ++i ) + for (int i = 0 ; i < NARGS ; ++i ) { valueInt [i] = DCint (i); valueLongLong[i] = DClonglong(i); valueDouble [i] = DCdouble (i); valuePointer [i] = DCpointer (i); - } + } } void arg(DCCallVM* pCall, int select, int pos) { - switch(select) + switch(select) { case 0: dcArgInt ( pCall, valueInt [pos] ); break; case 1: dcArgLongLong( pCall, valueLongLong[pos] ); break; @@ -78,7 +78,7 @@ } } -#define assert(x) if (!(x)) return false +#define test(x) if (!(x)) return false bool test_ellipsis_case(int x) { @@ -86,19 +86,19 @@ DCCallVM* pCall = dcNewCallVM(4096); - assert( dcGetError(pCall) == DC_ERROR_NONE ); - + test( dcGetError(pCall) == DC_ERROR_NONE ); + dcMode(pCall, DC_CALL_C_ELLIPSIS); dcReset(pCall); - - assert( dcGetError(pCall) == DC_ERROR_NONE ); - + + test( dcGetError(pCall) == DC_ERROR_NONE ); + int y = x; int selects[NARGS] = { 0 }; int pos = 0; - if (y > 0) + if (y > 0) { - int select = (y-1) % NTYPES; + int select = (y-1) % NTYPES; selects[pos] = select; arg(pCall,select,pos); y = (y-1) / NTYPES; @@ -107,21 +107,21 @@ dcMode(pCall, DC_CALL_C_ELLIPSIS_VARARGS); - for(; y>0; ++pos) + for(; y>0; ++pos) { - int select = (y-1) % NTYPES; + int select = (y-1) % NTYPES; selects[pos] = select; arg(pCall,select,pos); y = (y-1) / NTYPES; } dcCallVoid(pCall,getFunc(x)); - - assert( getId() == x ); - + + test( getId() == x ); + for(int i=0; i<pos; ++i) { - assert( equals( selects[i], i, getArg(i) ) ); + test( equals( selects[i], i, getArg(i) ) ); } - + dcFree(pCall); return true; } @@ -157,7 +157,7 @@ init(); if (argc == 2) { int index = atoi(argv[1]); - success = run_range( index, index+1 ); + success = run_range( index, index+1 ); } else if (argc == 3) { int from = atoi(argv[1]); int to = atoi(argv[2])+1; @@ -167,11 +167,11 @@ success = run_range(0,ncalls); } - printf("result: ellipsis: %s\n", success ? "1" : "0"); + printf("result: ellipsis: %d\n", success); dcTest_deInitPlatform(); - return (success) ? 0 : -1; + return !success; } } // extern "C"
--- a/test/resolve_self/main.c Sun Oct 03 19:41:41 2021 +0200 +++ b/test/resolve_self/main.c Tue Oct 05 21:53:04 2021 +0200 @@ -6,7 +6,7 @@ Description: License: - Copyright (c) 2011-2018 Daniel Adler <dadler@uni-goettingen.de>, + Copyright (c) 2011-2021 Daniel Adler <dadler@uni-goettingen.de>, Tassilo Philipp <tphilipp@potion-studios.com> Permission to use, copy, modify, and distribute this software for any @@ -25,8 +25,8 @@ #include "../../dynload/dynload.h" #include "../../dyncall/dyncall_macros.h" -#include <assert.h> #include "../common/platformInit.h" +#include "../common/platformInit.c" /* Impl. for functions only used in this translation unit */ #ifdef DC_WINDOWS #define DLL_EXPORT __declspec( dllexport ) @@ -48,7 +48,14 @@ int status; DLSyms* pSyms; DLLib* pLib = dlLoadLibrary(NULL); - assert(pLib); + + dcTest_initPlatform(); + + if(!pLib) { + printf("failed to self-load via dlLoadLibrary(NULL)\n"); + return 1; + } + printf("self loaded at %p\n", pLib); address = dlFindSymbol(pLib, "add_dd_d"); @@ -68,6 +75,9 @@ dlSymsCleanup(pSyms);*/ printf("result: resolve_self: %d\n", status); - return 0; + + dcTest_deInitPlatform(); + + return !status; }
--- a/test/sign/sign.c Sun Oct 03 19:41:41 2021 +0200 +++ b/test/sign/sign.c Tue Oct 05 21:53:04 2021 +0200 @@ -6,7 +6,7 @@ Description: License: - Copyright (c) 2011-2018 Daniel Adler <dadler@uni-goettingen.de>, + Copyright (c) 2011-2021 Daniel Adler <dadler@uni-goettingen.de>, Tassilo Philipp <tphilipp@potion-studios.com> Permission to use, copy, modify, and distribute this software for any @@ -25,7 +25,6 @@ #include "dyncall.h" -#include "../common/platformInit.h" // This program demonstrates the need for 'unsigned' integers and the // ability to implement zero/sign extensions for small integers.
--- a/test/suite/main.c Sun Oct 03 19:41:41 2021 +0200 +++ b/test/suite/main.c Tue Oct 05 21:53:04 2021 +0200 @@ -3,10 +3,10 @@ Package: dyncall Library: test File: test/suite/main.c - Description: + Description: License: - Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>, + Copyright (c) 2007-2021 Daniel Adler <dadler@uni-goettingen.de>, Tassilo Philipp <tphilipp@potion-studios.com> Permission to use, copy, modify, and distribute this software for any @@ -89,13 +89,13 @@ valueDouble[i] = (DCdouble) (i); valuePointer[i] = (DCpointer) (ptrdiff_t) (i); valueFloat[i] = (DCfloat) (i); - } + } } void push(DCCallVM* pCall, int select, int pos) { - switch(select) + switch(select) { case ID_BOOL: dcArgBool ( pCall, valueBool [pos] ); break; case ID_INT: dcArgInt ( pCall, valueInt [pos] ); break; @@ -107,7 +107,7 @@ } -#define assert(x) if (!(x)) return DC_FALSE +#define test(x) if (!(x)) return DC_FALSE DCbool test(int x) @@ -120,21 +120,21 @@ dcReset(pCall); clearValues(); - for(pos = 0; y>0; ++pos) + for(pos = 0; y>0; ++pos) { - int select = (y-1) % NTYPES; + int select = (y-1) % NTYPES; selects[pos] = select; push(pCall,select,pos); y = (y-1) / NTYPES; } dcCallVoid(pCall,getFunc(x)); - - assert( getId() == x ); - + + test( getId() == x ); + for(i = 0;i<pos;++i) { - assert( equals( selects[i], i, getArg(i) ) ); + test( equals( selects[i], i, getArg(i) ) ); } - + dcFree(pCall); return DC_TRUE; } @@ -170,7 +170,7 @@ init(); if (argc == 2) { int index = atoi(argv[1]); - success = run_range( index, index+1 ); + success = run_range( index, index+1 ); } else if (argc == 3) { int from = atoi(argv[1]); int to = atoi(argv[2])+1; @@ -180,9 +180,10 @@ success = run_range(0,ncalls); } - printf("result: suite: %s\n", success ? "1" : "0"); + printf("result: suite: %d\n", success); dcTest_deInitPlatform(); - return (success) ? 0 : -1; + return !success; } +
--- a/test/suite2/main.cc Sun Oct 03 19:41:41 2021 +0200 +++ b/test/suite2/main.cc Tue Oct 05 21:53:04 2021 +0200 @@ -3,10 +3,10 @@ Package: dyncall Library: test File: test/suite2/main.cc - Description: + Description: License: - Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>, + Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>, Tassilo Philipp <tphilipp@potion-studios.com> Permission to use, copy, modify, and distribute this software for any @@ -88,12 +88,12 @@ const DCsigchar* ptr = sig; DCsigchar ch; int pos; - + pos = 0; pCall = dcNewCallVM(4096); dcReset(pCall); - + while ( (ch=*ptr++) != '\0' ) { switch(ch) { case DC_SIGCHAR_BOOL: dcArgBool ( pCall, valueBool [pos] ); break; @@ -111,8 +111,8 @@ dcCallVoid( pCall, fi->funcptr ); - - if ( getId() == x ) { + + if ( getId() == x ) { ptr = sig; pos = 0; @@ -137,7 +137,7 @@ } printf("%d-%s:%d\n", x, sig, r); - + dcFree(pCall); return r; @@ -162,7 +162,7 @@ init(); if (argc == 2) { int index = atoi(argv[1]); - success = run_range( index, index+1 ); + success = run_range( index, index+1 ); } else if (argc == 3) { int from = atoi(argv[1]); int to = atoi(argv[2])+1; @@ -171,11 +171,11 @@ success = run_range(0,NCASES); } - printf("result: suite2: %s\n", success ? "1" : "0"); + printf("result: suite2: %d\n", success); dcTest_deInitPlatform(); - return (success) ? 0 : -1; + return !success; } } // extern "C"
--- a/test/suite2_x86win32fast/main.cc Sun Oct 03 19:41:41 2021 +0200 +++ b/test/suite2_x86win32fast/main.cc Tue Oct 05 21:53:04 2021 +0200 @@ -176,11 +176,11 @@ success = run_range(0,NCASES); } - printf("result: suite2_x86win32fast: %s\n", success ? "1" : "0"); + printf("result: suite2_x86win32fast: %d\n", success); dcTest_deInitPlatform(); - return (success) ? 0 : -1; + return !success; } } // extern "C"
--- a/test/suite2_x86win32std/main.cc Sun Oct 03 19:41:41 2021 +0200 +++ b/test/suite2_x86win32std/main.cc Tue Oct 05 21:53:04 2021 +0200 @@ -169,11 +169,11 @@ success = run_range(0,NCASES); } - printf("result: suite2_x86win32std: %s\n", success ? "1" : "0"); + printf("result: suite2_x86win32std: %d\n", success); dcTest_deInitPlatform(); - return (success) ? 0 : -1; + return !success; } } // extern "C"
--- a/test/suite3/main.cc Sun Oct 03 19:41:41 2021 +0200 +++ b/test/suite3/main.cc Tue Oct 05 21:53:04 2021 +0200 @@ -3,10 +3,10 @@ Package: dyncall Library: test File: test/suite3/main.cc - Description: + Description: License: - Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>, + Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>, Tassilo Philipp <tphilipp@potion-studios.com> Permission to use, copy, modify, and distribute this software for any @@ -69,13 +69,13 @@ valueLongLong[i] = DClonglong(i); valueDouble[i] = DCdouble(i); valueFloat[i] = DCfloat(i); - } + } } void push(DCCallVM* pCall, int select, int pos) { - switch(select) + switch(select) { case 0: dcArgInt ( pCall, valueInt [pos] ); break; case 1: dcArgLongLong( pCall, valueLongLong[pos] ); break; @@ -85,7 +85,7 @@ } -#define assert(x) if (!(x)) return false +#define test(x) if (!(x)) return false bool test(int x) @@ -97,21 +97,21 @@ int y = x; int selects[NARGS] = { 0, }; int pos = 0; - for(pos = 0;y>0;++pos) + for(pos = 0;y>0;++pos) { - int select = (y-1) % NTYPES; + int select = (y-1) % NTYPES; selects[pos] = select; push(pCall,select,pos); y = (y-1) / NTYPES; } dcCallVoid(pCall,getFunc(x)); - - assert( getId() == x ); - + + test( getId() == x ); + for(int i = 0;i<pos;++i) { - assert( equals( selects[i], i, getArg(i) ) ); + test( equals( selects[i], i, getArg(i) ) ); } - + dcFree(pCall); return true; } @@ -146,7 +146,7 @@ init(); if (argc == 2) { int index = atoi(argv[1]); - success = run_range( index, index+1 ); + success = run_range( index, index+1 ); } else if (argc == 3) { int from = atoi(argv[1]); int to = atoi(argv[2])+1; @@ -156,11 +156,11 @@ success = run_range(0,ncalls); } - printf("result: suite3: %s\n", success ? "1" : "0"); + printf("result: suite3: %d\n", success); dcTest_deInitPlatform(); - return (success) ? 0 : -1; + return !success; } } // extern "C"
--- a/test/suite_floats/main.cc Sun Oct 03 19:41:41 2021 +0200 +++ b/test/suite_floats/main.cc Tue Oct 05 21:53:04 2021 +0200 @@ -3,10 +3,10 @@ Package: dyncall Library: test File: test/suite_floats/main.cc - Description: + Description: License: - Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>, + Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>, Tassilo Philipp <tphilipp@potion-studios.com> Permission to use, copy, modify, and distribute this software for any @@ -61,13 +61,13 @@ for (int i = 0 ; i < NARGS ; ++i ) { valueDouble[i] = DCdouble(i); valueFloat[i] = DCfloat(i); - } + } } void push(DCCallVM* pCall, int select, int pos) { - switch(select) + switch(select) { case 0: dcArgDouble ( pCall, valueDouble [pos] ); break; case 1: dcArgFloat ( pCall, valueFloat [pos] ); break; @@ -75,7 +75,7 @@ } -#define assert(x) if (!(x)) return false +#define test(x) if (!(x)) return false bool test(int x) @@ -87,21 +87,21 @@ int y = x; int selects[NARGS] = { 0, }; int pos = 0; - for(pos = 0;y>0;++pos) + for(pos = 0;y>0;++pos) { - int select = (y-1) % NTYPES; + int select = (y-1) % NTYPES; selects[pos] = select; push(pCall,select,pos); y = (y-1) / NTYPES; } dcCallVoid(pCall,getFunc(x)); - - assert( getId() == x ); - + + test( getId() == x ); + for(int i = 0;i<pos;++i) { - assert( equals( selects[i], i, getArg(i) ) ); + test( equals( selects[i], i, getArg(i) ) ); } - + dcFree(pCall); return true; } @@ -136,7 +136,7 @@ init(); if (argc == 2) { int index = atoi(argv[1]); - success = run_range( index, index+1 ); + success = run_range( index, index+1 ); } else if (argc == 3) { int from = atoi(argv[1]); int to = atoi(argv[2])+1; @@ -146,11 +146,11 @@ success = run_range(0,ncalls); } - printf("result: suite_floats: %s\n", success ? "1" : "0"); + printf("result: suite_floats: %d\n", success); dcTest_deInitPlatform(); - return (success) ? 0 : -1; + return !success; } } // extern "C"
--- a/test/suite_x86win32fast/main.cc Sun Oct 03 19:41:41 2021 +0200 +++ b/test/suite_x86win32fast/main.cc Tue Oct 05 21:53:04 2021 +0200 @@ -3,10 +3,10 @@ Package: dyncall Library: test File: test/suite_x86win32fast/main.cc - Description: + Description: License: - Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>, + Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>, Tassilo Philipp <tphilipp@potion-studios.com> Permission to use, copy, modify, and distribute this software for any @@ -80,13 +80,13 @@ valueDouble[i] = DCdouble(i); valuePointer[i] = DCpointer(i); valueFloat[i] = DCfloat(i); - } + } } void push(DCCallVM* pCall, int select, int pos) { - switch(select) + switch(select) { case 0: dcArgBool( pCall, valueBool[pos] ); break; case 1: dcArgInt( pCall, valueInt[pos] ); break; @@ -98,7 +98,7 @@ } -#define assert(x) if (!(x)) return false +#define test(x) if (!(x)) return false bool test(int x) @@ -116,21 +116,21 @@ int y = x; int selects[NARGS] = { 0, }; int pos = 0; - for(pos = 0;y>0;++pos) + for(pos = 0;y>0;++pos) { - int select = (y-1) % NTYPES; + int select = (y-1) % NTYPES; selects[pos] = select; push(pCall,select,pos); y = (y-1) / NTYPES; } dcCallVoid(pCall,getFunc(x)); - - assert( getId() == x ); - + + test( getId() == x ); + for(int i = 0;i<pos;++i) { - assert( equals( selects[i], i, getArg(i) ) ); + test( equals( selects[i], i, getArg(i) ) ); } - + dcFree(pCall); return true; } @@ -167,7 +167,7 @@ init(); if (argc == 2) { int index = atoi(argv[1]); - success = run_range( index, index+1 ); + success = run_range( index, index+1 ); } else if (argc == 3) { int from = atoi(argv[1]); int to = atoi(argv[2])+1; @@ -176,12 +176,12 @@ int ncalls = powerfact(NTYPES,NARGS)+1; success = run_range(0,ncalls); } - - printf("result: suite_x86win32fast: %s\n", success ? "1" : "0"); + + printf("result: suite_x86win32fast: %d\n", success); dcTest_deInitPlatform(); - return (success) ? 0 : -1; + return !success; } } // extern "C"
--- a/test/suite_x86win32std/main.cc Sun Oct 03 19:41:41 2021 +0200 +++ b/test/suite_x86win32std/main.cc Tue Oct 05 21:53:04 2021 +0200 @@ -3,10 +3,10 @@ Package: dyncall Library: test File: test/suite_x86win32std/main.cc - Description: + Description: License: - Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>, + Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>, Tassilo Philipp <tphilipp@potion-studios.com> Permission to use, copy, modify, and distribute this software for any @@ -79,13 +79,13 @@ valueDouble[i] = DCdouble(i); valuePointer[i] = DCpointer(i); valueFloat[i] = DCfloat(i); - } + } } void push(DCCallVM* pCall, int select, int pos) { - switch(select) + switch(select) { case 0: dcArgBool( pCall, valueBool[pos] ); break; case 1: dcArgInt( pCall, valueInt[pos] ); break; @@ -97,7 +97,7 @@ } -#define assert(x) if (!(x)) return false +#define test(x) if (!(x)) return false bool test(int x) @@ -110,21 +110,21 @@ int y = x; int selects[NARGS] = { 0, }; int pos = 0; - for(pos = 0;y>0;++pos) + for(pos = 0;y>0;++pos) { - int select = (y-1) % NTYPES; + int select = (y-1) % NTYPES; selects[pos] = select; push(pCall,select,pos); y = (y-1) / NTYPES; } dcCallVoid(pCall,getFunc(x)); - - assert( getId() == x ); - + + test( getId() == x ); + for(int i = 0;i<pos;++i) { - assert( equals( selects[i], i, getArg(i) ) ); + test( equals( selects[i], i, getArg(i) ) ); } - + dcFree(pCall); return true; } @@ -161,7 +161,7 @@ init(); if (argc == 2) { int index = atoi(argv[1]); - success = run_range( index, index+1 ); + success = run_range( index, index+1 ); } else if (argc == 3) { int from = atoi(argv[1]); int to = atoi(argv[2])+1; @@ -171,11 +171,11 @@ success = run_range(0,ncalls); } - printf("result: suite_x86win32std: %s\n", success ? "1" : "0"); - + printf("result: suite_x86win32std: %d\n", success); + dcTest_deInitPlatform(); - return (success) ? 0 : -1; + return !success; } } // extern "C"
--- a/test/syscall/syscall.c Sun Oct 03 19:41:41 2021 +0200 +++ b/test/syscall/syscall.c Tue Oct 05 21:53:04 2021 +0200 @@ -6,7 +6,7 @@ Description: License: - Copyright (c) 2011-2018 Daniel Adler <dadler@uni-goettingen.de>, + Copyright (c) 2011-2021 Daniel Adler <dadler@uni-goettingen.de>, Tassilo Philipp <tphilipp@potion-studios.com> Permission to use, copy, modify, and distribute this software for any @@ -25,15 +25,8 @@ #include "dyncall.h" #include <sys/syscall.h> -#include <assert.h> DCCallVM* callvm; -void syscallvm_init() -{ - callvm = dcNewCallVM(4096); - dcMode(callvm, DC_CALL_SYS_DEFAULT); - assert( dcGetError(callvm) == DC_ERROR_NONE ); -} int syscall_write(int fd, char* buf, size_t len) { @@ -46,8 +39,15 @@ int main(int argc, char* argv[]) { - syscallvm_init(); - syscall_write(1/*stdout*/, "result: syscall: 1\n", 19); - return 0; + int r = -1; + callvm = dcNewCallVM(4096); + dcMode(callvm, DC_CALL_SYS_DEFAULT); + + if(dcGetError(callvm) == DC_ERROR_NONE) + { + r = syscall_write(1/*stdout*/, "result: syscall: ", 17); + r += syscall_write(1/*stdout*/, r==17?"1":"0", 2); + } + return !(r == 19); }