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
f4183347
Commit
f4183347
authored
Jun 17, 2013
by
Russell Belfer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update clar to latest version
parent
de0555a3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
24 deletions
+36
-24
tests-clar/clar.c
+28
-20
tests-clar/clar/sandbox.h
+8
-4
No files found.
tests-clar/clar.c
View file @
f4183347
...
...
@@ -183,10 +183,10 @@ clar_run_test(
}
static
void
clar_run_suite
(
const
struct
clar_suite
*
suite
,
const
char
*
name
)
clar_run_suite
(
const
struct
clar_suite
*
suite
,
const
char
*
filter
)
{
const
struct
clar_func
*
test
=
suite
->
tests
;
size_t
i
,
name
len
;
size_t
i
,
match
len
;
if
(
!
suite
->
enabled
)
return
;
...
...
@@ -200,21 +200,21 @@ clar_run_suite(const struct clar_suite *suite, const char *name)
_clar
.
active_suite
=
suite
->
name
;
_clar
.
suite_errors
=
0
;
if
(
name
)
{
if
(
filter
)
{
size_t
suitelen
=
strlen
(
suite
->
name
);
namelen
=
strlen
(
name
);
if
(
name
len
<=
suitelen
)
{
name
=
NULL
;
matchlen
=
strlen
(
filter
);
if
(
match
len
<=
suitelen
)
{
filter
=
NULL
;
}
else
{
name
+=
suitelen
;
while
(
*
name
==
':'
)
++
name
;
namelen
=
strlen
(
name
);
filter
+=
suitelen
;
while
(
*
filter
==
':'
)
++
filter
;
matchlen
=
strlen
(
filter
);
}
}
for
(
i
=
0
;
i
<
suite
->
test_count
;
++
i
)
{
if
(
name
&&
strncmp
(
test
[
i
].
name
,
name
,
name
len
))
if
(
filter
&&
strncmp
(
test
[
i
].
name
,
filter
,
match
len
))
continue
;
_clar
.
active_test
=
test
[
i
].
name
;
...
...
@@ -230,7 +230,7 @@ clar_usage(const char *arg)
{
printf
(
"Usage: %s [options]
\n\n
"
,
arg
);
printf
(
"Options:
\n
"
);
printf
(
" -sname
\t
Run only the suite with `name`
\n
"
);
printf
(
" -sname
\t
Run only the suite with `name`
(can go to individual test name)
\n
"
);
printf
(
" -iname
\t
Include the suite with `name`
\n
"
);
printf
(
" -xname
\t
Exclude the suite with `name`
\n
"
);
printf
(
" -q
\t
Only report tests that had an error
\n
"
);
...
...
@@ -256,21 +256,20 @@ clar_parse_args(int argc, char **argv)
case
'x'
:
{
/* given suite name */
int
offset
=
(
argument
[
2
]
==
'='
)
?
3
:
2
,
found
=
0
;
char
action
=
argument
[
1
];
size_t
j
,
len
,
cmplen
;
size_t
j
,
arglen
,
suite
len
,
cmplen
;
argument
+=
offset
;
len
=
strlen
(
argument
);
arg
len
=
strlen
(
argument
);
if
(
len
==
0
)
if
(
arg
len
==
0
)
clar_usage
(
argv
[
0
]);
for
(
j
=
0
;
j
<
_clar_suite_count
;
++
j
)
{
cmplen
=
strlen
(
_clar_suites
[
j
].
name
);
if
(
cmplen
>
len
)
cmplen
=
len
;
suitelen
=
strlen
(
_clar_suites
[
j
].
name
);
cmplen
=
(
arglen
<
suitelen
)
?
arglen
:
suitelen
;
if
(
strncmp
(
argument
,
_clar_suites
[
j
].
name
,
cmplen
)
==
0
)
{
int
exact
=
!
strcmp
(
argument
,
_clar_suites
[
j
].
name
);
int
exact
=
(
arglen
>=
suitelen
);
++
found
;
...
...
@@ -419,7 +418,16 @@ void clar__assert_equal_s(
if
(
!
match
)
{
char
buf
[
4096
];
snprint_eq
(
buf
,
sizeof
(
buf
),
"'%s' != '%s'"
,
s1
,
s2
);
if
(
s1
&&
s2
)
{
int
pos
;
for
(
pos
=
0
;
s1
[
pos
]
==
s2
[
pos
]
&&
s1
[
pos
]
&&
s2
[
pos
];
++
pos
)
/* find differing byte offset */
;
snprint_eq
(
buf
,
sizeof
(
buf
),
"'%s' != '%s' (at byte %d)"
,
s1
,
s2
,
pos
);
}
else
{
snprint_eq
(
buf
,
sizeof
(
buf
),
"'%s' != '%s'"
,
s1
,
s2
);
}
clar__fail
(
file
,
line
,
err
,
buf
,
should_abort
);
}
}
...
...
tests-clar/clar/sandbox.h
View file @
f4183347
...
...
@@ -18,9 +18,9 @@ static int
find_tmp_path
(
char
*
buffer
,
size_t
length
)
{
#ifndef _WIN32
static
const
size_t
var_count
=
4
;
static
const
size_t
var_count
=
5
;
static
const
char
*
env_vars
[]
=
{
"TMPDIR"
,
"TMP"
,
"TEMP"
,
"USERPROFILE"
"
CLAR_TMP"
,
"
TMPDIR"
,
"TMP"
,
"TEMP"
,
"USERPROFILE"
};
size_t
i
;
...
...
@@ -43,6 +43,12 @@ find_tmp_path(char *buffer, size_t length)
}
#else
DWORD
env_len
;
if
((
env_len
=
GetEnvironmentVariable
(
"CLAR_TMP"
,
buffer
,
length
))
>
0
&&
env_len
<
length
)
return
0
;
if
(
GetTempPath
((
DWORD
)
length
,
buffer
))
return
0
;
#endif
...
...
@@ -61,9 +67,7 @@ static void clar_unsandbox(void)
if
(
_clar_path
[
0
]
==
'\0'
)
return
;
#ifdef _WIN32
chdir
(
".."
);
#endif
fs_rm
(
_clar_path
);
}
...
...
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