[SETUPLIB][USETUP] Make the GENERIC_LIST store the items display text in UNICODE...
[reactos.git] / base / setup / lib / utils / arcname_tests.c
1 /*
2 * PROJECT: ReactOS Setup Library
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Tests for the arcname.c functions:
5 * ArcPathNormalize(), ArcPathToNtPath().
6 * COPYRIGHT: Copyright 2017-2018 Hermes Belusca-Maito
7 *
8 * You may need to fix the included headers before being able to
9 * compile this file (this file has only been compiled under VS).
10 */
11
12 #include <stdio.h>
13 #include <tchar.h>
14 #include <conio.h>
15
16 #define WIN32_NO_STATUS
17 #include <windows.h>
18 #include <winternl.h>
19 #undef WIN32_NO_STATUS
20
21 #include <ntstatus.h>
22
23 #include <strsafe.h>
24
25 #include "arcname.h"
26
27 #define OBJ_NAME_PATH_SEPARATOR ((WCHAR)L'\\')
28
29 int _tmain(int argc, _TCHAR* argv[])
30 {
31 WCHAR ArcPath[MAX_PATH] = L"multi(5)disk()rdisk(1)partition()\\ReactOS";
32 WCHAR NormalizedArcPathBuffer[MAX_PATH];
33 UNICODE_STRING NormalizedArcPath;
34 WCHAR NtPathBuffer[MAX_PATH];
35 UNICODE_STRING NtPath;
36
37 NormalizedArcPath.Buffer = NormalizedArcPathBuffer;
38 NormalizedArcPath.Length = 0;
39 NormalizedArcPath.MaximumLength = sizeof(NormalizedArcPathBuffer);
40
41 ArcPathNormalize(&NormalizedArcPath, ArcPath);
42 wprintf(L"ArcPath = '%s' ; Normalized = '%wZ'\n", ArcPath, &NormalizedArcPath);
43
44 NtPath.Buffer = NtPathBuffer;
45 NtPath.Length = 0;
46 NtPath.MaximumLength = sizeof(NtPathBuffer);
47
48 ArcPathToNtPath(&NtPath, NormalizedArcPath.Buffer);
49 // wprintf(L"ArcPath = '%s' ; NtPath = '%wZ'\n", ArcPath, &NtPath);
50 wprintf(L"NtPath = '%wZ'\n", &NtPath);
51 ArcPathToNtPath(&NtPath, L"ramdisk(0)"); // OK
52 wprintf(L"NtPath = '%wZ'\n", &NtPath);
53 ArcPathToNtPath(&NtPath, L"ramdisk(0)\\ReactOS\\system32\\ntoskrnl.exe"); // OK
54 wprintf(L"NtPath = '%wZ'\n", &NtPath);
55 ArcPathToNtPath(&NtPath, L"net(0)\\Foobar"); // OK but not supported
56 wprintf(L"NtPath = '%wZ'\n", &NtPath);
57 ArcPathToNtPath(&NtPath, L"net(0)disk(1)\\Foobar"); // Bad
58 wprintf(L"NtPath = '%wZ'\n", &NtPath);
59 ArcPathToNtPath(&NtPath, L"scsi(2)disk(1)rdisk(3)"); // OK
60 wprintf(L"NtPath = '%wZ'\n", &NtPath);
61 ArcPathToNtPath(&NtPath, L"scsi(2)disk(1)fdisk(3)"); // OK
62 wprintf(L"NtPath = '%wZ'\n", &NtPath);
63 ArcPathToNtPath(&NtPath, L"scsi(2)cdrom(1)"); // Bad: missing fdisk
64 wprintf(L"NtPath = '%wZ'\n", &NtPath);
65 ArcPathToNtPath(&NtPath, L"scsi(2)cdrom(1)cdrom(0)"); // Bad: twice cdrom
66 wprintf(L"NtPath = '%wZ'\n", &NtPath);
67 ArcPathToNtPath(&NtPath, L"scsi(2)cdrom(1)fdisk(0)"); // OK
68 wprintf(L"NtPath = '%wZ'\n", &NtPath);
69 ArcPathToNtPath(&NtPath, L"scsi(2)cdrom(1)rdisk(0)"); // Bad; cdrom controller and rdisk peripheral
70 wprintf(L"NtPath = '%wZ'\n", &NtPath);
71 ArcPathToNtPath(&NtPath, L"multi(2)cdrom(1)fdisk(0)"); // Bad: multi adapter cannot have cdrom controller
72 wprintf(L"NtPath = '%wZ'\n", &NtPath);
73 ArcPathToNtPath(&NtPath, L"multi(2)rdisk(1)cdrom(1)fdisk(0)"); // Bad: rdisk is not a controller
74 wprintf(L"NtPath = '%wZ'\n", &NtPath);
75 ArcPathToNtPath(&NtPath, L"multi(2)disk(1)cdrom(1)fdisk(0)"); // OK (disk(1) ignored)
76 wprintf(L"NtPath = '%wZ'\n", &NtPath);
77 ArcPathToNtPath(&NtPath, L"multi(2)disk(1)rdisk(1)fdisk(0)"); // Same (and also fdisk is not considered as part of ARC path)
78 wprintf(L"NtPath = '%wZ'\n", &NtPath);
79 ArcPathToNtPath(&NtPath, L"multi(2)disk(1)rdisk(1)partition(3)"); // OK (disk(1) ignored)
80 wprintf(L"NtPath = '%wZ'\n", &NtPath);
81
82 _getch();
83
84 /* All these are OK */
85 ArcPathToNtPath(&NtPath, L"scsi(0)disk(3)rdisk(0)partition(1)\\OS.DIR");
86 wprintf(L"NtPath = '%wZ'\n", &NtPath);
87 ArcPathToNtPath(&NtPath, L"scsi(1)disk(3)rdisk(3)partition(2)\\OS\\ARCOS\\LOADER");
88 wprintf(L"NtPath = '%wZ'\n", &NtPath);
89
90 _getch();
91
92 /* All these are OK */
93 ArcPathToNtPath(&NtPath, L"multi(0)disk(0)rdisk(0)partition(1)");
94 wprintf(L"NtPath = '%wZ'\n", &NtPath);
95 ArcPathToNtPath(&NtPath, L"multi(0)disk(0)rdisk(0)partition(0)");
96 wprintf(L"NtPath = '%wZ'\n", &NtPath);
97 ArcPathToNtPath(&NtPath, L"multi(0)disk(0)cdrom(3)");
98 wprintf(L"NtPath = '%wZ'\n", &NtPath);
99 ArcPathToNtPath(&NtPath, L"ramdisk(0)");
100 wprintf(L"NtPath = '%wZ'\n", &NtPath);
101 ArcPathToNtPath(&NtPath, L"net(0)");
102 wprintf(L"NtPath = '%wZ'\n", &NtPath);
103 ArcPathToNtPath(&NtPath, L"multi(0)disk(0)fdisk(0)");
104 wprintf(L"NtPath = '%wZ'\n", &NtPath);
105 ArcPathToNtPath(&NtPath, L"multi(0)disk(0)rdisk(1)partition(0)");
106 wprintf(L"NtPath = '%wZ'\n", &NtPath);
107 ArcPathToNtPath(&NtPath, L"multi(0)disk(0)rdisk(1)partition(3)");
108 wprintf(L"NtPath = '%wZ'\n", &NtPath);
109 ArcPathToNtPath(&NtPath, L"multi(0)disk(0)rdisk(1)partition(1)");
110 wprintf(L"NtPath = '%wZ'\n", &NtPath);
111 ArcPathToNtPath(&NtPath, L"multi(0)disk(0)rdisk(0)partition(3)");
112 wprintf(L"NtPath = '%wZ'\n", &NtPath);
113 ArcPathToNtPath(&NtPath, L"multi(0)disk(0)fdisk(1)partition(0)");
114 wprintf(L"NtPath = '%wZ'\n", &NtPath);
115 ArcPathToNtPath(&NtPath, L"multi(0)disk(0)fdisk(0)partition(0)");
116 wprintf(L"NtPath = '%wZ'\n", &NtPath);
117 ArcPathToNtPath(&NtPath, L"multi(0)disk(0)fdisk(1)");
118 wprintf(L"NtPath = '%wZ'\n", &NtPath);
119 ArcPathToNtPath(&NtPath, L"eisa(0)disk(0)fdisk(0)");
120 wprintf(L"NtPath = '%wZ'\n", &NtPath);
121 ArcPathToNtPath(&NtPath, L"eisa(0)disk(0)fdisk(1)partition(0)");
122 wprintf(L"NtPath = '%wZ'\n", &NtPath);
123 ArcPathToNtPath(&NtPath, L"eisa(0)disk(0)fdisk(0)partition(0)");
124 wprintf(L"NtPath = '%wZ'\n", &NtPath);
125
126 /* These are invalid storage ARC paths (but otherwise are valid ARC names) */
127 ArcPathToNtPath(&NtPath, L"multi(0)video(0)monitor(0)");
128 wprintf(L"NtPath = '%wZ'\n", &NtPath);
129 ArcPathToNtPath(&NtPath, L"multi(0)key(0)keyboard(0)");
130 wprintf(L"NtPath = '%wZ'\n", &NtPath);
131
132 _getch();
133 return 0;
134 }