source: rtems/testsuites/libtests/block08/bdbuf_test1_1.c @ 377c0cb0

4.104.115
Last change on this file since 377c0cb0 was 377c0cb0, checked in by Sebastian Huber <sebastian.huber@…>, on 05/17/10 at 08:34:55

2010-05-17 Sebastian Huber <sebastian.huber@…>

PR 1433/cpukit

  • block08/bdbuf_tests.c: Enabled tests 1.1, 1.2 and 1.3.
  • block08/bdbuf_test1_1.c, block08/bdbuf_test1_2.c, block08/bdbuf_test1_3.c: Use RTEMS_IO_ERROR instead of RTEMS_NO_MEMORY.
  • Property mode set to 100644
File size: 3.7 KB
Line 
1/*! @file
2 * @brief Check the behaviour of rtems_bdbuf_read() function
3 * with different reports from disk device driver.
4 *
5 * Test sequence:
6 * -# Call rtems_bdbuf_read() function and return 0 from disk device
7 *    driver ioctl() function, and the result of asynchronous read
8 *    complete notification is successful.
9 * -# Check that rtems_bdbuf_read() returns RTEMS_SUCCESSFUL and
10 *    provides buffer descriptor.
11 * -# Call rtems_bdbuf_read() function and return -1 from disk device
12 *    driver ioctl() function (there will be no asynchronous read
13 *    complete notification).
14 * -# Check that rtems_bdbuf_read() returns RTEMS_IO_ERROR.
15 * -# Call rtems_bdbuf_read() function and return 0 from disk device
16 *    driver ioctl() function, but the result of asynchronous read
17 *    complete notification is faulty (with some erroneous status).
18 * -# Check that rtems_bdbuf_read() returns that status and does not
19 *    return buffer descriptor.
20 *
21 * Copyright (C) 2010 OKTET Labs, St.-Petersburg, Russia
22 * Author: Oleg Kravtsov <Oleg.Kravtsov@oktetlabs.ru>
23 *
24 * The license and distribution terms for this file may be
25 * found in the file LICENSE in this distribution or at
26 * http://www.rtems.com/license/LICENSE.
27 */
28
29#include <bdbuf_tests.h>
30
31static rtems_task bdbuf_test1_1_thread1(rtems_task_argument arg);
32
33#define TEST_BLK_NUM 10
34
35void
36bdbuf_test1_1_main()
37{
38    bdbuf_test_msg msg;
39
40    TEST_START("Test 1.1");
41
42    /*
43     * Create working thread that will call rtems_bdbuf_read() function.
44     */
45    START_THREAD(1, bdbuf_test1_1_thread1);
46   
47    /*
48     * Step 1:
49     * Check that rtems_bdbuf_read() returns RTEMS_SUCCESSFUL
50     * when device driver returns 0 from ioctl() call and
51     * return RTEMS_SUCCESSFUL status in asynchronous
52     * callback notification.
53     */
54    WAIT_DRV_MSG(&msg);
55    SEND_DRV_MSG(0, 0, RTEMS_SUCCESSFUL, 0);
56
57    WAIT_THREAD_SYNC(1);
58    TEST_CHECK_RESULT("2");
59
60    CONTINUE_THREAD(1);
61
62    /*
63     * Step 3:
64     * Check that rtems_bdbuf_read() returns RTEMS_IO_ERROR
65     * return code, when device driver returns -1 from ioctl() call.
66     */
67    WAIT_DRV_MSG(&msg);
68    SEND_DRV_MSG(-1, EFAULT, RTEMS_SUCCESSFUL, 0);
69
70    WAIT_THREAD_SYNC(1);
71    TEST_CHECK_RESULT("4");
72
73    CONTINUE_THREAD(1);
74
75    /*
76     * Step 5:
77     * Check that rtems_bdbuf_read() returns status obtained
78     * from device driver via asynchonous notification.
79     * On this step device driver returns 0 from ioctl() call,
80     * but notification callback is called with RTEMS_IO_ERROR status.
81     */
82    WAIT_DRV_MSG(&msg);
83    SEND_DRV_MSG(0, 0, RTEMS_IO_ERROR, EFAULT);
84
85    WAIT_THREAD_SYNC(1);
86    TEST_CHECK_RESULT("6");
87
88    CONTINUE_THREAD(1);
89
90    TEST_END();
91}
92
93
94static rtems_task
95bdbuf_test1_1_thread1(rtems_task_argument arg)
96{
97    rtems_status_code   rc;
98    rtems_bdbuf_buffer *bd1 = NULL;
99    rtems_bdbuf_buffer *bd2 = NULL;
100
101    /*
102     * Step 1-2:
103     * Successful read operation.
104     */
105    rc = rtems_bdbuf_read(test_dev, 0, &bd1);
106    if (rc != RTEMS_SUCCESSFUL)
107    {
108        TEST_FAILED();
109    }
110    rc = rtems_bdbuf_release(bd1);
111    if (rc != RTEMS_SUCCESSFUL)
112    {
113        TEST_FAILED();
114    }
115
116    CONTINUE_MAIN(1);
117
118    /*
119     * Step 3-4:
120     * Read operation fails with RTEMS_IO_ERROR code.
121     * The function shall not update user pointer.
122     */
123    rc = rtems_bdbuf_read(test_dev, TEST_BLK_NUM, &bd2);
124    if (rc != RTEMS_IO_ERROR || bd2 != NULL)
125    {
126        TEST_FAILED();
127    }
128
129    CONTINUE_MAIN(1);
130
131    /*
132     * Step 5-6:
133     * Read operation fails with RTEMS_IO_ERROR code.
134     * The function shall not update user pointer.
135     */
136    rc = rtems_bdbuf_read(test_dev, TEST_BLK_NUM, &bd2);
137    if (rc != RTEMS_IO_ERROR || bd2 != NULL)
138    {
139        TEST_FAILED();
140    }
141
142    CONTINUE_MAIN(1);
143
144    THREAD_END();
145}
146
Note: See TracBrowser for help on using the repository browser.