source: rtems/testsuites/samples/capture/init.c @ af43554

5
Last change on this file since af43554 was af43554, checked in by Sebastian Huber <sebastian.huber@…>, on 10/26/17 at 11:59:11

tests: Remove TEST_INIT

The TEST_EXTERN is a used only by the system.h style tests and they use
CONFIGURE_INIT appropriately.

Update #3170.
Update #3199.

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2012.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may in
6 *  the file LICENSE in this distribution or at
7 *  http://www.rtems.org/license/LICENSE.
8 */
9
10#define CONFIGURE_INIT
11
12#ifdef HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include "system.h"
17#include <stdio.h>
18#include <stdlib.h>
19
20#include <rtems.h>
21#include <rtems/capture-cli.h>
22#include <rtems/monitor.h>
23#include <rtems/shell.h>
24
25/* forward declarations to avoid warnings */
26rtems_task Init(rtems_task_argument argument);
27static void notification(int fd, int seconds_remaining, void *arg);
28
29const char rtems_test_name[] = "CAPTURE ENGINE";
30
31volatile int can_proceed = 1;
32
33static void notification(int fd, int seconds_remaining, void *arg)
34{
35  printf(
36    "Press any key to start capture engine (%is remaining)\n",
37    seconds_remaining
38  );
39}
40
41rtems_task Init(
42  rtems_task_argument ignored
43)
44{
45  rtems_status_code   status;
46  rtems_task_priority old_priority;
47  rtems_mode          old_mode;
48
49  rtems_print_printer_fprintf_putc(&rtems_test_printer);
50  rtems_test_begin();
51
52  status = rtems_shell_wait_for_input(
53    STDIN_FILENO,
54    20,
55    notification,
56    NULL
57  );
58  if (status == RTEMS_SUCCESSFUL) {
59    /* lower the task priority to allow created tasks to execute */
60
61    rtems_task_set_priority(RTEMS_SELF, 20, &old_priority);
62    rtems_task_mode(RTEMS_PREEMPT,  RTEMS_PREEMPT_MASK, &old_mode);
63
64    while (!can_proceed)
65    {
66      printf ("Sleeping\n");
67      usleep (1000000);
68    }
69
70    rtems_monitor_init (0);
71    rtems_capture_cli_init (0);
72
73    setup_tasks_to_watch ();
74
75    rtems_task_delete (RTEMS_SELF);
76  } else {
77    rtems_test_end();
78
79    exit( 0 );
80  }
81}
Note: See TracBrowser for help on using the repository browser.