Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccan
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mirror
ccan
Commits
453fdc02
Commit
453fdc02
authored
Nov 12, 2012
by
Rusty Russell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ccanlint: add testdepends support.
Signed-off-by:
Rusty Russell
<
rusty@rustcorp.com.au
>
parent
19902365
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
155 additions
and
66 deletions
+155
-66
tools/ccanlint/tests/depends_accurate.c
tools/ccanlint/tests/depends_accurate.c
+47
-29
tools/ccanlint/tests/depends_build.c
tools/ccanlint/tests/depends_build.c
+20
-12
tools/ccanlint/tests/depends_build_without_features.c
tools/ccanlint/tests/depends_build_without_features.c
+15
-8
tools/ccanlint/tests/depends_exist.c
tools/ccanlint/tests/depends_exist.c
+57
-10
tools/ccanlint/tests/tests_compile.c
tools/ccanlint/tests/tests_compile.c
+12
-5
tools/ccanlint/tests/tests_compile.h
tools/ccanlint/tests/tests_compile.h
+1
-1
tools/ccanlint/tests/tests_compile_coverage.c
tools/ccanlint/tests/tests_compile_coverage.c
+1
-1
tools/manifest.c
tools/manifest.c
+1
-0
tools/manifest.h
tools/manifest.h
+1
-0
No files found.
tools/ccanlint/tests/depends_accurate.c
View file @
453fdc02
...
...
@@ -16,7 +16,7 @@
#include <string.h>
#include <ctype.h>
static
bool
has_dep
(
struct
manifest
*
m
,
const
char
*
depname
)
static
bool
has_dep
(
struct
manifest
*
m
,
bool
test_depend
,
const
char
*
depname
)
{
struct
manifest
*
i
;
...
...
@@ -28,21 +28,20 @@ static bool has_dep(struct manifest *m, const char *depname)
if
(
streq
(
i
->
basename
,
depname
))
return
true
;
}
if
(
test_depend
)
{
list_for_each
(
&
m
->
test_deps
,
i
,
list
)
{
if
(
streq
(
i
->
basename
,
depname
))
return
true
;
}
}
return
false
;
}
static
void
check_dep
ends_accurate
(
struct
manifest
*
m
,
unsigned
int
*
timeleft
,
struct
score
*
score
)
static
void
check_dep
_includes
(
struct
manifest
*
m
,
struct
score
*
score
,
struct
ccan_file
*
f
,
bool
test_depend
)
{
struct
list_head
*
list
;
foreach_ptr
(
list
,
&
m
->
c_files
,
&
m
->
h_files
,
&
m
->
run_tests
,
&
m
->
api_tests
,
&
m
->
compile_ok_tests
,
&
m
->
compile_fail_tests
,
&
m
->
other_test_c_files
)
{
struct
ccan_file
*
f
;
list_for_each
(
list
,
f
,
list
)
{
unsigned
int
i
;
char
**
lines
=
get_ccan_file_lines
(
f
);
struct
line_info
*
li
=
get_ccan_line_info
(
f
);
...
...
@@ -54,7 +53,7 @@ static void check_depends_accurate(struct manifest *m,
"ccan/+([^/]+)/"
,
&
mod
))
continue
;
if
(
has_dep
(
m
,
mod
))
if
(
has_dep
(
m
,
test_depend
,
mod
))
continue
;
/* FIXME: we can't be sure about
...
...
@@ -62,11 +61,30 @@ static void check_depends_accurate(struct manifest *m,
* complain. */
if
(
!
li
[
i
].
cond
)
{
score_file_error
(
score
,
f
,
i
+
1
,
"%s not listed in _info"
,
mod
);
"%s not listed in _info"
,
mod
);
}
}
}
static
void
check_depends_accurate
(
struct
manifest
*
m
,
unsigned
int
*
timeleft
,
struct
score
*
score
)
{
struct
list_head
*
list
;
foreach_ptr
(
list
,
&
m
->
c_files
,
&
m
->
h_files
)
{
struct
ccan_file
*
f
;
list_for_each
(
list
,
f
,
list
)
check_dep_includes
(
m
,
score
,
f
,
false
);
}
foreach_ptr
(
list
,
&
m
->
run_tests
,
&
m
->
api_tests
,
&
m
->
compile_ok_tests
,
&
m
->
compile_fail_tests
,
&
m
->
other_test_c_files
)
{
struct
ccan_file
*
f
;
list_for_each
(
list
,
f
,
list
)
check_dep_includes
(
m
,
score
,
f
,
true
);
}
if
(
!
score
->
error
)
{
...
...
@@ -79,7 +97,7 @@ struct ccanlint depends_accurate = {
.
key
=
"depends_accurate"
,
.
name
=
"Module's CCAN dependencies are the only CCAN files #included"
,
.
check
=
check_depends_accurate
,
.
needs
=
"depends_exist"
.
needs
=
"depends_exist
test_depends_exist
"
};
REGISTER_TEST
(
depends_accurate
);
tools/ccanlint/tests/depends_build.c
View file @
453fdc02
#include <tools/ccanlint/ccanlint.h>
#include <tools/tools.h>
#include <ccan/talloc/talloc.h>
#include <ccan/foreach/foreach.h>
#include <ccan/str/str.h>
#include <sys/types.h>
#include <sys/stat.h>
...
...
@@ -79,19 +80,26 @@ char *build_submodule(struct manifest *m, const char *flags,
static
void
check_depends_built
(
struct
manifest
*
m
,
unsigned
int
*
timeleft
,
struct
score
*
score
)
{
struct
list_head
*
list
;
foreach_ptr
(
list
,
&
m
->
deps
,
&
m
->
test_deps
)
{
struct
manifest
*
i
;
list_for_each
(
list
,
i
,
list
)
{
char
*
errstr
;
list_for_each
(
&
m
->
deps
,
i
,
list
)
{
char
*
errstr
=
build_submodule
(
i
,
cflags
,
COMPILE_NORMAL
);
errstr
=
build_submodule
(
i
,
cflags
,
COMPILE_NORMAL
);
if
(
errstr
)
{
score
->
error
=
talloc_asprintf
(
score
,
"Dependency %s"
" did not build:
\n
%s"
,
i
->
basename
,
errstr
);
" did not"
" build:
\n
%s"
,
i
->
basename
,
errstr
);
return
;
}
}
}
score
->
pass
=
true
;
score
->
score
=
score
->
total
;
...
...
@@ -102,7 +110,7 @@ struct ccanlint depends_build = {
.
name
=
"Module's CCAN dependencies can be found or built"
,
.
check
=
check_depends_built
,
.
can_run
=
can_build
,
.
needs
=
"depends_exist"
.
needs
=
"depends_exist
test_depends_exist
"
};
REGISTER_TEST
(
depends_build
);
tools/ccanlint/tests/depends_build_without_features.c
View file @
453fdc02
...
...
@@ -2,6 +2,7 @@
#include <tools/tools.h>
#include <ccan/talloc/talloc.h>
#include <ccan/str/str.h>
#include <ccan/foreach/foreach.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
...
...
@@ -27,23 +28,29 @@ static void check_depends_built_without_features(struct manifest *m,
unsigned
int
*
timeleft
,
struct
score
*
score
)
{
struct
list_head
*
list
;
struct
manifest
*
i
;
char
*
flags
;
flags
=
talloc_asprintf
(
score
,
"%s %s"
,
cflags
,
REDUCE_FEATURES_FLAGS
);
list_for_each
(
&
m
->
deps
,
i
,
list
)
{
char
*
errstr
=
build_submodule
(
i
,
flags
,
COMPILE_NOFEAT
);
foreach_ptr
(
list
,
&
m
->
deps
,
&
m
->
test_deps
)
{
list_for_each
(
list
,
i
,
list
)
{
char
*
errstr
=
build_submodule
(
i
,
flags
,
COMPILE_NOFEAT
);
if
(
errstr
)
{
score
->
error
=
talloc_asprintf
(
score
,
"Dependency %s"
" did not build:
\n
%s"
,
i
->
basename
,
errstr
);
" did not"
" build:
\n
%s"
,
i
->
basename
,
errstr
);
return
;
}
}
}
score
->
pass
=
true
;
score
->
score
=
score
->
total
;
...
...
tools/ccanlint/tests/depends_exist.c
View file @
453fdc02
...
...
@@ -14,7 +14,20 @@
#include <string.h>
#include <ctype.h>
static
bool
add_dep
(
struct
manifest
*
m
,
const
char
*
dep
,
struct
score
*
score
)
static
bool
have_dep
(
struct
manifest
*
m
,
const
char
*
dep
)
{
struct
manifest
*
i
;
list_for_each
(
&
m
->
deps
,
i
,
list
)
if
(
streq
(
i
->
basename
,
dep
+
strlen
(
"ccan/"
)))
return
true
;
return
false
;
}
static
bool
add_dep
(
struct
manifest
*
m
,
struct
list_head
*
deplist
,
const
char
*
dep
,
struct
score
*
score
)
{
struct
stat
st
;
struct
manifest
*
subm
;
...
...
@@ -29,7 +42,7 @@ static bool add_dep(struct manifest *m, const char *dep, struct score *score)
return
false
;
}
subm
=
get_manifest
(
m
,
dir
);
list_add_tail
(
&
m
->
deps
,
&
subm
->
list
);
list_add_tail
(
deplist
,
&
subm
->
list
);
return
true
;
}
...
...
@@ -39,11 +52,32 @@ static void check_depends_exist(struct manifest *m,
{
unsigned
int
i
;
char
**
deps
;
char
*
updir
=
talloc_strdup
(
m
,
m
->
dir
);
bool
needs_tap
;
if
(
strrchr
(
updir
,
'/'
))
*
strrchr
(
updir
,
'/'
)
=
'\0'
;
if
(
safe_mode
)
deps
=
get_safe_ccan_deps
(
m
,
m
->
dir
,
"depends"
,
true
);
else
deps
=
get_deps
(
m
,
m
->
dir
,
"depends"
,
true
,
get_or_compile_info
);
for
(
i
=
0
;
deps
[
i
];
i
++
)
{
if
(
!
strstarts
(
deps
[
i
],
"ccan/"
))
continue
;
if
(
!
add_dep
(
m
,
&
m
->
deps
,
deps
[
i
],
score
))
return
;
}
score
->
pass
=
true
;
score
->
score
=
score
->
total
;
}
static
void
check_test_depends_exist
(
struct
manifest
*
m
,
unsigned
int
*
timeleft
,
struct
score
*
score
)
{
unsigned
int
i
;
char
**
deps
;
bool
needs_tap
;
/* We may need libtap for testing, unless we're "tap" */
if
(
streq
(
m
->
basename
,
"tap"
))
{
...
...
@@ -55,16 +89,18 @@ static void check_depends_exist(struct manifest *m,
}
if
(
safe_mode
)
deps
=
get_safe_ccan_deps
(
m
,
m
->
dir
,
"depends"
,
true
);
deps
=
get_safe_ccan_deps
(
m
,
m
->
dir
,
"
test
depends"
,
true
);
else
deps
=
get_deps
(
m
,
m
->
dir
,
"depends"
,
true
,
deps
=
get_deps
(
m
,
m
->
dir
,
"
test
depends"
,
true
,
get_or_compile_info
);
for
(
i
=
0
;
deps
[
i
];
i
++
)
{
if
(
!
strstarts
(
deps
[
i
],
"ccan/"
))
continue
;
if
(
!
add_dep
(
m
,
deps
[
i
],
score
))
/* Don't add dependency twice: we can only be on one list! */
if
(
!
have_dep
(
m
,
deps
[
i
])
&&
!
add_dep
(
m
,
&
m
->
test_deps
,
deps
[
i
],
score
))
return
;
if
(
streq
(
deps
[
i
],
"ccan/tap"
))
{
...
...
@@ -72,7 +108,8 @@ static void check_depends_exist(struct manifest *m,
}
}
if
(
needs_tap
&&
!
add_dep
(
m
,
"ccan/tap"
,
score
))
{
if
(
needs_tap
&&
!
have_dep
(
m
,
"ccan/tap"
)
&&
!
add_dep
(
m
,
&
m
->
test_deps
,
"ccan/tap"
,
score
))
{
return
;
}
...
...
@@ -89,3 +126,13 @@ struct ccanlint depends_exist = {
};
REGISTER_TEST
(
depends_exist
);
struct
ccanlint
test_depends_exist
=
{
.
key
=
"test_depends_exist"
,
.
name
=
"Module's CCAN test dependencies can be found"
,
.
compulsory
=
false
,
.
check
=
check_test_depends_exist
,
.
needs
=
"depends_exist"
};
REGISTER_TEST
(
test_depends_exist
);
tools/ccanlint/tests/tests_compile.c
View file @
453fdc02
...
...
@@ -42,23 +42,30 @@ char *test_obj_list(const struct manifest *m, bool link_with_module,
list
=
talloc_asprintf_append
(
list
,
" %s"
,
i
->
compiled
[
own_ctype
]);
/* Other ccan modules. */
/* Other ccan modules
(normal depends)
. */
list_for_each
(
&
m
->
deps
,
subm
,
list
)
{
if
(
subm
->
compiled
[
ctype
])
list
=
talloc_asprintf_append
(
list
,
" %s"
,
subm
->
compiled
[
ctype
]);
}
/* Other ccan modules (test depends). */
list_for_each
(
&
m
->
test_deps
,
subm
,
list
)
{
if
(
subm
->
compiled
[
ctype
])
list
=
talloc_asprintf_append
(
list
,
" %s"
,
subm
->
compiled
[
ctype
]);
}
return
list
;
}
char
*
lib_list
(
const
struct
manifest
*
m
,
enum
compile_type
ctype
)
char
*
test_
lib_list
(
const
struct
manifest
*
m
,
enum
compile_type
ctype
)
{
unsigned
int
i
;
char
**
libs
;
char
*
ret
=
talloc_strdup
(
m
,
""
);
libs
=
get_libs
(
m
,
m
->
dir
,
"depends"
,
get_or_compile_info
);
libs
=
get_libs
(
m
,
m
->
dir
,
"
test
depends"
,
get_or_compile_info
);
for
(
i
=
0
;
libs
[
i
];
i
++
)
ret
=
talloc_asprintf_append
(
ret
,
"-l%s "
,
libs
[
i
]);
return
ret
;
...
...
@@ -84,7 +91,7 @@ static bool compile(const void *ctx,
if
(
!
compile_and_link
(
ctx
,
file
->
fullname
,
ccan_dir
,
test_obj_list
(
m
,
link_with_module
,
ctype
,
ctype
),
compiler
,
flags
,
lib_list
(
m
,
ctype
),
fname
,
compiler
,
flags
,
test_
lib_list
(
m
,
ctype
),
fname
,
output
))
{
talloc_free
(
fname
);
return
false
;
...
...
@@ -111,7 +118,7 @@ static void compile_async(const void *ctx,
compile_and_link_async
(
file
,
time_ms
,
file
->
fullname
,
ccan_dir
,
test_obj_list
(
m
,
link_with_module
,
ctype
,
ctype
),
compiler
,
flags
,
lib_list
(
m
,
ctype
),
compiler
,
flags
,
test_
lib_list
(
m
,
ctype
),
file
->
compiled
[
ctype
]);
}
...
...
tools/ccanlint/tests/tests_compile.h
View file @
453fdc02
...
...
@@ -3,4 +3,4 @@
char
*
test_obj_list
(
const
struct
manifest
*
m
,
bool
link_with_module
,
enum
compile_type
ctype
,
enum
compile_type
own_ctype
);
/* Library list as specified by ctype variant of _info. */
char
*
lib_list
(
const
struct
manifest
*
m
,
enum
compile_type
ctype
);
char
*
test_
lib_list
(
const
struct
manifest
*
m
,
enum
compile_type
ctype
);
tools/ccanlint/tests/tests_compile_coverage.c
View file @
453fdc02
...
...
@@ -46,7 +46,7 @@ static void cov_compile(const void *ctx,
COMPILE_NORMAL
,
COMPILE_COVERAGE
),
compiler
,
flags
,
lib_list
(
m
,
COMPILE_NORMAL
),
test_
lib_list
(
m
,
COMPILE_NORMAL
),
file
->
compiled
[
COMPILE_COVERAGE
]);
}
...
...
tools/manifest.c
View file @
453fdc02
...
...
@@ -237,6 +237,7 @@ struct manifest *get_manifest(const void *ctx, const char *dir)
list_head_init
(
&
m
->
examples
);
list_head_init
(
&
m
->
mangled_examples
);
list_head_init
(
&
m
->
deps
);
list_head_init
(
&
m
->
test_deps
);
len
=
strlen
(
m
->
dir
);
while
(
len
&&
m
->
dir
[
len
-
1
]
==
'/'
)
...
...
tools/manifest.h
View file @
453fdc02
...
...
@@ -38,6 +38,7 @@ struct manifest {
/* From tests/check_depends_exist.c */
struct
list_head
deps
;
struct
list_head
test_deps
;
/* From tests/license_exists.c */
enum
license
license
;
...
...
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