Mercurial > pub > dyncall > dyncall
comparison test/resolve_self/main.c @ 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 | f5577f6bf97a |
children |
comparison
equal
deleted
inserted
replaced
409:15698dc0cba3 | 410:7608e34098b0 |
---|---|
4 Library: test | 4 Library: test |
5 File: test/resolve_self/main.c | 5 File: test/resolve_self/main.c |
6 Description: | 6 Description: |
7 License: | 7 License: |
8 | 8 |
9 Copyright (c) 2011-2018 Daniel Adler <dadler@uni-goettingen.de>, | 9 Copyright (c) 2011-2021 Daniel Adler <dadler@uni-goettingen.de>, |
10 Tassilo Philipp <tphilipp@potion-studios.com> | 10 Tassilo Philipp <tphilipp@potion-studios.com> |
11 | 11 |
12 Permission to use, copy, modify, and distribute this software for any | 12 Permission to use, copy, modify, and distribute this software for any |
13 purpose with or without fee is hereby granted, provided that the above | 13 purpose with or without fee is hereby granted, provided that the above |
14 copyright notice and this permission notice appear in all copies. | 14 copyright notice and this permission notice appear in all copies. |
23 | 23 |
24 */ | 24 */ |
25 | 25 |
26 #include "../../dynload/dynload.h" | 26 #include "../../dynload/dynload.h" |
27 #include "../../dyncall/dyncall_macros.h" | 27 #include "../../dyncall/dyncall_macros.h" |
28 #include <assert.h> | |
29 #include "../common/platformInit.h" | 28 #include "../common/platformInit.h" |
29 #include "../common/platformInit.c" /* Impl. for functions only used in this translation unit */ | |
30 | 30 |
31 #ifdef DC_WINDOWS | 31 #ifdef DC_WINDOWS |
32 #define DLL_EXPORT __declspec( dllexport ) | 32 #define DLL_EXPORT __declspec( dllexport ) |
33 #else | 33 #else |
34 #define DLL_EXPORT | 34 #define DLL_EXPORT |
46 void* address; | 46 void* address; |
47 double result; | 47 double result; |
48 int status; | 48 int status; |
49 DLSyms* pSyms; | 49 DLSyms* pSyms; |
50 DLLib* pLib = dlLoadLibrary(NULL); | 50 DLLib* pLib = dlLoadLibrary(NULL); |
51 assert(pLib); | 51 |
52 dcTest_initPlatform(); | |
53 | |
54 if(!pLib) { | |
55 printf("failed to self-load via dlLoadLibrary(NULL)\n"); | |
56 return 1; | |
57 } | |
58 | |
52 printf("self loaded at %p\n", pLib); | 59 printf("self loaded at %p\n", pLib); |
53 | 60 |
54 address = dlFindSymbol(pLib, "add_dd_d"); | 61 address = dlFindSymbol(pLib, "add_dd_d"); |
55 if(address) { | 62 if(address) { |
56 printf("address of function add_dd_d at %p\n", address); | 63 printf("address of function add_dd_d at %p\n", address); |
66 /*pSyms = dlSymsInit(NULL); | 73 /*pSyms = dlSymsInit(NULL); |
67 printf("syms handle: %p\n", pSyms); | 74 printf("syms handle: %p\n", pSyms); |
68 dlSymsCleanup(pSyms);*/ | 75 dlSymsCleanup(pSyms);*/ |
69 | 76 |
70 printf("result: resolve_self: %d\n", status); | 77 printf("result: resolve_self: %d\n", status); |
71 return 0; | 78 |
79 dcTest_deInitPlatform(); | |
80 | |
81 return !status; | |
72 } | 82 } |
73 | 83 |