]> git.proxmox.com Git - swtpm.git/commitdiff
tests: Use python twisted for sendmsg on python 2
authorStefan Berger <stefanb@linux.vnet.ibm.com>
Fri, 29 Sep 2017 17:53:06 +0000 (13:53 -0400)
committerStefan Berger <stefanb@linux.vnet.ibm.com>
Fri, 29 Sep 2017 18:15:26 +0000 (14:15 -0400)
Rather than sending two separate messages with the bare python 2
API, use the python twisted package to send the control and data
in one sendmsg() call. This avoids occasional test failures in
the ctrlchannel test case that is currently sending the data and
control part of the message in 2 steps, which can lead to the
recpient not seeing the whole message.

Add python-twisted as a build dependency to the rpm and Debian
builds and the .travis.yml.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
.travis.yml
debian/control
dist/swtpm.spec
dist/swtpm.spec.in
tests/test_setdatafd.py

index 4bbb8280fe0e2e0141f2339c682894bc6088c6e3..129741dfefaea7fc50569d0ca4f2a7af8877f66c 100644 (file)
@@ -9,6 +9,7 @@ before_install:
 - pep8 $(find . -type f | grep -E "\.py$")
 - sudo apt-get -y install automake autoconf libtool libssl-dev sed make gawk sed bash
   dh-exec
+- sudo pip install twisted
 - git clone https://github.com/stefanberger/libtpms
 - cd libtpms
 - git checkout origin/tpm2-preview.rev146 -b tpm2-preview.rev146
index eeb44a1a164ca227a4009aaa3fe11823ff110ab3..a99281831c5b4534e3199f6a4f4704335ed62b63 100644 (file)
@@ -16,6 +16,7 @@ Build-Depends: automake,
               socat,
               findutils,
               tpm-tools (>= 1.3.8),
+              python-twisted
 # linux-image-extra
 
 Package: swtpm
index 148af2f4ff98ac3b516a6b6bf43d94da1831d2dd..ab0db406e56d2b70fd2bc125d260bb62f3d4e169 100644 (file)
@@ -27,7 +27,7 @@ BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root
 
 BuildRequires:  automake autoconf bash coreutils libtool sed
 BuildRequires:  libtpms-devel fuse-devel glib2-devel gmp-devel
-BuildRequires:  expect bash net-tools nss-devel socat
+BuildRequires:  expect bash net-tools nss-devel socat python-twisted
 %if %{with_gnutls}
 BuildRequires:  gnutls >= 3.1.0 gnutls-devel gnutls-utils
 BuildRequires:  libtasn1-devel libtasn1
index bee2344f58a7068fe325f6c0e400c65d982893e6..db34517521feffc444c2920cb914ec43af7743df 100644 (file)
@@ -27,7 +27,7 @@ BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root
 
 BuildRequires:  automake autoconf bash coreutils libtool sed
 BuildRequires:  libtpms-devel fuse-devel glib2-devel gmp-devel
-BuildRequires:  expect bash net-tools nss-devel socat
+BuildRequires:  expect bash net-tools nss-devel socat python-twisted
 %if %{with_gnutls}
 BuildRequires:  gnutls >= 3.1.0 gnutls-devel gnutls-utils
 BuildRequires:  libtasn1-devel libtasn1
index 74351d1965aa41ce6408615b1bb0a2bea9a51b60..114432ab10646f152fe2c345f218e24fd6ac871b 100755 (executable)
@@ -6,9 +6,10 @@ import socket
 import subprocess
 import time
 import struct
+
 from array import array
 if sys.version_info[0] < 3:
-    import _multiprocessing
+    import twisted.python.sendmsg as sendmsg
 
 
 def toString(arr):
@@ -56,8 +57,10 @@ def test_SetDatafd():
         ctrlfd.connect(sock_path)
         print("Sending data fd over ctrl fd...")
         if sys.version_info[0] < 3:
-            ctrlfd.send(cmd_set_data_fd)
-            _multiprocessing.sendfd(ctrlfd.fileno(), _fd.fileno())
+            sendmsg.sendmsg(ctrlfd, str(cmd_set_data_fd),
+                            [(socket.SOL_SOCKET,
+                              sendmsg.SCM_RIGHTS,
+                              struct.pack("i", _fd.fileno()))])
         else:
             ctrlfd.sendmsg([cmd_set_data_fd],
                            [(socket.SOL_SOCKET, socket.SCM_RIGHTS, fds)])