1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
2 | |
---|
3 | /* |
---|
4 | * Copyright (c) 2018 Chris Johns <chrisj@rtems.org>. All rights reserved. |
---|
5 | * |
---|
6 | * Redistribution and use in source and binary forms, with or without |
---|
7 | * modification, are permitted provided that the following conditions |
---|
8 | * are met: |
---|
9 | * 1. Redistributions of source code must retain the above copyright |
---|
10 | * notice, this list of conditions and the following disclaimer. |
---|
11 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
12 | * notice, this list of conditions and the following disclaimer in the |
---|
13 | * documentation and/or other materials provided with the distribution. |
---|
14 | * |
---|
15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
25 | * POSSIBILITY OF SUCH DAMAGE. |
---|
26 | */ |
---|
27 | |
---|
28 | #ifdef HAVE_CONFIG_H |
---|
29 | #include "config.h" |
---|
30 | #endif |
---|
31 | |
---|
32 | #include "tmacros.h" |
---|
33 | |
---|
34 | #include <errno.h> |
---|
35 | #include <string.h> |
---|
36 | #include <stdint.h> |
---|
37 | #include <unistd.h> |
---|
38 | |
---|
39 | #include <rtems/rtl/dlfcn-shell.h> |
---|
40 | #include <rtems/rtl/rtl.h> |
---|
41 | #include <rtems/rtl/rtl-shell.h> |
---|
42 | #include <rtems/shell.h> |
---|
43 | #include <rtems/imfs.h> |
---|
44 | |
---|
45 | #include "dl-load.h" |
---|
46 | |
---|
47 | const char rtems_test_name[] = "libdl (RTL) 10"; |
---|
48 | |
---|
49 | #include "dl10-tar.h" |
---|
50 | |
---|
51 | #define TARFILE_START dl10_tar |
---|
52 | #define TARFILE_SIZE dl10_tar_size |
---|
53 | |
---|
54 | static int test(void) |
---|
55 | { |
---|
56 | #if USE_SHELL_CMD |
---|
57 | int ret; |
---|
58 | ret = dl_load_test(); |
---|
59 | if (ret) |
---|
60 | rtems_test_exit(ret); |
---|
61 | #endif |
---|
62 | return 0; |
---|
63 | } |
---|
64 | |
---|
65 | static void notification(int fd, int seconds_remaining, void *arg) |
---|
66 | { |
---|
67 | printf( |
---|
68 | "Press any key to enter shell (%is remaining)\n", |
---|
69 | seconds_remaining |
---|
70 | ); |
---|
71 | } |
---|
72 | |
---|
73 | static void Init(rtems_task_argument arg) |
---|
74 | { |
---|
75 | int e; |
---|
76 | rtems_status_code sc; |
---|
77 | |
---|
78 | TEST_BEGIN(); |
---|
79 | |
---|
80 | e = rtems_tarfs_load("/", (void *)TARFILE_START, (size_t)TARFILE_SIZE); |
---|
81 | if (e != 0) |
---|
82 | { |
---|
83 | printf ("error: untar failed: %d\n", e); |
---|
84 | rtems_test_exit (1); |
---|
85 | exit (1); |
---|
86 | } |
---|
87 | |
---|
88 | test(); |
---|
89 | |
---|
90 | rtems_shell_init_environment (); |
---|
91 | |
---|
92 | printf ("RTL (libdl) commands: dl, rtl\n\n"); |
---|
93 | |
---|
94 | if (rtems_shell_add_cmd ("rtl", |
---|
95 | "rtl", |
---|
96 | "rtl -l", |
---|
97 | rtems_rtl_shell_command) == NULL) |
---|
98 | { |
---|
99 | printf("command add failed\n"); |
---|
100 | rtems_test_exit(1); |
---|
101 | exit (1); |
---|
102 | } |
---|
103 | |
---|
104 | |
---|
105 | sc = rtems_shell_wait_for_input (STDIN_FILENO, |
---|
106 | 20, |
---|
107 | notification, |
---|
108 | NULL); |
---|
109 | if (sc == RTEMS_SUCCESSFUL) { |
---|
110 | rtems_shell_init ("SHLL", |
---|
111 | RTEMS_MINIMUM_STACK_SIZE * 4, |
---|
112 | 100, |
---|
113 | "/dev/foobar", |
---|
114 | false, |
---|
115 | true, |
---|
116 | NULL); |
---|
117 | } |
---|
118 | |
---|
119 | TEST_END(); |
---|
120 | |
---|
121 | rtems_test_exit(0); |
---|
122 | } |
---|
123 | |
---|
124 | #define CONFIGURE_SHELL_COMMANDS_INIT |
---|
125 | #define CONFIGURE_SHELL_COMMANDS_ALL |
---|
126 | |
---|
127 | /* |
---|
128 | * Remove the commands that pull in libblock. |
---|
129 | */ |
---|
130 | #define CONFIGURE_SHELL_NO_COMMAND_BLKSYNC |
---|
131 | #define CONFIGURE_SHELL_NO_COMMAND_BLKSTATS |
---|
132 | #define CONFIGURE_SHELL_NO_COMMAND_FDISK |
---|
133 | #define CONFIGURE_SHELL_NO_COMMAND_MKRFS |
---|
134 | #define CONFIGURE_SHELL_NO_COMMAND_DEBUGRFS |
---|
135 | |
---|
136 | #include <rtems/shellconfig.h> |
---|
137 | |
---|
138 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
139 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
140 | |
---|
141 | #define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 10 |
---|
142 | |
---|
143 | #define CONFIGURE_MAXIMUM_TASKS 4 |
---|
144 | |
---|
145 | #define CONFIGURE_MAXIMUM_SEMAPHORES 4 |
---|
146 | |
---|
147 | #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION |
---|
148 | |
---|
149 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
150 | |
---|
151 | #define CONFIGURE_INIT_TASK_STACK_SIZE (CONFIGURE_MINIMUM_TASK_STACK_SIZE + (4U * 1024U)) |
---|
152 | |
---|
153 | #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT) |
---|
154 | |
---|
155 | #define CONFIGURE_UNIFIED_WORK_AREAS |
---|
156 | |
---|
157 | #define CONFIGURE_UNLIMITED_OBJECTS |
---|
158 | |
---|
159 | #define CONFIGURE_INIT |
---|
160 | |
---|
161 | #include <rtems/confdefs.h> |
---|