Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
steam-runtime-tools
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
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
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
steamrt
steam-runtime-tools
Commits
77171d9d
Commit
77171d9d
authored
4 years ago
by
Simon McVittie
Browse files
Options
Downloads
Patches
Plain Diff
tests: Test garbage-collection of mutable runtime copies
Signed-off-by:
Simon McVittie
<
smcv@collabora.com
>
parent
ee1bae76
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/containers.py
+59
-2
59 additions, 2 deletions
tests/containers.py
with
59 additions
and
2 deletions
tests/containers.py
+
59
−
2
View file @
77171d9d
...
@@ -78,9 +78,11 @@ SteamOS 2 'brewmaster', Debian 8 'jessie', Ubuntu 14.04 'trusty'.
...
@@ -78,9 +78,11 @@ SteamOS 2 'brewmaster', Debian 8 'jessie', Ubuntu 14.04 'trusty'.
"""
"""
import
contextlib
import
contextlib
import
fcntl
import
logging
import
logging
import
os
import
os
import
shutil
import
shutil
import
struct
import
subprocess
import
subprocess
import
sys
import
sys
import
tempfile
import
tempfile
...
@@ -335,6 +337,7 @@ class TestContainers(BaseTest):
...
@@ -335,6 +337,7 @@ class TestContainers(BaseTest):
scout
:
str
,
scout
:
str
,
*
,
*
,
copy
:
bool
=
False
,
copy
:
bool
=
False
,
gc
:
bool
=
True
,
locales
:
bool
=
False
,
locales
:
bool
=
False
,
only_prepare
:
bool
=
False
only_prepare
:
bool
=
False
)
->
None
:
)
->
None
:
...
@@ -366,6 +369,9 @@ class TestContainers(BaseTest):
...
@@ -366,6 +369,9 @@ class TestContainers(BaseTest):
if
copy
:
if
copy
:
argv
.
extend
([
'
--copy-runtime-into
'
,
temp
])
argv
.
extend
([
'
--copy-runtime-into
'
,
temp
])
if
not
gc
:
argv
.
append
(
'
--no-gc-runtimes
'
)
if
only_prepare
:
if
only_prepare
:
argv
.
append
(
'
--only-prepare
'
)
argv
.
append
(
'
--only-prepare
'
)
else
:
else
:
...
@@ -378,9 +384,38 @@ class TestContainers(BaseTest):
...
@@ -378,9 +384,38 @@ class TestContainers(BaseTest):
os
.
path
.
join
(
self
.
artifacts
,
'
tmp
'
,
'
inside-scout.py
'
),
os
.
path
.
join
(
self
.
artifacts
,
'
tmp
'
,
'
inside-scout.py
'
),
])
])
with
tee_file_and_stderr
(
# Create directories representing previous runs of
# pressure-vessel-wrap, so that we can assert that they are
# GC'd (or not) as desired.
# Do not delete because its name does not start with tmp-
os
.
makedirs
(
os
.
path
.
join
(
temp
,
'
donotdelete
'
),
exist_ok
=
True
)
# Delete
os
.
makedirs
(
os
.
path
.
join
(
temp
,
'
tmp-deleteme
'
),
exist_ok
=
True
)
# Delete, and assert that it is recursive
os
.
makedirs
(
os
.
path
.
join
(
temp
,
'
tmp-deleteme2
'
,
'
usr
'
,
'
lib
'
),
exist_ok
=
True
,
)
# Do not delete because it has ./keep
os
.
makedirs
(
os
.
path
.
join
(
temp
,
'
tmp-keep
'
,
'
keep
'
),
exist_ok
=
True
)
# Do not delete because we will read-lock .ref
os
.
makedirs
(
os
.
path
.
join
(
temp
,
'
tmp-rlock
'
),
exist_ok
=
True
)
# Do not delete because we will write-lock .ref
os
.
makedirs
(
os
.
path
.
join
(
temp
,
'
tmp-wlock
'
),
exist_ok
=
True
)
with
open
(
os
.
path
.
join
(
temp
,
'
tmp-rlock
'
,
'
.ref
'
),
'
w+
'
)
as
rlock_writer
,
open
(
os
.
path
.
join
(
temp
,
'
tmp-wlock
'
,
'
.ref
'
),
'
w
'
)
as
wlock_writer
,
tee_file_and_stderr
(
os
.
path
.
join
(
artifacts
,
'
inside-scout.log
'
)
os
.
path
.
join
(
artifacts
,
'
inside-scout.log
'
)
)
as
tee
:
)
as
tee
:
lockdata
=
struct
.
pack
(
'
hhlli
'
,
fcntl
.
F_RDLCK
,
0
,
0
,
0
,
0
)
fcntl
.
fcntl
(
rlock_writer
.
fileno
(),
fcntl
.
F_SETLKW
,
lockdata
)
lockdata
=
struct
.
pack
(
'
hhlli
'
,
fcntl
.
F_WRLCK
,
0
,
0
,
0
,
0
)
fcntl
.
fcntl
(
wlock_writer
.
fileno
(),
fcntl
.
F_SETLKW
,
lockdata
)
completed
=
self
.
run_subprocess
(
completed
=
self
.
run_subprocess
(
argv
,
argv
,
cwd
=
self
.
artifacts
,
cwd
=
self
.
artifacts
,
...
@@ -393,7 +428,29 @@ class TestContainers(BaseTest):
...
@@ -393,7 +428,29 @@ class TestContainers(BaseTest):
if
copy
:
if
copy
:
members
=
set
(
os
.
listdir
(
temp
))
members
=
set
(
os
.
listdir
(
temp
))
self
.
assertIn
(
'
.ref
'
,
members
)
self
.
assertIn
(
'
donotdelete
'
,
members
)
self
.
assertIn
(
'
tmp-keep
'
,
members
)
self
.
assertIn
(
'
tmp-rlock
'
,
members
)
self
.
assertIn
(
'
tmp-wlock
'
,
members
)
if
gc
:
self
.
assertNotIn
(
'
tmp-deleteme
'
,
members
)
self
.
assertNotIn
(
'
tmp-deleteme2
'
,
members
)
else
:
# These would have been deleted if not for --no-gc-runtimes
self
.
assertIn
(
'
tmp-deleteme
'
,
members
)
self
.
assertIn
(
'
tmp-deleteme2
'
,
members
)
members
.
discard
(
'
.ref
'
)
members
.
discard
(
'
.ref
'
)
members
.
discard
(
'
donotdelete
'
)
members
.
discard
(
'
tmp-deleteme
'
)
members
.
discard
(
'
tmp-deleteme2
'
)
members
.
discard
(
'
tmp-keep
'
)
members
.
discard
(
'
tmp-rlock
'
)
members
.
discard
(
'
tmp-wlock
'
)
# After discarding those, there should be exactly one left:
# the one we just created
self
.
assertEqual
(
len
(
members
),
1
)
self
.
assertEqual
(
len
(
members
),
1
)
tree
=
os
.
path
.
join
(
temp
,
members
.
pop
())
tree
=
os
.
path
.
join
(
temp
,
members
.
pop
())
...
@@ -429,7 +486,7 @@ class TestContainers(BaseTest):
...
@@ -429,7 +486,7 @@ class TestContainers(BaseTest):
)
)
with
self
.
subTest
(
'
copy
'
):
with
self
.
subTest
(
'
copy
'
):
self
.
_test_scout
(
'
scout_sysroot_copy
'
,
scout
,
copy
=
True
)
self
.
_test_scout
(
'
scout_sysroot_copy
'
,
scout
,
copy
=
True
,
gc
=
False
)
with
self
.
subTest
(
'
transient
'
):
with
self
.
subTest
(
'
transient
'
):
self
.
_test_scout
(
'
scout_sysroot
'
,
scout
,
locales
=
True
)
self
.
_test_scout
(
'
scout_sysroot
'
,
scout
,
locales
=
True
)
...
...
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