testsuite: Add libdl/dl05 reloc test.

This commit is contained in:
Chris Johns
2016-09-08 16:52:39 +10:00
parent 11323b7da9
commit d416061846
13 changed files with 1547 additions and 1 deletions
@@ -10,6 +10,7 @@ iostream
dl01
dl02
dl04
dl05
ftp01
fileio
flashdisk01
@@ -9,6 +9,7 @@ cdtest
dl01
dl02
dl04
dl05
fileio
flashdisk01
fsdosfsname01
@@ -11,6 +11,7 @@ crypt01
dl01
dl02
dl04
dl05
fileio
flashdisk01
fsdosfsformat01
+1 -1
View File
@@ -48,7 +48,7 @@ endif
if DLTESTS
_SUBDIRS += dl01 dl02 dl03
if HAS_CXX
_SUBDIRS += dl04
_SUBDIRS += dl04 dl05
endif
endif
+1
View File
@@ -128,6 +128,7 @@ dl01/Makefile
dl02/Makefile
dl03/Makefile
dl04/Makefile
dl05/Makefile
dumpbuf01/Makefile
ftp01/Makefile
gxx01/Makefile
+50
View File
@@ -0,0 +1,50 @@
rtems_tests_PROGRAMS = dl05
dl05_SOURCES = init.c dl-load.c dl-cpp.cpp dl-tar.c dl-tar.h
BUILT_SOURCES = dl-tar.c dl-tar.h
dist_rtems_tests_DATA = dl05.scn dl05.doc
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(top_srcdir)/../automake/compile.am
include $(top_srcdir)/../automake/leaf.am
AM_CPPFLAGS += -I$(top_srcdir)/../support/include
LINK_OBJS = $(dl05_OBJECTS)
LINK_LIBS = $(dl05_LDLIBS)
dl-o5.o: dl-o5.cpp
dl.tar: dl-o5.o
@rm -f $@
$(PAX) -w -f $@ $<
CLEANFILES += dl.tar
dl-tar.c: dl.tar
$(BIN2C) -C $< $@
CLEANFILES += dl-tar.c
dl-tar.h: dl.tar
$(BIN2C) -H $< $@
CLEANFILES += dl-tar.h
dl05.pre$(EXEEXT): $(dl05_OBJECTS) $(dl05_DEPENDENCIES)
@rm -f dl05.pre$(EXEEXT)
$(LINK.cc) $(CPU_CFLAGS) $(AM_CFLAGS) $(AM_LDFLAGS) \
-o $(basename $@)$(EXEEXT) $(LINK_OBJS) $(LINK_LIBS)
rm -f dl05.pre.ralf
dl05.pre: dl05.pre$(EXEEXT)
mv $< $@
CLEANFILES += dl05.pre
dl-sym.o: dl05.pre
rtems-syms -e -c "$(CFLAGS)" -o $@ $<
dl05$(EXEEXT): $(dl05_OBJECTS) $(dl05_DEPENDENCIES) dl-sym.o
@rm -f dl05$(EXEEXT)
$(LINK.cc) $(CPU_CFLAGS) $(AM_CFLAGS) $(AM_LDFLAGS) \
-o $(basename $@)$(EXEEXT) $(LINK_OBJS) dl-sym.o $(LINK_LIBS)
include $(top_srcdir)/../automake/local.am
+14
View File
@@ -0,0 +1,14 @@
/*
* The base image needs this to include the RTTI data.
*/
#include <cstdio>
#include <stdexcept>
#include "dl-load.h"
void exception_base(bool istrue)
{
printf("exception_base called\n");
if (istrue)
{
throw std::runtime_error("dummy call to link in symbols");
}
}
+47
View File
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2016 Chris Johns <chrisj@rtems.org>. All rights reserved.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "tmacros.h"
#include <stdio.h>
#include <dlfcn.h>
#include <rtems/rtl/rtl-trace.h>
#include "dl-load.h"
int dl_load_test(void)
{
void* handle;
const char* err;
void (*func)(void);
rtems_rtl_trace_set_mask(RTEMS_RTL_TRACE_ALL);
handle = dlopen("/dl-o5.o", RTLD_GLOBAL | RTLD_NOW);
err = dlerror();
if (err != NULL)
printf("dlopen: %s\n", err);
rtems_test_assert(handle != NULL);
func = dlsym(handle, "exception_dl");
err = dlerror ();
if (err)
printf ("dlsym: %s\n", err);
rtems_test_assert(func != NULL);
exception_base(false);
func();
rtems_test_assert(dlclose(handle) == 0);
return 0;
}
+25
View File
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2016 Chris Johns <chrisj@rtems.org>. All rights reserved.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#if !defined(_DL_LOAD_H_)
#define _DL_LOAD_H_
#ifdef __cplusplus
extern "C" {
#endif
void exception_base(bool istrue);
void exception_dl(void);
int dl_load_test(void);
#ifdef __cplusplus
}
#endif
#endif
+19
View File
@@ -0,0 +1,19 @@
#include <cstdio>
#include <stdexcept>
#include "dl-load.h" /* make the symbol a C linkage */
void exception_dl(void)
{
try
{
printf("exception_dl: throwing\n");
throw std::runtime_error("exception_dl throw");
}
catch (std::exception const& e)
{
printf("%s: caught: %s\n", __func__, e.what());
}
catch (...)
{
printf("%s: caught: unknown\n", __func__);
}
}
+24
View File
@@ -0,0 +1,24 @@
# Copyright (c) 2016 Chris Johns <chrisj@rtems.org>
#
# The license and distribution terms for this file may be
# found in the file LICENSE in this distribution or at
# http://www.rtems.org/license/LICENSE.
#
This file describes the directives and concepts tested by this test set.
test set name: dl04
directives:
dlopen
dlerror
dlclose
concepts:
+ Load a single ELF object file containing C++ code with an exception.
+ Throw the exception.
+ Unload the ELF file.
Note: the test fails because terminate is raised.
File diff suppressed because it is too large Load Diff
+82
View File
@@ -0,0 +1,82 @@
/*
* Copyright (c) 2016 Chris Johns <chrisj@rtems.org>. All rights reserved.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "tmacros.h"
#include <errno.h>
#include <string.h>
#include <stdint.h>
#include <unistd.h>
#include <rtems/rtl/rtl.h>
#include <rtems/untar.h>
#include "dl-load.h"
const char rtems_test_name[] = "libdl (RTL) 5";
/* forward declarations to avoid warnings */
static rtems_task Init(rtems_task_argument argument);
#include "dl-tar.h"
#define TARFILE_START dl_tar
#define TARFILE_SIZE dl_tar_size
static int test(void)
{
int ret;
ret = dl_load_test();
if (ret)
rtems_test_exit(ret);
return 0;
}
static void Init(rtems_task_argument arg)
{
int te;
TEST_BEGIN();
te = Untar_FromMemory((void *)TARFILE_START, (size_t)TARFILE_SIZE);
if (te != 0)
{
printf("untar failed: %d\n", te);
rtems_test_exit(1);
exit (1);
}
test();
TEST_END();
rtems_test_exit(0);
}
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
#define CONFIGURE_MAXIMUM_TASKS 1
#define CONFIGURE_MINIMUM_TASK_STACK_SIZE (8U * 1024U)
#define CONFIGURE_EXTRA_TASK_STACKS (8 * 1024)
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>