Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
88ac15dd
Commit
88ac15dd
authored
Nov 17, 2006
by
dfischer/df@kahlann.erinye.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MTR_BUILD_THREAD=auto selects a value for MTR_BUILD_THREAD from a pool (WL#2690)
parent
3a12df0b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
129 additions
and
0 deletions
+129
-0
mysql-test/lib/mtr_unique.pl
mysql-test/lib/mtr_unique.pl
+119
-0
mysql-test/mysql-test-run.pl
mysql-test/mysql-test-run.pl
+10
-0
No files found.
mysql-test/lib/mtr_unique.pl
0 → 100644
View file @
88ac15dd
#
# This file is used from mysql-test-run.pl when choosing
# port numbers and directories to use for running mysqld.
#
use
strict
;
use
Fcntl
'
:flock
';
#
# Requested IDs are stored in a hash and released upon END.
#
my
%
mtr_unique_assigned_ids
=
();
END
{
while
(
my
(
$id
,
$file
)
=
each
(
%
mtr_unique_assigned_ids
))
{
print
"
Autoreleasing
$file
:
$id
\n
";
mtr_release_unique_id
(
$file
,
$id
);
}
}
#
# Require a unique, numerical ID, given a file name (where all
# requested IDs are stored), a minimum and a maximum value.
#
# We use flock to implement locking for the ID file and ignore
# possible problems arising from lack of support for it on
# some platforms (it should work on most, and the possible
# race condition would occur rarely). The proper solution for
# this is a daemon that manages IDs, of course.
#
# If no unique ID within the specified parameters can be
# obtained, return undef.
#
sub
mtr_require_unique_id
($$$)
{
my
$file
=
shift
;
my
$min
=
shift
;
my
$max
=
shift
;
my
$ret
=
undef
;
chmod
0777
,
"
$file
.sem
";
open
SEM
,
"
>
",
"
$file
.sem
"
or
die
"
can't write to
$file
.sem
";
flock
SEM
,
LOCK_EX
or
die
"
can't lock
$file
.sem
";
if
(
!
-
e
$file
)
{
open
FILE
,
"
>
",
$file
or
die
"
can't create
$file
";
close
FILE
;
}
chmod
0777
,
$file
;
open
FILE
,
"
+<
",
$file
or
die
"
can't open
$file
";
select
undef
,
undef
,
undef
,
0.2
;
seek
FILE
,
0
,
0
;
my
%
taken
=
();
while
(
<
FILE
>
)
{
chomp
;
my
(
$id
,
$pid
)
=
split
/ /
;
$taken
{
$id
}
=
$pid
;
}
seek
FILE
,
0
,
2
;
for
(
my
$i
=
$min
;
$i
<=
$max
;
++
$i
)
{
if
(
!
exists
$taken
{
$i
})
{
print
FILE
"
$i
$$
\n
";
$ret
=
$i
;
last
;
}
}
close
FILE
;
flock
SEM
,
LOCK_UN
or
warn
"
can't unlock
$file
.sem
";
close
SEM
;
$mtr_unique_assigned_ids
{
$ret
}
=
$file
if
defined
$ret
;
return
$ret
;
}
#
# Require a unique ID like above, but sleep if no ID can be
# obtained immediately.
#
sub
mtr_require_unique_id_and_wait
($$$)
{
my
$ret
=
mtr_require_unique_id
(
$_
[
0
],
$_
[
1
],
$_
[
2
]);
while
(
!
defined
$ret
)
{
sleep
10
;
$ret
=
mtr_require_unique_id
(
$_
[
0
],
$_
[
1
],
$_
[
2
]);
}
return
$ret
;
}
#
# Release a unique ID.
#
sub
mtr_release_unique_id
($$)
{
my
$file
=
shift
;
my
$myid
=
shift
;
open
SEM
,
"
>
",
"
$file
.sem
"
or
die
"
can't write to
$file
.sem
";
flock
SEM
,
LOCK_EX
or
die
"
can't lock
$file
.sem
";
if
(
!
-
e
$file
)
{
open
FILE
,
"
>
",
$file
or
die
"
can't create
$file
";
close
FILE
;
}
open
FILE
,
"
+<
",
$file
or
die
"
can't open
$file
";
select
undef
,
undef
,
undef
,
0.2
;
seek
FILE
,
0
,
0
;
my
%
taken
=
();
while
(
<
FILE
>
)
{
chomp
;
my
(
$id
,
$pid
)
=
split
/ /
;
$taken
{
$id
}
=
$pid
;
}
delete
$taken
{
$myid
};
seek
FILE
,
0
,
0
;
truncate
FILE
,
0
or
die
"
can't truncate
$file
";
for
my
$k
(
keys
%
taken
)
{
print
FILE
$k
.
'
'
.
$taken
{
$k
}
.
"
\n
";
}
close
FILE
;
flock
SEM
,
LOCK_UN
or
warn
"
can't unlock
$file
.sem
";
close
SEM
;
delete
$mtr_unique_assigned_ids
{
$myid
};
}
1
;
mysql-test/mysql-test-run.pl
View file @
88ac15dd
...
...
@@ -85,6 +85,7 @@ require "lib/mtr_diff.pl";
require
"
lib/mtr_match.pl
";
require
"
lib/mtr_misc.pl
";
require
"
lib/mtr_stress.pl
";
require
"
lib/mtr_unique.pl
";
$
Devel::Trace::
TRACE
=
1
;
...
...
@@ -449,6 +450,15 @@ sub initial_setup () {
select
(
STDOUT
);
$|
=
1
;
# Make unbuffered
# If so requested, we try to avail ourselves of a unique build thread number.
if
(
$ENV
{'
MTR_BUILD_THREAD
'}
)
{
if
(
lc
(
$ENV
{'
MTR_BUILD_THREAD
'})
eq
'
auto
'
)
{
print
"
Requesting build thread...
";
$ENV
{'
MTR_BUILD_THREAD
'}
=
mtr_require_unique_id_and_wait
("
/tmp/mysql-test-ports
",
200
,
299
);
print
"
got
"
.
$ENV
{'
MTR_BUILD_THREAD
'}
.
"
\n
";
}
}
$glob_scriptname
=
basename
(
$0
);
# We require that we are in the "mysql-test" directory
...
...
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