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
d1d6625c
Commit
d1d6625c
authored
Jan 18, 2010
by
Rusty Russell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New test: run tests under valgrind.
(Also, remove bogus test dependency for hdr include check)
parent
8f7447e4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
120 additions
and
1 deletion
+120
-1
tools/ccanlint/tests/idempotent.c
tools/ccanlint/tests/idempotent.c
+1
-1
tools/ccanlint/tests/run_tests_valgrind.c
tools/ccanlint/tests/run_tests_valgrind.c
+119
-0
No files found.
tools/ccanlint/tests/idempotent.c
View file @
d1d6625c
...
...
@@ -138,4 +138,4 @@ struct ccanlint idempotent = {
.
describe
=
describe_idempotent
,
};
REGISTER_TEST
(
idempotent
,
&
trailing_whitespace
,
NULL
);
REGISTER_TEST
(
idempotent
,
NULL
);
tools/ccanlint/tests/run_tests_valgrind.c
0 → 100644
View file @
d1d6625c
#include <tools/ccanlint/ccanlint.h>
#include <tools/tools.h>
#include <ccan/talloc/talloc.h>
#include <ccan/str/str.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <limits.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <err.h>
#include <string.h>
#include <ctype.h>
/* Note: we already test safe_mode in run_tests.c */
static
const
char
*
can_run_vg
(
struct
manifest
*
m
)
{
char
*
output
=
run_command
(
m
,
"valgrind -q true"
);
if
(
output
)
return
talloc_asprintf
(
m
,
"No valgrind support: %s"
,
output
);
return
NULL
;
}
struct
run_tests_result
{
struct
list_node
list
;
struct
ccan_file
*
file
;
const
char
*
output
;
};
static
void
*
do_run_tests_vg
(
struct
manifest
*
m
)
{
struct
list_head
*
list
=
talloc
(
m
,
struct
list_head
);
struct
run_tests_result
*
res
;
struct
ccan_file
*
i
;
char
*
cmdout
;
list_head_init
(
list
);
list_for_each
(
&
m
->
run_tests
,
i
,
list
)
{
run_tests
.
total_score
++
;
/* FIXME: timeout here */
cmdout
=
run_command
(
m
,
"valgrind -q %s"
,
i
->
compiled
);
if
(
cmdout
)
{
res
=
talloc
(
list
,
struct
run_tests_result
);
res
->
file
=
i
;
res
->
output
=
talloc_steal
(
res
,
cmdout
);
list_add_tail
(
list
,
&
res
->
list
);
}
}
list_for_each
(
&
m
->
api_tests
,
i
,
list
)
{
run_tests
.
total_score
++
;
/* FIXME: timeout here */
cmdout
=
run_command
(
m
,
"valgrind -q %s"
,
i
->
compiled
);
if
(
cmdout
)
{
res
=
talloc
(
list
,
struct
run_tests_result
);
res
->
file
=
i
;
res
->
output
=
talloc_steal
(
res
,
cmdout
);
list_add_tail
(
list
,
&
res
->
list
);
}
}
if
(
list_empty
(
list
))
{
talloc_free
(
list
);
list
=
NULL
;
}
return
list
;
}
static
unsigned
int
score_run_tests_vg
(
struct
manifest
*
m
,
void
*
check_result
)
{
struct
list_head
*
list
=
check_result
;
struct
run_tests_result
*
i
;
unsigned
int
score
=
run_tests
.
total_score
;
list_for_each
(
list
,
i
,
list
)
score
--
;
return
score
;
}
static
const
char
*
describe_run_tests_vg
(
struct
manifest
*
m
,
void
*
check_result
)
{
struct
list_head
*
list
=
check_result
;
char
*
descrip
=
talloc_strdup
(
check_result
,
"Running tests under valgrind failed:
\n
"
);
struct
run_tests_result
*
i
;
list_for_each
(
list
,
i
,
list
)
descrip
=
talloc_asprintf_append
(
descrip
,
"Running %s:
\n
%s"
,
i
->
file
->
name
,
i
->
output
);
return
descrip
;
}
static
void
run_under_debugger_vg
(
struct
manifest
*
m
,
void
*
check_result
)
{
struct
list_head
*
list
=
check_result
;
struct
run_tests_result
*
first
;
if
(
!
ask
(
"Should I run the first failing test under the debugger?"
))
return
;
first
=
list_top
(
list
,
struct
run_tests_result
,
list
);
run_command
(
m
,
"valgrind --db-attach=yes %s"
,
first
->
file
->
compiled
);
}
struct
ccanlint
run_tests_vg
=
{
.
name
=
"run and api tests under valgrind"
,
.
score
=
score_run_tests_vg
,
.
check
=
do_run_tests_vg
,
.
describe
=
describe_run_tests_vg
,
.
can_run
=
can_run_vg
,
.
handle
=
run_under_debugger_vg
};
REGISTER_TEST
(
run_tests_vg
,
&
run_tests
,
NULL
);
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