source: rtems/testsuites/libtests/block03/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: 3.7 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 512
44
45#define BLOCK_COUNT 2
46
47static dev_t dev;
48
49static volatile bool sync_done = false;
50
51static rtems_id task_id_low;
52
53static rtems_id task_id_high;
54
55static void task_low(rtems_task_argument arg)
56{
57  rtems_status_code sc = RTEMS_SUCCESSFUL;
58  rtems_bdbuf_buffer *bd = NULL;
59
60  rtems_test_assert(!sync_done);
61
62  printk("L: try access: 0\n");
63
64  sc = rtems_bdbuf_get(dev, 0, &bd);
65  ASSERT_SC(sc);
66
67  rtems_test_assert(sync_done);
68
69  printk("L: access: 0\n");
70
71  rtems_test_assert(bd->block == 0);
72
73  printk("*** END OF TEST BLOCK 3 ***\n");
74
75  exit(0);
76}
77
78static void task_high(rtems_task_argument arg)
79{
80  rtems_status_code sc = RTEMS_SUCCESSFUL;
81  rtems_bdbuf_buffer *bd = NULL;
82
83  rtems_test_assert(!sync_done);
84
85  printk("H: try access: 0\n");
86
87  sc = rtems_bdbuf_get(dev, 0, &bd);
88  ASSERT_SC(sc);
89
90  rtems_test_assert(sync_done);
91
92  printk("H: access: 0\n");
93
94  printk("H: release: 0\n");
95
96  sc = rtems_bdbuf_release(bd);
97  ASSERT_SC(sc);
98
99  printk("H: release done: 0\n");
100
101  printk("H: try access: 1\n");
102
103  sc = rtems_bdbuf_get(dev, 1, &bd);
104  ASSERT_SC(sc);
105
106  printk("H: access: 1\n");
107
108  /* If we reach this code, we have likely a bug */
109
110  printk("H: release: 1\n");
111
112  sc = rtems_bdbuf_release(bd);
113  ASSERT_SC(sc);
114
115  printk("H: release done: 1\n");
116
117  rtems_task_delete(RTEMS_SELF);
118}
119
120static rtems_task Init(rtems_task_argument argument)
121{
122  rtems_status_code sc = RTEMS_SUCCESSFUL;
123  rtems_bdbuf_buffer *bd = NULL;
124
125  printk("\n\n*** TEST BLOCK 3 ***\n");
126
127  sc = rtems_disk_io_initialize();
128  ASSERT_SC(sc);
129
130  sc = ramdisk_register(BLOCK_SIZE, BLOCK_COUNT, false, "/dev/rda", &dev);
131  ASSERT_SC(sc);
132
133  sc = rtems_task_create(
134    rtems_build_name(' ', 'L', 'O', 'W'),
135    PRIORITY_LOW,
136    0,
137    RTEMS_DEFAULT_MODES,
138    RTEMS_DEFAULT_ATTRIBUTES,
139    &task_id_low
140  );
141  ASSERT_SC(sc);
142
143  sc = rtems_task_start(task_id_low, task_low, 0);
144  ASSERT_SC(sc);
145
146  sc = rtems_task_create(
147    rtems_build_name('H', 'I', 'G', 'H'),
148    PRIORITY_HIGH,
149    0,
150    RTEMS_DEFAULT_MODES,
151    RTEMS_DEFAULT_ATTRIBUTES,
152    &task_id_high
153  );
154  ASSERT_SC(sc);
155
156  sc = rtems_task_start(task_id_high, task_high, 0);
157  ASSERT_SC(sc);
158
159  sc = rtems_bdbuf_get(dev, 0, &bd);
160  ASSERT_SC(sc);
161
162  sc = rtems_bdbuf_sync(bd);
163  ASSERT_SC(sc);
164
165  printk("I: sync done: 0\n");
166
167  sync_done = true;
168
169  sc = rtems_task_suspend(RTEMS_SELF);
170  ASSERT_SC(sc);
171}
172
173#define CONFIGURE_INIT
174
175#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
176#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
177#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
178
179#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
180
181#define CONFIGURE_MAXIMUM_TASKS 5
182#define CONFIGURE_MAXIMUM_DRIVERS 2
183
184#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
185
186#define CONFIGURE_INIT_TASK_PRIORITY PRIORITY_INIT
187#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_DEFAULT_ATTRIBUTES
188#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_DEFAULT_MODES
189
190#define CONFIGURE_SWAPOUT_TASK_PRIORITY PRIORITY_SWAPOUT
191
192#define CONFIGURE_BDBUF_BUFFER_MIN_SIZE BLOCK_SIZE
193#define CONFIGURE_BDBUF_BUFFER_MAX_SIZE BLOCK_SIZE
194#define CONFIGURE_BDBUF_CACHE_MEMORY_SIZE BLOCK_SIZE
195
196#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.