source: rtems/testsuites/libtests/block04/init.c @ c4b8b147

Last change on this file since c4b8b147 was c4b8b147, checked in by Sebastian Huber <sebastian.huber@…>, on Nov 3, 2017 at 7:35:38 AM

tests: Use simple console driver

Update #3170.
Update #3199.

  • Property mode set to 100644
File size: 3.5 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup test_bdbuf
5 *
6 * @brief Bdbuf test.
7 */
8
9/*
10 * Copyright (c) 2009-2012 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Obere Lagerstr. 30
14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.org/license/LICENSE.
21 */
22
23#ifdef HAVE_CONFIG_H
24#include "config.h"
25#endif
26
27#include "tmacros.h"
28
29#include <rtems.h>
30#include <rtems/bspIo.h>
31#include <rtems/ramdisk.h>
32#include <rtems/bdbuf.h>
33#include <rtems/diskdevs.h>
34
35const char rtems_test_name[] = "BLOCK 4";
36
37/* forward declarations to avoid warnings */
38static rtems_task Init(rtems_task_argument argument);
39
40#define ASSERT_SC(sc) rtems_test_assert((sc) == RTEMS_SUCCESSFUL)
41
42#define PRIORITY_INIT 10
43
44#define PRIORITY_SWAPOUT 50
45
46#define PRIORITY_HIGH 30
47
48#define PRIORITY_LOW 40
49
50#define BLOCK_SIZE 512
51
52#define BLOCK_COUNT 1
53
54static rtems_disk_device *dd;
55
56static rtems_id task_id_low;
57
58static rtems_id task_id_high;
59
60static void task_low(rtems_task_argument arg)
61{
62  rtems_status_code sc = RTEMS_SUCCESSFUL;
63  rtems_bdbuf_buffer *bd = NULL;
64
65  printk("L: try access: 0\n");
66
67  sc = rtems_bdbuf_get(dd, 0, &bd);
68  ASSERT_SC(sc);
69
70  printk("L: access: 0\n");
71
72  sc = rtems_task_resume(task_id_high);
73  ASSERT_SC(sc);
74
75  sc = rtems_bdbuf_sync(bd);
76  ASSERT_SC(sc);
77
78  printk("L: sync done: 0\n");
79
80  rtems_test_assert(false);
81}
82
83static void task_high(rtems_task_argument arg)
84{
85  rtems_status_code sc = RTEMS_SUCCESSFUL;
86  rtems_bdbuf_buffer *bd = NULL;
87
88  sc = rtems_task_suspend(RTEMS_SELF);
89  ASSERT_SC(sc);
90
91  printk("H: try access: 0\n");
92
93  sc = rtems_bdbuf_get(dd, 0, &bd);
94  ASSERT_SC(sc);
95
96  printk("H: access: 0\n");
97
98  printk("H: release: 0\n");
99
100  sc = rtems_bdbuf_release(bd);
101  ASSERT_SC(sc);
102
103  printk("H: release done: 0\n");
104
105  TEST_END();
106
107  exit(0);
108}
109
110static rtems_task Init(rtems_task_argument argument)
111{
112  rtems_status_code sc = RTEMS_SUCCESSFUL;
113  dev_t dev = 0;
114
115  TEST_BEGIN();
116
117  sc = rtems_disk_io_initialize();
118  ASSERT_SC(sc);
119
120  sc = ramdisk_register(BLOCK_SIZE, BLOCK_COUNT, false, "/dev/rda", &dev);
121  ASSERT_SC(sc);
122
123  dd = rtems_disk_obtain(dev);
124  rtems_test_assert(dd != NULL);
125
126  sc = rtems_task_create(
127    rtems_build_name(' ', 'L', 'O', 'W'),
128    PRIORITY_LOW,
129    0,
130    RTEMS_DEFAULT_MODES,
131    RTEMS_DEFAULT_ATTRIBUTES,
132    &task_id_low
133  );
134  ASSERT_SC(sc);
135
136  sc = rtems_task_start(task_id_low, task_low, 0);
137  ASSERT_SC(sc);
138
139  sc = rtems_task_create(
140    rtems_build_name('H', 'I', 'G', 'H'),
141    PRIORITY_HIGH,
142    0,
143    RTEMS_DEFAULT_MODES,
144    RTEMS_DEFAULT_ATTRIBUTES,
145    &task_id_high
146  );
147  ASSERT_SC(sc);
148
149  sc = rtems_task_start(task_id_high, task_high, 0);
150  ASSERT_SC(sc);
151
152  sc = rtems_task_suspend(RTEMS_SELF);
153  ASSERT_SC(sc);
154}
155
156#define CONFIGURE_INIT
157
158#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
159#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
160#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
161
162#define CONFIGURE_MAXIMUM_TASKS 3
163#define CONFIGURE_MAXIMUM_DRIVERS 2
164
165#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
166
167#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
168
169#define CONFIGURE_INIT_TASK_PRIORITY PRIORITY_INIT
170#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_DEFAULT_ATTRIBUTES
171#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_DEFAULT_MODES
172
173#define CONFIGURE_SWAPOUT_TASK_PRIORITY PRIORITY_SWAPOUT
174
175#define CONFIGURE_BDBUF_BUFFER_MIN_SIZE BLOCK_SIZE
176#define CONFIGURE_BDBUF_BUFFER_MAX_SIZE BLOCK_SIZE
177#define CONFIGURE_BDBUF_CACHE_MEMORY_SIZE BLOCK_SIZE
178
179#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.