Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
c74770c5
Commit
c74770c5
authored
Jan 28, 2020
by
Fabian Maurer
Committed by
Alexandre Julliard
Jan 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
find/tests: Add tests for file based search.
Signed-off-by:
Fabian Maurer
<
dark.shadow4@web.de
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
0ca19c3c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
111 additions
and
9 deletions
+111
-9
find.c
programs/find/tests/find.c
+111
-9
No files found.
programs/find/tests/find.c
View file @
c74770c5
...
...
@@ -180,10 +180,44 @@ static void run_find_stdin_(const WCHAR *commandline, const BYTE *input, int inp
heap_free
(
child_output
);
}
static
void
run_find_file_
(
const
WCHAR
*
commandline
,
const
BYTE
*
input
,
int
input_len
,
const
BYTE
*
out_expected
,
int
out_expected_len
,
int
exitcode_expected
,
const
char
*
file
,
int
line
)
{
char
path_temp_file
[
MAX_PATH
];
char
path_temp_dir
[
MAX_PATH
];
HANDLE
handle_file
;
WCHAR
commandline_new
[
MAX_PATH
];
BYTE
*
out_expected_new
;
char
header
[
MAX_PATH
];
int
header_len
;
GetTempPathA
(
ARRAY_SIZE
(
path_temp_dir
),
path_temp_dir
);
GetTempFileNameA
(
path_temp_dir
,
""
,
0
,
path_temp_file
);
handle_file
=
CreateFileA
(
path_temp_file
,
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
NULL
);
write_to_handle
(
handle_file
,
input
,
input_len
);
CloseHandle
(
handle_file
);
wsprintfW
(
commandline_new
,
L"%s %hs"
,
commandline
,
path_temp_file
);
CharUpperA
(
path_temp_file
);
wsprintfA
(
header
,
"
\r\n
---------- %s
\r\n
"
,
path_temp_file
);
header_len
=
lstrlenA
(
header
);
out_expected_new
=
heap_alloc
(
header_len
+
out_expected_len
);
memcpy
(
out_expected_new
,
header
,
header_len
);
memcpy
(
out_expected_new
+
header_len
,
out_expected
,
out_expected_len
);
run_find_stdin_
(
commandline_new
,
(
BYTE
*
)
""
,
0
,
out_expected_new
,
header_len
+
out_expected_len
,
exitcode_expected
,
file
,
line
);
heap_free
(
out_expected_new
);
DeleteFileA
(
path_temp_file
);
}
#define run_find_stdin_str(commandline, input, out_expected, exitcode_expected) \
run_find_st
din_str_(commandline, input, out_expected, exitcode_expected
, __FILE__, __LINE__)
run_find_st
r_(commandline, input, out_expected, exitcode_expected, 0
, __FILE__, __LINE__)
static
void
run_find_stdin_str_
(
const
char
*
commandline
,
const
char
*
input
,
const
char
*
out_expected
,
int
exitcode_expected
,
const
char
*
file
,
int
line
)
#define run_find_file_str(commandline, input, out_expected, exitcode_expected) \
run_find_str_(commandline, input, out_expected, exitcode_expected, 1, __FILE__, __LINE__)
static
void
run_find_str_
(
const
char
*
commandline
,
const
char
*
input
,
const
char
*
out_expected
,
int
exitcode_expected
,
BOOL
is_file
,
const
char
*
file
,
int
line
)
{
WCHAR
*
commandlineW
;
int
len_commandlineW
;
...
...
@@ -193,15 +227,20 @@ static void run_find_stdin_str_(const char *commandline, const char *input, cons
commandlineW
=
heap_alloc
(
len_commandlineW
*
sizeof
(
WCHAR
));
MultiByteToWideChar
(
CP_UTF8
,
0
,
commandline
,
-
1
,
commandlineW
,
len_commandlineW
);
run_find_stdin_
(
commandlineW
,
(
BYTE
*
)
input
,
lstrlenA
(
input
),
(
BYTE
*
)
out_expected
,
lstrlenA
(
out_expected
),
exitcode_expected
,
file
,
line
);
if
(
is_file
)
run_find_file_
(
commandlineW
,
(
BYTE
*
)
input
,
lstrlenA
(
input
),
(
BYTE
*
)
out_expected
,
lstrlenA
(
out_expected
),
exitcode_expected
,
file
,
line
);
else
run_find_stdin_
(
commandlineW
,
(
BYTE
*
)
input
,
lstrlenA
(
input
),
(
BYTE
*
)
out_expected
,
lstrlenA
(
out_expected
),
exitcode_expected
,
file
,
line
);
heap_free
(
commandlineW
);
}
#define run_find_stdin_unicode(input, out_expected, exitcode_expected) \
run_find_
stdin_unicode_(input, sizeof(input), out_expected, sizeof(out_expected), exitcode_expected,
__FILE__, __LINE__)
run_find_
unicode_(input, sizeof(input), out_expected, sizeof(out_expected), exitcode_expected, 0,
__FILE__, __LINE__)
static
void
run_find_stdin_unicode_
(
const
BYTE
*
input
,
int
input_len
,
const
BYTE
*
out_expected
,
int
out_expected_len
,
int
exitcode_expected
,
const
char
*
file
,
int
line
)
#define run_find_file_unicode(input, out_expected, exitcode_expected) \
run_find_unicode_(input, sizeof(input), out_expected, sizeof(out_expected), exitcode_expected, 1, __FILE__, __LINE__)
static
void
run_find_unicode_
(
const
BYTE
*
input
,
int
input_len
,
const
BYTE
*
out_expected
,
int
out_expected_len
,
int
exitcode_expected
,
BOOL
is_file
,
const
char
*
file
,
int
line
)
{
/* Need "test" as char and quoted wchar */
static
const
WCHAR
wstr_quoted_test
[]
=
{
'"'
,
't'
,
'e'
,
's'
,
't'
,
'"'
,
0
};
...
...
@@ -219,7 +258,10 @@ static void run_find_stdin_unicode_(const BYTE *input, int input_len, const BYTE
exitcode_expected
=
1
;
}
run_find_stdin_
(
wstr_quoted_test
,
input
,
input_len
,
out_expected_mangled
,
out_expected_mangled_len
,
exitcode_expected
,
file
,
line
);
if
(
is_file
)
run_find_file_
(
wstr_quoted_test
,
input
,
input_len
,
out_expected_mangled
,
out_expected_mangled_len
,
exitcode_expected
,
file
,
line
);
else
run_find_stdin_
(
wstr_quoted_test
,
input
,
input_len
,
out_expected_mangled
,
out_expected_mangled_len
,
exitcode_expected
,
file
,
line
);
}
static
void
test_errors
(
void
)
...
...
@@ -230,6 +272,8 @@ static void test_errors(void)
todo_wine
/* Quotes are not properly passed into wine yet */
run_find_stdin_str
(
"
\"
test"
,
""
,
"FIND: Parameter format not correct
\r\n
"
,
2
);
run_find_stdin_str
(
"
\"
test
\"
/XYZ"
,
""
,
"FIND: Invalid switch
\r\n
"
,
2
);
todo_wine
run_find_stdin_str
(
"
\"
test
\"
C:
\\
doesnotexist.dat"
,
""
,
"File not found - C:
\\
DOESNOTEXIST.DAT
\r\n
"
,
1
);
}
static
void
test_singleline_without_switches
(
void
)
...
...
@@ -272,7 +316,7 @@ static const BYTE str_rus_utf8_nobom[] = { 0xD0,0xBF,0xD1,0x
static
const
BYTE
str_en_utf8_bom
[]
=
{
0xEF
,
0xBB
,
0xBF
,
'e'
,
'n'
,
't'
,
'e'
,
's'
,
't'
,
'\r'
,
'\n'
};
static
const
BYTE
str_en_utf8_nobom
[]
=
{
'e'
,
'n'
,
't'
,
'e'
,
's'
,
't'
,
'\r'
,
'\n'
};
static
void
test_unicode_support
(
void
)
static
void
test_unicode_support
_stdin
(
void
)
{
/* Test unicode support on STDIN
* Those depend on the active codepage - e.g. 932 (japanese) behaves different from 1252 (latin)
...
...
@@ -302,6 +346,62 @@ static void test_unicode_support(void)
run_find_stdin_unicode
(
str_jap_utf16le_bom
,
str_jap_utf16le_bom
,
0
);
}
static
void
test_file_search
(
void
)
{
todo_wine
run_find_file_str
(
"
\"\"
"
,
"test"
,
""
,
1
);
todo_wine
run_find_file_str
(
"
\"
test
\"
"
,
""
,
""
,
1
);
todo_wine
run_find_file_str
(
"
\"
test
\"
"
,
"test"
,
"test
\r\n
"
,
0
);
todo_wine
run_find_file_str
(
"
\"
test
\"
"
,
"test2"
,
"test2
\r\n
"
,
0
);
todo_wine
run_find_file_str
(
"
\"
test
\"
"
,
"test
\r
2"
,
"test
\r
2
\r\n
"
,
0
);
todo_wine
run_find_file_str
(
"
\"
test2
\"
"
,
"test"
,
""
,
1
);
todo_wine
run_find_file_str
(
"
\"
test
\"
"
,
"test
\n
other
\n
test2
\n
test3"
,
"test
\r\n
test2
\r\n
test3
\r\n
"
,
0
);
}
static
void
test_unicode_support_file
(
void
)
{
/* Test unicode support on files */
/* Test UTF-8 BOM */
todo_wine
run_find_file_unicode
(
str_en_utf8_nobom
,
str_en_utf8_nobom
,
0
);
todo_wine
run_find_file_unicode
(
str_en_utf8_bom
,
str_en_utf8_bom
,
0
);
/* Test russian characters */
todo_wine
run_find_file_unicode
(
str_rus_utf8_bom
,
str_rus_utf8_bom
,
0
);
todo_wine
run_find_file_unicode
(
str_rus_utf8_nobom
,
str_rus_utf8_nobom
,
0
);
/* Test japanese characters */
todo_wine
run_find_file_unicode
(
str_jap_utf8_nobom
,
str_jap_utf8_nobom
,
0
);
todo_wine
run_find_file_unicode
(
str_jap_utf8_bom
,
str_jap_utf8_bom
,
0
);
todo_wine
run_find_file_unicode
(
str_jap_shiftjis
,
str_jap_shiftjis
,
0
);
/* Test unsupported encodings */
todo_wine
run_find_file_unicode
(
str_jap_utf16le_nobom
,
str_empty
,
1
);
todo_wine
run_find_file_unicode
(
str_jap_utf16be_bom
,
str_empty
,
1
);
todo_wine
run_find_file_unicode
(
str_jap_utf16be_nobom
,
str_empty
,
1
);
/* Test utf16le */
todo_wine
run_find_file_unicode
(
str_jap_utf16le_bom
,
str_jap_utf16le_bom
,
0
);
}
START_TEST
(
find
)
{
if
(
PRIMARYLANGID
(
GetUserDefaultUILanguage
())
!=
LANG_ENGLISH
)
...
...
@@ -314,5 +414,7 @@ START_TEST(find)
}
test_singleline_without_switches
();
test_multiline
();
test_unicode_support
();
test_unicode_support_stdin
();
test_file_search
();
test_unicode_support_file
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment