Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:33

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  * Copyright (c) 2018 Chris Johns <chrisj@rtems.org>.  All rights reserved.
0005  *
0006  * Redistribution and use in source and binary forms, with or without
0007  * modification, are permitted provided that the following conditions
0008  * are met:
0009  * 1. Redistributions of source code must retain the above copyright
0010  *    notice, this list of conditions and the following disclaimer.
0011  * 2. Redistributions in binary form must reproduce the above copyright
0012  *    notice, this list of conditions and the following disclaimer in the
0013  *    documentation and/or other materials provided with the distribution.
0014  *
0015  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0016  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0017  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0018  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0019  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0020  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0021  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0022  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0023  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0024  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0025  * POSSIBILITY OF SUCH DAMAGE.
0026  */
0027 
0028 #ifdef HAVE_CONFIG_H
0029 #include "config.h"
0030 #endif
0031 
0032 #include "tmacros.h"
0033 
0034 #include <errno.h>
0035 #include <string.h>
0036 #include <stdint.h>
0037 #include <unistd.h>
0038 
0039 #include <rtems/rtl/dlfcn-shell.h>
0040 #include <rtems/rtl/rtl.h>
0041 #include <rtems/rtl/rtl-shell.h>
0042 #include <rtems/shell.h>
0043 #include <rtems/imfs.h>
0044 
0045 #include "dl-load.h"
0046 
0047 const char rtems_test_name[] = "libdl (RTL) 10";
0048 
0049 #include "dl10-tar.h"
0050 
0051 #define TARFILE_START dl10_tar
0052 #define TARFILE_SIZE  dl10_tar_size
0053 
0054 static int test(void)
0055 {
0056 #if USE_SHELL_CMD
0057   int ret;
0058   ret = dl_load_test();
0059   if (ret)
0060     rtems_test_exit(ret);
0061 #endif
0062   return 0;
0063 }
0064 
0065 static void notification(int fd, int seconds_remaining, void *arg)
0066 {
0067   printf(
0068     "Press any key to enter shell (%is remaining)\n",
0069     seconds_remaining
0070   );
0071 }
0072 
0073 static void Init(rtems_task_argument arg)
0074 {
0075   int e;
0076   rtems_status_code sc;
0077 
0078   TEST_BEGIN();
0079 
0080   e = rtems_tarfs_load("/", (void *)TARFILE_START, (size_t)TARFILE_SIZE);
0081   if (e != 0)
0082   {
0083     printf ("error: untar failed: %d\n", e);
0084     rtems_test_exit (1);
0085     exit (1);
0086   }
0087 
0088   test();
0089 
0090   rtems_shell_init_environment ();
0091 
0092   printf ("RTL (libdl) commands: dl, rtl\n\n");
0093 
0094   if (rtems_shell_add_cmd ("rtl",
0095                            "rtl",
0096                            "rtl -l",
0097                            rtems_rtl_shell_command) == NULL)
0098   {
0099     printf("command add failed\n");
0100     rtems_test_exit(1);
0101     exit (1);
0102   }
0103 
0104 
0105   sc = rtems_shell_wait_for_input (STDIN_FILENO,
0106                                    20,
0107                                    notification,
0108                                    NULL);
0109   if (sc == RTEMS_SUCCESSFUL) {
0110     rtems_shell_init ("SHLL",
0111                       RTEMS_MINIMUM_STACK_SIZE * 4,
0112                       100,
0113                       "/dev/foobar",
0114                       false,
0115                       true,
0116                       NULL);
0117   }
0118 
0119   TEST_END();
0120 
0121   rtems_test_exit(0);
0122 }
0123 
0124 #define CONFIGURE_SHELL_COMMANDS_INIT
0125 #define CONFIGURE_SHELL_COMMANDS_ALL
0126 
0127 /*
0128  * Remove the commands that pull in libblock.
0129  */
0130 #define CONFIGURE_SHELL_NO_COMMAND_BLKSYNC
0131 #define CONFIGURE_SHELL_NO_COMMAND_BLKSTATS
0132 #define CONFIGURE_SHELL_NO_COMMAND_FDISK
0133 #define CONFIGURE_SHELL_NO_COMMAND_MKRFS
0134 #define CONFIGURE_SHELL_NO_COMMAND_DEBUGRFS
0135 
0136 #include <rtems/shellconfig.h>
0137 
0138 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
0139 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
0140 
0141 #define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 10
0142 
0143 #define CONFIGURE_MAXIMUM_TASKS 4
0144 
0145 #define CONFIGURE_MAXIMUM_SEMAPHORES 4
0146 
0147 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
0148 
0149 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
0150 
0151 #define CONFIGURE_INIT_TASK_STACK_SIZE (CONFIGURE_MINIMUM_TASK_STACK_SIZE + (4U * 1024U))
0152 
0153 #define CONFIGURE_INIT_TASK_ATTRIBUTES   (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT)
0154 
0155 #define CONFIGURE_UNIFIED_WORK_AREAS
0156 
0157 #define CONFIGURE_UNLIMITED_OBJECTS
0158 
0159 #define CONFIGURE_INIT
0160 
0161 #include <rtems/confdefs.h>