forked from Imagelibrary/rtems
libdl: Back port C++ exception throw and catch from 4.12.
Closes #2956.
This commit is contained in:
@@ -44,7 +44,7 @@ _SUBDIRS += syscall01
|
||||
endif
|
||||
|
||||
if DLTESTS
|
||||
_SUBDIRS += dl01 dl02
|
||||
_SUBDIRS += dl01 dl02 dl03 dl04 dl05
|
||||
endif
|
||||
|
||||
include $(top_srcdir)/../automake/test-subdirs.am
|
||||
|
||||
@@ -127,6 +127,9 @@ deviceio01/Makefile
|
||||
devnullfatal01/Makefile
|
||||
dl01/Makefile
|
||||
dl02/Makefile
|
||||
dl03/Makefile
|
||||
dl04/Makefile
|
||||
dl05/Makefile
|
||||
dumpbuf01/Makefile
|
||||
ftp01/Makefile
|
||||
gxx01/Makefile
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
|
||||
|
||||
*** BEGIN OF TEST libdl (RTL) 1 ***
|
||||
load: /dl-o1.o
|
||||
handle: 0x2137d8 loaded
|
||||
Loaded module: argc:2
|
||||
[../../../../../../../../rtems.master/c/src/../../testsuites/libtests/dl01/dl-o1.c]
|
||||
handle: 0x2048cf0 loaded
|
||||
Loaded module: argc:2 [/opt/work/chris/rtems/kernel/rtems.git/c/src/../../testsuites/libtests/dl01/dl-o1.c]
|
||||
0: Line 1
|
||||
1: Line 2
|
||||
Loaded module: argc:3
|
||||
[../../../../../../../../rtems.master/c/src/../../testsuites/libtests/dl01/dl-o1.c]
|
||||
Loaded module: argc:3 [/opt/work/chris/rtems/kernel/rtems.git/c/src/../../testsuites/libtests/dl01/dl-o1.c]
|
||||
0: Call 2, line 1
|
||||
1: Call 2, line 2
|
||||
2: Call 2, line 3
|
||||
handle: 0x2137d8 closed
|
||||
handle: 0x2048cf0 closed
|
||||
*** END OF TEST libdl (RTL) 1 ***
|
||||
|
||||
@@ -73,6 +73,8 @@ static void Init(rtems_task_argument arg)
|
||||
|
||||
#define CONFIGURE_EXTRA_TASK_STACKS (8 * 1024)
|
||||
|
||||
#define CONFIGURE_MAXIMUM_SEMAPHORES 1
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
@@ -80,4 +82,3 @@ static void Init(rtems_task_argument arg)
|
||||
#define CONFIGURE_INIT
|
||||
|
||||
#include <rtems/confdefs.h>
|
||||
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
|
||||
|
||||
*** BEGIN OF TEST libdl (RTL) 2 ***
|
||||
load: /dl-o1.o
|
||||
handle: 0x2150d0 has unresolved externals
|
||||
handle: 0x204da80 has unresolved externals
|
||||
load: /dl-o2.o
|
||||
handle: 0x215838 loaded
|
||||
Loaded module: argc:4
|
||||
[../../../../../../../../rtems.master/c/src/../../testsuites/libtests/dl02/dl-o1.c]
|
||||
handle: 0x204ea98 loaded
|
||||
Loaded module: argc:4 [/opt/work/chris/rtems/kernel/rtems.git/c/src/../../testsuites/libtests/dl02/dl-o1.c]
|
||||
0: 1
|
||||
1: 2
|
||||
2: 3
|
||||
3: 4
|
||||
Loaded module: argc:4
|
||||
[../../../../../../../../rtems.master/c/src/../../testsuites/libtests/dl02/dl-o2.c]
|
||||
Loaded module: argc:4 [/opt/work/chris/rtems/kernel/rtems.git/c/src/../../testsuites/libtests/dl02/dl-o2.c]
|
||||
0: 1
|
||||
1: 2
|
||||
2: 3
|
||||
3: 4
|
||||
dl_o1_callback: string in dl_o2
|
||||
rtems_main: callback count: 3
|
||||
handle: 0x2150d0 closed
|
||||
handle: 0x215838 closed
|
||||
handle: 0x204da80 closed
|
||||
handle: 0x204ea98 closed
|
||||
*** END OF TEST libdl (RTL) 2 ***
|
||||
|
||||
@@ -73,6 +73,8 @@ static void Init(rtems_task_argument arg)
|
||||
|
||||
#define CONFIGURE_EXTRA_TASK_STACKS (8 * 1024)
|
||||
|
||||
#define CONFIGURE_MAXIMUM_SEMAPHORES 1
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
|
||||
19
testsuites/libtests/dl03/Makefile.am
Normal file
19
testsuites/libtests/dl03/Makefile.am
Normal file
@@ -0,0 +1,19 @@
|
||||
rtems_tests_PROGRAMS = dl03
|
||||
dl03_SOURCES = init.c dl-cache.c
|
||||
|
||||
dist_rtems_tests_DATA = dl03.scn dl03.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 = $(dl03_OBJECTS)
|
||||
LINK_LIBS = $(dl03_LDLIBS)
|
||||
|
||||
dl03$(EXEEXT): $(dl03_OBJECTS) $(dl03_DEPENDENCIES)
|
||||
@rm -f dl03$(EXEEXT)
|
||||
$(make-exe)
|
||||
|
||||
include $(top_srcdir)/../automake/local.am
|
||||
296
testsuites/libtests/dl03/dl-cache.c
Normal file
296
testsuites/libtests/dl03/dl-cache.c
Normal file
@@ -0,0 +1,296 @@
|
||||
/*
|
||||
* 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 <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <rtems/rtl/rtl.h>
|
||||
#include <rtems/rtl/rtl-obj-cache.h>
|
||||
#include <rtems/rtl/rtl-trace.h>
|
||||
|
||||
#include "dl-cache.h"
|
||||
|
||||
#define CACHE_SIZE (2048)
|
||||
#define CACHE_SIZE_TOO_BIG (-1)
|
||||
#define CACHE_BUFFER_SIZE (CACHE_SIZE * 4)
|
||||
|
||||
static uint8_t* contents;
|
||||
|
||||
static const char const* filename = "/dl-test";
|
||||
|
||||
static void dl_cache_create_file(void)
|
||||
{
|
||||
uint16_t* p;
|
||||
int fd;
|
||||
int i;
|
||||
rtems_test_assert((contents = malloc(CACHE_BUFFER_SIZE)) != NULL);
|
||||
memset(contents, 0, CACHE_BUFFER_SIZE);
|
||||
p = (uint16_t*) contents;
|
||||
for (i = 0; i < (CACHE_BUFFER_SIZE / sizeof(uint16_t)); ++i)
|
||||
*p++ = i;
|
||||
rtems_test_assert((fd = open(filename,
|
||||
O_WRONLY | O_TRUNC | O_CREAT,
|
||||
S_IRUSR | S_IWUSR)) >= 0);
|
||||
rtems_test_assert(write(fd, contents, CACHE_BUFFER_SIZE) == CACHE_BUFFER_SIZE);
|
||||
rtems_test_assert(close(fd) >= 0);
|
||||
}
|
||||
|
||||
static bool dl_cache_check(void* buffer, off_t offset, size_t length)
|
||||
{
|
||||
uint16_t* b;
|
||||
uint16_t* c;
|
||||
int i;
|
||||
b = buffer;
|
||||
c = (uint16_t*) (contents + offset);
|
||||
printf("cache: buffer: ");
|
||||
for (i = 0; i < 4; ++i)
|
||||
printf("%04x/%04x ", b[i], c[i]);
|
||||
printf("\n");
|
||||
return memcmp(buffer, contents + offset, length) == 0;
|
||||
}
|
||||
|
||||
static off_t dl_cache_buffer_offset(rtems_rtl_obj_cache_t* cache, void* buffer)
|
||||
{
|
||||
return (off_t) (((uint8_t*) buffer) - ((uint8_t*) cache->buffer));
|
||||
}
|
||||
|
||||
static void dl_init_rtl(void)
|
||||
{
|
||||
/*
|
||||
* Check the RTL object is created and can be locked and unlocked.
|
||||
*/
|
||||
rtems_test_assert(rtems_rtl_data () == NULL);
|
||||
rtems_test_assert(rtems_rtl_lock () != NULL);
|
||||
rtems_test_assert(rtems_rtl_unlock () == true);
|
||||
rtems_test_assert(rtems_rtl_data () != NULL);
|
||||
rtems_rtl_trace_set_mask(RTEMS_RTL_TRACE_ALL | RTEMS_RTL_TRACE_CACHE);
|
||||
}
|
||||
|
||||
int dl_cache_test(void)
|
||||
{
|
||||
rtems_rtl_obj_cache_t cache;
|
||||
int fd;
|
||||
void* buffer;
|
||||
off_t offset_in;
|
||||
off_t offset;
|
||||
size_t length_in;
|
||||
size_t length;
|
||||
|
||||
/*
|
||||
* Make sure the RTL can initialise.
|
||||
*/
|
||||
dl_init_rtl();
|
||||
|
||||
/*
|
||||
* Create the file to test the cache with.
|
||||
*/
|
||||
dl_cache_create_file();
|
||||
|
||||
/*
|
||||
* Check the too big error is handled.
|
||||
*/
|
||||
printf ("cache create with large size\n");
|
||||
rtems_test_assert(rtems_rtl_obj_cache_open(&cache,
|
||||
CACHE_SIZE_TOO_BIG) == false);
|
||||
|
||||
/*
|
||||
* Create a cache.
|
||||
*/
|
||||
printf ("cache create\n");
|
||||
rtems_test_assert(rtems_rtl_obj_cache_open(&cache,
|
||||
CACHE_SIZE) == true);
|
||||
rtems_test_assert(cache.fd == -1);
|
||||
rtems_test_assert(cache.file_size == 0);
|
||||
rtems_test_assert(cache.size == CACHE_SIZE);
|
||||
rtems_test_assert(cache.buffer != NULL);
|
||||
|
||||
/*
|
||||
* Open the file to use with the cache tests.
|
||||
*/
|
||||
printf ("cache file open\n");
|
||||
rtems_test_assert((fd = open(filename, O_RDONLY)) >= 0);
|
||||
|
||||
buffer = NULL; offset_in = 0; length_in = length = CACHE_SIZE / 2;
|
||||
printf("cache read: in: offset=%d length=%d\n", (int) offset_in, (int) length);
|
||||
rtems_test_assert(rtems_rtl_obj_cache_read(&cache,
|
||||
fd,
|
||||
offset_in,
|
||||
&buffer,
|
||||
&length) == true);
|
||||
offset = dl_cache_buffer_offset(&cache, buffer);
|
||||
printf("cache read: out: offset=%d length=%d\n", (int) offset, (int) length);
|
||||
rtems_test_assert(offset == offset_in);
|
||||
rtems_test_assert(length == length_in);
|
||||
rtems_test_assert(dl_cache_check(buffer, (int) offset_in, length) == true);
|
||||
|
||||
buffer = NULL; offset_in = 0; length_in = length = CACHE_SIZE;
|
||||
printf("cache read: in: offset=%d length=%d\n", (int) offset_in, (int) length);
|
||||
rtems_test_assert(rtems_rtl_obj_cache_read(&cache,
|
||||
fd,
|
||||
offset_in,
|
||||
&buffer,
|
||||
&length) == true);
|
||||
offset = dl_cache_buffer_offset(&cache, buffer);
|
||||
printf("cache read: out: offset=%d length=%d\n", (int) offset, (int) length);
|
||||
rtems_test_assert(offset == offset_in);
|
||||
rtems_test_assert(length == length_in);
|
||||
rtems_test_assert(dl_cache_check(buffer, (int) offset_in, length) == true);
|
||||
|
||||
buffer = NULL; offset_in = CACHE_SIZE / 2; length_in = length = CACHE_SIZE / 2;
|
||||
printf("cache read: in: offset=%d length=%d\n", (int) offset_in, (int) length);
|
||||
rtems_test_assert(rtems_rtl_obj_cache_read(&cache,
|
||||
fd,
|
||||
offset_in,
|
||||
&buffer,
|
||||
&length) == true);
|
||||
offset = dl_cache_buffer_offset(&cache, buffer);
|
||||
printf("cache read: out: offset=%d length=%d\n", (int) offset, (int) length);
|
||||
rtems_test_assert(offset == offset_in);
|
||||
rtems_test_assert(length == length_in);
|
||||
rtems_test_assert(dl_cache_check(buffer, (int) offset_in, length) == true);
|
||||
|
||||
buffer = NULL; offset_in = CACHE_BUFFER_SIZE - CACHE_SIZE; length_in = length = CACHE_SIZE;
|
||||
printf("cache read: in: offset=%d length=%d\n", (int) offset_in, (int) length);
|
||||
rtems_test_assert(rtems_rtl_obj_cache_read(&cache,
|
||||
fd,
|
||||
offset_in,
|
||||
&buffer,
|
||||
&length) == true);
|
||||
offset = dl_cache_buffer_offset(&cache, buffer);
|
||||
printf("cache read: out: offset=%d length=%d\n", (int) offset, (int) length);
|
||||
rtems_test_assert(offset == 0);
|
||||
rtems_test_assert(length == length_in);
|
||||
rtems_test_assert(dl_cache_check(buffer, (int) offset_in, length) == true);
|
||||
|
||||
buffer = NULL; offset_in = CACHE_BUFFER_SIZE - (CACHE_SIZE / 2); length_in = length = CACHE_SIZE / 2;
|
||||
printf("cache read: in: offset=%d length=%d\n", (int) offset_in, (int) length);
|
||||
rtems_test_assert(rtems_rtl_obj_cache_read(&cache,
|
||||
fd,
|
||||
offset_in,
|
||||
&buffer,
|
||||
&length) == true);
|
||||
offset = dl_cache_buffer_offset(&cache, buffer);
|
||||
printf("cache read: out: offset=%d length=%d\n", (int) offset, (int) length);
|
||||
rtems_test_assert(offset == (CACHE_SIZE / 2));
|
||||
rtems_test_assert(length == length_in);
|
||||
rtems_test_assert(dl_cache_check(buffer, (int) offset_in, length) == true);
|
||||
|
||||
buffer = NULL; offset_in = 0; length_in = length = CACHE_SIZE / 4;
|
||||
printf("cache read: in: offset=%d length=%d\n", (int) offset_in, (int) length);
|
||||
rtems_test_assert(rtems_rtl_obj_cache_read(&cache,
|
||||
fd,
|
||||
offset_in,
|
||||
&buffer,
|
||||
&length) == true);
|
||||
offset = dl_cache_buffer_offset(&cache, buffer);
|
||||
printf("cache read: out: offset=%d length=%d\n", (int) offset, (int) length);
|
||||
rtems_test_assert(offset == offset_in);
|
||||
rtems_test_assert(length == length_in);
|
||||
rtems_test_assert(dl_cache_check(buffer, (int) offset_in, length) == true);
|
||||
|
||||
buffer = NULL; offset_in = 0; length_in = length = CACHE_SIZE / 8;
|
||||
printf("cache read: in: offset=%d length=%d\n", (int) offset_in, (int) length);
|
||||
rtems_test_assert(rtems_rtl_obj_cache_read(&cache,
|
||||
fd,
|
||||
offset_in,
|
||||
&buffer,
|
||||
&length) == true);
|
||||
offset = dl_cache_buffer_offset(&cache, buffer);
|
||||
printf("cache read: out: offset=%d length=%d\n", (int) offset, (int) length);
|
||||
rtems_test_assert(offset == offset_in);
|
||||
rtems_test_assert(length == length_in);
|
||||
rtems_test_assert(dl_cache_check(buffer, (int) offset_in, length) == true);
|
||||
|
||||
buffer = NULL; offset_in = 0; length_in = length = CACHE_SIZE;
|
||||
printf("cache read: in: offset=%d length=%d\n", (int) offset_in, (int) length);
|
||||
rtems_test_assert(rtems_rtl_obj_cache_read(&cache,
|
||||
fd,
|
||||
offset_in,
|
||||
&buffer,
|
||||
&length) == true);
|
||||
offset = dl_cache_buffer_offset(&cache, buffer);
|
||||
printf("cache read: out: offset=%d length=%d\n", (int) offset, (int) length);
|
||||
rtems_test_assert(offset == offset_in);
|
||||
rtems_test_assert(length == length_in);
|
||||
rtems_test_assert(dl_cache_check(buffer, (int) offset_in, length) == true);
|
||||
|
||||
buffer = NULL; offset_in = CACHE_BUFFER_SIZE - 40; length_in = length = 16;
|
||||
printf("cache read: in: offset=%d length=%d\n", (int) offset_in, (int) length);
|
||||
rtems_test_assert(rtems_rtl_obj_cache_read(&cache,
|
||||
fd,
|
||||
offset_in,
|
||||
&buffer,
|
||||
&length) == true);
|
||||
offset = dl_cache_buffer_offset(&cache, buffer);
|
||||
printf("cache read: out: offset=%d length=%d\n", (int) offset, (int) length);
|
||||
rtems_test_assert(length == length_in);
|
||||
rtems_test_assert(dl_cache_check(buffer, (int) offset_in, length) == true);
|
||||
|
||||
buffer = NULL; offset_in = CACHE_BUFFER_SIZE - 40; length_in = length = 40;
|
||||
printf("cache read: in: offset=%d length=%d\n", (int) offset_in, (int) length);
|
||||
rtems_test_assert(rtems_rtl_obj_cache_read(&cache,
|
||||
fd,
|
||||
offset_in,
|
||||
&buffer,
|
||||
&length) == true);
|
||||
offset = dl_cache_buffer_offset(&cache, buffer);
|
||||
printf("cache read: out: offset=%d length=%d\n", (int) offset, (int) length);
|
||||
rtems_test_assert(length == length_in);
|
||||
rtems_test_assert(dl_cache_check(buffer, (int) offset_in, length) == true);
|
||||
|
||||
buffer = NULL; offset_in = CACHE_BUFFER_SIZE - 40; length_in = length = 80;
|
||||
printf("cache read: in: offset=%d length=%d\n", (int) offset_in, (int) length);
|
||||
rtems_test_assert(rtems_rtl_obj_cache_read(&cache,
|
||||
fd,
|
||||
offset_in,
|
||||
&buffer,
|
||||
&length) == true);
|
||||
offset = dl_cache_buffer_offset(&cache, buffer);
|
||||
printf("cache read: out: offset=%d length=%d\n", (int) offset, (int) length);
|
||||
rtems_test_assert(length == 40);
|
||||
rtems_test_assert(dl_cache_check(buffer, (int) offset_in, length) == true);
|
||||
|
||||
buffer = NULL; offset_in = CACHE_BUFFER_SIZE - CACHE_SIZE + 80;
|
||||
length_in = length = 20;
|
||||
printf("cache read: in: offset=%d length=%d\n", (int) offset_in, (int) length);
|
||||
rtems_test_assert(rtems_rtl_obj_cache_read(&cache,
|
||||
fd,
|
||||
offset_in,
|
||||
&buffer,
|
||||
&length) == true);
|
||||
offset = dl_cache_buffer_offset(&cache, buffer);
|
||||
printf("cache read: out: offset=%d length=%d\n", (int) offset, (int) length);
|
||||
rtems_test_assert(length == length_in);
|
||||
rtems_test_assert(dl_cache_check(buffer, (int) offset_in, length) == true);
|
||||
|
||||
buffer = NULL; offset_in = CACHE_BUFFER_SIZE - 40;
|
||||
length_in = length = 40;
|
||||
printf("cache read: in: offset=%d length=%d\n", (int) offset_in, (int) length);
|
||||
rtems_test_assert(rtems_rtl_obj_cache_read(&cache,
|
||||
fd,
|
||||
offset_in,
|
||||
&buffer,
|
||||
&length) == true);
|
||||
offset = dl_cache_buffer_offset(&cache, buffer);
|
||||
printf("cache read: out: offset=%d length=%d\n", (int) offset, (int) length);
|
||||
rtems_test_assert(length == length_in);
|
||||
rtems_test_assert(dl_cache_check(buffer, (int) offset_in, length) == true);
|
||||
|
||||
rtems_rtl_obj_cache_close(&cache);
|
||||
|
||||
return 0;
|
||||
}
|
||||
14
testsuites/libtests/dl03/dl-cache.h
Normal file
14
testsuites/libtests/dl03/dl-cache.h
Normal file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* 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_CACHE_H_)
|
||||
#define _DL_CACHE_H_
|
||||
|
||||
int dl_cache_test(void);
|
||||
|
||||
#endif
|
||||
28
testsuites/libtests/dl03/dl03.doc
Normal file
28
testsuites/libtests/dl03/dl03.doc
Normal file
@@ -0,0 +1,28 @@
|
||||
# Copyright (c) 2014 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: dl02
|
||||
|
||||
directives:
|
||||
|
||||
dlopen
|
||||
dlinfo
|
||||
dlsym
|
||||
dlclose
|
||||
|
||||
concepts:
|
||||
|
||||
+ Load 2 interdependent ELF object files.
|
||||
+ Check there are no unreolved externals. There should be unresolved
|
||||
externals after the first lond and none after the second load.
|
||||
+ Locate the rtems_main symbol in dl-o1.
|
||||
+ Call the rtems_main sym and have that function call the second object.
|
||||
Call the second download with a callback handler to a symbol in the first
|
||||
object file.
|
||||
+ Unload the ELF files.
|
||||
69
testsuites/libtests/dl03/dl03.scn
Normal file
69
testsuites/libtests/dl03/dl03.scn
Normal file
@@ -0,0 +1,69 @@
|
||||
|
||||
|
||||
*** BEGIN OF TEST libdl (RTL) 3 ***
|
||||
cache create with large size
|
||||
rtl: alloc: new: OBJECT addr=0x0 size=4294967295
|
||||
cache create
|
||||
rtl: alloc: new: OBJECT addr=0x2038bc8 size=2048
|
||||
cache file open
|
||||
cache read: in: offset=0 length=1024
|
||||
rtl: cache: 3: fd=-1 offset=0 length=1024 area=[0,1024] cache=[0,0] size=0
|
||||
rtl: cache: 3: seek: offset=0 buffer_offset=0 read=2048 cache=[0,2048] dist=0
|
||||
cache read: out: offset=0 length=1024
|
||||
cache: buffer: 0000/0000 0001/0001 0002/0002 0003/0003
|
||||
cache read: in: offset=0 length=2048
|
||||
rtl: cache: 3: fd=3 offset=0 length=2048 area=[0,2048] cache=[0,2048] size=8192
|
||||
cache read: out: offset=0 length=2048
|
||||
cache: buffer: 0000/0000 0001/0001 0002/0002 0003/0003
|
||||
cache read: in: offset=1024 length=1024
|
||||
rtl: cache: 3: fd=3 offset=1024 length=1024 area=[1024,2048] cache=[0,2048] size=8192
|
||||
cache read: out: offset=1024 length=1024
|
||||
cache: buffer: 0200/0200 0201/0201 0202/0202 0203/0203
|
||||
cache read: in: offset=6144 length=2048
|
||||
rtl: cache: 3: fd=3 offset=6144 length=2048 area=[6144,8192] cache=[0,2048] size=8192
|
||||
rtl: cache: 3: seek: offset=6144 buffer_offset=0 read=2048 cache=[6144,8192] dist=2048
|
||||
cache read: out: offset=0 length=2048
|
||||
cache: buffer: 0c00/0c00 0c01/0c01 0c02/0c02 0c03/0c03
|
||||
cache read: in: offset=7168 length=1024
|
||||
rtl: cache: 3: fd=3 offset=7168 length=1024 area=[7168,8192] cache=[6144,8192] size=8192
|
||||
cache read: out: offset=1024 length=1024
|
||||
cache: buffer: 0e00/0e00 0e01/0e01 0e02/0e02 0e03/0e03
|
||||
cache read: in: offset=0 length=512
|
||||
rtl: cache: 3: fd=3 offset=0 length=512 area=[0,512] cache=[6144,8192] size=8192
|
||||
rtl: cache: 3: seek: offset=0 buffer_offset=0 read=2048 cache=[0,2048] dist=8192
|
||||
cache read: out: offset=0 length=512
|
||||
cache: buffer: 0000/0000 0001/0001 0002/0002 0003/0003
|
||||
cache read: in: offset=0 length=256
|
||||
rtl: cache: 3: fd=3 offset=0 length=256 area=[0,256] cache=[0,2048] size=8192
|
||||
cache read: out: offset=0 length=256
|
||||
cache: buffer: 0000/0000 0001/0001 0002/0002 0003/0003
|
||||
cache read: in: offset=0 length=2048
|
||||
rtl: cache: 3: fd=3 offset=0 length=2048 area=[0,2048] cache=[0,2048] size=8192
|
||||
cache read: out: offset=0 length=2048
|
||||
cache: buffer: 0000/0000 0001/0001 0002/0002 0003/0003
|
||||
cache read: in: offset=8152 length=16
|
||||
rtl: cache: 3: fd=3 offset=8152 length=16 area=[8152,8168] cache=[0,2048] size=8192
|
||||
rtl: cache: 3: seek: offset=8152 buffer_offset=0 read=40 cache=[8152,8192] dist=40
|
||||
cache read: out: offset=0 length=16
|
||||
cache: buffer: 0fec/0fec 0fed/0fed 0fee/0fee 0fef/0fef
|
||||
cache read: in: offset=8152 length=40
|
||||
rtl: cache: 3: fd=3 offset=8152 length=40 area=[8152,8192] cache=[8152,8192] size=8192
|
||||
cache read: out: offset=0 length=40
|
||||
cache: buffer: 0fec/0fec 0fed/0fed 0fee/0fee 0fef/0fef
|
||||
cache read: in: offset=8152 length=80
|
||||
rtl: cache: 3: fd=3 offset=8152 length=80 area=[8152,8232] cache=[8152,8192] size=8192
|
||||
rtl: cache: 3: truncate length=40
|
||||
cache read: out: offset=0 length=40
|
||||
cache: buffer: 0fec/0fec 0fed/0fed 0fee/0fee 0fef/0fef
|
||||
cache read: in: offset=6224 length=20
|
||||
rtl: cache: 3: fd=3 offset=6224 length=20 area=[6224,6244] cache=[8152,8192] size=8192
|
||||
rtl: cache: 3: seek: offset=6224 buffer_offset=0 read=1968 cache=[6224,8192] dist=1968
|
||||
cache read: out: offset=0 length=20
|
||||
cache: buffer: 0c28/0c28 0c29/0c29 0c2a/0c2a 0c2b/0c2b
|
||||
cache read: in: offset=8152 length=40
|
||||
rtl: cache: 3: fd=3 offset=8152 length=40 area=[8152,8192] cache=[6224,8192] size=8192
|
||||
cache read: out: offset=1928 length=40
|
||||
cache: buffer: 0fec/0fec 0fed/0fed 0fee/0fee 0fef/0fef
|
||||
rtl: cache: 3: close
|
||||
rtl: alloc: del: OBJECT addr=0x2038bc8
|
||||
*** END OF TEST libdl (RTL) 3 ***
|
||||
67
testsuites/libtests/dl03/init.c
Normal file
67
testsuites/libtests/dl03/init.c
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2014 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 "dl-cache.h"
|
||||
|
||||
const char rtems_test_name[] = "libdl (RTL) 3";
|
||||
|
||||
/* forward declarations to avoid warnings */
|
||||
static rtems_task Init(rtems_task_argument argument);
|
||||
|
||||
static int test(void)
|
||||
{
|
||||
int ret;
|
||||
ret = dl_cache_test();
|
||||
if (ret)
|
||||
rtems_test_exit(ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void Init(rtems_task_argument arg)
|
||||
{
|
||||
TEST_BEGIN();
|
||||
|
||||
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_MAXIMUM_SEMAPHORES 1
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
#define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT)
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
|
||||
#include <rtems/confdefs.h>
|
||||
50
testsuites/libtests/dl04/Makefile.am
Normal file
50
testsuites/libtests/dl04/Makefile.am
Normal file
@@ -0,0 +1,50 @@
|
||||
rtems_tests_PROGRAMS = dl04
|
||||
# include a C++ file in the source to trick automake into adding C++ rules <sigh>.
|
||||
dl04_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 = dl04.scn dl04.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 = $(dl04_OBJECTS)
|
||||
LINK_LIBS = $(dl04_LDLIBS)
|
||||
|
||||
dl-o4.o: dl-o4.cpp
|
||||
|
||||
dl.tar: dl-o4.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
|
||||
|
||||
dl04.pre$(EXEEXT): $(dl04_OBJECTS) $(dl04_DEPENDENCIES)
|
||||
@rm -f dl04.pre$(EXEEXT)
|
||||
$(make-exe)
|
||||
rm -f dl04.pre.ralf
|
||||
|
||||
dl04.pre: dl04.pre$(EXEEXT)
|
||||
mv $< $@
|
||||
CLEANFILES += dl04.pre
|
||||
|
||||
dl-sym.o: dl04.pre
|
||||
rtems-syms -e -c "$(CFLAGS)" -o $@ $<
|
||||
|
||||
dl04$(EXEEXT): $(dl04_OBJECTS) $(dl04_DEPENDENCIES) dl-sym.o
|
||||
@rm -f dl04$(EXEEXT)
|
||||
$(LINK.c) $(CPU_CFLAGS) $(AM_CFLAGS) $(AM_LDFLAGS) \
|
||||
-o $(basename $@)$(EXEEXT) $(LINK_OBJS) dl-sym.o $(LINK_LIBS)
|
||||
|
||||
include $(top_srcdir)/../automake/local.am
|
||||
4
testsuites/libtests/dl04/dl-cpp.cpp
Normal file
4
testsuites/libtests/dl04/dl-cpp.cpp
Normal file
@@ -0,0 +1,4 @@
|
||||
/* empty file to trick automake. */
|
||||
class empty
|
||||
{
|
||||
};
|
||||
37
testsuites/libtests/dl04/dl-load.c
Normal file
37
testsuites/libtests/dl04/dl-load.c
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
rtems_rtl_trace_set_mask(RTEMS_RTL_TRACE_ALL);
|
||||
handle = dlopen("/dl-o4.o", RTLD_GLOBAL | RTLD_NOW);
|
||||
err = dlerror();
|
||||
if (err != NULL)
|
||||
printf("dlopen: %s\n", err);
|
||||
rtems_test_assert(handle != NULL);
|
||||
rtems_test_assert(dlclose(handle) == 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
14
testsuites/libtests/dl04/dl-load.h
Normal file
14
testsuites/libtests/dl04/dl-load.h
Normal file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* 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_
|
||||
|
||||
int dl_load_test(void);
|
||||
|
||||
#endif
|
||||
30
testsuites/libtests/dl04/dl-o4.cpp
Normal file
30
testsuites/libtests/dl04/dl-o4.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
class Foo {
|
||||
public:
|
||||
Foo() {};
|
||||
~Foo() {};
|
||||
|
||||
virtual void f1() {};
|
||||
virtual void f2() {};
|
||||
virtual void f3() {};
|
||||
virtual void f4() {};
|
||||
virtual void f5() {};
|
||||
virtual void f6() {};
|
||||
virtual void f7() {};
|
||||
};
|
||||
|
||||
class Bar : public Foo {
|
||||
};
|
||||
|
||||
void baz(void)
|
||||
{
|
||||
Bar b;
|
||||
|
||||
b.f1();
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
void func(void)
|
||||
{
|
||||
baz();
|
||||
}
|
||||
}
|
||||
21
testsuites/libtests/dl04/dl04.doc
Normal file
21
testsuites/libtests/dl04/dl04.doc
Normal file
@@ -0,0 +1,21 @@
|
||||
# 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 that tests the cache handling.
|
||||
+ Unload the ELF file.
|
||||
1004
testsuites/libtests/dl04/dl04.scn
Normal file
1004
testsuites/libtests/dl04/dl04.scn
Normal file
File diff suppressed because it is too large
Load Diff
84
testsuites/libtests/dl04/init.c
Normal file
84
testsuites/libtests/dl04/init.c
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 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) 4";
|
||||
|
||||
/* 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_MAXIMUM_SEMAPHORES 1
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
|
||||
#include <rtems/confdefs.h>
|
||||
50
testsuites/libtests/dl05/Makefile.am
Normal file
50
testsuites/libtests/dl05/Makefile.am
Normal 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
|
||||
30
testsuites/libtests/dl05/dl-cpp.cpp
Normal file
30
testsuites/libtests/dl05/dl-cpp.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* The base image needs this to include the RTTI data.
|
||||
*/
|
||||
#include <cstdio>
|
||||
#include <stdexcept>
|
||||
#include "dl-load.h"
|
||||
void exception_base(bool throw_runtime)
|
||||
{
|
||||
printf("%s: begin\n", __func__);
|
||||
try
|
||||
{
|
||||
if (throw_runtime)
|
||||
throw std::runtime_error("eb: throw std::runtime_error");
|
||||
else
|
||||
throw dl_test_throw_me("eb: throw me");
|
||||
}
|
||||
catch (std::exception const& e)
|
||||
{
|
||||
printf("%s: caught: %s\n", __func__, e.what());
|
||||
}
|
||||
catch (dl_test_throw_me const& e)
|
||||
{
|
||||
printf("%s: caught: %s\n", __func__, e.what());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
printf("%s: caught: unknown\n", __func__);
|
||||
}
|
||||
printf("%s: end\n", __func__);
|
||||
}
|
||||
63
testsuites/libtests/dl05/dl-load.c
Normal file
63
testsuites/libtests/dl05/dl-load.c
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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)(bool );
|
||||
#if __i386__
|
||||
/*
|
||||
* std::runtime_error destructor locks up in atomics.
|
||||
*/
|
||||
bool throw_runtime = false;
|
||||
#else
|
||||
bool throw_runtime = true;
|
||||
#endif
|
||||
|
||||
rtems_rtl_trace_set_mask(RTEMS_RTL_TRACE_ALL);
|
||||
|
||||
handle = dlopen("/dl-o5.o", RTLD_GLOBAL | RTLD_NOW);
|
||||
if (handle == NULL)
|
||||
{
|
||||
err = dlerror();
|
||||
if (err != NULL)
|
||||
printf("dlopen: %s\n", err);
|
||||
}
|
||||
rtems_test_assert(handle != NULL);
|
||||
|
||||
func = dlsym(handle, "exception_dl");
|
||||
if (func == NULL) {
|
||||
err = dlerror ();
|
||||
if (err)
|
||||
printf ("dlsym: %s\n", err);
|
||||
}
|
||||
rtems_test_assert(func != NULL);
|
||||
|
||||
exception_base(throw_runtime);
|
||||
|
||||
func(throw_runtime);
|
||||
|
||||
rtems_test_assert(dlclose(handle) == 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
51
testsuites/libtests/dl05/dl-load.h
Normal file
51
testsuites/libtests/dl05/dl-load.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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 throw_runtime);
|
||||
void exception_dl(bool throw_runtime);
|
||||
|
||||
int dl_load_test(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
class dl_test_throw_me
|
||||
{
|
||||
public:
|
||||
dl_test_throw_me(const char* message) :
|
||||
message (message) {
|
||||
}
|
||||
dl_test_throw_me(const dl_test_throw_me& orig) :
|
||||
message (orig.message) {
|
||||
}
|
||||
dl_test_throw_me() :
|
||||
message (0) {
|
||||
}
|
||||
|
||||
~dl_test_throw_me() {
|
||||
}
|
||||
|
||||
const char* what() const {
|
||||
return message;
|
||||
}
|
||||
|
||||
private:
|
||||
const char* message;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
28
testsuites/libtests/dl05/dl-o5.cpp
Normal file
28
testsuites/libtests/dl05/dl-o5.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include <cstdio>
|
||||
#include <stdexcept>
|
||||
#include "dl-load.h" /* make the symbol a C linkage */
|
||||
void exception_dl(bool throw_runtime)
|
||||
{
|
||||
printf("exception_dl: begin\n");
|
||||
try
|
||||
{
|
||||
printf("exception_dl: throwing...\n");
|
||||
if (throw_runtime)
|
||||
throw std::runtime_error("throw std::runtime_error object");
|
||||
else
|
||||
throw dl_test_throw_me("throw dl_test_throw_me object");
|
||||
}
|
||||
catch (dl_test_throw_me const& e)
|
||||
{
|
||||
printf("%s: caught: %s\n", __func__, e.what());
|
||||
}
|
||||
catch (std::exception const& e)
|
||||
{
|
||||
printf("%s: caught: %s\n", __func__, e.what());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
printf("%s: caught: unknown\n", __func__);
|
||||
}
|
||||
printf("exception_dl: end\n");
|
||||
}
|
||||
24
testsuites/libtests/dl05/dl05.doc
Normal file
24
testsuites/libtests/dl05/dl05.doc
Normal 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.
|
||||
1424
testsuites/libtests/dl05/dl05.scn
Normal file
1424
testsuites/libtests/dl05/dl05.scn
Normal file
File diff suppressed because it is too large
Load Diff
86
testsuites/libtests/dl05/init.c
Normal file
86
testsuites/libtests/dl05/init.c
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* 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 (32U * 1024U)
|
||||
|
||||
#define CONFIGURE_EXTRA_TASK_STACKS (64 * 1024)
|
||||
|
||||
#define CONFIGURE_MAXIMUM_POSIX_KEYS 2
|
||||
|
||||
#define CONFIGURE_MAXIMUM_SEMAPHORES 4
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
|
||||
#include <rtems/confdefs.h>
|
||||
Reference in New Issue
Block a user