Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[telepathy-gabble] Fix running some tests. Contributes to JB#42708
All of these were failing on readlink parameter busybox doesn't
support. Changed that.

For rest the python3 port seems halfway there, failing a lot on
bytes vs strings typing. Fixed some of those, not sure would it be
worth the effort in handling all if we don't really do telepathy-gabble
development.

Now 132 out of 245 pass which is already quite a lot better.
  • Loading branch information
pvuorela committed Mar 22, 2021
1 parent 1cd8837 commit ca33343
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 18 deletions.
2 changes: 1 addition & 1 deletion rpm/0001-Change-test-dir.patch
@@ -1,7 +1,7 @@
From d7a1817b963b54a82fd33fc6a750cc2785379011 Mon Sep 17 00:00:00 2001
From: Pekka Vuorela <pekka.vuorela@jolla.com>
Date: Mon, 22 Mar 2021 15:53:39 +0200
Subject: [PATCH 1/6] Change test dir
Subject: [PATCH 1/7] Change test dir

---
configure.ac | 2 +-
Expand Down
@@ -1,7 +1,7 @@
From db4530c886411b3925a566a8eb7d3494f6894429 Mon Sep 17 00:00:00 2001
From: John Brooks <john.brooks@jollamobile.com>
Date: Tue, 10 Dec 2013 19:45:53 -0700
Subject: [PATCH 2/6] Change default keepalive-interval to 2.5 minutes
Subject: [PATCH 2/7] Change default keepalive-interval to 2.5 minutes

Waking up and sending packets at 30 second intervals is unreasonable for
mobile, and seems more frequent than actually necessary. An interval of
Expand Down
@@ -1,7 +1,7 @@
From bc814d028d6a733b93f839767f693b4f5d1744bf Mon Sep 17 00:00:00 2001
From: Islam Amer <islam.amer@jollamobile.com>
Date: Wed, 30 Apr 2014 00:30:43 +0300
Subject: [PATCH 3/6] switch to using gireactor to work with new gi based
Subject: [PATCH 3/7] switch to using gireactor to work with new gi based
pygobject2

---
Expand Down
@@ -1,7 +1,7 @@
From 2bbcbb875e2e434c658e9a0d79b5d0deca3e2ab1 Mon Sep 17 00:00:00 2001
From: Debarshi Ray <debarshir@freedesktop.org>
Date: Tue, 5 Nov 2013 16:42:06 +0100
Subject: [PATCH 4/6] xmpp-console: Explicitly state python in the shebang
Subject: [PATCH 4/7] xmpp-console: Explicitly state python in the shebang

This will make sure that we are not running against an unwanted version
of Python offered by a software collection.
Expand Down
2 changes: 1 addition & 1 deletion rpm/0005-Port-tools-to-python3.patch
@@ -1,7 +1,7 @@
From d25b5f74758f0e13f08ef9aa5a061f5040299845 Mon Sep 17 00:00:00 2001
From: Pekka Vuorela <pekka.vuorela@jolla.com>
Date: Mon, 22 Mar 2021 15:51:15 +0200
Subject: [PATCH 5/6] Port tools to python3
Subject: [PATCH 5/7] Port tools to python3

---
tools/c-constants-gen.py | 6 ++---
Expand Down
55 changes: 42 additions & 13 deletions rpm/0006-Port-tests-to-python3.patch
@@ -1,10 +1,10 @@
From cad5cc81187e290f62fb62abc6553c0570058416 Mon Sep 17 00:00:00 2001
From 3855763b9a9c91850fe56d880b427396743f0055 Mon Sep 17 00:00:00 2001
From: Pekka Vuorela <pekka.vuorela@jolla.com>
Date: Mon, 22 Mar 2021 15:51:58 +0200
Subject: [PATCH 6/6] Port tests to python3
Subject: [PATCH 6/7] Port tests to python3

