Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pcl-expect
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
Per Cederqvist
pcl-expect
Commits
c70a2dfe
Commit
c70a2dfe
authored
20 years ago
by
Per Cederqvist
Browse files
Options
Downloads
Patches
Plain Diff
Initial commit.
parent
025a1b0f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
test/.cvsignore
+2
-0
2 additions, 0 deletions
test/.cvsignore
test/__init__.py
+0
-0
0 additions, 0 deletions
test/__init__.py
test/test_popen.py
+104
-0
104 additions, 0 deletions
test/test_popen.py
test/test_spawn.py
+46
-0
46 additions, 0 deletions
test/test_spawn.py
with
152 additions
and
0 deletions
test/.cvsignore
0 → 100644
+
2
−
0
View file @
c70a2dfe
*.pyc
*.pyo
This diff is collapsed.
Click to expand it.
test/__init__.py
0 → 100644
+
0
−
0
View file @
c70a2dfe
This diff is collapsed.
Click to expand it.
test/test_popen.py
0 → 100644
+
104
−
0
View file @
c70a2dfe
#!/usr/bin/env python
import
unittest
import
time
import
signal
from
pcl_expect
import
Controller
from
pcl_expect.popen
import
Popen
class
Timeout
(
Exception
):
pass
def
handler
(
signo
,
stk
):
raise
Timeout
()
class
TestPopen
(
unittest
.
TestCase
):
def
setUp
(
self
):
signal
.
signal
(
signal
.
SIGALRM
,
handler
)
signal
.
alarm
(
20
)
def
tearDown
(
self
):
signal
.
alarm
(
0
)
def
test_popen_sleep_1
(
self
):
t0
=
time
.
time
()
sleeper
=
Popen
(
'
sleep 1
'
)
x
=
Controller
()
while
x
.
loop
():
if
sleeper
.
re
(
x
,
'
.
'
):
self
.
fail
(
'
got output from sleep
'
)
elif
x
.
timeout
():
self
.
fail
(
'
timeout waiting for sleep to terminate
'
)
elif
sleeper
.
eof
(
x
):
break
status
=
sleeper
.
close
()
self
.
assertEqual
(
status
,
None
)
t1
=
time
.
time
()
self
.
assertAlmostEqual
(
t0
+
1.0
,
t1
,
1
,
'
sleep 1 slept too long or too short
'
)
def
test_popen_sleep_1_compat
(
self
):
t0
=
time
.
time
()
sleeper
=
Popen
(
'
sleep 1
'
)
x
=
Controller
()
while
x
.
loop
():
if
x
.
re
(
sleeper
,
'
.
'
):
self
.
fail
(
'
got output from sleep
'
)
elif
x
.
timeout
():
self
.
fail
(
'
timeout waiting for sleep to terminate
'
)
elif
x
.
eof
(
sleeper
):
break
status
=
sleeper
.
close
()
self
.
assertEqual
(
status
,
None
)
t1
=
time
.
time
()
self
.
assertAlmostEqual
(
t0
+
1.0
,
t1
,
1
,
'
sleep 1 slept too long or too short
'
)
def
test_read_hello
(
self
):
hello
=
Popen
(
'
echo hello, world
'
)
x
=
Controller
()
while
x
.
loop
():
if
hello
.
re
(
x
,
'
hello, world
\n
'
):
break
x
=
Controller
()
while
x
.
loop
():
if
hello
.
eof
(
x
):
break
status
=
hello
.
close
()
self
.
assertEqual
(
status
,
None
)
def
test_read_hello_partial
(
self
):
hello
=
Popen
(
'
echo hello, world
'
)
x
=
Controller
()
while
x
.
loop
():
if
hello
.
re
(
x
,
'
hello
'
):
break
x
=
Controller
()
while
x
.
loop
():
if
hello
.
re
(
x
,
'
, world
'
):
break
x
=
Controller
()
while
x
.
loop
():
if
hello
.
re
(
x
,
'
\n
'
):
break
x
=
Controller
()
while
x
.
loop
():
if
hello
.
eof
(
x
):
break
status
=
hello
.
close
()
self
.
assertEqual
(
status
,
None
)
def
test_read_hello_compat
(
self
):
hello
=
Popen
(
'
echo hello, world
'
)
x
=
Controller
()
while
x
.
loop
():
if
x
.
re
(
hello
,
'
hello, world
\n
'
):
break
x
=
Controller
()
while
x
.
loop
():
if
x
.
eof
(
hello
):
break
status
=
hello
.
close
()
self
.
assertEqual
(
status
,
None
)
if
__name__
==
'
__main__
'
:
unittest
.
main
()
This diff is collapsed.
Click to expand it.
test/test_spawn.py
0 → 100755
+
46
−
0
View file @
c70a2dfe
#!/usr/bin/env python
import
unittest
import
time
import
pcl_expect
import
pcl_expect.spawn
class
TestSpawn
(
unittest
.
TestCase
):
def
test_spawn_sleep_1
(
self
):
t0
=
time
.
time
()
sleeper
=
pcl_expect
.
spawn
.
Spawn
([
'
sleep
'
,
'
1
'
])
x
=
pcl_expect
.
Controller
()
while
x
.
loop
():
if
sleeper
.
re
(
x
,
'
.
'
):
self
.
fail
(
'
got output from sleep
'
)
elif
x
.
timeout
():
self
.
fail
(
'
timeout waiting for sleep to terminate
'
)
elif
sleeper
.
eof
(
x
):
break
pid
,
status
=
sleeper
.
close
()
self
.
assertEqual
(
status
,
0
)
t1
=
time
.
time
()
self
.
assertAlmostEqual
(
t0
+
1.0
,
t1
,
1
,
'
sleep 1 slept too long or too short
'
)
def
test_spawn_sleep_1_compat
(
self
):
t0
=
time
.
time
()
sleeper
=
pcl_expect
.
spawn
.
Spawn
([
'
sleep
'
,
'
1
'
])
x
=
pcl_expect
.
Controller
()
while
x
.
loop
():
if
x
.
re
(
sleeper
,
'
.
'
):
self
.
fail
(
'
got output from sleep
'
)
elif
x
.
timeout
():
self
.
fail
(
'
timeout waiting for sleep to terminate
'
)
elif
x
.
eof
(
sleeper
):
break
pid
,
status
=
sleeper
.
close
()
self
.
assertEqual
(
status
,
0
)
t1
=
time
.
time
()
self
.
assertAlmostEqual
(
t0
+
1.0
,
t1
,
1
,
'
sleep 1 slept too long or too short
'
)
if
__name__
==
'
__main__
'
:
unittest
.
main
()
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