ReactOS 0.4.15-dev-8241-g63935f8
DelNode.c File Reference
#include <apitest.h>
#include <windef.h>
#include <stdio.h>
Include dependency graph for DelNode.c:

Go to the source code of this file.

Classes

struct  NODEA
 
struct  NODEW
 
struct  ENTRY
 

Macros

#define ADN_DEL_IF_EMPTY   0x00000001
 
#define ADN_DONT_DEL_SUBDIRS   0x00000002
 
#define ADN_DONT_DEL_DIR   0x00000004
 
#define ADN_DEL_UNC_PATHS   0x00000008
 
#define FLAGS0   0
 
#define FLAGS1   ADN_DEL_IF_EMPTY
 
#define FLAGS2   ADN_DONT_DEL_DIR
 
#define FLAGS3   ADN_DONT_DEL_SUBDIRS
 
#define FLAGS4   (ADN_DONT_DEL_DIR | ADN_DONT_DEL_SUBDIRS)
 
#define FLAGS5   (ADN_DEL_IF_EMPTY | ADN_DONT_DEL_DIR)
 
#define FLAGS6   (ADN_DEL_IF_EMPTY | ADN_DONT_DEL_SUBDIRS)
 
#define FLAGS7   (ADN_DEL_IF_EMPTY | ADN_DONT_DEL_DIR | ADN_DONT_DEL_SUBDIRS)
 
#define FLAGS8   0xFFFFFFFF
 

Typedefs

typedef HRESULT(WINAPIDELNODEA) (LPCSTR, DWORD)
 
typedef HRESULT(WINAPIDELNODEW) (LPCWSTR, DWORD)
 

Enumerations

enum  ENTRY_ACTION_TYPE {
  EAT_CREATE , EAT_DELETE , EAT_CHECK_EXIST , EAT_CHECK_NON_EXIST ,
  EAT_CALL
}
 

Functions

static charGetPathA (const char *item)
 
static WCHARGetPathW (const WCHAR *item)
 
static void cleanupA (void)
 
static void Test_DelNodeA (void)
 
static void cleanupW (void)
 
static void Test_DelNodeW (void)
 
 START_TEST (DelNode)
 

Variables

static HINSTANCE s_hAdvPack = NULL
 
static DELNODEA s_pDelNodeA = NULL
 
static DELNODEW s_pDelNodeW = NULL
 
static const NODEA s_nodesA []
 
static const NODEW s_nodesW []
 
static const ENTRY s_entries []
 
static char s_cur_dir_A [MAX_PATH] = ""
 
static WCHAR s_cur_dir_W [MAX_PATH] = L""
 

Macro Definition Documentation

◆ ADN_DEL_IF_EMPTY

#define ADN_DEL_IF_EMPTY   0x00000001

Definition at line 13 of file DelNode.c.

◆ ADN_DEL_UNC_PATHS

#define ADN_DEL_UNC_PATHS   0x00000008

Definition at line 16 of file DelNode.c.

◆ ADN_DONT_DEL_DIR

#define ADN_DONT_DEL_DIR   0x00000004

Definition at line 15 of file DelNode.c.

◆ ADN_DONT_DEL_SUBDIRS

#define ADN_DONT_DEL_SUBDIRS   0x00000002

Definition at line 14 of file DelNode.c.

◆ FLAGS0

#define FLAGS0   0

Definition at line 71 of file DelNode.c.

◆ FLAGS1

#define FLAGS1   ADN_DEL_IF_EMPTY

Definition at line 72 of file DelNode.c.

◆ FLAGS2

#define FLAGS2   ADN_DONT_DEL_DIR

Definition at line 73 of file DelNode.c.

◆ FLAGS3

Definition at line 74 of file DelNode.c.

◆ FLAGS4

Definition at line 75 of file DelNode.c.

◆ FLAGS5

Definition at line 76 of file DelNode.c.

◆ FLAGS6

Definition at line 77 of file DelNode.c.

◆ FLAGS7

Definition at line 78 of file DelNode.c.

◆ FLAGS8

#define FLAGS8   0xFFFFFFFF

Definition at line 79 of file DelNode.c.

