Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
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
pikelang
pike
Commits
652cba4a
Commit
652cba4a
authored
14 years ago
by
Martin Stjernholm
Browse files
Options
Downloads
Patches
Plain Diff
Made the logging functions atomic to work well in threaded tests.
parent
42f5b79f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/modules/Tools.pmod/Testsuite.pmod
+31
-21
31 additions, 21 deletions
lib/modules/Tools.pmod/Testsuite.pmod
with
31 additions
and
21 deletions
lib/modules/Tools.pmod/Testsuite.pmod
+
31
−
21
View file @
652cba4a
...
@@ -39,8 +39,32 @@ void log_start (int verbosity, int on_tty)
...
@@ -39,8 +39,32 @@ void log_start (int verbosity, int on_tty)
last_line_inplace = 0;
last_line_inplace = 0;
}
}
protected Thread.Mutex log_mutex = Thread.Mutex();
protected int twiddler_counter = -1;
protected int twiddler_counter = -1;
protected void unlocked_log_msg_cont (string msg)
{
if (last_line_inplace && last_line_length) {
write ("\n");
last_line_length = 0;
}
last_log = 0;
write (msg);
twiddler_counter = -1;
last_line_inplace = 0;
if (has_suffix (msg, "\n") || has_suffix (msg, "\r"))
last_line_length = 0;
else {
array(string) msg_lines = msg / "\n";
if (sizeof (msg_lines) > 1) last_line_length = 0;
// FIXME: This length calculation is too simplistic since it
// assumes 1 char == 1 position.
last_line_length += sizeof (msg_lines[-1]);
}
}
void log_msg (string msg, mixed... args)
void log_msg (string msg, mixed... args)
//! Logs a testsuite message. The message is shown regardless of the
//! Logs a testsuite message. The message is shown regardless of the
//! verbosity level. If the previous message was logged without a
//! verbosity level. If the previous message was logged without a
...
@@ -52,6 +76,8 @@ void log_msg (string msg, mixed... args)
...
@@ -52,6 +76,8 @@ void log_msg (string msg, mixed... args)
{
{
if (sizeof (args)) msg = sprintf (msg, @args);
if (sizeof (args)) msg = sprintf (msg, @args);
Thread.MutexKey lock = log_mutex->lock();
if (last_line_length) {
if (last_line_length) {
write ("\n");
write ("\n");
last_line_length = 0;
last_line_length = 0;
...
@@ -63,7 +89,7 @@ void log_msg (string msg, mixed... args)
...
@@ -63,7 +89,7 @@ void log_msg (string msg, mixed... args)
last_log = 0;
last_log = 0;
}
}
log_msg_cont (msg);
unlocked_
log_msg_cont (msg);
}
}
void log_msg_cont (string msg, mixed... args)
void log_msg_cont (string msg, mixed... args)
...
@@ -73,26 +99,8 @@ void log_msg_cont (string msg, mixed... args)
...
@@ -73,26 +99,8 @@ void log_msg_cont (string msg, mixed... args)
//! @[log_status].
//! @[log_status].
{
{
if (sizeof (args)) msg = sprintf (msg, @args);
if (sizeof (args)) msg = sprintf (msg, @args);
Thread.MutexKey lock = log_mutex->lock();
if (last_line_inplace && last_line_length) {
unlocked_log_msg_cont (msg);
write ("\n");
last_line_length = 0;
}
last_log = 0;
write (msg);
twiddler_counter = -1;
last_line_inplace = 0;
if (has_suffix (msg, "\n") || has_suffix (msg, "\r"))
last_line_length = 0;
else {
array(string) msg_lines = msg / "\n";
if (sizeof (msg_lines) > 1) last_line_length = 0;
// FIXME: This length calculation is too simplistic since it
// assumes 1 char == 1 position.
last_line_length += sizeof (msg_lines[-1]);
}
}
}
void log_status (string msg, mixed... args)
void log_status (string msg, mixed... args)
...
@@ -122,6 +130,8 @@ void log_status (string msg, mixed... args)
...
@@ -122,6 +130,8 @@ void log_status (string msg, mixed... args)
{
{
if (sizeof (args)) msg = sprintf (msg, @args);
if (sizeof (args)) msg = sprintf (msg, @args);
Thread.MutexKey lock = log_mutex->lock();
switch (verbosity) {
switch (verbosity) {
case 0:
case 0:
last_log = (msg != "" && msg);
last_log = (msg != "" && msg);
...
...
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