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
e8a92fe1
Commit
e8a92fe1
authored
Jan 21, 2013
by
Russell Belfer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update clar to a80e7f30
parent
1bf7bee3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
24 deletions
+54
-24
tests-clar/clar.c
+25
-9
tests-clar/clar.h
+6
-0
tests-clar/clar/print.h
+3
-2
tests-clar/generate.py
+20
-13
No files found.
tests-clar/clar.c
View file @
e8a92fe1
/*
* Copyright (c) Vicent Marti. All rights reserved.
*
* This file is part of clar, distributed under the ISC license.
* For full terms see the included COPYING file.
*/
#include <assert.h>
#include <setjmp.h>
#include <stdlib.h>
...
...
@@ -75,6 +81,7 @@ static struct {
int
report_errors_only
;
int
exit_on_error
;
int
report_suite_names
;
struct
clar_error
*
errors
;
struct
clar_error
*
last_error
;
...
...
@@ -207,12 +214,12 @@ clar_usage(const char *arg)
{
printf
(
"Usage: %s [options]
\n\n
"
,
arg
);
printf
(
"Options:
\n
"
);
printf
(
" -sname
\t
\t
Run only the suite with `name`
\n
"
);
printf
(
" -iname
\t
\t
Include the suite with `name`
\n
"
);
printf
(
" -xname
\t
\t
Exclude the suite with `name`
\n
"
);
printf
(
" -q
\t
\t
Only report tests that had an error
\n
"
);
printf
(
" -Q
\t
\t
Quit as soon as a test fails
\n
"
);
printf
(
" -l
\t
\t
Print suite names
\n
"
);
printf
(
" -sname
\t
Run only the suite with `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
"
);
printf
(
" -Q
\t
Quit as soon as a test fails
\n
"
);
printf
(
" -l
\t
Print suite names
\n
"
);
exit
(
-
1
);
}
...
...
@@ -231,7 +238,7 @@ clar_parse_args(int argc, char **argv)
case
's'
:
case
'i'
:
case
'x'
:
{
/* given suite name */
int
offset
=
(
argument
[
2
]
==
'='
)
?
3
:
2
;
int
offset
=
(
argument
[
2
]
==
'='
)
?
3
:
2
,
found
=
0
;
char
action
=
argument
[
1
];
size_t
j
,
len
;
...
...
@@ -243,16 +250,25 @@ clar_parse_args(int argc, char **argv)
for
(
j
=
0
;
j
<
_clar_suite_count
;
++
j
)
{
if
(
strncmp
(
argument
,
_clar_suites
[
j
].
name
,
len
)
==
0
)
{
int
exact
=
!
strcmp
(
argument
,
_clar_suites
[
j
].
name
);
++
found
;
if
(
!
exact
)
_clar
.
report_suite_names
=
1
;
switch
(
action
)
{
case
's'
:
clar_run_suite
(
&
_clar_suites
[
j
]);
break
;
case
'i'
:
_clar_suites
[
j
].
enabled
=
1
;
break
;
case
'x'
:
_clar_suites
[
j
].
enabled
=
0
;
break
;
}
break
;
if
(
exact
)
break
;
}
}
if
(
j
==
_clar_suite_count
)
{
if
(
!
found
)
{
clar_print_onabort
(
"No suite matching '%s' found.
\n
"
,
argument
);
exit
(
-
1
);
}
...
...
tests-clar/clar.h
View file @
e8a92fe1
/*
* Copyright (c) Vicent Marti. All rights reserved.
*
* This file is part of clar, distributed under the ISC license.
* For full terms see the included COPYING file.
*/
#ifndef __CLAR_TEST_H__
#define __CLAR_TEST_H__
...
...
tests-clar/clar/print.h
View file @
e8a92fe1
...
...
@@ -45,9 +45,10 @@ static void clar_print_ontest(const char *test_name, int test_number, int failed
static
void
clar_print_onsuite
(
const
char
*
suite_name
,
int
suite_index
)
{
/* noop */
if
(
_clar
.
report_suite_names
)
printf
(
"
\n
%s"
,
suite_name
);
(
void
)
suite_index
;
(
void
)
suite_name
;
}
static
void
clar_print_onabort
(
const
char
*
msg
,
...)
...
...
tests-clar/generate.py
View file @
e8a92fe1
#!/usr/bin/env python
#
# Copyright (c) Vicent Marti. All rights reserved.
#
# This file is part of clar, distributed under the ISC license.
# For full terms see the included COPYING file.
#
from
__future__
import
with_statement
from
string
import
Template
...
...
@@ -11,12 +17,12 @@ class Module(object):
def
_render_callback
(
self
,
cb
):
if
not
cb
:
return
'{ NULL, NULL }'
return
'{ "
%
s", &
%
s }'
%
(
cb
[
'short_name'
],
cb
[
'symbol'
])
return
'
{ NULL, NULL }'
return
'
{ "
%
s", &
%
s }'
%
(
cb
[
'short_name'
],
cb
[
'symbol'
])
class
DeclarationTemplate
(
Template
):
def
render
(
self
):
out
=
"
\n
"
.
join
(
"extern
%
s;"
%
cb
[
'declaration'
]
for
cb
in
self
.
module
.
callbacks
)
out
=
"
\n
"
.
join
(
"extern
%
s;"
%
cb
[
'declaration'
]
for
cb
in
self
.
module
.
callbacks
)
+
"
\n
"
if
self
.
module
.
initialize
:
out
+=
"extern
%
s;
\n
"
%
self
.
module
.
initialize
[
'declaration'
]
...
...
@@ -36,12 +42,13 @@ class Module(object):
class
InfoTemplate
(
Template
):
def
render
(
self
):
return
Template
(
r"""{
"${clean_name}",
${initialize},
${cleanup},
${cb_ptr}, ${cb_count}, ${enabled}
}"""
r"""
{
"${clean_name}",
${initialize},
${cleanup},
${cb_ptr}, ${cb_count}, ${enabled}
}"""
)
.
substitute
(
clean_name
=
self
.
module
.
clean_name
(),
initialize
=
self
.
_render_callback
(
self
.
module
.
initialize
),
...
...
@@ -208,13 +215,13 @@ class TestSuite(object):
data
.
write
(
t
.
render
())
suites
=
"static struct clar_suite _clar_suites[] = {"
+
','
.
join
(
Module
.
InfoTemplate
(
module
)
.
render
()
for
module
in
s
elf
.
modules
.
values
(
)
)
+
"
};
"
Module
.
InfoTemplate
(
module
)
.
render
()
for
module
in
s
orted
(
self
.
modules
.
values
(),
key
=
lambda
module
:
module
.
name
)
)
+
"
\n
};
\n
"
data
.
write
(
suites
)
data
.
write
(
"static const size_t _clar_suite_count =
%
d;"
%
self
.
suite_count
())
data
.
write
(
"static const size_t _clar_callback_count =
%
d;"
%
self
.
callback_count
())
data
.
write
(
"static const size_t _clar_suite_count =
%
d;
\n
"
%
self
.
suite_count
())
data
.
write
(
"static const size_t _clar_callback_count =
%
d;
\n
"
%
self
.
callback_count
())
suite
.
save_cache
()
return
True
...
...
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