ReactOS 0.4.15-dev-5836-g942b022
FindExecutable.cpp File Reference
#include "shelltest.h"
#include <stdio.h>
#include <shlwapi.h>
#include "shell32_apitest_sub.h"
Include dependency graph for FindExecutable.cpp:

Go to the source code of this file.

Classes

struct  TEST_ENTRY
 

Macros

#define DIR_0   NULL
 
#define DIR_1   "."
 
#define DIR_2   ".."
 
#define DIR_3   s_win_dir
 
#define DIR_4   "(invalid)"
 

Typedefs

typedef struct TEST_ENTRY TEST_ENTRY
 

Functions

static BOOL GetSubProgramPath (void)
 
static void DoTestEntry (const TEST_ENTRY *pEntry)
 
 START_TEST (FindExecutable)
 

Variables

static char s_sub_program [MAX_PATH]
 
static char s_win_dir [MAX_PATH]
 
static char s_win_notepad [MAX_PATH]
 
static char s_sys_notepad [MAX_PATH]
 
static char s_win_test_exe [MAX_PATH]
 
static char s_sys_test_exe [MAX_PATH]
 
static char s_win_bat_file [MAX_PATH]
 
static char s_sys_bat_file [MAX_PATH]
 
static char s_win_txt_file [MAX_PATH]
 
static char s_sys_txt_file [MAX_PATH]
 
static const TEST_ENTRY s_entries []
 

Macro Definition Documentation

◆ DIR_0

#define DIR_0   NULL

Definition at line 55 of file FindExecutable.cpp.

◆ DIR_1

#define DIR_1   "."

Definition at line 56 of file FindExecutable.cpp.

◆ DIR_2

#define DIR_2   ".."

Definition at line 57 of file FindExecutable.cpp.

◆ DIR_3

#define DIR_3   s_win_dir

Definition at line 58 of file FindExecutable.cpp.

◆ DIR_4

#define DIR_4   "(invalid)"

Definition at line 59 of file FindExecutable.cpp.

Typedef Documentation

◆ TEST_ENTRY

Function Documentation

◆ DoTestEntry()

static void DoTestEntry ( const TEST_ENTRY pEntry)
static

Definition at line 190 of file FindExecutable.cpp.

191{
192 char result[MAX_PATH];
193 result[0] = 0;
194 BOOL ret = ((INT_PTR)FindExecutableA(pEntry->file, pEntry->dir, result) > 32);
195 ok(ret == pEntry->ret, "Line %u: ret expected %d, got %d\n", pEntry->lineno, pEntry->ret, ret);
196
198
199 ok(lstrcmpiA(result, pEntry->result) == 0,
200 "Line %u: result expected '%s', got '%s'\n",
201 pEntry->lineno, pEntry->result, result);
202}
#define ok(value,...)
Definition: atltest.h:57
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI GetLongPathNameA(IN LPCSTR lpszShortPath, OUT LPSTR lpszLongPath, IN DWORD cchBuffer)
Definition: path.c:1671
unsigned int BOOL
Definition: ntddk_ex.h:94
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
GLuint64EXT * result
Definition: glext.h:11304
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
HINSTANCE WINAPI FindExecutableA(LPCSTR lpFile, LPCSTR lpDirectory, LPSTR lpResult)
Definition: shlexec.cpp:1214
#define _countof(array)
Definition: sndvol32.h:68
int32_t INT_PTR
Definition: typedefs.h:64
int ret

Referenced by START_TEST().

◆ GetSubProgramPath()

static BOOL GetSubProgramPath ( void  )
static

Definition at line 16 of file FindExecutable.cpp.

17{
20 PathAppendA(s_sub_program, "shell32_apitest_sub.exe");
21
23 {
25 PathAppendA(s_sub_program, "testdata\\shell32_apitest_sub.exe");
26
28 {
29 return FALSE;
30 }
31 }
32
33 return TRUE;
34}
static char s_sub_program[MAX_PATH]
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
DWORD WINAPI GetModuleFileNameA(HINSTANCE hModule, LPSTR lpFilename, DWORD nSize)
Definition: loader.c:539
BOOL WINAPI PathRemoveFileSpecA(LPSTR lpszPath)
Definition: path.c:586
BOOL WINAPI PathFileExistsA(LPCSTR lpszPath)
Definition: path.c:1755
BOOL WINAPI PathAppendA(LPSTR lpszPath, LPCSTR lpszAppend)
Definition: path.c:106

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( FindExecutable  )

