-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add gst_video_sync integration test #408
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#!/usr/bin/env python | ||
|
||
PKG = 'lg_media' | ||
NAME = 'test_gst_video_sync_integration' | ||
|
||
import unittest | ||
import rospy | ||
import json | ||
import subprocess | ||
import tempfile | ||
import wave | ||
from interactivespaces_msgs.msg import GenericMessage | ||
from contextlib import contextmanager | ||
|
||
|
||
@contextmanager | ||
def generate_silence(): | ||
with tempfile.NamedTemporaryFile() as f: | ||
wav = wave.open(f.name, mode='wb') | ||
wav.setsampwidth(2) | ||
wav.setnchannels(1) | ||
wav.setframerate(8000) | ||
wav.writeframes(bytes([0 * 800000])) | ||
wav.close() | ||
yield f.name | ||
|
||
|
||
class TestGstVideoSyncIntegration(unittest.TestCase): | ||
def setUp(self): | ||
self.scene_pub = rospy.Publisher('/director/scene', GenericMessage, queue_size=10) | ||
rospy.sleep(1) | ||
|
||
def test_scene(self): | ||
with generate_silence() as fname: | ||
content_url = 'file://{}'.format(fname) | ||
scene = { | ||
'name': NAME, | ||
'description': NAME, | ||
'duration': 60, | ||
'slug': NAME, | ||
'windows': [ | ||
{ | ||
'activity': 'video', | ||
'activity_config': { | ||
}, | ||
'assets': [ | ||
content_url, | ||
], | ||
'presentation_viewport': 'center', | ||
'width': 640, | ||
'height': 480, | ||
'x_coord': 0, | ||
'y_coord': 0, | ||
}, | ||
], | ||
} | ||
self.scene_pub.publish(GenericMessage(type='json', message=json.dumps(scene))) | ||
rospy.sleep(1) | ||
|
||
subprocess.check_call([ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. subprocess call - check for execution of untrusted input. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Starting a process with a partial executable path |
||
'pgrep', | ||
'-af', | ||
'gst_video_sync\s.*-u\s{}'.format(content_url), | ||
]) | ||
|
||
scene = { | ||
'name': NAME + '_off', | ||
'description': NAME + '_off', | ||
'duration': 0, | ||
'slug': NAME + '_off', | ||
'windows': [], | ||
} | ||
self.scene_pub.publish(GenericMessage(type='json', message=json.dumps(scene))) | ||
rospy.sleep(1) | ||
|
||
with self.assertRaises(subprocess.CalledProcessError): | ||
subprocess.check_call([ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. subprocess call - check for execution of untrusted input. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Starting a process with a partial executable path |
||
'pgrep', | ||
'-af', | ||
'gst_video_sync\s.*-u\s{}'.format(content_url), | ||
]) | ||
|
||
|
||
if __name__ == '__main__': | ||
import rostest | ||
rospy.init_node(NAME) | ||
rostest.rosrun(PKG, NAME, TestGstVideoSyncIntegration) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<launch> | ||
<param name="/viewport/center" value="640x480+0+0" /> | ||
<node name="gst_video_sync" pkg="lg_media" type="gstreamer.py"> | ||
<param name="viewport" value="center" /> | ||
</node> | ||
<test test-name="test_gst_video_sync_integration" pkg="lg_media" type="test_gst_video_sync_integration.py" /> | ||
</launch> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider possible security implications associated with subprocess module.