This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository libx2goclient. commit 64ffafde6de0a1604b44909071863083e54a58d1 Author: Mihai Moldovan <ionic@ionic.de> Date: Fri Apr 30 12:49:09 2021 +0200 src/test/sshtest.c: run all tests twice - with concrete implementation and super class semantics. This should test if all functions work well and can be used interchangeably - which should be the case. --- src/test/sshtest.c | 58 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/src/test/sshtest.c b/src/test/sshtest.c index b1c827e..93c9444 100644 --- a/src/test/sshtest.c +++ b/src/test/sshtest.c @@ -202,13 +202,18 @@ static _Bool test_x2goclient_network_ssh_set_conn_ret (X2GoClientNetworkSSH *net return (ret); } -static _Bool test_x2goclient_network_ssh_connect_after_connect (X2GoClientNetworkSSH *net_ssh, const gboolean conn_ret) { +static _Bool test_x2goclient_network_ssh_connect_after_connect (X2GoClientNetworkSSH *net_ssh, const gboolean conn_ret, const _Bool use_super) { _Bool ret = TRUE; /* Connect again, shouldn't cause anything to change. */ gboolean conn_ret_new = FALSE; g_printf ("Trying to connect again...\n"); - conn_ret_new = x2goclient_network_ssh_connect (net_ssh, NULL); + if (use_super) { + conn_ret_new = x2goclient_network_connect ((X2GoClientNetwork*) (net_ssh), NULL); + } + else { + conn_ret_new = x2goclient_network_ssh_connect (net_ssh, NULL); + } g_printf ("Connection status: %s.\n", x2goclient_bool_to_str (conn_ret_new)); ret &= (conn_ret == conn_ret_new); @@ -220,13 +225,18 @@ static _Bool test_x2goclient_network_ssh_connect_after_connect (X2GoClientNetwor return (ret); } -static _Bool test_x2goclient_network_ssh_connect (X2GoClientNetworkSSH *net_ssh, gboolean * const conn_ret) { +static _Bool test_x2goclient_network_ssh_connect (X2GoClientNetworkSSH *net_ssh, gboolean * const conn_ret, const _Bool use_super) { _Bool ret = (!(!(conn_ret))); if (ret) { /* Actually connect. */ g_printf ("Trying to connect...\n"); - (*conn_ret) = x2goclient_network_ssh_connect (net_ssh, NULL); + if (use_super) { + (*conn_ret) = x2goclient_network_connect ((X2GoClientNetwork*) (net_ssh), NULL); + } + else { + (*conn_ret) = x2goclient_network_ssh_connect (net_ssh, NULL); + } g_printf ("Connection status: %s.\n", x2goclient_bool_to_str (*conn_ret)); } @@ -244,12 +254,18 @@ static _Bool test_x2goclient_network_ssh_connect (X2GoClientNetworkSSH *net_ssh, return (ret); } -static _Bool test_x2goclient_network_ssh_disconnect (X2GoClientNetworkSSH *net_ssh) { +static _Bool test_x2goclient_network_ssh_disconnect (X2GoClientNetworkSSH *net_ssh, const _Bool use_super) { _Bool ret = TRUE; /* Actually disconnect. */ g_printf ("Trying to disconnect...\n"); - gboolean disconn_ret = x2goclient_network_ssh_disconnect (net_ssh, NULL); + gboolean disconn_ret = FALSE; + if (use_super) { + disconn_ret = x2goclient_network_disconnect ((X2GoClientNetwork*) (net_ssh), NULL); + } + else { + disconn_ret = x2goclient_network_ssh_disconnect (net_ssh, NULL); + } g_printf ("Disconnection status: %s.\n", x2goclient_bool_to_str (disconn_ret)); ret &= disconn_ret; @@ -266,9 +282,18 @@ static _Bool test_x2goclient_network_ssh_disconnect (X2GoClientNetworkSSH *net_s return (ret); } -static _Bool test_x2goclient_network_ssh (const GString * const ssh_uri) { +static _Bool test_x2goclient_network_ssh (const GString * const ssh_uri, const _Bool use_super) { _Bool ret = TRUE; + g_printf ("Testing X2GoClientNetworkSSH with "); + if (use_super) { + g_printf ("super class (X2GoClientNetwork)"); + } + else { + g_printf ("actual class"); + } + g_printf (" interactions.\n"); + /* Create object. */ X2GoClientNetworkSSH *net_ssh = x2goclient_network_ssh_new (NULL); @@ -296,11 +321,11 @@ static _Bool test_x2goclient_network_ssh (const GString * const ssh_uri) { gboolean conn_ret = FALSE; if (ret) { - ret &= test_x2goclient_network_ssh_connect (net_ssh, &conn_ret); + ret &= test_x2goclient_network_ssh_connect (net_ssh, &conn_ret, use_super); } if (ret) { - ret &= test_x2goclient_network_ssh_connect_after_connect (net_ssh, conn_ret); + ret &= test_x2goclient_network_ssh_connect_after_connect (net_ssh, conn_ret, use_super); } if (ret) { @@ -309,7 +334,7 @@ static _Bool test_x2goclient_network_ssh (const GString * const ssh_uri) { } if (ret) { - ret &= test_x2goclient_network_ssh_disconnect (net_ssh); + ret &= test_x2goclient_network_ssh_disconnect (net_ssh, use_super); } if (ret) { @@ -317,7 +342,7 @@ static _Bool test_x2goclient_network_ssh (const GString * const ssh_uri) { * Connect again, checking whether a connect-disconnect-connect cycle works * correctly. */ - ret &= test_x2goclient_network_ssh_connect (net_ssh, &conn_ret); + ret &= test_x2goclient_network_ssh_connect (net_ssh, &conn_ret, use_super); } if (ret) { @@ -353,9 +378,14 @@ int main (const int argc, const char * const * const argv) { /* Initialize ret to failure. */ ret = EXIT_FAILURE; - if (test_x2goclient_network_ssh (ssh_uri)) { - /* We'll only not fail if all tests succeded. */ - ret = EXIT_SUCCESS; + + /* First, do the test with concrete classes. */ + if (test_x2goclient_network_ssh (ssh_uri, FALSE)) { + /* Then, with super classes. */ + if (test_x2goclient_network_ssh (ssh_uri, TRUE)) { + /* We'll only not fail if all tests succeeded. */ + ret = EXIT_SUCCESS; + } } } -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/libx2goclient.git