From 993d5e30fa9085a05cc8231c49750e8bcc03170e Mon Sep 17 00:00:00 2001 From: Thorsten Kukuk Date: Sun, 12 Mar 2006 08:36:42 +0000 Subject: Relevant BUGIDs: Purpose of commit: new feature Commit summary: --------------- Add lot of tests for make check --- tests/tst-dlopen.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/tst-dlopen.c (limited to 'tests/tst-dlopen.c') diff --git a/tests/tst-dlopen.c b/tests/tst-dlopen.c new file mode 100644 index 00000000..9090367b --- /dev/null +++ b/tests/tst-dlopen.c @@ -0,0 +1,40 @@ +/* + Copyright (C) Nalin Dahyabhai 2003 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. +*/ + +#include +#include +#include +#include + +/* Simple program to see if dlopen() would succeed. */ +int main(int argc, char **argv) +{ + int i; + struct stat st; + char buf[PATH_MAX]; + + for (i = 1; i < argc; i++) { + if (dlopen(argv[i], RTLD_NOW)) { + fprintf(stdout, "dlopen() of \"%s\" succeeded.\n", + argv[i]); + } else { + snprintf(buf, sizeof(buf), "./%s", argv[i]); + if ((stat(buf, &st) == 0) && dlopen(buf, RTLD_NOW)) { + fprintf(stdout, "dlopen() of \"./%s\" " + "succeeded.\n", argv[i]); + } else { + fprintf(stdout, "dlopen() of \"%s\" failed: " + "%s\n", argv[i], dlerror()); + return 1; + } + } + } + return 0; +} + -- cgit v1.2.3