ReactOS  0.4.15-dev-3451-gf606fec
FindExecutable.cpp File Reference
#include "shelltest.h"
#include <stdio.h>
#include <shlwapi.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 54 of file FindExecutable.cpp.

◆ DIR_1

#define DIR_1   "."

Definition at line 55 of file FindExecutable.cpp.

◆ DIR_2

#define DIR_2   ".."

Definition at line 56 of file FindExecutable.cpp.

◆ DIR_3

#define DIR_3   s_win_dir

Definition at line 57 of file FindExecutable.cpp.

◆ DIR_4

#define DIR_4   "(invalid)"

Definition at line 58 of file FindExecutable.cpp.

Typedef Documentation

◆ TEST_ENTRY

Function Documentation

◆ DoTestEntry()

static void DoTestEntry ( const TEST_ENTRY pEntry)
static

Definition at line 189 of file FindExecutable.cpp.

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

Referenced by START_TEST().

◆ GetSubProgramPath()

static BOOL GetSubProgramPath ( void  )
static

Definition at line 15 of file FindExecutable.cpp.

16 {
19  PathAppendA(s_sub_program, "shell32_apitest_sub.exe");
20 
22  {
24  PathAppendA(s_sub_program, "testdata\\shell32_apitest_sub.exe");
25 
27  {
28  return FALSE;
29  }
30  }
31 
32  return TRUE;
33 }
#define TRUE
Definition: types.h:120
BOOL WINAPI PathAppendA(LPSTR lpszPath, LPCSTR lpszAppend)
Definition: path.c:106
BOOL WINAPI PathFileExistsA(LPCSTR lpszPath)
Definition: path.c:1754
DWORD WINAPI GetModuleFileNameA(HINSTANCE hModule, LPSTR lpFilename, DWORD nSize)
Definition: loader.c:539
BOOL WINAPI PathRemoveFileSpecA(LPSTR lpszPath)
Definition: path.c:586
static char s_sub_program[MAX_PATH]
#define FALSE
Definition: types.h:117
#define _countof(array)
Definition: sndvol32.h:68
#define NULL
Definition: types.h:112

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( FindExecutable  )

Definition at line 203 of file FindExecutable.cpp.

204 {
205  if (!GetSubProgramPath())
206  {
207  skip("shell32_apitest_sub.exe not found\n");
208  return;
209  }
210 
211  char cur_dir[MAX_PATH];
212  GetCurrentDirectoryA(_countof(cur_dir), cur_dir);
213  if (PathIsRootA(cur_dir))
214  {
215  skip("Don't use this program at root directory\n");
216  return;
217  }
218 
220 
222  PathAppendA(s_win_notepad, "notepad.exe");
223 
225  PathAppendA(s_sys_notepad, "notepad.exe");
226 
228  PathAppendA(s_win_test_exe, "test program.exe");
230  if (!ret)
231  {
232  skip("Please retry with admin rights\n");
233  return;
234  }
235 
237  PathAppendA(s_sys_test_exe, "test program.exe");
239 
241  PathAppendA(s_win_bat_file, "test program.bat");
242  fclose(fopen(s_win_bat_file, "wb"));
244 
246  PathAppendA(s_sys_bat_file, "test program.bat");
247  fclose(fopen(s_sys_bat_file, "wb"));
249 
251  PathAppendA(s_win_txt_file, "test file.txt");
252  fclose(fopen(s_win_txt_file, "wb"));
254 
256  PathAppendA(s_sys_txt_file, "test file.txt");
257  fclose(fopen(s_sys_txt_file, "wb"));
259 
260  for (UINT iTest = 0; iTest < _countof(s_entries); ++iTest)
261  {
262  DoTestEntry(&s_entries[iTest]);
263  }
264 
271 }
static char s_sys_bat_file[MAX_PATH]
static char s_win_bat_file[MAX_PATH]
static const TEST_ENTRY s_entries[]
#define TRUE
Definition: types.h:120
BOOL WINAPI PathAppendA(LPSTR lpszPath, LPCSTR lpszAppend)
Definition: path.c:106
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2282
BOOL WINAPI PathFileExistsA(LPCSTR lpszPath)
Definition: path.c:1754
BOOL WINAPI CopyFileA(IN LPCSTR lpExistingFileName, IN LPCSTR lpNewFileName, IN BOOL bFailIfExists)
Definition: copy.c:404
static void DoTestEntry(const TEST_ENTRY *pEntry)
static char s_win_notepad[MAX_PATH]
static char s_sys_txt_file[MAX_PATH]
static char s_sub_program[MAX_PATH]
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static char s_win_txt_file[MAX_PATH]
#define ok_int(expression, result)
Definition: atltest.h:134
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
static BOOL GetSubProgramPath(void)
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
int ret
static char s_win_test_exe[MAX_PATH]
static char s_sys_test_exe[MAX_PATH]
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
BOOL WINAPI PathIsRootA(LPCSTR lpszPath)
Definition: path.c:1601
static char s_sys_notepad[MAX_PATH]
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2145
UINT WINAPI GetWindowsDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2336
unsigned int UINT
Definition: ndis.h:50
#define skip(...)
Definition: atltest.h:64
static char s_win_dir[MAX_PATH]

Variable Documentation

◆ s_entries

const TEST_ENTRY s_entries[]
static

Definition at line 60 of file FindExecutable.cpp.

Referenced by START_TEST().

◆ s_sub_program

char s_sub_program[MAX_PATH]
static

Definition at line 12 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 50 of file FindExecutable.cpp.

Referenced by START_TEST().

◆ s_sys_notepad

char s_sys_notepad[MAX_PATH]
static

Definition at line 46 of file FindExecutable.cpp.

Referenced by START_TEST().

◆ s_sys_test_exe

char s_sys_test_exe[MAX_PATH]
static

Definition at line 48 of file FindExecutable.cpp.

Referenced by START_TEST().

◆ s_sys_txt_file

char s_sys_txt_file[MAX_PATH]
static

Definition at line 52 of file FindExecutable.cpp.

Referenced by START_TEST().

◆ s_win_bat_file

char s_win_bat_file[MAX_PATH]
static

Definition at line 49 of file FindExecutable.cpp.

Referenced by START_TEST().

◆ s_win_dir

char s_win_dir[MAX_PATH]
static

Definition at line 44 of file FindExecutable.cpp.

Referenced by START_TEST().

◆ s_win_notepad

char s_win_notepad[MAX_PATH]
static

Definition at line 45 of file FindExecutable.cpp.

Referenced by START_TEST().

◆ s_win_test_exe

char s_win_test_exe[MAX_PATH]
static

Definition at line 47 of file FindExecutable.cpp.

Referenced by START_TEST().

◆ s_win_txt_file

char s_win_txt_file[MAX_PATH]
static

Definition at line 51 of file FindExecutable.cpp.

Referenced by START_TEST().