1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
2 | |
---|
3 | /* |
---|
4 | * COPYRIGHT (c) 1989-2012. |
---|
5 | * On-Line Applications Research Corporation (OAR). |
---|
6 | * |
---|
7 | * Redistribution and use in source and binary forms, with or without |
---|
8 | * modification, are permitted provided that the following conditions |
---|
9 | * are met: |
---|
10 | * 1. Redistributions of source code must retain the above copyright |
---|
11 | * notice, this list of conditions and the following disclaimer. |
---|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
13 | * notice, this list of conditions and the following disclaimer in the |
---|
14 | * documentation and/or other materials provided with the distribution. |
---|
15 | * |
---|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
26 | * POSSIBILITY OF SUCH DAMAGE. |
---|
27 | */ |
---|
28 | |
---|
29 | #define CONFIGURE_INIT |
---|
30 | |
---|
31 | #ifdef HAVE_CONFIG_H |
---|
32 | #include "config.h" |
---|
33 | #endif |
---|
34 | |
---|
35 | #include "system.h" |
---|
36 | |
---|
37 | #include <rtems.h> |
---|
38 | #include <rtems/capture-cli.h> |
---|
39 | #include <rtems/monitor.h> |
---|
40 | #include <rtems/shell.h> |
---|
41 | #include <tmacros.h> |
---|
42 | |
---|
43 | const char rtems_test_name[] = "CAPTURE ENGINE"; |
---|
44 | |
---|
45 | volatile int can_proceed = 1; |
---|
46 | |
---|
47 | static void notification(int fd, int seconds_remaining, void *arg) |
---|
48 | { |
---|
49 | printf( |
---|
50 | "Press any key to start capture engine (%is remaining)\n", |
---|
51 | seconds_remaining |
---|
52 | ); |
---|
53 | } |
---|
54 | |
---|
55 | rtems_task Init( |
---|
56 | rtems_task_argument ignored |
---|
57 | ) |
---|
58 | { |
---|
59 | rtems_status_code status; |
---|
60 | rtems_task_priority old_priority; |
---|
61 | rtems_mode old_mode; |
---|
62 | |
---|
63 | rtems_print_printer_fprintf_putc(&rtems_test_printer); |
---|
64 | TEST_BEGIN(); |
---|
65 | |
---|
66 | status = rtems_shell_wait_for_input( |
---|
67 | STDIN_FILENO, |
---|
68 | 20, |
---|
69 | notification, |
---|
70 | NULL |
---|
71 | ); |
---|
72 | if (status == RTEMS_SUCCESSFUL) { |
---|
73 | /* lower the task priority to allow created tasks to execute */ |
---|
74 | |
---|
75 | rtems_task_set_priority(RTEMS_SELF, 20, &old_priority); |
---|
76 | rtems_task_mode(RTEMS_PREEMPT, RTEMS_PREEMPT_MASK, &old_mode); |
---|
77 | |
---|
78 | while (!can_proceed) |
---|
79 | { |
---|
80 | printf ("Sleeping\n"); |
---|
81 | usleep (1000000); |
---|
82 | } |
---|
83 | |
---|
84 | rtems_monitor_init (0); |
---|
85 | rtems_capture_cli_init (0); |
---|
86 | |
---|
87 | setup_tasks_to_watch (); |
---|
88 | |
---|
89 | rtems_task_exit(); |
---|
90 | } else { |
---|
91 | TEST_END(); |
---|
92 | rtems_test_exit( 0 ); |
---|
93 | } |
---|
94 | } |
---|