---
tests/twisted/addressing.py | 22 ++++----
tests/twisted/addressing.py | 22 +++----
tests/twisted/bytestream.py | 4 +-
tests/twisted/caps/advertise-contact-caps.py | 2 +-
tests/twisted/caps/advertise-legacy.py | 8 +--
Expand All @@ -16,7 +16,7 @@ Subject: [PATCH 6/6] Port tests to python3
tests/twisted/caps/jingle-caps.py | 2 +-
tests/twisted/caps/receive-jingle.py | 30 +++++-----
tests/twisted/caps/trust-thyself.py | 8 +--
tests/twisted/caps_helper.py | 30 +++++-----
tests/twisted/caps_helper.py | 36 ++++++------
tests/twisted/client-types.py | 2 +-
tests/twisted/cm/protocol.py | 6 +-
.../connect/disco-error-from-bare-jid.py | 2 +-
Expand Down Expand Up @@ -44,7 +44,7 @@ Subject: [PATCH 6/6] Port tests to python3
.../test-send-file-to-unknown-contact.py | 4 +-
.../test-send-file-wait-to-provide.py | 2 +-
tests/twisted/file-transfer/test-uri.py | 2 +-
tests/twisted/gabbletest.py | 56 +++++++++----------
tests/twisted/gabbletest.py | 58 +++++++++----------
tests/twisted/gateways.py | 2 +-
.../jingle-share/file_transfer_helper.py | 2 +-
.../jingle-share/test-caps-file-transfer.py | 4 +-
Expand Down Expand Up @@ -82,7 +82,7 @@ Subject: [PATCH 6/6] Port tests to python3
tests/twisted/jingle/incoming-basics.py | 6 +-
.../jingle/incoming-call-stream-error.py | 6 +-
.../jingle/incoming-gmail-modern-jingle.py | 4 +-
tests/twisted/jingle/initial-audio-video.py | 25 +++++----
tests/twisted/jingle/initial-audio-video.py | 25 ++++----
tests/twisted/jingle/jingletest2.py | 8 +--
tests/twisted/jingle/misuse.py | 8 +--
tests/twisted/jingle/outgoing-basics.py | 6 +-
Expand All @@ -106,7 +106,7 @@ Subject: [PATCH 6/6] Port tests to python3
tests/twisted/jingle/test-wait-for-caps.py | 4 +-
.../twisted/jingle/transport-info-parsing.py | 4 +-
tests/twisted/jingle/unknown-session.py | 4 +-
tests/twisted/mail-notification.py | 16 +++---
tests/twisted/mail-notification.py | 16 ++---
tests/twisted/muc/banned.py | 2 +-
tests/twisted/muc/chat-states.py | 2 +-
tests/twisted/muc/kicked.py | 2 +-
Expand Down Expand Up @@ -163,7 +163,7 @@ Subject: [PATCH 6/6] Port tests to python3
tests/twisted/vcard/get-contact-info.py | 12 ++--
tests/twisted/vcard/overlapping-sets.py | 6 +-
tests/twisted/vcard/refresh-contact-info.py | 12 ++--
tests/twisted/vcard/set-contact-info.py | 50 ++++++++---------
tests/twisted/vcard/set-contact-info.py | 50 ++++++++--------
tests/twisted/vcard/supported-fields.py | 2 +-
tests/twisted/vcard/test-alias-empty-vcard.py | 2 +-
tests/twisted/vcard/test-alias-message.py | 8 +--
Expand All @@ -173,7 +173,7 @@ Subject: [PATCH 6/6] Port tests to python3
tests/twisted/vcard/test-avatar-tokens.py | 2 +-
tests/twisted/vcard/test-set-alias.py | 12 ++--
tests/twisted/vcard/update-get-failed.py | 2 +-
169 files changed, 591 insertions(+), 590 deletions(-)
169 files changed, 595 insertions(+), 594 deletions(-)

diff --git a/tests/twisted/addressing.py b/tests/twisted/addressing.py
index 9528e12cb..a0d50b55f 100644
Expand Down Expand Up @@ -542,7 +542,7 @@ index 34a145b62..12f7b2ac7 100644
caps = conn.Capabilities.AdvertiseCapabilities(add, remove)

diff --git a/tests/twisted/caps_helper.py b/tests/twisted/caps_helper.py
index 11b05d9d8..e55b217a6 100644
index 11b05d9d8..399108bb8 100644
--- a/tests/twisted/caps_helper.py
+++ b/tests/twisted/caps_helper.py
@@ -161,12 +161,12 @@ def compute_caps_hash(identities, features, dataforms):
Expand All @@ -569,6 +569,15 @@ index 11b05d9d8..e55b217a6 100644
field = x.addElement('field')
field['var'] = var

@@ -285,7 +285,7 @@ def disco_caps(q, stream, presence):
(identities, features, dataforms) = extract_disco_parts(event.stanza)

# Check if the hash matches the announced capabilities
- assertEquals(compute_caps_hash(identities, features, dataforms), ver)
+ assertEquals(compute_caps_hash(identities, features, dataforms), ver.encode())

return (event, features, dataforms)

@@ -323,7 +323,7 @@ def send_presence(q, conn, stream, contact, caps, initial=True, show=None):

