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
e6b3004d
Commit
e6b3004d
authored
4 years ago
by
Simon McVittie
Browse files
Options
Downloads
Patches
Plain Diff
tests: Test -adverb command
Signed-off-by:
Simon McVittie
<
smcv@collabora.com
>
parent
c7be64f7
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
tests/adverb.py
+96
-0
96 additions, 0 deletions
tests/adverb.py
tests/meson.build
+1
-0
1 addition, 0 deletions
tests/meson.build
with
97 additions
and
0 deletions
tests/adverb.py
0 → 100755
+
96
−
0
View file @
e6b3004d
#!/usr/bin/env python3
# Copyright 2020 Collabora Ltd.
#
# SPDX-License-Identifier: MIT
import
logging
import
os
import
signal
import
subprocess
import
sys
import
tempfile
try
:
import
typing
typing
# placate pyflakes
except
ImportError
:
pass
from
testutils
import
(
BaseTest
,
test_main
,
)
logger
=
logging
.
getLogger
(
'
test-adverb
'
)
class
TestAdverb
(
BaseTest
):
def
setUp
(
self
)
->
None
:
super
().
setUp
()
if
'
PRESSURE_VESSEL_UNINSTALLED
'
in
os
.
environ
:
self
.
adverb
=
self
.
command_prefix
+
[
os
.
path
.
join
(
self
.
top_builddir
,
'
src
'
,
'
pressure-vessel-adverb
'
),
]
else
:
self
.
skipTest
(
'
Not available as an installed-test
'
)
def
test_stdio_passthrough
(
self
)
->
None
:
proc
=
subprocess
.
Popen
(
self
.
adverb
+
[
'
--
'
,
'
sh
'
,
'
-euc
'
,
'''
if [
"
$(cat)
"
!=
"
hello, world!
"
]; then
exit 1
fi
echo $$
exec >/dev/null
exec sleep infinity
'''
,
],
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
2
,
universal_newlines
=
True
,
)
pid
=
0
try
:
stdin
=
proc
.
stdin
assert
stdin
is
not
None
stdin
.
write
(
'
hello, world!
'
)
stdin
.
close
()
stdout
=
proc
.
stdout
assert
stdout
is
not
None
pid
=
int
(
stdout
.
read
().
strip
())
finally
:
if
pid
:
os
.
kill
(
pid
,
signal
.
SIGTERM
)
else
:
proc
.
terminate
()
self
.
assertIn
(
proc
.
wait
(),
(
128
+
signal
.
SIGTERM
,
-
signal
.
SIGTERM
),
)
def
tearDown
(
self
)
->
None
:
super
().
tearDown
()
if
__name__
==
'
__main__
'
:
assert
sys
.
version_info
>=
(
3
,
4
),
\
'
Python 3.4+ is required
'
test_main
()
# vi: set sw=4 sts=4 et:
This diff is collapsed.
Click to expand it.
tests/meson.build
+
1
−
0
View file @
e6b3004d
...
...
@@ -31,6 +31,7 @@ test_env.set(
test_env
.
set
(
'PRESSURE_VESSEL_UNINSTALLED'
,
'yes'
)
tests
=
[
'adverb.py'
,
'cheap-copy.py'
,
'containers.py'
,
'invocation.py'
,
...
...
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