mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-18 18:56:21 +00:00
They were disabled in 171b6e73c9.
Enable the functional test suite and replaces the
dependency on libexpect with a custom solution.
The native solution allows for specific optimizations like automatic
ANSI code stripping, which is essential for reliable pattern matching in
an ncurses interface.
Custom PTY management via libutil provides full control over the process
lifecycle, resolving issues where tests would hang indefinitely.
We use forkpty from libutil.
Addiiotnally this commit implements automatic ANSI escape sequence
filtering to improve matching consistency.
This will get rid of the colors in matches. It's still something that we
need to think about more since basically we will not test out
color/theme system this way.
We also add non-blocking poll() and SIGKILL based teardown logic to
ensure clean test termination.
We added the functional tests to both autotools and meson.
They are only build when tests are enabled and stabber + libutil are
present.
Meson will print this out nicely in the summary.
Regards https://github.com/profanity-im/profanity/issues/789
153 lines
5.4 KiB
C
153 lines
5.4 KiB
C
#include <glib.h>
|
|
#include "prof_cmocka.h"
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include <stabber.h>
|
|
|
|
#include "proftest.h"
|
|
|
|
void
|
|
ping_server(void** state)
|
|
{
|
|
stbbr_for_id("prof_disco_info_onconnect_*",
|
|
"<iq id='prof_disco_info_onconnect_*' to='stabber@localhost/profanity' type='result' from='localhost'>"
|
|
"<query xmlns='http://jabber.org/protocol/disco#info'>"
|
|
"<identity category='server' type='im' name='Prosody'/>"
|
|
"<feature var='urn:xmpp:ping'/>"
|
|
"</query>"
|
|
"</iq>");
|
|
|
|
stbbr_for_id("prof_ping_*",
|
|
"<iq id='prof_ping_*' type='result' to='stabber@localhost/profanity'/>");
|
|
stbbr_for_id("prof_ping_*",
|
|
"<iq id='prof_ping_*' type='result' to='stabber@localhost/profanity'/>");
|
|
|
|
prof_connect();
|
|
|
|
prof_input("/ping");
|
|
assert_true(stbbr_received(
|
|
"<iq id='prof_ping_*' type='get'>"
|
|
"<ping xmlns='urn:xmpp:ping'/>"
|
|
"</iq>"));
|
|
assert_true(prof_output_exact("Ping response from server"));
|
|
|
|
prof_input("/ping");
|
|
assert_true(stbbr_received(
|
|
"<iq id='prof_ping_*' type='get'>"
|
|
"<ping xmlns='urn:xmpp:ping'/>"
|
|
"</iq>"));
|
|
assert_true(prof_output_exact("Ping response from server"));
|
|
}
|
|
|
|
void
|
|
ping_server_not_supported(void** state)
|
|
{
|
|
stbbr_for_id("prof_disco_info_onconnect_*",
|
|
"<iq id='prof_disco_info_onconnect_*' to='stabber@localhost/profanity' type='result' from='localhost'>"
|
|
"<query xmlns='http://jabber.org/protocol/disco#info'>"
|
|
"<identity category='server' type='im' name='Stabber'/>"
|
|
"</query>"
|
|
"</iq>");
|
|
|
|
prof_connect();
|
|
|
|
prof_input("/ping");
|
|
assert_true(prof_output_exact("Server does not support ping requests."));
|
|
}
|
|
|
|
void
|
|
ping_responds_to_server_request(void** state)
|
|
{
|
|
prof_connect();
|
|
|
|
stbbr_send(
|
|
"<iq id='pingtest1' type='get' to='stabber@localhost/profanity' from='localhost'>"
|
|
"<ping xmlns='urn:xmpp:ping'/>"
|
|
"</iq>");
|
|
|
|
assert_true(stbbr_received(
|
|
"<iq id='pingtest1' type='result' from='stabber@localhost/profanity' to='localhost'/>"));
|
|
}
|
|
|
|
void
|
|
ping_jid(void** state)
|
|
{
|
|
stbbr_for_id("prof_caps_*",
|
|
"<iq id='prof_caps_*' to='stabber@localhost/profanity' type='result' from='buddy1@localhost/mobile'>"
|
|
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='>"
|
|
"<identity category='client' type='console' name='Profanity0.6.0'/>"
|
|
"<feature var='urn:xmpp:ping'/>"
|
|
"<feature var='http://jabber.org/protocol/disco#info'/>"
|
|
"<feature var='http://jabber.org/protocol/caps'/>"
|
|
"</query>"
|
|
"</iq>");
|
|
|
|
prof_connect();
|
|
|
|
stbbr_send(
|
|
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
|
|
"<priority>10</priority>"
|
|
"<status>I'm here</status>"
|
|
"<c "
|
|
"hash='sha-1' "
|
|
"xmlns='http://jabber.org/protocol/caps' "
|
|
"node='http://profanity-im.github.io' "
|
|
"ver='LpT2xs3nun7jC2sq4gg3WRDQFZ4='"
|
|
"/>"
|
|
"</presence>");
|
|
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
|
|
|
|
assert_true(stbbr_received(
|
|
"<iq id='prof_caps_*' to='buddy1@localhost/mobile' type='get'>"
|
|
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='/>"
|
|
"</iq>"));
|
|
|
|
stbbr_for_id("prof_ping_*",
|
|
"<iq from='buddy1@localhost/mobile' to='stabber@localhost' id='prof_ping_*' type='result'/>");
|
|
|
|
prof_input("/ping buddy1@localhost/mobile");
|
|
|
|
assert_true(stbbr_received(
|
|
"<iq id='prof_ping_*' type='get' to='buddy1@localhost/mobile'>"
|
|
"<ping xmlns='urn:xmpp:ping'/>"
|
|
"</iq>"));
|
|
assert_true(prof_output_exact("Ping response from buddy1@localhost/mobile"));
|
|
}
|
|
|
|
void
|
|
ping_jid_not_supported(void** state)
|
|
{
|
|
stbbr_for_id("prof_caps_*",
|
|
"<iq id='prof_caps_*' to='stabber@localhost/profanity' type='result' from='buddy1@localhost/mobile'>"
|
|
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='>"
|
|
"<identity category='client' type='console' name='Profanity0.6.0'/>"
|
|
"<feature var='http://jabber.org/protocol/disco#info'/>"
|
|
"<feature var='http://jabber.org/protocol/caps'/>"
|
|
"</query>"
|
|
"</iq>");
|
|
|
|
prof_connect();
|
|
|
|
stbbr_send(
|
|
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
|
|
"<priority>10</priority>"
|
|
"<status>I'm here</status>"
|
|
"<c "
|
|
"hash='sha-1' "
|
|
"xmlns='http://jabber.org/protocol/caps' "
|
|
"node='http://profanity-im.github.io' "
|
|
"ver='LpT2xs3nun7jC2sq4gg3WRDQFZ4='"
|
|
"/>"
|
|
"</presence>");
|
|
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
|
|
|
|
assert_true(stbbr_received(
|
|
"<iq id='prof_caps_*' to='buddy1@localhost/mobile' type='get'>"
|
|
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='/>"
|
|
"</iq>"));
|
|
|
|
prof_input("/ping buddy1@localhost/mobile");
|
|
assert_true(prof_output_exact("buddy1@localhost/mobile does not support ping requests."));
|
|
}
|