source: rtems/testsuites/libtests/block02/init.c @ 7d3f9c6

4.115
Last change on this file since 7d3f9c6 was 7d3f9c6, checked in by Ralf Corsepius <ralf.corsepius@…>, on 02/22/11 at 07:37:03

Add HAVE_CONFIG_H.

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