comparison test/resolve_self/main.c @ 214:0592eb360af2

tests: - added dynload_plain test - added some more output to resolv_self - cleanups
author Tassilo Philipp
date Thu, 06 Apr 2017 02:13:57 +0200
parents 3e629dc19168
children 318a9ffc2b85
comparison
equal deleted inserted replaced
213:98057b3b28c2 214:0592eb360af2
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-2015 Daniel Adler <dadler@uni-goettingen.de>, 9 Copyright (c) 2011-2017 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.
46 void* address; 46 void* address;
47 double result; 47 double result;
48 int status; 48 int status;
49 DLLib* pLib = dlLoadLibrary(NULL); 49 DLLib* pLib = dlLoadLibrary(NULL);
50 assert(pLib); 50 assert(pLib);
51 printf("self loaded at %p\n", pLib);
51 52
52 address = dlFindSymbol(pLib, "add_dd_d"); 53 address = dlFindSymbol(pLib, "add_dd_d");
53 assert(address); 54 if(address) {
54 result = ( (double (*) (double,double) ) address ) (20.0, 3.0); 55 printf("address of function add_dd_d at %p\n", address);
55 status = (result == 23); 56 result = ( (double (*) (double,double) ) address ) (20.0, 3.0);
57 status = (result == 23);
58 } else {
59 printf("can't resolve address of add_dd_d, it doesn't seem to be a *dynamic* symbol\n");
60 status = 0;
61 }
56 printf("result: resolve_self: %d\n", status); 62 printf("result: resolve_self: %d\n", status);
57 return 0; 63 return 0;
58 } 64 }