[KMTESTS:IO]
[reactos.git] / rostests / kmtests / ntos_io / IoReadWrite.h
1 /*
2 * PROJECT: ReactOS kernel-mode tests
3 * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
4 * PURPOSE: Read/Write operations test declarations
5 * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
6 */
7
8 #ifndef _KMTEST_IOREADFILE_H_
9 #define _KMTEST_IOREADFILE_H_
10
11 #define TEST_FILE_SIZE 17
12
13 #define KEY_SUCCEED 0x00
14 #define KEY_FAIL_MISALIGNED 0x81
15 #define KEY_FAIL_OVERFLOW 0x82
16 #define KEY_FAIL_PARTIAL 0x83
17 #define KEY_FAIL_BUSY 0x84
18 #define KEY_FAIL_VERIFY_REQUIRED 0x85
19
20 #define KEY_FAIL_UNSUCCESSFUL 0xc1
21 #define KEY_FAIL_NOT_IMPLEMENTED 0xc2
22 #define KEY_FAIL_ACCESS_VIOLATION 0xc3
23 #define KEY_FAIL_IN_PAGE_ERROR 0xc4
24 #define KEY_FAIL_EOF 0xc5
25 #define KEY_FAIL_ACCESS_DENIED 0xc6
26 #define KEY_FAIL_MISALIGNED_ERROR 0xc7
27 #define KEY_RESULT_MASK 0xff
28
29 #define KEY_NEXT(key) ( (key) == KEY_FAIL_MISALIGNED_ERROR ? 0xff : \
30 (key) == KEY_FAIL_VERIFY_REQUIRED ? KEY_FAIL_UNSUCCESSFUL : \
31 (key) == KEY_SUCCEED ? KEY_FAIL_MISALIGNED : \
32 (key) + 1 )
33 #define KEY_ERROR(key) (((key) & 0xc0) == 0xc0)
34 static
35 NTSTATUS
36 TestGetReturnStatus(
37 _In_ ULONG LockKey)
38 {
39 switch (LockKey & KEY_RESULT_MASK)
40 {
41 case KEY_SUCCEED:
42 return STATUS_SUCCESS;
43
44 case KEY_FAIL_MISALIGNED:
45 return STATUS_DATATYPE_MISALIGNMENT;
46 case KEY_FAIL_OVERFLOW:
47 return STATUS_BUFFER_OVERFLOW;
48 case KEY_FAIL_PARTIAL:
49 return STATUS_PARTIAL_COPY;
50 case KEY_FAIL_BUSY:
51 return STATUS_DEVICE_BUSY;
52 case KEY_FAIL_VERIFY_REQUIRED:
53 return STATUS_VERIFY_REQUIRED;
54
55 case KEY_FAIL_UNSUCCESSFUL:
56 return STATUS_UNSUCCESSFUL;
57 case KEY_FAIL_NOT_IMPLEMENTED:
58 return STATUS_NOT_IMPLEMENTED;
59 case KEY_FAIL_ACCESS_VIOLATION:
60 return STATUS_ACCESS_VIOLATION;
61 case KEY_FAIL_IN_PAGE_ERROR:
62 return STATUS_IN_PAGE_ERROR;
63 case KEY_FAIL_EOF:
64 return STATUS_END_OF_FILE;
65 case KEY_FAIL_ACCESS_DENIED:
66 return STATUS_ACCESS_DENIED;
67 case KEY_FAIL_MISALIGNED_ERROR:
68 return STATUS_DATATYPE_MISALIGNMENT_ERROR;
69 default:
70 ok(0, "Key = %lx\n", LockKey);
71 return STATUS_INVALID_PARAMETER;
72 }
73 }
74
75 #define KEY_USE_FASTIO 0x100
76 #define KEY_RETURN_PENDING 0x200
77
78 #define KEY_DATA(c) (((c) & 0xff) << 24)
79 #define KEY_GET_DATA(key) ((key) >> 24)
80
81 #endif /* !defined _KMTEST_IOREADFILE_H_ */