source: rtems/testsuites/samples/capture/init.c @ 98c6d50

Last change on this file since 98c6d50 was 98c6d50, checked in by Chris Johns <chrisj@…>, on Oct 19, 2017 at 5:39:16 AM

testsuite: Use printk for all test output where possible.

  • Remove the printf support leaving the direct printk support configured with TESTS_USE_PRINTK and all other output goes via a buffered vsniprintf call to printk.
  • Control the test's single init for functions and global data with TEST_INIT and not CONFIGURE_INIT. They are now separate.

Updates #3170.

  • 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#define TEST_INIT
17
18#include "system.h"
19#include <stdio.h>
20#include <stdlib.h>
21
22#include <rtems.h>
23#include <rtems/capture-cli.h>
24#include <rtems/monitor.h>
25#include <rtems/shell.h>
26
27/* forward declarations to avoid warnings */
28rtems_task Init(rtems_task_argument argument);
29static void notification(int fd, int seconds_remaining, void *arg);
30
31const char rtems_test_name[] = "CAPTURE ENGINE";
32rtems_printer rtems_test_printer;
33
34volatile int can_proceed = 1;
35
36static void notification(int fd, int seconds_remaining, void *arg)
37{
38  printf(
39    "Press any key to start capture engine (%is remaining)\n",
40    seconds_remaining
41  );
42}
43
44rtems_task Init(
45  rtems_task_argument ignored
46)
47{
48  rtems_status_code   status;
49  rtems_task_priority old_priority;
50  rtems_mode          old_mode;
51
52  rtems_print_printer_printf(&rtems_test_printer);
53  rtems_test_begin();
54
55  status = rtems_shell_wait_for_input(
56    STDIN_FILENO,
57    20,
58    notification,
59    NULL
60  );
61  if (status == RTEMS_SUCCESSFUL) {
62    /* lower the task priority to allow created tasks to execute */
63
64    rtems_task_set_priority(RTEMS_SELF, 20, &old_priority);
65    rtems_task_mode(RTEMS_PREEMPT,  RTEMS_PREEMPT_MASK, &old_mode);
66
67    while (!can_proceed)
68    {
69      printf ("Sleeping\n");
70      usleep (1000000);
71    }
72
73    rtems_monitor_init (0);
74    rtems_capture_cli_init (0);
75
76    setup_tasks_to_watch ();
77
78    rtems_task_delete (RTEMS_SELF);
79  } else {
80    rtems_test_end();
81
82    exit( 0 );
83  }
84}
Note: See TracBrowser for help on using the repository browser.