tests/snprintf/Makefile
tests/test-nevents/Makefile
tests/test-libustinstr-malloc/Makefile
+ tests/dlopen/Makefile
libustinstr-malloc/Makefile
libustfork/Makefile
ustd/Makefile
-SUBDIRS = hello hello2 basic basic_long fork simple_include snprintf test-nevents test-libustinstr-malloc
+SUBDIRS = hello hello2 basic basic_long fork simple_include snprintf test-nevents test-libustinstr-malloc dlopen
dist_noinst_SCRIPTS = test_loop runtests trace_matches
--- /dev/null
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
+noinst_PROGRAMS = dlopen
+noinst_LTLIBRARIES = libdummy.la
+libdummy_la_SOURCES = libdummy.c
+libdummy_la_LIBADD = $(top_builddir)/libust/libust.la $(top_builddir)/libust-initializer.o
+libdummy_la_LDFLAGS = -rpath /nowhere
+dlopen_SOURCES = dlopen.c
+dlopen_LDADD = -ldl $(top_builddir)/libust/libust.la $(top_builddir)/libust-initializer.o
+
+noinst_SCRIPTS = run
+EXTRA_DIST = run
--- /dev/null
+/* Copyright (C) 2010 Oussama El Mfadli, Alexis Hallé
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <dlfcn.h>
+#include <stdio.h>
+#include <ust/marker.h>
+
+int main()
+{
+ int (*fptr)();
+
+ trace_mark(ust, from_main_before_lib, "%s", "Event occured in the main program before"
+ " the opening of the library\n");
+ void *lib_handle = dlopen("libdummy.so", RTLD_LAZY);
+
+ if (lib_handle == NULL) {
+ fprintf(stderr, "%s\n", dlerror());
+ return 1;
+ }
+
+ fptr = (int (*)())dlsym(lib_handle, "exported_function");
+
+ if ( fptr == NULL) {
+ fprintf(stderr, "%s\n", dlerror());
+ return 1;
+ }
+
+ (*fptr)();
+ dlclose(lib_handle);
+
+ trace_mark(ust, from_main_after_lib,"%s", "Event occured in the main program after "
+ "the library has been closed\n");
+
+ return 0;
+}
--- /dev/null
+/* Copyright (C) 2010 Oussama El Mfadli, Alexis Hallé
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <ust/marker.h>
+
+void exported_function()
+{
+ trace_mark(ust, from_library, "%s", "Event occured in library function");
+}
--- /dev/null
+#!/bin/sh
+
+UST_AUTOPROBE=1 UST_TRACE=1 LD_LIBRARY_PATH=./.libs $1 ./dlopen
echo "Valgrind output is in $VALG_OUT"
NOFAIL [ -z "$(<$VALG_OUT)" ]
+### dlopen ###
+starttest "dlopen"
+LD_LIBRARY_PATH=$TESTDIR/dlopen/.libs NOFAIL usttrace $TESTDIR/dlopen/dlopen
+trace_loc=$(usttrace -W)
+NOFAIL $MATCHES -N "from_library" -n 1 "^ust.from_library:" $trace_loc
+NOFAIL $MATCHES -N "from_main_before_lib" -n 1 "^ust.from_main_before_lib:" $trace_loc
+NOFAIL $MATCHES -N "from_main_after_lib" -n 1 "^ust.from_main_after_lib:" $trace_loc
echo "************************************"
echo "$0: All passed"
echo "************************************"