q.expect('dbus-signal', signal='PresencesChanged',
Expand All @@ -578,7 +587,16 @@ index 11b05d9d8..e55b217a6 100644

# no special capabilities
assertEquals([(h, cs.CHANNEL_TYPE_TEXT, 3, 0)],
@@ -356,20 +356,20 @@ if __name__ == '__main__':
@@ -347,7 +347,7 @@ def send_disco_reply(stream, stanza, identities, features, dataforms={}):

if __name__ == '__main__':
# example from XEP-0115
- assertEquals('QgayPKawpkPSDYmwT/WM94uAlu0=',
+ assertEquals(b'QgayPKawpkPSDYmwT/WM94uAlu0=',
compute_caps_hash(['client/pc//Exodus 0.9.1'],
["http://jabber.org/protocol/disco#info",
"http://jabber.org/protocol/disco#items",
@@ -356,21 +356,21 @@ if __name__ == '__main__':
{}))

# another example from XEP-0115
Expand Down Expand Up @@ -609,7 +627,9 @@ index 11b05d9d8..e55b217a6 100644
+ 'software_version': ['0.11'],
},
}
assertEquals('q07IKJEyjvHSyhy//CH0CxmKi8w=',
- assertEquals('q07IKJEyjvHSyhy//CH0CxmKi8w=',
+ assertEquals(b'q07IKJEyjvHSyhy//CH0CxmKi8w=',
compute_caps_hash(identities, features, dataforms))
diff --git a/tests/twisted/client-types.py b/tests/twisted/client-types.py
index 2eaeebedb..c4ad5170f 100644
--- a/tests/twisted/client-types.py
Expand Down Expand Up @@ -1089,7 +1109,7 @@ index b8b6dee0d..d6960c1b7 100644

def assertNoURI(ft_channel):
diff --git a/tests/twisted/gabbletest.py b/tests/twisted/gabbletest.py
index e6b8baa0e..01474ca5f 100644
index e6b8baa0e..34165f619 100644
--- a/tests/twisted/gabbletest.py
+++ b/tests/twisted/gabbletest.py
@@ -75,7 +75,7 @@ def make_muc_presence(affiliation, role, muc_jid, alias, jid=None, photo=None):
Expand Down Expand Up @@ -1133,6 +1153,15 @@ index e6b8baa0e..01474ca5f 100644

self.xmlstream.sendHeader()

@@ -233,7 +233,7 @@ class XmppAuthenticator(GabbleAuthenticator):

def auth(self, auth):
assert (base64.b64decode(str(auth)) ==
- '\x00%s\x00%s' % (self.username, self.password))
+ ('\x00%s\x00%s' % (self.username, self.password)).encode())

success = domish.Element((ns.NS_XMPP_SASL, 'success'))
self.xmlstream.send(success)
@@ -304,8 +304,8 @@ class StreamFactory(twisted.internet.protocol.Factory):
self.streams = streams
self.jids = jids
Expand Down
28 changes: 28 additions & 0 deletions rpm/0007-Switch-readlink-parameter-from-e-to-f.patch
@@ -0,0 +1,28 @@
From ba755ff4768b3f38d0c174984782b6cf0bf06873 Mon Sep 17 00:00:00 2001
From: Pekka Vuorela <pekka.vuorela@jolla.com>
Date: Mon, 22 Mar 2021 16:00:21 +0200
Subject: [PATCH 7/7] Switch readlink parameter from -e to -f

Should be good enough here and works with the busybox tool.
---
tests/twisted/run-test.sh.in | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/twisted/run-test.sh.in b/tests/twisted/run-test.sh.in
index 8dd5fd660..99f3f3358 100644
--- a/tests/twisted/run-test.sh.in
+++ b/tests/twisted/run-test.sh.in
@@ -1,8 +1,8 @@
#!/bin/sh

if test "x$GABBLE_TEST_UNINSTALLED" = x; then
- script_fullname=`readlink -e "@gabbletestsdir@/twisted/run-test.sh"`
- if [ `readlink -e "$0"` != "$script_fullname" ] ; then
+ script_fullname=`readlink -f "@gabbletestsdir@/twisted/run-test.sh"`
+ if [ `readlink -f "$0"` != "$script_fullname" ] ; then
echo "This script is meant to be installed at $script_fullname" >&2
exit 1
fi
--
2.30.2

2 changes: 2 additions & 0 deletions rpm/telepathy-gabble.spec
Expand Up @@ -13,6 +13,7 @@ Patch3: 0003-switch-to-using-gireactor-to-work-with-new-gi-based-.patch
Patch4: 0004-xmpp-console-Explicitly-state-python-in-the-shebang.patch
Patch5: 0005-Port-tools-to-python3.patch
Patch6: 0006-Port-tests-to-python3.patch
Patch7: 0007-Switch-readlink-parameter-from-e-to-f.patch
Patch20: wocky-Make-GTK-Docs-optional.patch
Patch21: wocky-fix-mem-leak.patch
Patch22: wocky-openssl-1.1-compat.patch
Expand Down Expand Up @@ -73,6 +74,7 @@ The %{name}-tests package contains tests and tests.xml for automated testing.
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1

%__cp %{SOURCE1} tests/
%__cp %{SOURCE2} tests/
Expand Down

0 comments on commit ca33343

Please sign in to comment.