Typedef Documentation

◆ DELNODEA

typedef HRESULT(WINAPI * DELNODEA) (LPCSTR, DWORD)

Definition at line 19 of file DelNode.c.

◆ DELNODEW

typedef HRESULT(WINAPI * DELNODEW) (LPCWSTR, DWORD)

Definition at line 20 of file DelNode.c.

Enumeration Type Documentation

◆ ENTRY_ACTION_TYPE

Enumerator
EAT_CREATE 
EAT_DELETE 
EAT_CHECK_EXIST 
EAT_CHECK_NON_EXIST 
EAT_CALL 

Definition at line 52 of file DelNode.c.

53{
ENTRY_ACTION_TYPE
Definition: DelNode.c:53
@ EAT_CALL
Definition: DelNode.c:58
@ EAT_CREATE
Definition: DelNode.c:54
@ EAT_CHECK_EXIST
Definition: DelNode.c:56
@ EAT_DELETE
Definition: DelNode.c:55
@ EAT_CHECK_NON_EXIST
Definition: DelNode.c:57

Function Documentation

◆ cleanupA()

static void cleanupA ( void  )
static

Definition at line 378 of file DelNode.c.

379{
380 size_t i, k;
381 for (k = 0; k < 4; ++k)
382 {
383 for (i = 0; i < _countof(s_nodesA); ++i)
384 {
385 const NODEA *node = &s_nodesA[i];
386 char *path = GetPathA(node->item);
387
390 }
391 }
392}
static const NODEA s_nodesA[]
Definition: DelNode.c:32
static char * GetPathA(const char *item)
Definition: DelNode.c:360
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:714
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
int k
Definition: mpi.c:3369
#define _countof(array)
Definition: sndvol32.h:70
Definition: DelNode.c:27
Definition: dlist.c:348

Referenced by Test_DelNodeA().

◆ cleanupW()

static void cleanupW ( void  )
static

Definition at line 466 of file DelNode.c.

467{
468 size_t i, k;
469 for (k = 0; k < 4; ++k)
470 {
471 for (i = 0; i < _countof(s_nodesW); ++i)
472 {
473 const NODEW *node = &s_nodesW[i];
474 WCHAR *path = GetPathW(node->item);
475
478 }
479 }
480}
static const NODEW s_nodesW[]
Definition: DelNode.c:45
static WCHAR * GetPathW(const WCHAR *item)
Definition: DelNode.c:369
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
Definition: dir.c:732
Definition: DelNode.c:40
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by Test_DelNodeW().

◆ GetPathA()

static char * GetPathA ( const char item)
static

Definition at line 360 of file DelNode.c.

361{
362 static char s_path[MAX_PATH];
363 lstrcpyA(s_path, s_cur_dir_A);
364 lstrcatA(s_path, "\\");
365 lstrcatA(s_path, item);
366 return s_path;
367}
static char s_cur_dir_A[MAX_PATH]
Definition: DelNode.c:357
#define MAX_PATH
Definition: compat.h:34
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
static ATOM item
Definition: dde.c:856

Referenced by cleanupA(), and Test_DelNodeA().

◆ GetPathW()

static WCHAR * GetPathW ( const WCHAR item)
static

Definition at line 369 of file DelNode.c.

370{
371 static WCHAR s_path[MAX_PATH];
372 lstrcpyW(s_path, s_cur_dir_W);
373 lstrcatW(s_path, L"\\");
374 lstrcatW(s_path, item);
375 return s_path;
376}
static WCHAR s_cur_dir_W[MAX_PATH]
Definition: DelNode.c:358
#define lstrcpyW
Definition: compat.h:749
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define L(x)
Definition: ntvdm.h:50

Referenced by cleanupW(), and Test_DelNodeW().

◆ START_TEST()

START_TEST ( DelNode  )

Definition at line 554 of file DelNode.c.

555{
556 s_hAdvPack = LoadLibraryA("advpack.dll");
557 if (s_hAdvPack == NULL)
558 {
559 skip("unable to load advpack.dll\n");
560 return;
561 }
562
563 /* DelNodeA */
565 if (s_pDelNodeA)
566 {
568 }
569 else
570 {
571 skip("DelNodeA not found in advpack.dll\n");
572 }
573
574 /* DelNodeW */
576 if (s_pDelNodeW)
577 {
579 }
580 else
581 {
582 skip("DelNodeW not found in advpack.dll\n");
583 }
584
587}
static DELNODEW s_pDelNodeW
Definition: DelNode.c:24
static HINSTANCE s_hAdvPack
Definition: DelNode.c:22
static void Test_DelNodeW(void)
Definition: DelNode.c:482
HRESULT(WINAPI * DELNODEW)(LPCWSTR, DWORD)
Definition: DelNode.c:20
static DELNODEA s_pDelNodeA
Definition: DelNode.c:23
HRESULT(WINAPI * DELNODEA)(LPCSTR, DWORD)
Definition: DelNode.c:19
static void Test_DelNodeA(void)
Definition: DelNode.c:394
#define skip(...)
Definition: atltest.h:64
#define NULL
Definition: types.h:112
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111

◆ Test_DelNodeA()

static void Test_DelNodeA ( void  )
static

Definition at line 394 of file DelNode.c.

395{
396 DWORD attr;
397 size_t i;
398
400 {
401 skip("GetCurrentDirectoryA failed\n");
402 return;
403 }
404
405 cleanupA();
406
407 for (i = 0; i < _countof(s_entries); ++i)
408 {
409 const ENTRY *entry = &s_entries[i];
410 INT lineno = entry->lineno;
411 const NODEA *node = &s_nodesA[entry->node];
412 char *path = GetPathA(node->item);
413 INT ret;
414
415 switch (entry->action_type)
416 {
417 case EAT_CREATE:
418 if (node->is_dir)
419 {
421
423 ok(attr != INVALID_FILE_ATTRIBUTES, "Line %d: path:%s, attr:0x%08lX\n", lineno, path, attr);
424 ok((attr & FILE_ATTRIBUTE_DIRECTORY), "Line %d: path:%s, attr:0x%08lX\n", lineno, path, attr);
425 }
426 else
427 {
428 fclose(fopen(path, "w"));
429
431 ok(attr != INVALID_FILE_ATTRIBUTES, "Line %d: attr was 0x%08lX\n", lineno, attr);
432 ok(!(attr & FILE_ATTRIBUTE_DIRECTORY), "Line %d: attr was 0x%08lX\n", lineno, attr);
433 }
434 break;
435 case EAT_DELETE:
436 if (node->is_dir)
437 {
439 }
440 else
441 {
443 }
445 ok(attr == INVALID_FILE_ATTRIBUTES, "Line %d: cannot delete\n", lineno);
446 break;
447 case EAT_CHECK_EXIST:
449 ok(attr != INVALID_FILE_ATTRIBUTES, "Line %d: attr was 0x%08lX\n", lineno, attr);
450 break;
453 ok(attr == INVALID_FILE_ATTRIBUTES, "Line %d: attr was 0x%08lX\n", lineno, attr);
454 break;
455 case EAT_CALL:
456 ret = (*s_pDelNodeA)(path, entry->flags);
457 ok(ret == entry->ret, "Line %d: ret:%d, path:%s, flags:0x%08lX\n",
458 lineno, ret, path, entry->flags);
459 break;
460 }
461 }
462
463 cleanupA();
464}
static const ENTRY s_entries[]
Definition: DelNode.c:82
static void cleanupA(void)
Definition: DelNode.c:378
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
Definition: fileinfo.c:636
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2146
unsigned long DWORD
Definition: ntddk_ex.h:95
_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)
uint32_t entry
Definition: isohybrid.c:63
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
Definition: DelNode.c:62
Definition: cookie.c:202
int32_t INT
Definition: typedefs.h:58
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
int ret