Definition at line 204 of file FindExecutable.cpp.

205{
206 if (!GetSubProgramPath())
207 {
208 skip("shell32_apitest_sub.exe not found\n");
209 return;
210 }
211
212 char cur_dir[MAX_PATH];
213 GetCurrentDirectoryA(_countof(cur_dir), cur_dir);
214 if (PathIsRootA(cur_dir))
215 {
216 skip("Don't use this program at root directory\n");
217 return;
218 }
219
221
223 PathAppendA(s_win_notepad, "notepad.exe");
224
226 PathAppendA(s_sys_notepad, "notepad.exe");
227
229 PathAppendA(s_win_test_exe, "test program.exe");
231 if (!ret)
232 {
233 skip("Please retry with admin rights\n");
234 return;
235 }
236
238 PathAppendA(s_sys_test_exe, "test program.exe");
240
242 PathAppendA(s_win_bat_file, "test program.bat");
245
247 PathAppendA(s_sys_bat_file, "test program.bat");
250
252 PathAppendA(s_win_txt_file, "test file.txt");
255
257 PathAppendA(s_sys_txt_file, "test file.txt");
260
261 for (UINT iTest = 0; iTest < _countof(s_entries); ++iTest)
262 {
263 DoTestEntry(&s_entries[iTest]);
264 }
265
272
274}
static char s_win_dir[MAX_PATH]
static char s_win_txt_file[MAX_PATH]
static char s_win_bat_file[MAX_PATH]
static void DoTestEntry(const TEST_ENTRY *pEntry)
static const TEST_ENTRY s_entries[]
static char s_win_test_exe[MAX_PATH]
static char s_sys_bat_file[MAX_PATH]
static char s_sys_txt_file[MAX_PATH]
static char s_win_notepad[MAX_PATH]
static char s_sys_test_exe[MAX_PATH]
static char s_sys_notepad[MAX_PATH]
static BOOL GetSubProgramPath(void)
#define skip(...)
Definition: atltest.h:64
#define ok_int(expression, result)
Definition: atltest.h:134
BOOL WINAPI CopyFileA(IN LPCSTR lpExistingFileName, IN LPCSTR lpNewFileName, IN BOOL bFailIfExists)
Definition: copy.c:404
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2146
UINT WINAPI GetWindowsDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2337
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2283
BOOL WINAPI PathIsRootA(LPCSTR lpszPath)
Definition: path.c:1602
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
unsigned int UINT
Definition: ndis.h:50
static HWND DoWaitForWindow(LPCWSTR clsname, LPCWSTR text, BOOL bClosing, BOOL bForce)
#define CLASSNAME

Variable Documentation

◆ s_entries

const TEST_ENTRY s_entries[]
static

Definition at line 61 of file FindExecutable.cpp.

Referenced by START_TEST().

◆ s_sub_program

char s_sub_program[MAX_PATH]
static

Definition at line 13 of file FindExecutable.cpp.

Referenced by GetSubProgramPath(), and START_TEST().

◆ s_sys_bat_file

char s_sys_bat_file[MAX_PATH]
static

Definition at line 51 of file FindExecutable.cpp.

Referenced by START_TEST().

◆ s_sys_notepad

char s_sys_notepad[MAX_PATH]
static

Definition at line 47 of file FindExecutable.cpp.

Referenced by START_TEST().

◆ s_sys_test_exe

char s_sys_test_exe[MAX_PATH]
static

Definition at line 49 of file FindExecutable.cpp.

Referenced by START_TEST().

◆ s_sys_txt_file

char s_sys_txt_file[MAX_PATH]
static

Definition at line 53 of file FindExecutable.cpp.

Referenced by START_TEST().

◆ s_win_bat_file

char s_win_bat_file[MAX_PATH]
static

Definition at line 50 of file FindExecutable.cpp.

Referenced by START_TEST().

◆ s_win_dir

char s_win_dir[MAX_PATH]
static

Definition at line 45 of file FindExecutable.cpp.

Referenced by START_TEST().

◆ s_win_notepad

char s_win_notepad[MAX_PATH]
static

Definition at line 46 of file FindExecutable.cpp.

Referenced by START_TEST().

◆ s_win_test_exe

char s_win_test_exe[MAX_PATH]
static

Definition at line 48 of file FindExecutable.cpp.

Referenced by START_TEST().

◆ s_win_txt_file

char s_win_txt_file[MAX_PATH]
static

Definition at line 52 of file FindExecutable.cpp.

Referenced by START_TEST().