Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
spbro
OpenXG-RAN
Commits
f21b5d2e
Commit
f21b5d2e
authored
Sep 25, 2024
by
Robert Schmidt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CI: Add basic unittest for cls_cmd
parent
606e2c74
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
0 deletions
+64
-0
ci-scripts/tests/cmd.py
ci-scripts/tests/cmd.py
+56
-0
ci-scripts/tests/scripts/hello-fail.sh
ci-scripts/tests/scripts/hello-fail.sh
+4
-0
ci-scripts/tests/scripts/hello-world.sh
ci-scripts/tests/scripts/hello-world.sh
+4
-0
No files found.
ci-scripts/tests/cmd.py
0 → 100644
View file @
f21b5d2e
import
sys
import
logging
logging
.
basicConfig
(
level
=
logging
.
DEBUG
,
stream
=
sys
.
stdout
,
format
=
"[%(asctime)s] %(levelname)8s: %(message)s"
)
import
os
import
unittest
sys
.
path
.
append
(
'./'
)
# to find OAI imports below
import
cls_cmd
class
TestCmd
(
unittest
.
TestCase
):
def
test_local_cmd
(
self
):
with
cls_cmd
.
getConnection
(
"localhost"
)
as
cmd
:
self
.
assertTrue
(
isinstance
(
cmd
,
cls_cmd
.
LocalCmd
))
with
cls_cmd
.
getConnection
(
"None"
)
as
cmd
:
self
.
assertTrue
(
isinstance
(
cmd
,
cls_cmd
.
LocalCmd
))
with
cls_cmd
.
getConnection
(
"none"
)
as
cmd
:
self
.
assertTrue
(
isinstance
(
cmd
,
cls_cmd
.
LocalCmd
))
with
cls_cmd
.
getConnection
(
None
)
as
cmd
:
self
.
assertTrue
(
isinstance
(
cmd
,
cls_cmd
.
LocalCmd
))
ret
=
cmd
.
run
(
"true"
)
self
.
assertEqual
(
ret
.
args
,
"true"
)
self
.
assertEqual
(
ret
.
returncode
,
0
)
self
.
assertEqual
(
ret
.
stdout
,
""
)
ret
=
cmd
.
run
(
"false"
)
self
.
assertEqual
(
ret
.
args
,
"false"
)
self
.
assertEqual
(
ret
.
returncode
,
1
)
self
.
assertEqual
(
ret
.
stdout
,
""
)
ret
=
cmd
.
run
(
"echo test"
)
self
.
assertEqual
(
ret
.
args
,
"echo test"
)
self
.
assertEqual
(
ret
.
returncode
,
0
)
self
.
assertEqual
(
ret
.
stdout
,
"test"
)
@
unittest
.
skip
(
"need to be able to passwordlessly SSH to localhost, also disable stty -ixon"
)
def
test_remote_cmd
(
self
):
with
cls_cmd
.
getConnection
(
"127.0.0.1"
)
as
cmd
:
self
.
assertTrue
(
isinstance
(
cmd
,
cls_cmd
.
RemoteCmd
))
ret
=
cmd
.
run
(
"true"
)
self
.
assertEqual
(
ret
.
args
,
"true"
)
self
.
assertEqual
(
ret
.
returncode
,
0
)
self
.
assertEqual
(
ret
.
stdout
,
""
)
ret
=
cmd
.
run
(
"false"
)
self
.
assertEqual
(
ret
.
args
,
"false"
)
self
.
assertEqual
(
ret
.
returncode
,
1
)
self
.
assertEqual
(
ret
.
stdout
,
""
)
ret
=
cmd
.
run
(
"echo test"
)
self
.
assertEqual
(
ret
.
args
,
"echo test"
)
self
.
assertEqual
(
ret
.
returncode
,
0
)
self
.
assertEqual
(
ret
.
stdout
,
"test"
)
if
__name__
==
'__main__'
:
unittest
.
main
()
ci-scripts/tests/scripts/hello-fail.sh
0 → 100755
View file @
f21b5d2e
#!/bin/bash
echo
$@
false
ci-scripts/tests/scripts/hello-world.sh
0 → 100755
View file @
f21b5d2e
#!/bin/bash
set
-x
echo
hello, world
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