diff --git a/Makefile.am b/Makefile.am
index 0a7ca297..bf35fb0b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -304,6 +304,7 @@ check_PROGRAMS += tests/functionaltests/functionaltests
tests_functionaltests_functionaltests_SOURCES = $(functionaltest_sources)
tests_functionaltests_functionaltests_CPPFLAGS = -Itests/
tests_functionaltests_functionaltests_CFLAGS = $(AM_CFLAGS) -I/usr/include/tcl8.6 -I/usr/include/tcl8.5
+tests_functionaltests_functionaltests_LDFLAGS = -L$(top_srcdir)/external/stabber/.libs -Wl,-rpath,$(top_srcdir)/external/stabber/.libs
tests_functionaltests_functionaltests_LDADD = -lcmocka -lstabber -lexpect -ltcl8.6
man1_MANS = $(man1_sources)
diff --git a/external/stabber b/external/stabber
new file mode 160000
index 00000000..3e5c2200
--- /dev/null
+++ b/external/stabber
@@ -0,0 +1 @@
+Subproject commit 3e5c2200715666aad403d0076e8ab584b329965e
diff --git a/tests/functionaltests/proftest.c b/tests/functionaltests/proftest.c
index 4138b9d9..c5fa27ee 100644
--- a/tests/functionaltests/proftest.c
+++ b/tests/functionaltests/proftest.c
@@ -139,13 +139,17 @@ prof_start(void)
int
init_prof_test(void **state)
{
+ fprintf(stderr, "\n[TEST] init_prof_test() called\n");
gboolean started = FALSE;
for (int p = 5230; p < 5250; ++p) {
+ fprintf(stderr, "[TEST] Trying to start stabber on port %d\n", p);
if (stbbr_start(STBBR_LOGDEBUG, p, 0) == 0) {
stub_port = p;
+ fprintf(stderr, "[TEST] Stabber started successfully on port %d\n", p);
started = TRUE;
break;
}
+ fprintf(stderr, "[TEST] Port %d failed, trying next\n", p);
}
if (!started) {
assert_true(FALSE); // could not start stabber on any port in range
@@ -254,23 +258,66 @@ prof_connect_with_roster(const char *roster)
// Set up stabber to expect password "password"
stbbr_auth_passwd("password");
- stbbr_for_id("prof_presence_1",
- ""
- "0"
- ""
- ""
- );
-
char connect_cmd[128];
- snprintf(connect_cmd, sizeof(connect_cmd), "/connect stabber@localhost server 127.0.0.1 port %d tls allow", stub_port);
+ snprintf(connect_cmd, sizeof(connect_cmd), "/connect stabber@localhost server 127.0.0.1 port %d tls disable", stub_port);
+ fprintf(stderr, "\n[TEST] Sending connect command: %s\n", connect_cmd);
+ fprintf(stderr, "[TEST] stub_port = %d\n", stub_port);
prof_input(connect_cmd);
+
+ // Check password prompt appears
+ assert_true(prof_output_regex("password:"));
+
prof_input("password");
// Allow time for profanity to connect
- exp_timeout = 30;
- assert_true(prof_output_regex("stabber@localhost/profanity logged in successfully, .+online.+ \\(priority 0\\)\\."));
+ exp_timeout = 60;
+
+ // First check: did we get any connection message?
+ gboolean got_connecting = prof_output_regex("Connecting as stabber@localhost");
+ gboolean got_success = FALSE;
+ gboolean got_failure = FALSE;
+
+ if (got_connecting) {
+ fprintf(stderr, "\nDEBUG: Saw 'Connecting as' message, waiting longer for result...\n");
+ sleep(5); // Give extra time for SASL + bind
+
+ // Try to dump whatever is on the screen by sending Enter and reading response
+ prof_input("");
+ usleep(500000); // 0.5s
+
+ // Now wait for success or failure
+ got_success = prof_output_regex("logged in successfully");
+ if (!got_success) {
+ got_failure = prof_output_regex("failed|Failed|error|Error|disconnect|Disconnect");
+ if (!got_failure) {
+ fprintf(stderr, "\nDEBUG: No success or failure after 5s, sending /who to trigger output...\n");
+ // Send a command to see if connection is actually established
+ prof_input("/who");
+ usleep(500000);
+ got_success = prof_output_regex("logged in successfully|online");
+ }
+ }
+ } else {
+ // Maybe we went straight to success?
+ got_success = prof_output_regex("logged in successfully");
+ }
+
+ fprintf(stderr, "\nDEBUG: got_connecting=%d got_success=%d got_failure=%d\n",
+ got_connecting, got_success, got_failure);
+
+ if (got_success) {
+ assert_true(prof_output_regex(".+online.+ \\(priority 0\\)\\."));
+ } else {
+ assert_true(FALSE);
+ }
+
exp_timeout = 10;
- stbbr_wait_for("prof_presence_*");
+ // Wait for presence stanza to be sent (content-based, not ID-based)
+ assert_true(stbbr_received(
+ ""
+ ""
+ ""
+ ));
}
void