2 * Unit tests for advpack.dll
4 * Copyright (C) 2005 Robert Reif
5 * Copyright (C) 2005 Sami Aario
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "wine/test.h"
27 static HRESULT (WINAPI *pGetVersionFromFile)(LPSTR,LPDWORD,LPDWORD,BOOL);
28 static HRESULT (WINAPI *pDelNode)(LPCSTR,DWORD);
30 static void version_test(void)
36 hr = pGetVersionFromFile("kernel32.dll", &major, &minor, FALSE);
37 ok (hr == S_OK, "GetVersionFromFileEx(kernel32.dll) failed, returned "
40 trace("kernel32.dll Language ID: 0x%08lx, Codepage ID: 0x%08lx\n",
44 hr = pGetVersionFromFile("kernel32.dll", &major, &minor, TRUE);
45 ok (hr == S_OK, "GetVersionFromFileEx(kernel32.dll) failed, returned "
48 trace("kernel32.dll version: %d.%d.%d.%d\n", HIWORD(major), LOWORD(major),
49 HIWORD(minor), LOWORD(minor));
52 static void delnode_test(void)
56 CHAR currDir[MAX_PATH];
59 /* Native DelNode apparently does not support relative paths, so we use
60 absolute paths for testing */
61 currDirLen = GetCurrentDirectoryA(sizeof(currDir) / sizeof(CHAR), currDir);
62 assert(currDirLen > 0 && currDirLen < sizeof(currDir) / sizeof(CHAR));
64 if(currDir[currDirLen - 1] == '\\')
65 currDir[--currDirLen] = 0;
67 /* Simple tests; these should fail. */
68 hr = pDelNode(NULL, 0);
69 ok (hr == E_FAIL, "DelNode called with NULL pathname should return E_FAIL\n");
71 ok (hr == E_FAIL, "DelNode called with empty pathname should return E_FAIL\n");
73 /* Test deletion of a file. */
74 hn = CreateFile("DelNodeTestFile1", GENERIC_WRITE, 0, NULL,
75 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
76 assert(hn != INVALID_HANDLE_VALUE);
78 hr = pDelNode(lstrcat(currDir, "\\DelNodeTestFile1"), 0);
79 ok (hr == S_OK, "DelNode failed deleting a single file\n");
80 currDir[currDirLen] = '\0';
82 /* Test deletion of an empty directory. */
83 CreateDirectoryA("DelNodeTestDir", NULL);
84 hr = pDelNode(lstrcat(currDir, "\\DelNodeTestDir"), 0);
85 ok (hr == S_OK, "DelNode failed deleting an empty directory\n");
86 currDir[currDirLen] = '\0';
88 /* Test deletion of a directory containing one file. */
89 CreateDirectoryA("DelNodeTestDir", NULL);
90 hn = CreateFile("DelNodeTestDir\\DelNodeTestFile1", GENERIC_WRITE, 0, NULL,
91 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
92 assert(hn != INVALID_HANDLE_VALUE);
94 hr = pDelNode(lstrcat(currDir, "\\DelNodeTestDir"), 0);
95 ok (hr == S_OK, "DelNode failed deleting a directory containing one file\n");
96 currDir[currDirLen] = '\0';
98 /* Test deletion of a directory containing multiple files. */
99 CreateDirectoryA("DelNodeTestDir", NULL);
100 hn = CreateFile("DelNodeTestDir\\DelNodeTestFile1", GENERIC_WRITE, 0, NULL,
101 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
102 assert(hn != INVALID_HANDLE_VALUE);
104 hn = CreateFile("DelNodeTestDir\\DelNodeTestFile2", GENERIC_WRITE, 0, NULL,
105 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
106 assert(hn != INVALID_HANDLE_VALUE);
108 hn = CreateFile("DelNodeTestDir\\DelNodeTestFile3", GENERIC_WRITE, 0, NULL,
109 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
110 assert(hn != INVALID_HANDLE_VALUE);
112 hr = pDelNode(lstrcat(currDir, "\\DelNodeTestDir"), 0);
113 ok (hr == S_OK, "DelNode failed deleting a directory containing multiple files\n");
114 currDir[currDirLen] = '\0';
121 hdll = LoadLibraryA("advpack.dll");
125 pGetVersionFromFile = (void*)GetProcAddress(hdll, "GetVersionFromFile");
126 pDelNode = (void*)GetProcAddress(hdll, "DelNode");
127 if (!pGetVersionFromFile || !pDelNode)