a306c851d5adbb4673a70ed6cd16562421575b9b
[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_SUCCESS_WAIT1 0x01
15
16 #define KEY_INFO_EXISTS 0x41
17
18 #define KEY_FAIL_MISALIGNED 0x81
19 #define KEY_FAIL_OVERFLOW 0x82
20 #define KEY_FAIL_PARTIAL 0x83
21 #define KEY_FAIL_BUSY 0x84
22 #define KEY_FAIL_VERIFY_REQUIRED 0x85
23
24 #define KEY_FAIL_UNSUCCESSFUL 0xc1
25 #define KEY_FAIL_NOT_IMPLEMENTED 0xc2
26 #define KEY_FAIL_ACCESS_VIOLATION 0xc3
27 #define KEY_FAIL_IN_PAGE_ERROR 0xc4
28 #define KEY_FAIL_EOF 0xc5
29 #define KEY_FAIL_ACCESS_DENIED 0xc6
30 #define KEY_FAIL_MISALIGNED_ERROR 0xc7
31 #define KEY_RESULT_MASK 0xff
32
33 #define KEY_NEXT(key) ( (key) == KEY_FAIL_MISALIGNED_ERROR ? 0xff : \
34 (key) == KEY_FAIL_VERIFY_REQUIRED ? KEY_FAIL_UNSUCCESSFUL : \
35 (key) == KEY_INFO_EXISTS ? KEY_FAIL_MISALIGNED : \
36 (key) == KEY_SUCCESS_WAIT1 ? KEY_INFO_EXISTS : \
37 (key) + 1 )
38 #define KEY_ERROR(key) (((key) & 0xc0) == 0xc0)
39 static
40 NTSTATUS
41 TestGetReturnStatus(
42 _In_ ULONG LockKey)
43 {
44 switch (LockKey & KEY_RESULT_MASK)
45 {
46 case KEY_SUCCEED:
47 return STATUS_SUCCESS;
48 case KEY_SUCCESS_WAIT1:
49 return STATUS_WAIT_1;
50
51 case KEY_INFO_EXISTS:
52 return STATUS_OBJECT_NAME_EXISTS;
53
54 case KEY_FAIL_MISALIGNED:
55 return STATUS_DATATYPE_MISALIGNMENT;
56 case KEY_FAIL_OVERFLOW:
57 return STATUS_BUFFER_OVERFLOW;
58 case KEY_FAIL_PARTIAL:
59 return STATUS_PARTIAL_COPY;
60 case KEY_FAIL_BUSY:
61 return STATUS_DEVICE_BUSY;
62 case KEY_FAIL_VERIFY_REQUIRED:
63 return STATUS_VERIFY_REQUIRED;
64
65 case KEY_FAIL_UNSUCCESSFUL:
66 return STATUS_UNSUCCESSFUL;
67 case KEY_FAIL_NOT_IMPLEMENTED:
68 return STATUS_NOT_IMPLEMENTED;
69 case KEY_FAIL_ACCESS_VIOLATION:
70 return STATUS_ACCESS_VIOLATION;
71 case KEY_FAIL_IN_PAGE_ERROR:
72 return STATUS_IN_PAGE_ERROR;
73 case KEY_FAIL_EOF:
74 return STATUS_END_OF_FILE;
75 case KEY_FAIL_ACCESS_DENIED:
76 return STATUS_ACCESS_DENIED;
77 case KEY_FAIL_MISALIGNED_ERROR:
78 return STATUS_DATATYPE_MISALIGNMENT_ERROR;
79 default:
80 ok(0, "Key = %lx\n", LockKey);
81 return STATUS_INVALID_PARAMETER;
82 }
83 }
84
85 #define KEY_USE_FASTIO 0x100
86 #define KEY_RETURN_PENDING 0x200
87
88 #define KEY_DATA(c) (((c) & 0xff) << 24)
89 #define KEY_GET_DATA(key) ((key) >> 24)
90
91 #endif /* !defined _KMTEST_IOREADFILE_H_ */