source: rtems/testsuites/libtests/dl10/init.c @ 93ebc9d

Last change on this file since 93ebc9d was 93ebc9d, checked in by Sebastian Huber <sebastian.huber@…>, on 01/14/22 at 06:59:34

libtests/dl10: Enter shell on demand

Use rtems_shell_wait_for_input() similar to other potentially
interactive test programs.

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/*
2 * Copyright (c) 2018 Chris Johns <chrisj@rtems.org>.  All rights reserved.
3 *
4 * The license and distribution terms for this file may be
5 * found in the file LICENSE in this distribution or at
6 * http://www.rtems.org/license/LICENSE.
7 */
8
9#ifdef HAVE_CONFIG_H
10#include "config.h"
11#endif
12
13#include "tmacros.h"
14
15#include <errno.h>
16#include <string.h>
17#include <stdint.h>
18#include <unistd.h>
19
20#include <rtems/rtl/dlfcn-shell.h>
21#include <rtems/rtl/rtl.h>
22#include <rtems/rtl/rtl-shell.h>
23#include <rtems/shell.h>
24#include <rtems/imfs.h>
25
26#include "dl-load.h"
27
28const char rtems_test_name[] = "libdl (RTL) 10";
29
30#include "dl10-tar.h"
31
32#define TARFILE_START dl10_tar
33#define TARFILE_SIZE  dl10_tar_size
34
35static int test(void)
36{
37#if USE_SHELL_CMD
38  int ret;
39  ret = dl_load_test();
40  if (ret)
41    rtems_test_exit(ret);
42#endif
43  return 0;
44}
45
46static void notification(int fd, int seconds_remaining, void *arg)
47{
48  printf(
49    "Press any key to enter shell (%is remaining)\n",
50    seconds_remaining
51  );
52}
53
54static void Init(rtems_task_argument arg)
55{
56  int e;
57  rtems_status_code sc;
58
59  TEST_BEGIN();
60
61  e = rtems_tarfs_load("/", (void *)TARFILE_START, (size_t)TARFILE_SIZE);
62  if (e != 0)
63  {
64    printf ("error: untar failed: %d\n", e);
65    rtems_test_exit (1);
66    exit (1);
67  }
68
69  test();
70
71  rtems_shell_init_environment ();
72
73  printf ("RTL (libdl) commands: dl, rtl\n\n");
74
75  if (rtems_shell_add_cmd ("rtl",
76                           "rtl",
77                           "rtl -l",
78                           rtems_rtl_shell_command) == NULL)
79  {
80    printf("command add failed\n");
81    rtems_test_exit(1);
82    exit (1);
83  }
84
85
86  sc = rtems_shell_wait_for_input (STDIN_FILENO,
87                                   20,
88                                   notification,
89                                   NULL);
90  if (sc == RTEMS_SUCCESSFUL) {
91    rtems_shell_init ("SHLL",
92                      RTEMS_MINIMUM_STACK_SIZE * 4,
93                      100,
94                      "/dev/foobar",
95                      false,
96                      true,
97                      NULL);
98  }
99
100  TEST_END();
101
102  rtems_test_exit(0);
103}
104
105#define CONFIGURE_SHELL_COMMANDS_INIT
106#define CONFIGURE_SHELL_COMMANDS_ALL
107
108/*
109 * Remove the commands that pull in libblock.
110 */
111#define CONFIGURE_SHELL_NO_COMMAND_BLKSYNC
112#define CONFIGURE_SHELL_NO_COMMAND_BLKSTATS
113#define CONFIGURE_SHELL_NO_COMMAND_FDISK
114#define CONFIGURE_SHELL_NO_COMMAND_MKRFS
115#define CONFIGURE_SHELL_NO_COMMAND_DEBUGRFS
116
117#include <rtems/shellconfig.h>
118
119#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
120#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
121
122#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 10
123
124#define CONFIGURE_MAXIMUM_TASKS 4
125
126#define CONFIGURE_MAXIMUM_SEMAPHORES 4
127
128#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
129
130#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
131
132#define CONFIGURE_INIT_TASK_STACK_SIZE (8U * 1024U)
133
134#define CONFIGURE_INIT_TASK_ATTRIBUTES   (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT)
135
136#define CONFIGURE_UNIFIED_WORK_AREAS
137
138#define CONFIGURE_UNLIMITED_OBJECTS
139
140#define CONFIGURE_INIT
141
142#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.