mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-18 21:36: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
135 lines
3.8 KiB
C
135 lines
3.8 KiB
C
#include <glib.h>
|
|
#include "prof_cmocka.h"
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include <stabber.h>
|
|
|
|
#include "proftest.h"
|
|
|
|
void
|
|
send_enable_carbons(void** state)
|
|
{
|
|
prof_connect();
|
|
|
|
prof_input("/carbons on");
|
|
|
|
assert_true(stbbr_received(
|
|
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"));
|
|
}
|
|
|
|
void
|
|
connect_with_carbons_enabled(void** state)
|
|
{
|
|
prof_input("/carbons on");
|
|
|
|
prof_connect();
|
|
|
|
assert_true(stbbr_received(
|
|
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"));
|
|
}
|
|
|
|
void
|
|
send_disable_carbons(void** state)
|
|
{
|
|
prof_input("/carbons on");
|
|
|
|
prof_connect();
|
|
|
|
prof_input("/carbons off");
|
|
|
|
assert_true(stbbr_received(
|
|
"<iq id='*' type='set'><disable xmlns='urn:xmpp:carbons:2'/></iq>"));
|
|
}
|
|
|
|
void
|
|
receive_carbon(void** state)
|
|
{
|
|
prof_input("/carbons on");
|
|
|
|
prof_connect();
|
|
assert_true(stbbr_received(
|
|
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"));
|
|
|
|
stbbr_send(
|
|
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
|
|
"<priority>10</priority>"
|
|
"<status>On my mobile</status>"
|
|
"</presence>");
|
|
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\""));
|
|
prof_input("/msg Buddy1");
|
|
assert_true(prof_output_exact("unencrypted"));
|
|
|
|
stbbr_send(
|
|
"<message type='chat' to='stabber@localhost/profanity' from='stabber@localhost'>"
|
|
"<received xmlns='urn:xmpp:carbons:2'>"
|
|
"<forwarded xmlns='urn:xmpp:forward:0'>"
|
|
"<message id='prof_msg_7' xmlns='jabber:client' type='chat' lang='en' to='stabber@localhost/profanity' from='buddy1@localhost/mobile'>"
|
|
"<body>test carbon from recipient</body>"
|
|
"</message>"
|
|
"</forwarded>"
|
|
"</received>"
|
|
"</message>");
|
|
|
|
assert_true(prof_output_regex("Buddy1/mobile: .+test carbon from recipient"));
|
|
}
|
|
|
|
void
|
|
receive_self_carbon(void** state)
|
|
{
|
|
prof_input("/carbons on");
|
|
|
|
prof_connect();
|
|
assert_true(stbbr_received(
|
|
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"));
|
|
|
|
stbbr_send(
|
|
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
|
|
"<priority>10</priority>"
|
|
"<status>On my mobile</status>"
|
|
"</presence>");
|
|
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\""));
|
|
prof_input("/msg Buddy1");
|
|
assert_true(prof_output_exact("unencrypted"));
|
|
|
|
stbbr_send(
|
|
"<message type='chat' to='stabber@localhost/profanity' from='stabber@localhost'>"
|
|
"<sent xmlns='urn:xmpp:carbons:2'>"
|
|
"<forwarded xmlns='urn:xmpp:forward:0'>"
|
|
"<message id='59' xmlns='jabber:client' type='chat' to='buddy1@localhost/mobile' lang='en' from='stabber@localhost/profanity'>"
|
|
"<body>self sent carbon</body>"
|
|
"</message>"
|
|
"</forwarded>"
|
|
"</sent>"
|
|
"</message>");
|
|
|
|
assert_true(prof_output_regex("me: .+self sent carbon"));
|
|
}
|
|
|
|
void
|
|
receive_private_carbon(void** state)
|
|
{
|
|
prof_input("/carbons on");
|
|
|
|
prof_connect();
|
|
assert_true(stbbr_received(
|
|
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"));
|
|
|
|
stbbr_send(
|
|
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
|
|
"<priority>10</priority>"
|
|
"<status>On my mobile</status>"
|
|
"</presence>");
|
|
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\""));
|
|
prof_input("/msg Buddy1");
|
|
assert_true(prof_output_exact("unencrypted"));
|
|
|
|
stbbr_send(
|
|
"<message type='chat' to='stabber@localhost/profanity' from='buddy1@localhost/mobile'>"
|
|
"<body>Private carbon</body>"
|
|
"<private xmlns='urn:xmpp:carbons:2'/>"
|
|
"</message>");
|
|
|
|
assert_true(prof_output_regex("Buddy1/mobile: .+Private carbon"));
|
|
}
|