mirror of
https://github.com/stefanberger/swtpm.git
synced 2026-08-24 18:53:29 +00:00
tests: Use python twisted for sendmsg on python 2
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>
This commit is contained in:
parent
a00e882c0a
commit
5c7f8386ce
@ -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
|
||||
|
||||
1
debian/control
vendored
1
debian/control
vendored
@ -16,6 +16,7 @@ Build-Depends: automake,
|
||||
socat,
|
||||
findutils,
|
||||
tpm-tools (>= 1.3.8),
|
||||
python-twisted
|
||||
# linux-image-extra
|
||||
|
||||
Package: swtpm
|
||||
|
||||
2
dist/swtpm.spec
vendored
2
dist/swtpm.spec
vendored
@ -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
|
||||
|
||||
2
dist/swtpm.spec.in
vendored
2
dist/swtpm.spec.in
vendored
@ -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
|
||||
|
||||
@ -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)])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user