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

5
Last change on this file since acc9d064 was acc9d064, checked in by Sebastian Huber <sebastian.huber@…>, on 10/26/17 at 11:59:10

tests: Remove obsolete TESTS_USE_PRINTK

Update #3170.
Update #3199.

  • Property mode set to 100644
File size: 3.6 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#define TEST_INIT
28
29#include "tmacros.h"
30
31#include <rtems.h>
32#include <rtems/bspIo.h>
33#include <rtems/ramdisk.h>
34#include <rtems/bdbuf.h>
35#include <rtems/diskdevs.h>
36
37const char rtems_test_name[] = "BLOCK 4";
38
39/* forward declarations to avoid warnings */
40static rtems_task Init(rtems_task_argument argument);
41
42#define ASSERT_SC(sc) rtems_test_assert((sc) == RTEMS_SUCCESSFUL)
43
44#define PRIORITY_INIT 10
45
46#define PRIORITY_SWAPOUT 50
47
48#define PRIORITY_HIGH 30
49
50#define PRIORITY_LOW 40
51
52#define BLOCK_SIZE 512
53
54#define BLOCK_COUNT 1
55
56static rtems_disk_device *dd;
57
58static rtems_id task_id_low;
59
60static rtems_id task_id_high;
61
62static void task_low(rtems_task_argument arg)
63{
64  rtems_status_code sc = RTEMS_SUCCESSFUL;
65  rtems_bdbuf_buffer *bd = NULL;
66
67  printk("L: try access: 0\n");
68
69  sc = rtems_bdbuf_get(dd, 0, &bd);
70  ASSERT_SC(sc);
71
72  printk("L: access: 0\n");
73
74  sc = rtems_task_resume(task_id_high);
75  ASSERT_SC(sc);
76
77  sc = rtems_bdbuf_sync(bd);
78  ASSERT_SC(sc);
79
80  printk("L: sync done: 0\n");
81
82  rtems_test_assert(false);
83}
84
85static void task_high(rtems_task_argument arg)
86{
87  rtems_status_code sc = RTEMS_SUCCESSFUL;
88  rtems_bdbuf_buffer *bd = NULL;
89
90  sc = rtems_task_suspend(RTEMS_SELF);
91  ASSERT_SC(sc);
92
93  printk("H: try access: 0\n");
94
95  sc = rtems_bdbuf_get(dd, 0, &bd);
96  ASSERT_SC(sc);
97
98  printk("H: access: 0\n");
99
100  printk("H: release: 0\n");
101
102  sc = rtems_bdbuf_release(bd);
103  ASSERT_SC(sc);
104
105  printk("H: release done: 0\n");
106
107  TEST_END();
108
109  exit(0);
110}
111
112static rtems_task Init(rtems_task_argument argument)
113{
114  rtems_status_code sc = RTEMS_SUCCESSFUL;
115  dev_t dev = 0;
116
117  TEST_BEGIN();
118
119  sc = rtems_disk_io_initialize();
120  ASSERT_SC(sc);
121
122  sc = ramdisk_register(BLOCK_SIZE, BLOCK_COUNT, false, "/dev/rda", &dev);
123  ASSERT_SC(sc);
124
125  dd = rtems_disk_obtain(dev);
126  rtems_test_assert(dd != NULL);
127
128  sc = rtems_task_create(
129    rtems_build_name(' ', 'L', 'O', 'W'),
130    PRIORITY_LOW,
131    0,
132    RTEMS_DEFAULT_MODES,
133    RTEMS_DEFAULT_ATTRIBUTES,
134    &task_id_low
135  );
136  ASSERT_SC(sc);
137
138  sc = rtems_task_start(task_id_low, task_low, 0);
139  ASSERT_SC(sc);
140
141  sc = rtems_task_create(
142    rtems_build_name('H', 'I', 'G', 'H'),
143    PRIORITY_HIGH,
144    0,
145    RTEMS_DEFAULT_MODES,
146    RTEMS_DEFAULT_ATTRIBUTES,
147    &task_id_high
148  );
149  ASSERT_SC(sc);
150
151  sc = rtems_task_start(task_id_high, task_high, 0);
152  ASSERT_SC(sc);
153
154  sc = rtems_task_suspend(RTEMS_SELF);
155  ASSERT_SC(sc);
156}
157
158#define CONFIGURE_INIT
159
160#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
161#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
162#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
163
164#define CONFIGURE_MAXIMUM_TASKS 3
165#define CONFIGURE_MAXIMUM_DRIVERS 2
166
167#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
168
169#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
170
171#define CONFIGURE_INIT_TASK_PRIORITY PRIORITY_INIT
172#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_DEFAULT_ATTRIBUTES
173#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_DEFAULT_MODES
174
175#define CONFIGURE_SWAPOUT_TASK_PRIORITY PRIORITY_SWAPOUT
176
177#define CONFIGURE_BDBUF_BUFFER_MIN_SIZE BLOCK_SIZE
178#define CONFIGURE_BDBUF_BUFFER_MAX_SIZE BLOCK_SIZE
179#define CONFIGURE_BDBUF_CACHE_MEMORY_SIZE BLOCK_SIZE
180
181#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.