source: rtems/testsuites/libtests/block02/init.c @ 500fcd5

4.104.115
Last change on this file since 500fcd5 was 500fcd5, checked in by Joel Sherrill <joel.sherrill@…>, on 12/08/09 at 17:52:49

2009-12-08 Joel Sherrill <joel.sherrill@…>

  • block01/init.c, block02/init.c, block03/init.c, block04/init.c, block05/init.c, block07/init.c, bspcmdline01/init.c, stringto01/init.c, stringto01/stringto_test_template.h, termios01/init.c, termios01/termios_testdriver.c, termios02/init.c: Use rtems_test_assert() consistently instead of system assert(). rtems_test_assert() is designed to integrate into the RTEMS test suite infrastructure.
  • Property mode set to 100644
File size: 3.9 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#include "tmacros.h"
23
24#include <rtems.h>
25#include <rtems/ramdisk.h>
26#include <rtems/bdbuf.h>
27#include <rtems/diskdevs.h>
28
29#define ASSERT_SC(sc) rtems_test_assert((sc) == RTEMS_SUCCESSFUL)
30
31#define PRIORITY_INIT 10
32
33#define PRIORITY_SWAPOUT 50
34
35#define PRIORITY_HIGH 30
36
37#define PRIORITY_LOW 40
38
39#define BLOCK_SIZE_A 512
40
41#define BLOCK_COUNT_A 2
42
43#define BLOCK_SIZE_B 1024
44
45#define BLOCK_COUNT_B 1
46
47static dev_t dev_a;
48
49static dev_t dev_b;
50
51static volatile bool sync_done = false;
52
53static rtems_id task_id_low;
54
55static rtems_id task_id_high;
56
57static void task_low(rtems_task_argument arg)
58{
59  rtems_status_code sc = RTEMS_SUCCESSFUL;
60  rtems_bdbuf_buffer *bd = NULL;
61
62  rtems_test_assert(!sync_done);
63
64  printk("L: try access: A0\n");
65
66  sc = rtems_bdbuf_get(dev_a, 0, &bd);
67  ASSERT_SC(sc);
68
69  rtems_test_assert(sync_done);
70
71  printk("L: access: A0\n");
72
73  rtems_test_assert(bd->dev == dev_a);
74
75  printk("*** END OF TEST BLOCK 2 ***\n");
76
77  exit(0);
78}
79
80static void task_high(rtems_task_argument arg)
81{
82  rtems_status_code sc = RTEMS_SUCCESSFUL;
83  rtems_bdbuf_buffer *bd = NULL;
84
85  rtems_test_assert(!sync_done);
86
87  printk("H: try access: A0\n");
88
89  sc = rtems_bdbuf_get(dev_a, 0, &bd);
90  ASSERT_SC(sc);
91
92  rtems_test_assert(sync_done);
93
94  printk("H: access: A0\n");
95
96  printk("H: release: A0\n");
97
98  sc = rtems_bdbuf_release(bd);
99  ASSERT_SC(sc);
100
101  printk("H: release done: A0\n");
102
103  printk("H: try access: B0\n");
104
105  sc = rtems_bdbuf_get(dev_b, 0, &bd);
106  ASSERT_SC(sc);
107
108  printk("H: access: B0\n");
109
110  /* If we reach this code, we have likely a bug */
111
112  printk("H: release: B0\n");
113
114  sc = rtems_bdbuf_release(bd);
115  ASSERT_SC(sc);
116
117  printk("H: release done: B0\n");
118
119  rtems_task_delete(RTEMS_SELF);
120}
121
122static rtems_task Init(rtems_task_argument argument)
123{
124  rtems_status_code sc = RTEMS_SUCCESSFUL;
125  rtems_bdbuf_buffer *bd = NULL;
126
127  printk("\n\n*** TEST BLOCK 2 ***\n");
128
129  sc = rtems_disk_io_initialize();
130  ASSERT_SC(sc);
131
132  sc = ramdisk_register(BLOCK_SIZE_A, BLOCK_COUNT_A, false, "/dev/rda", &dev_a);
133  ASSERT_SC(sc);
134
135  sc = ramdisk_register(BLOCK_SIZE_B, BLOCK_COUNT_B, false, "/dev/rdb", &dev_b);
136  ASSERT_SC(sc);
137
138  sc = rtems_task_create(
139    rtems_build_name(' ', 'L', 'O', 'W'),
140    PRIORITY_LOW,
141    0,
142    RTEMS_DEFAULT_MODES,
143    RTEMS_DEFAULT_ATTRIBUTES,
144    &task_id_low
145  );
146  ASSERT_SC(sc);
147
148  sc = rtems_task_start(task_id_low, task_low, 0);
149  ASSERT_SC(sc);
150
151  sc = rtems_task_create(
152    rtems_build_name('H', 'I', 'G', 'H'),
153    PRIORITY_HIGH,
154    0,
155    RTEMS_DEFAULT_MODES,
156    RTEMS_DEFAULT_ATTRIBUTES,
157    &task_id_high
158  );
159  ASSERT_SC(sc);
160
161  sc = rtems_task_start(task_id_high, task_high, 0);
162  ASSERT_SC(sc);
163
164  sc = rtems_bdbuf_get(dev_a, 0, &bd);
165  ASSERT_SC(sc);
166
167  sc = rtems_bdbuf_sync(bd);
168  ASSERT_SC(sc);
169
170  printk("I: sync done: A0\n");
171
172  sync_done = true;
173
174  sc = rtems_task_suspend(RTEMS_SELF);
175  ASSERT_SC(sc);
176}
177
178#define CONFIGURE_INIT
179
180#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
181#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
182#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
183
184#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
185
186#define CONFIGURE_MAXIMUM_TASKS 5
187#define CONFIGURE_MAXIMUM_DRIVERS 3
188#define CONFIGURE_MAXIMUM_SEMAPHORES 5
189
190#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
191
192#define CONFIGURE_INIT_TASK_PRIORITY PRIORITY_INIT
193#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_DEFAULT_ATTRIBUTES
194#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_DEFAULT_MODES
195
196#define CONFIGURE_SWAPOUT_TASK_PRIORITY PRIORITY_SWAPOUT
197
198#define CONFIGURE_BDBUF_BUFFER_MIN_SIZE BLOCK_SIZE_A
199#define CONFIGURE_BDBUF_BUFFER_MAX_SIZE BLOCK_SIZE_B
200#define CONFIGURE_BDBUF_CACHE_MEMORY_SIZE BLOCK_SIZE_B
201
202#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.