From dad6fd4333c4b05af08bd78714acefb5a86f1af9 Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Sun, 10 Mar 2019 07:04:42 +1300 Subject: libdl: Add an archive command - The archive command lists archives, symbols and any duplicate symbols. - Change the RTL shell commands to the rtems_printer to allow the output to be captured. --- testsuites/libtests/dl10/dl-load.c | 141 +++++++++++++++++++++++++++++++++++++ testsuites/libtests/dl10/dl-load.h | 21 ++++++ testsuites/libtests/dl10/dl-o1.c | 61 ++++++++++++++++ testsuites/libtests/dl10/dl-o1.h | 23 ++++++ testsuites/libtests/dl10/dl-o2.c | 39 ++++++++++ testsuites/libtests/dl10/dl-o2.h | 25 +++++++ testsuites/libtests/dl10/dl-o3.c | 40 +++++++++++ testsuites/libtests/dl10/dl-o3.h | 15 ++++ testsuites/libtests/dl10/dl-o4.c | 40 +++++++++++ testsuites/libtests/dl10/dl-o4.h | 29 ++++++++ testsuites/libtests/dl10/dl-o5.c | 36 ++++++++++ testsuites/libtests/dl10/dl-o5.h | 30 ++++++++ testsuites/libtests/dl10/dl-o6.c | 18 +++++ testsuites/libtests/dl10/dl10.doc | 22 ++++++ testsuites/libtests/dl10/dl10.scn | 41 +++++++++++ testsuites/libtests/dl10/init.c | 137 +++++++++++++++++++++++++++++++++++ 16 files changed, 718 insertions(+) create mode 100644 testsuites/libtests/dl10/dl-load.c create mode 100644 testsuites/libtests/dl10/dl-load.h create mode 100644 testsuites/libtests/dl10/dl-o1.c create mode 100644 testsuites/libtests/dl10/dl-o1.h create mode 100644 testsuites/libtests/dl10/dl-o2.c create mode 100644 testsuites/libtests/dl10/dl-o2.h create mode 100644 testsuites/libtests/dl10/dl-o3.c create mode 100644 testsuites/libtests/dl10/dl-o3.h create mode 100644 testsuites/libtests/dl10/dl-o4.c create mode 100644 testsuites/libtests/dl10/dl-o4.h create mode 100644 testsuites/libtests/dl10/dl-o5.c create mode 100644 testsuites/libtests/dl10/dl-o5.h create mode 100644 testsuites/libtests/dl10/dl-o6.c create mode 100644 testsuites/libtests/dl10/dl10.doc create mode 100644 testsuites/libtests/dl10/dl10.scn create mode 100644 testsuites/libtests/dl10/init.c (limited to 'testsuites/libtests/dl10') diff --git a/testsuites/libtests/dl10/dl-load.c b/testsuites/libtests/dl10/dl-load.c new file mode 100644 index 0000000000..dee1d6e9cc --- /dev/null +++ b/testsuites/libtests/dl10/dl-load.c @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2014 Chris Johns . + * 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. + */ + +#define TEST_TRACE 0 +#if TEST_TRACE + #define DEBUG_TRACE (RTEMS_RTL_TRACE_DETAIL | \ + RTEMS_RTL_TRACE_WARNING | \ + RTEMS_RTL_TRACE_LOAD | \ + RTEMS_RTL_TRACE_UNLOAD | \ + RTEMS_RTL_TRACE_SYMBOL | \ + RTEMS_RTL_TRACE_RELOC | \ + RTEMS_RTL_TRACE_LOAD_SECT | \ + RTEMS_RTL_TRACE_ALLOCATOR | \ + RTEMS_RTL_TRACE_UNRESOLVED | \ + RTEMS_RTL_TRACE_ARCHIVES | \ + RTEMS_RTL_TRACE_DEPENDENCY) + /* RTEMS_RTL_TRACE_ALL */ +#define DL_DEBUG_TRACE DEBUG_TRACE +#define DL_DEBUG_CMD 1 +#else +#define DL_DEBUG_TRACE 0 +#define DL_DEBUG_CMD 0 +#endif + +#include + +#include "dl-load.h" + +#include + +#include +#include + +typedef int (*call_sig)(void); + +static void dl_load_dump (void) +{ +#if DL_DEBUG_CMD + char* list[] = { "rtl", "list", NULL }; + char* sym[] = { "rtl", "sym", NULL }; + printf ("RTL List:\n"); + rtems_rtl_shell_command (2, list); + printf ("RTL Sym:\n"); + rtems_rtl_shell_command (2, sym); +#endif +} + +static bool dl_check_resolved(void* handle, bool has_unresolved) +{ + int unresolved = 0; + if (dlinfo (handle, RTLD_DI_UNRESOLVED, &unresolved) == 0) + return 1; + if (has_unresolved) + { + if (unresolved == 0) + { + dl_load_dump(); + return false; + } + } + else + { + if (unresolved != 0) + { + dl_load_dump(); + return false; + } + } + printf ("handel: %p: no unresolved externals\n", handle); + return true; +} + +static void* dl_load_obj(const char* name, bool has_unresolved) +{ + void* handle; + + printf("load: %s\n", name); + + handle = dlopen (name, RTLD_NOW | RTLD_GLOBAL); + if (!handle) + { + printf("dlopen failed: %s\n", dlerror()); + return NULL; + } + + dl_check_resolved (handle, has_unresolved); + + printf ("handle: %p loaded\n", handle); + + return handle; +} + +static void dl_close (void* handle) +{ + int r; + printf ("handle: %p closing\n", handle); + r = dlclose (handle); + if (r != 0) + printf("dlclose failed: %s\n", dlerror()); + rtems_test_assert (r == 0); +} + +static int dl_call (void* handle, const char* func) +{ + call_sig call = dlsym (handle, func); + if (call == NULL) + { + printf("dlsym failed: symbol not found: %s\n", func); + return 1; + } + call (); + return 0; +} + +int dl_load_test(void) +{ + void* o1; + + printf ("Test source (link in strstr): %s\n", dl_localise_file (__FILE__)); + +#if DL_DEBUG_TRACE + rtems_rtl_trace_set_mask (DL_DEBUG_TRACE); +#endif + + o1 = dl_load_obj("/dl10-o1.o", false); + if (!o1) + return 1; + + if (!dl_check_resolved (o1, false)) + return 1; + + dl_load_dump (); + + return 0; +} diff --git a/testsuites/libtests/dl10/dl-load.h b/testsuites/libtests/dl10/dl-load.h new file mode 100644 index 0000000000..72872917aa --- /dev/null +++ b/testsuites/libtests/dl10/dl-load.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2014, 2018 Chris Johns . 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. + */ + +#include + +#if !defined(_DL_LOAD_H_) +#define _DL_LOAD_H_ + +static inline const char* dl_localise_file (const char* file) +{ + return (const char*) strstr (file, "testsuites"); +} + +int dl_load_test(void); + +#endif diff --git a/testsuites/libtests/dl10/dl-o1.c b/testsuites/libtests/dl10/dl-o1.c new file mode 100644 index 0000000000..e6173f3a78 --- /dev/null +++ b/testsuites/libtests/dl10/dl-o1.c @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2018 Chris Johns . + * 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. + */ + +#include "dl-o1.h" + +#include +#include "dl-load.h" +#include "dl-o1.h" +#include "dl-o2.h" + +#define printf(...) rtems_printf(&rtems_test_printer, __VA_ARGS__); + +/* + * Create some symbols. The uninitialised will be in the common section with + * separated text and data and this means there is no actual section in the ELF + * file, the details for this are in the symbols. + */ +int dl01_bss1; /* unitialised, .bss */ +float dl01_bss2[30]; /* unitialised, .bss */ +char dl01_bss3[10]; /* unitialised, .bss */ +int dl01_data1 = 1; /* initialised, .data */ +float dl01_data2 = 0.3333; /* initialised, .data */ +const int dl01_const1 = 3; /* read-only, .const */ +const float dl01_const2 = 0.666; /* read-only, .const */ +int dl01_func1(void) /* code, .text */ +{ + return 4; +} + +/* + * Yes a decl in the source. This is a modules main and I could not find which + * header main is defined in. + */ +int rtems_main_o1 (void); + +#define DL_NAME "dlo1" +#define PAINT_VAR(_v) sizeof(_v), &_v, _v + +int rtems_main_o1 (void) +{ + printf (DL_NAME ": module: %s\n", dl_localise_file (__FILE__)); + printf (DL_NAME ": dl01_bss1: %4zu: %p: %d\n", PAINT_VAR (dl01_bss1)); + printf (DL_NAME ": dl01_bss2: %4zu: %p: %f\n", PAINT_VAR (dl01_bss2[0])); + printf (DL_NAME ": dl01_bss3: %4zu: %p: %02x\n", PAINT_VAR (dl01_bss3[0])); + printf (DL_NAME ": dl01_data1: %4zu: %p: %d\n", PAINT_VAR (dl01_data1)); + /* no %f in the rtems test printer */ + printf (DL_NAME ": dl01_data2: %4zu: %p: %f\n", PAINT_VAR (dl01_data2)); + printf (DL_NAME ": dl01_const1: %4zu: %p: %d\n", PAINT_VAR (dl01_const1)); + printf (DL_NAME ": dl01_const2: %4zu: %p: %f\n", PAINT_VAR (dl01_const2)); + printf (DL_NAME ": dl01_func1: %4zu: %p\n", sizeof(dl01_func1), &dl01_func1); + + rtems_main_o2 (); + + return 0; +} diff --git a/testsuites/libtests/dl10/dl-o1.h b/testsuites/libtests/dl10/dl-o1.h new file mode 100644 index 0000000000..f6a10f1481 --- /dev/null +++ b/testsuites/libtests/dl10/dl-o1.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2018 Chris Johns . + * 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(DL01_H) +#define DL01_H + +extern int dl01_bss1; +extern float dl01_bss2[30]; +extern char dl01_bss3[10]; +extern int dl01_data1; +extern float dl01_data2; +extern const int dl01_const1; +extern const float dl01_const2; + +int dl01_func1(void); + +#endif diff --git a/testsuites/libtests/dl10/dl-o2.c b/testsuites/libtests/dl10/dl-o2.c new file mode 100644 index 0000000000..e58c8750e9 --- /dev/null +++ b/testsuites/libtests/dl10/dl-o2.c @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2014 Chris Johns . 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. + */ + +#include "dl-load.h" +#include "dl-o2.h" +#include "dl-o3.h" + +#include + +#define printf(...) rtems_printf(&rtems_test_printer, __VA_ARGS__); + +int dl02_bss1; +float dl02_bss2[7]; +char dl02_bss3[21]; +int dl02_data1; +float dl02_data2; + +#define DL_NAME "dlo2" +#define PAINT_VAR(_v) sizeof(_v), &_v, _v + +int rtems_main_o2 (void) +{ + printf (DL_NAME ": module: %s\n", dl_localise_file (__FILE__)); + printf (DL_NAME ": dl02_bss1: %4zu: %p: %d\n", PAINT_VAR (dl02_bss1)); + printf (DL_NAME ": dl02_bss2: %4zu: %p: %f\n", PAINT_VAR (dl02_bss2[0])); + printf (DL_NAME ": dl02_bss3: %4zu: %p: %02x\n", PAINT_VAR (dl02_bss3[0])); + printf (DL_NAME ": dl02_data1: %4zu: %p: %d\n", PAINT_VAR (dl02_data1)); + /* no %f in the rtems test printer */ + printf (DL_NAME ": dl02_data2: %4zu: %p: %f\n", PAINT_VAR (dl02_data2)); + + rtems_main_o3 (); + + return 0; +} diff --git a/testsuites/libtests/dl10/dl-o2.h b/testsuites/libtests/dl10/dl-o2.h new file mode 100644 index 0000000000..d6c1820f46 --- /dev/null +++ b/testsuites/libtests/dl10/dl-o2.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2018 Chris Johns . + * 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(DL02_H) +#define DL02_H + +/* + * A set of variables in dl-o2 reference by dl-03. + */ + +extern int dl02_bss1; +extern float dl02_bss2[7]; +extern char dl02_bss3[21]; +extern int dl02_data1; +extern float dl02_data2; + +int rtems_main_o2 (void); + +#endif diff --git a/testsuites/libtests/dl10/dl-o3.c b/testsuites/libtests/dl10/dl-o3.c new file mode 100644 index 0000000000..c84b3d72ad --- /dev/null +++ b/testsuites/libtests/dl10/dl-o3.c @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2014 Chris Johns . 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. + */ + +#include "dl-load.h" +#include "dl-o3.h" +#include "dl-o4.h" +#include "dl-o5.h" + +#include +#include + +#define printf(...) rtems_printf(&rtems_test_printer, __VA_ARGS__); + +#define DL_NAME "dlo3" +#define PAINT_VAR(_v) sizeof(_v), &_v, _v + +int rtems_main_o3 () +{ + printf (DL_NAME ": module: %s\n", dl_localise_file (__FILE__)); + printf (DL_NAME ": dl04_unresolv_1: %4zu: %p: %d\n", PAINT_VAR (dl04_unresolv_1)); + printf (DL_NAME ": dl04_unresolv_2: %4zu: %p: %f\n", PAINT_VAR (dl04_unresolv_2)); + printf (DL_NAME ": dl04_unresolv_3: %4zu: %p: %02x\n", PAINT_VAR (dl04_unresolv_3)); + printf (DL_NAME ": dl04_unresolv_4: %4zu: %p: %p\n", PAINT_VAR (dl04_unresolv_4)); + printf (DL_NAME ": dl04_unresolv_5: %4zu: %p: %d\n", PAINT_VAR (dl04_unresolv_5)); + printf (DL_NAME ": dl04_unresolv_6: %4zu: %p: %s\n", PAINT_VAR (dl04_unresolv_6)); + printf (DL_NAME ": dl05_unresolv_1: %4zu: %p: %" PRIu64 "\n", PAINT_VAR (dl05_unresolv_1)); + printf (DL_NAME ": dl05_unresolv_2: %4zu: %p: %" PRIu16 "\n", PAINT_VAR (dl05_unresolv_2)); + printf (DL_NAME ": dl05_unresolv_3: %4zu: %p: %" PRIu32 "\n", PAINT_VAR (dl05_unresolv_3)); + printf (DL_NAME ": dl05_unresolv_4: %4zu: %p: %" PRIu8 "\n", PAINT_VAR (dl05_unresolv_4)); + printf (DL_NAME ": dl05_unresolv_5: %4zu: %p: %" PRIi64 "\n", PAINT_VAR (dl05_unresolv_5)); + + rtems_main_o4 (); + + return 0; +} diff --git a/testsuites/libtests/dl10/dl-o3.h b/testsuites/libtests/dl10/dl-o3.h new file mode 100644 index 0000000000..8c5d18dfb1 --- /dev/null +++ b/testsuites/libtests/dl10/dl-o3.h @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2018 Chris Johns . + * 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(DL03_H) +#define DL03_H + +int rtems_main_o3 (void); + +#endif diff --git a/testsuites/libtests/dl10/dl-o4.c b/testsuites/libtests/dl10/dl-o4.c new file mode 100644 index 0000000000..72dfbc6850 --- /dev/null +++ b/testsuites/libtests/dl10/dl-o4.c @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2014 Chris Johns . 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. + */ + +#include "dl-load.h" +#include "dl-o4.h" +#include "dl-o5.h" + +#include + +#define printf(...) rtems_printf(&rtems_test_printer, __VA_ARGS__); + +int dl04_unresolv_1; +float dl04_unresolv_2; +char dl04_unresolv_3; +char* dl04_unresolv_4; +const int dl04_unresolv_5 = 4; +const char* dl04_unresolv_6 = "dl-O4"; + +#define DL_NAME "dlo4" +#define PAINT_VAR(_v) sizeof(_v), &_v, _v + +int rtems_main_o4 (void) +{ + printf (DL_NAME ": module: %s\n", dl_localise_file (__FILE__)); + printf (DL_NAME ": dl04_unresolv_1: %4zu: %p: %d\n", PAINT_VAR (dl04_unresolv_1)); + printf (DL_NAME ": dl04_unresolv_2: %4zu: %p: %f\n", PAINT_VAR (dl04_unresolv_2)); + printf (DL_NAME ": dl04_unresolv_3: %4zu: %p: %02x\n", PAINT_VAR (dl04_unresolv_3)); + printf (DL_NAME ": dl04_unresolv_4: %4zu: %p: %p\n", PAINT_VAR (dl04_unresolv_4)); + printf (DL_NAME ": dl04_unresolv_5: %4zu: %p: %d\n", PAINT_VAR (dl04_unresolv_5)); + printf (DL_NAME ": dl04_unresolv_6: %4zu: %p: %s\n", PAINT_VAR (dl04_unresolv_6)); + + rtems_main_o5 (); + + return 0; +} diff --git a/testsuites/libtests/dl10/dl-o4.h b/testsuites/libtests/dl10/dl-o4.h new file mode 100644 index 0000000000..bab9fc1ae4 --- /dev/null +++ b/testsuites/libtests/dl10/dl-o4.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2018 Chris Johns . + * 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(DL04_H) +#define DL04_H + +/* + * A set of variables in dl-o4 referenced by dl-03 and unresolved when dl-o3 is + * loaded. They are all uninitialised variables with various sizes in a mixed + * order to get various alignments. These and dl-o5 variables are designed to + * force the dependent tables to grow. + */ + +extern int dl04_unresolv_1; +extern float dl04_unresolv_2; +extern char dl04_unresolv_3; +extern char* dl04_unresolv_4; +extern const int dl04_unresolv_5; +extern const char* dl04_unresolv_6; + +int rtems_main_o4 (void); + +#endif diff --git a/testsuites/libtests/dl10/dl-o5.c b/testsuites/libtests/dl10/dl-o5.c new file mode 100644 index 0000000000..be496392c9 --- /dev/null +++ b/testsuites/libtests/dl10/dl-o5.c @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2014 Chris Johns . 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. + */ + +#include "dl-load.h" +#include "dl-o5.h" + +#include +#include + +#define printf(...) rtems_printf(&rtems_test_printer, __VA_ARGS__); + +uint64_t dl05_unresolv_1; +uint16_t dl05_unresolv_2; +uint32_t dl05_unresolv_3; +uint8_t dl05_unresolv_4; +int64_t dl05_unresolv_5; + +#define DL_NAME "dlo5" +#define PAINT_VAR(_v) sizeof(_v), &_v, _v + +int rtems_main_o5 (void) +{ + printf (DL_NAME ": module: %s\n", dl_localise_file (__FILE__)); + printf (DL_NAME ": dl05_unresolv_1: %4zu: %p: %" PRIu64 "\n", PAINT_VAR (dl05_unresolv_1)); + printf (DL_NAME ": dl05_unresolv_2: %4zu: %p: %" PRIu16 "\n", PAINT_VAR (dl05_unresolv_2)); + printf (DL_NAME ": dl05_unresolv_3: %4zu: %p: %" PRIu32 "\n", PAINT_VAR (dl05_unresolv_3)); + printf (DL_NAME ": dl05_unresolv_4: %4zu: %p: %" PRIu8 "\n", PAINT_VAR (dl05_unresolv_4)); + printf (DL_NAME ": dl05_unresolv_5: %4zu: %p: %" PRIi64 "\n", PAINT_VAR (dl05_unresolv_5)); + + return 0; +} diff --git a/testsuites/libtests/dl10/dl-o5.h b/testsuites/libtests/dl10/dl-o5.h new file mode 100644 index 0000000000..bb4ce468a2 --- /dev/null +++ b/testsuites/libtests/dl10/dl-o5.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2018 Chris Johns . + * 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. + */ + +#include + +#if !defined(DL05_H) +#define DL05_H + +/* + * A set of variables in dl-o5 referenced by dl-03 and unresolved when dl-o3 is + * loaded. They are all uninitialised variables with various sizes in a mixed + * order to get various alignments. These and dl-o4 variables are designed to + * force the dependent tables to grow. + */ + +extern uint64_t dl05_unresolv_1; +extern uint16_t dl05_unresolv_2; +extern uint32_t dl05_unresolv_3; +extern uint8_t dl05_unresolv_4; +extern int64_t dl05_unresolv_5; + +int rtems_main_o5 (void); + +#endif diff --git a/testsuites/libtests/dl10/dl-o6.c b/testsuites/libtests/dl10/dl-o6.c new file mode 100644 index 0000000000..5e03a30773 --- /dev/null +++ b/testsuites/libtests/dl10/dl-o6.c @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2014 Chris Johns . 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. + */ + +#include "dl-load.h" + +#include +#include + +int rtems_main_o5 (void) +{ + /* duplicate symbol in archive */ + return 0; +} diff --git a/testsuites/libtests/dl10/dl10.doc b/testsuites/libtests/dl10/dl10.doc new file mode 100644 index 0000000000..82469da593 --- /dev/null +++ b/testsuites/libtests/dl10/dl10.doc @@ -0,0 +1,22 @@ +# Copyright (c) 2019 Chris Johns +# +# 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: dl10 + +directives: + + dlopen + dlinfo + dlsym + dlclose + +concepts: + ++ Load modules from archives that have duplicate symbols. ++ Wait a shell prompt to test the RTL commands. diff --git a/testsuites/libtests/dl10/dl10.scn b/testsuites/libtests/dl10/dl10.scn new file mode 100644 index 0000000000..dec2c42c68 --- /dev/null +++ b/testsuites/libtests/dl10/dl10.scn @@ -0,0 +1,41 @@ +*** BEGIN OF TEST libdl (RTL) 10 *** +*** TEST VERSION: 5.0.0.c1aa9685eaa9d5d321c965a2aa44f868b7834c23 +*** TEST STATE: EXPECTED-PASS +*** TEST BUILD: RTEMS_NETWORKING RTEMS_POSIX_API +*** TEST TOOLS: 7.4.0 20181206 (RTEMS 5, RSB 98588a55961a92f5d27bfd756dfc9e31b2b1bf98, Newlib 3e24fbf6f) +RTL (libdl) commands: dl, rtl + + +RTEMS Shell on /dev/foobar. Use 'help' to list commands. +SHLL [/] # rtl obj load dl10-o1.o +SHLL [/] # rtl list -l + dl10-o1.o + unresolved : 0 + users : 1 + references : 0 + symbols : 9 + symbol memory : 281 + /libdl10_1.a:dl10-o2.o + unresolved : 0 + users : 0 + references : 1 + symbols : 6 + symbol memory : 186 + /libdl10_2.a:dl10-o5.o + unresolved : 0 + users : 0 + references : 2 + symbols : 6 + symbol memory : 214 + /libdl10_2.a:dl10-o3.o + unresolved : 0 + users : 0 + references : 1 + symbols : 1 + symbol memory : 34 + /libdl10_1.a:dl10-o4.o + unresolved : 0 + users : 0 + references : 1 + symbols : 7 + symbol memory : 250 diff --git a/testsuites/libtests/dl10/init.c b/testsuites/libtests/dl10/init.c new file mode 100644 index 0000000000..d297567f84 --- /dev/null +++ b/testsuites/libtests/dl10/init.c @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2018 Chris Johns . 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 +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "dl-load.h" + +const char rtems_test_name[] = "libdl (RTL) 10"; + +/* forward declarations to avoid warnings */ +static rtems_task Init(rtems_task_argument argument); + +#include "dl10-tar.h" + +#define TARFILE_START dl10_tar +#define TARFILE_SIZE dl10_tar_size + +static int test(void) +{ +#if USE_SHELL_CMD + int ret; + ret = dl_load_test(); + if (ret) + rtems_test_exit(ret); +#endif + return 0; +} + +static void Init(rtems_task_argument arg) +{ + int e; + + TEST_BEGIN(); + + e = Untar_FromMemory((void *)TARFILE_START, (size_t)TARFILE_SIZE); + if (e != 0) + { + printf ("error: untar failed: %d\n", e); + rtems_test_exit (1); + exit (1); + } + + e = symlink ("libdl-dl10.conf", "/etc/libdl.conf"); + if (e != 0) + { + printf ("error: untar failed: %d\n", e); + rtems_test_exit (1); + exit (1); + } + + test(); + + rtems_shell_init_environment (); + + printf ("RTL (libdl) commands: dl, rtl\n\n"); + + if (rtems_shell_add_cmd ("rtl", + "rtl", + "rtl -l", + rtems_rtl_shell_command) == NULL) + { + printf("command add failed\n"); + rtems_test_exit(1); + exit (1); + } + + rtems_shell_init ("SHLL", + RTEMS_MINIMUM_STACK_SIZE * 4, + 100, + "/dev/foobar", + false, + true, + NULL); + + TEST_END(); + + rtems_test_exit(0); +} + +#define CONFIGURE_SHELL_COMMANDS_INIT +#define CONFIGURE_SHELL_COMMANDS_ALL + +/* + * Remove the commands that pull in libblock. + */ +#define CONFIGURE_SHELL_NO_COMMAND_BLKSYNC +#define CONFIGURE_SHELL_NO_COMMAND_BLKSTATS +#define CONFIGURE_SHELL_NO_COMMAND_FDISK +#define CONFIGURE_SHELL_NO_COMMAND_MKRFS +#define CONFIGURE_SHELL_NO_COMMAND_DEBUGRFS + +#include + +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER + +#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 10 + +#define CONFIGURE_MAXIMUM_TASKS 4 + +#define CONFIGURE_MAXIMUM_SEMAPHORES 4 + +#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_INIT_TASK_STACK_SIZE (8U * 1024U) + +#define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT) + +#define CONFIGURE_UNIFIED_WORK_AREAS + +#define CONFIGURE_UNLIMITED_OBJECTS + +#define CONFIGURE_INIT + +#include -- cgit v1.2.3