Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
The Tor Project
Core
Tor
Commits
c01f9d9f
Commit
c01f9d9f
authored
9 years ago
by
Nick Mathewson
Browse files
Options
Downloads
Patches
Plain Diff
Fix style and compilation in log_test_helpers
parent
f7748131
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/test/log_test_helpers.c
+25
-12
25 additions, 12 deletions
src/test/log_test_helpers.c
src/test/log_test_helpers.h
+5
-2
5 additions, 2 deletions
src/test/log_test_helpers.h
with
30 additions
and
14 deletions
src/test/log_test_helpers.c
+
25
−
12
View file @
c01f9d9f
...
...
@@ -33,8 +33,8 @@ mock_clean_saved_logs(void)
saved_logs
=
NULL
;
}
char
*
mock_
saved_log_at
(
int
ix
)
static
mock_saved_log_entry_t
*
mock_
get_log_entry
(
int
ix
)
{
int
saved_log_count
=
mock_saved_log_number
();
if
(
ix
<
0
)
{
...
...
@@ -42,21 +42,29 @@ mock_saved_log_at(int ix)
}
if
(
saved_log_count
<=
ix
)
return
NULL
;
return
smartlist_get
(
saved_logs
,
ix
);
}
const
char
*
mock_saved_log_at
(
int
ix
)
{
mock_saved_log_entry_t
*
ent
=
mock_get_log_entry
(
ix
);
if
(
ent
)
return
ent
->
generated_msg
;
else
return
""
;
return
((
mock_saved_log_entry_t
*
)
smartlist_get
(
saved_logs
,
ix
))
->
generated_msg
;
}
int
mock_saved_severity_at
(
int
ix
)
{
int
saved_log_count
=
mock_saved_log_number
();
if
(
ix
<
0
)
{
ix
=
saved_log_count
+
ix
;
}
if
(
saved_log_count
<=
ix
)
mock_saved_log_entry_t
*
ent
=
mock_get_log_entry
(
ix
);
if
(
ent
)
return
ent
->
severity
;
else
return
-
1
;
return
((
mock_saved_log_entry_t
*
)
smartlist_get
(
saved_logs
,
ix
))
->
severity
;
}
int
...
...
@@ -74,11 +82,15 @@ mock_saved_logs(void)
}
void
mock_saving_logv
(
int
severity
,
log_domain_mask_t
domain
,
const
char
*
funcname
,
const
char
*
suffix
,
const
char
*
format
,
va_list
ap
)
mock_saving_logv
(
int
severity
,
log_domain_mask_t
domain
,
const
char
*
funcname
,
const
char
*
suffix
,
const
char
*
format
,
va_list
ap
)
{
(
void
)
domain
;
char
*
buf
=
tor_malloc_zero
(
10240
);
int
n
;
n
=
tor_vsnprintf
(
buf
,
10240
,
format
,
ap
);
tor_assert
(
n
<
10240
-
1
);
buf
[
n
]
=
'\n'
;
buf
[
n
+
1
]
=
'\0'
;
...
...
@@ -87,7 +99,8 @@ mock_saving_logv(int severity, log_domain_mask_t domain, const char *funcname, c
e
->
funcname
=
funcname
;
e
->
suffix
=
suffix
;
e
->
format
=
format
;
e
->
generated_msg
=
buf
;
e
->
generated_msg
=
tor_strdup
(
buf
);
tor_free
(
buf
);
if
(
!
saved_logs
)
saved_logs
=
smartlist_new
();
...
...
This diff is collapsed.
Click to expand it.
src/test/log_test_helpers.h
+
5
−
2
View file @
c01f9d9f
...
...
@@ -15,12 +15,15 @@ typedef struct mock_saved_log_entry_t {
struct
mock_saved_log_entry_t
*
next
;
}
mock_saved_log_entry_t
;
void
mock_saving_logv
(
int
severity
,
log_domain_mask_t
domain
,
const
char
*
funcname
,
const
char
*
suffix
,
const
char
*
format
,
va_list
ap
);
void
mock_saving_logv
(
int
severity
,
log_domain_mask_t
domain
,
const
char
*
funcname
,
const
char
*
suffix
,
const
char
*
format
,
va_list
ap
)
CHECK_PRINTF
(
5
,
0
);
void
mock_clean_saved_logs
(
void
);
const
smartlist_t
*
mock_saved_logs
(
void
);
int
setup_capture_of_logs
(
int
new_level
);
void
teardown_capture_of_logs
(
int
prev
);
char
*
mock_saved_log_at
(
int
ix
);
const
char
*
mock_saved_log_at
(
int
ix
);
int
mock_saved_severity_at
(
int
ix
);
int
mock_saved_log_number
(
void
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment