[3/4] test/others/rpc: also run RPC version command via service

Submitted by Adrian Reber on May 31, 2018, 9 a.m.

Details

Message ID 1527757205-12889-4-git-send-email-adrian@lisas.de
State Accepted
Series "Series without cover letter"
Commit 2d4209add303b6c0798219d2d77fed6dda7900af
Headers show

Commit Message

Adrian Reber May 31, 2018, 9 a.m.
From: Adrian Reber <areber@redhat.com>

This extends the test.py to also run the RPC command VERSION via 'criu
service'. It was already running using 'criu swrk'.

Signed-off-by: Adrian Reber <areber@redhat.com>
---
 test/others/rpc/test.py | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

Patch hide | download patch | download mbox

diff --git a/test/others/rpc/test.py b/test/others/rpc/test.py
index 601a34f..63eef37 100755
--- a/test/others/rpc/test.py
+++ b/test/others/rpc/test.py
@@ -42,3 +42,40 @@  else:
 
 	if resp.dump.restored:
 		print 'Restored'
+
+# Connect to service socket
+s = socket.socket(socket.AF_UNIX, socket.SOCK_SEQPACKET)
+s.connect(args['socket'])
+
+# Create criu msg, set it's type to dump request
+# and set dump options. Checkout more options in protobuf/rpc.proto
+req = rpc.criu_req()
+req.type = rpc.VERSION
+
+# Send request
+s.send(req.SerializeToString())
+
+# Recv response
+resp = rpc.criu_resp()
+MAX_MSG_SIZE = 1024
+resp.ParseFromString(s.recv(MAX_MSG_SIZE))
+
+if resp.type != rpc.VERSION:
+	print('RPC: Unexpected msg type')
+	sys.exit(-1)
+else:
+	if resp.success:
+		print('RPC: Success')
+		print('CRIU major %d' % resp.version.major)
+		print('CRIU minor %d' % resp.version.minor)
+		if resp.version.HasField('gitid'):
+			print('CRIU gitid %s' % resp.version.gitid)
+		if resp.version.HasField('sublevel'):
+			print('CRIU sublevel %s' % resp.version.sublevel)
+		if resp.version.HasField('extra'):
+			print('CRIU extra %s' % resp.version.extra)
+		if resp.version.HasField('name'):
+			print('CRIU name %s' % resp.version.name)
+	else:
+		print 'Fail'
+		sys.exit(-1)