Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
6b11eb51
Commit
6b11eb51
authored
Dec 08, 2014
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core::link test: clean up junction point name
parent
80b01c8f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
7 deletions
+50
-7
tests/core/link.c
+50
-7
No files found.
tests/core/link.c
View file @
6b11eb51
...
...
@@ -23,7 +23,7 @@ void test_core_link__cleanup(void)
}
#ifdef GIT_WIN32
static
bool
is_administrator
(
void
)
static
bool
should_run
(
void
)
{
static
SID_IDENTIFIER_AUTHORITY
authority
=
{
SECURITY_NT_AUTHORITY
};
PSID
admin_sid
;
...
...
@@ -35,6 +35,11 @@ static bool is_administrator(void)
return
is_admin
?
true
:
false
;
}
#else
static
bool
should_run
(
void
)
{
return
true
;
}
#endif
static
void
do_symlink
(
const
char
*
old
,
const
char
*
new
,
int
is_dir
)
...
...
@@ -48,9 +53,6 @@ static void do_symlink(const char *old, const char *new, int is_dir)
HMODULE
module
;
create_symlink_func
pCreateSymbolicLink
;
if
(
!
is_administrator
())
clar__skip
();
cl_assert
(
module
=
GetModuleHandle
(
"kernel32"
));
cl_assert
(
pCreateSymbolicLink
=
(
create_symlink_func
)
GetProcAddress
(
module
,
"CreateSymbolicLinkA"
));
...
...
@@ -67,9 +69,6 @@ static void do_hardlink(const char *old, const char *new)
HMODULE
module
;
create_hardlink_func
pCreateHardLink
;
if
(
!
is_administrator
())
clar__skip
();
cl_assert
(
module
=
GetModuleHandle
(
"kernel32"
));
cl_assert
(
pCreateHardLink
=
(
create_hardlink_func
)
GetProcAddress
(
module
,
"CreateHardLinkA"
));
...
...
@@ -147,6 +146,8 @@ static void do_junction(const char *old, const char *new)
CloseHandle
(
handle
);
LocalFree
(
reparse_buf
);
git_buf_free
(
&
unparsed_buf
);
}
static
void
do_custom_reparse
(
const
char
*
path
)
...
...
@@ -235,6 +236,9 @@ void test_core_link__stat_symlink(void)
{
struct
stat
st
;
if
(
!
should_run
())
clar__skip
();
cl_git_rewritefile
(
"stat_target"
,
"This is the target of a symbolic link.
\n
"
);
do_symlink
(
"stat_target"
,
"stat_symlink"
,
0
);
...
...
@@ -251,6 +255,9 @@ void test_core_link__stat_symlink_directory(void)
{
struct
stat
st
;
if
(
!
should_run
())
clar__skip
();
p_mkdir
(
"stat_dirtarget"
,
0777
);
do_symlink
(
"stat_dirtarget"
,
"stat_dirlink"
,
1
);
...
...
@@ -265,6 +272,9 @@ void test_core_link__stat_symlink_chain(void)
{
struct
stat
st
;
if
(
!
should_run
())
clar__skip
();
cl_git_rewritefile
(
"stat_final_target"
,
"Final target of some symbolic links...
\n
"
);
do_symlink
(
"stat_final_target"
,
"stat_chain_3"
,
0
);
do_symlink
(
"stat_chain_3"
,
"stat_chain_2"
,
0
);
...
...
@@ -279,6 +289,9 @@ void test_core_link__stat_dangling_symlink(void)
{
struct
stat
st
;
if
(
!
should_run
())
clar__skip
();
do_symlink
(
"stat_nonexistent"
,
"stat_dangling"
,
0
);
cl_must_fail
(
p_stat
(
"stat_nonexistent"
,
&
st
));
...
...
@@ -289,6 +302,9 @@ void test_core_link__stat_dangling_symlink_directory(void)
{
struct
stat
st
;
if
(
!
should_run
())
clar__skip
();
do_symlink
(
"stat_nonexistent"
,
"stat_dangling_dir"
,
1
);
cl_must_fail
(
p_stat
(
"stat_nonexistent_dir"
,
&
st
));
...
...
@@ -300,6 +316,9 @@ void test_core_link__lstat_symlink(void)
git_buf
target_path
=
GIT_BUF_INIT
;
struct
stat
st
;
if
(
!
should_run
())
clar__skip
();
/* Windows always writes the canonical path as the link target, so
* write the full path on all platforms.
*/
...
...
@@ -324,6 +343,9 @@ void test_core_link__lstat_symlink_directory(void)
git_buf
target_path
=
GIT_BUF_INIT
;
struct
stat
st
;
if
(
!
should_run
())
clar__skip
();
git_buf_join
(
&
target_path
,
'/'
,
clar_sandbox_path
(),
"lstat_dirtarget"
);
p_mkdir
(
"lstat_dirtarget"
,
0777
);
...
...
@@ -343,6 +365,9 @@ void test_core_link__lstat_dangling_symlink(void)
{
struct
stat
st
;
if
(
!
should_run
())
clar__skip
();
do_symlink
(
"lstat_nonexistent"
,
"lstat_dangling"
,
0
);
cl_must_fail
(
p_lstat
(
"lstat_nonexistent"
,
&
st
));
...
...
@@ -356,6 +381,9 @@ void test_core_link__lstat_dangling_symlink_directory(void)
{
struct
stat
st
;
if
(
!
should_run
())
clar__skip
();
do_symlink
(
"lstat_nonexistent"
,
"lstat_dangling_dir"
,
1
);
cl_must_fail
(
p_lstat
(
"lstat_nonexistent"
,
&
st
));
...
...
@@ -454,6 +482,9 @@ void test_core_link__stat_hardlink(void)
{
struct
stat
st
;
if
(
!
should_run
())
clar__skip
();
cl_git_rewritefile
(
"stat_hardlink1"
,
"This file has many names!
\n
"
);
do_hardlink
(
"stat_hardlink1"
,
"stat_hardlink2"
);
...
...
@@ -470,6 +501,9 @@ void test_core_link__lstat_hardlink(void)
{
struct
stat
st
;
if
(
!
should_run
())
clar__skip
();
cl_git_rewritefile
(
"lstat_hardlink1"
,
"This file has many names!
\n
"
);
do_hardlink
(
"lstat_hardlink1"
,
"lstat_hardlink2"
);
...
...
@@ -537,6 +571,9 @@ void test_core_link__readlink_symlink(void)
int
len
;
char
buf
[
2048
];
if
(
!
should_run
())
clar__skip
();
git_buf_join
(
&
target_path
,
'/'
,
clar_sandbox_path
(),
"readlink_target"
);
cl_git_rewritefile
(
"readlink_target"
,
"This is the target of a symlink
\n
"
);
...
...
@@ -558,6 +595,9 @@ void test_core_link__readlink_dangling(void)
int
len
;
char
buf
[
2048
];
if
(
!
should_run
())
clar__skip
();
git_buf_join
(
&
target_path
,
'/'
,
clar_sandbox_path
(),
"readlink_nonexistent"
);
do_symlink
(
git_buf_cstr
(
&
target_path
),
"readlink_dangling"
,
0
);
...
...
@@ -579,6 +619,9 @@ void test_core_link__readlink_multiple(void)
int
len
;
char
buf
[
2048
];
if
(
!
should_run
())
clar__skip
();
git_buf_join
(
&
target_path
,
'/'
,
clar_sandbox_path
(),
"readlink_final"
);
git_buf_join
(
&
path3
,
'/'
,
clar_sandbox_path
(),
"readlink_3"
);
git_buf_join
(
&
path2
,
'/'
,
clar_sandbox_path
(),
"readlink_2"
);
...
...
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