Referenced by START_TEST().

◆ Test_DelNodeW()

static void Test_DelNodeW ( void  )
static

Definition at line 482 of file DelNode.c.

483{
484 DWORD attr;
485 size_t i;
486
488 {
489 skip("GetCurrentDirectoryA failed\n");
490 return;
491 }
492
493 cleanupW();
494
495 for (i = 0; i < _countof(s_entries); ++i)
496 {
497 const ENTRY *entry = &s_entries[i];
498 INT lineno = entry->lineno;
499 const NODEW *node = &s_nodesW[entry->node];
500 WCHAR *path = GetPathW(node->item);
501 INT ret;
502
503 switch (entry->action_type)
504 {
505 case EAT_CREATE:
506 if (node->is_dir)
507 {
509
511 ok(attr != INVALID_FILE_ATTRIBUTES, "Line %d: path:%S, attr:0x%08lX\n", lineno, path, attr);
512 ok((attr & FILE_ATTRIBUTE_DIRECTORY), "Line %d: path:%S, attr:0x%08lX\n", lineno, path, attr);
513 }
514 else
515 {
516 fclose(_wfopen(path, L"w"));
517
519 ok(attr != INVALID_FILE_ATTRIBUTES, "Line %d: attr was 0x%08lX\n", lineno, attr);
520 ok(!(attr & FILE_ATTRIBUTE_DIRECTORY), "Line %d: attr was 0x%08lX\n", lineno, attr);
521 }
522 break;
523 case EAT_DELETE:
524 if (node->is_dir)
525 {
527 }
528 else
529 {
531 }
533 ok(attr == INVALID_FILE_ATTRIBUTES, "Line %d: cannot delete\n", lineno);
534 break;
535 case EAT_CHECK_EXIST:
537 ok(attr != INVALID_FILE_ATTRIBUTES, "Line %d: attr was 0x%08lX\n", lineno, attr);
538 break;
541 ok(attr == INVALID_FILE_ATTRIBUTES, "Line %d: attr was 0x%08lX\n", lineno, attr);
542 break;
543 case EAT_CALL:
544 ret = (*s_pDelNodeW)(path, entry->flags);
545 ok(ret == entry->ret, "Line %d: ret:%d, path:%S, flags:0x%08lX\n",
546 lineno, ret, path, entry->flags);
547 break;
548 }
549 }
550
551 cleanupW();
552}
static void cleanupW(void)
Definition: DelNode.c:466
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:756
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
_Check_return_ _CRTIMP FILE *__cdecl _wfopen(_In_z_ const wchar_t *_Filename, _In_z_ const wchar_t *_Mode)

Referenced by START_TEST().

Variable Documentation

◆ s_cur_dir_A

char s_cur_dir_A[MAX_PATH] = ""
static

Definition at line 357 of file DelNode.c.

Referenced by GetPathA(), and Test_DelNodeA().

◆ s_cur_dir_W

WCHAR s_cur_dir_W[MAX_PATH] = L""
static

Definition at line 358 of file DelNode.c.

Referenced by GetPathW(), and Test_DelNodeW().

◆ s_entries

const ENTRY s_entries[]
static

Definition at line 82 of file DelNode.c.

Referenced by Test_DelNodeA(), and Test_DelNodeW().

◆ s_hAdvPack

HINSTANCE s_hAdvPack = NULL
static

Definition at line 22 of file DelNode.c.

Referenced by START_TEST().

◆ s_nodesA

const NODEA s_nodesA[]
static
Initial value:
=
{
{ "dir1", TRUE },
{ "dir1\\dir2", TRUE },
{ "dir1\\dir2\\file1", FALSE },
}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117

Definition at line 32 of file DelNode.c.

Referenced by cleanupA(), and Test_DelNodeA().

◆ s_nodesW

const NODEW s_nodesW[]
static
Initial value:
=
{
{ L"dir1", TRUE },
{ L"dir1\\dir2", TRUE },
{ L"dir1\\dir2\\file1", FALSE },
}

Definition at line 45 of file DelNode.c.

Referenced by cleanupW(), and Test_DelNodeW().

◆ s_pDelNodeA

DELNODEA s_pDelNodeA = NULL
static

Definition at line 23 of file DelNode.c.

Referenced by START_TEST().

◆ s_pDelNodeW

DELNODEW s_pDelNodeW = NULL
static

Definition at line 24 of file DelNode.c.

Referenced by START_TEST().