[Spice-devel] [PATCH spice-server v3 05/12] test-sasl: Add code for mocking function to test state
Christophe Fergeau
cfergeau at redhat.com
Thu Jan 4 14:21:34 UTC 2018
In the shortlog, "Add code *to* mocking functions .."?
On Fri, Dec 22, 2017 at 10:07:06AM +0000, Frediano Ziglio wrote:
> Check some functions are called in a given sequence.
>
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
> server/tests/test-sasl.c | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/server/tests/test-sasl.c b/server/tests/test-sasl.c
> index e9493f10e..4b1d778c0 100644
> --- a/server/tests/test-sasl.c
> +++ b/server/tests/test-sasl.c
> @@ -30,6 +30,10 @@
> #include "basic-event-loop.h"
>
> static char *mechlist;
> +static bool mechlist_called;
> +static bool start_called;
> +static bool step_called;
> +static bool encode_called;
>
> static void
> check_sasl_conn(sasl_conn_t *conn)
> @@ -50,6 +54,8 @@ sasl_decode(sasl_conn_t *conn,
> const char **output, unsigned *outputlen)
> {
> check_sasl_conn(conn);
> + g_assert(start_called);
> +
> return SASL_NOTDONE;
> }
>
> @@ -59,6 +65,9 @@ sasl_encode(sasl_conn_t *conn,
> const char **output, unsigned *outputlen)
> {
> check_sasl_conn(conn);
> + g_assert(start_called);
> +
> + encode_called = true;
> return SASL_NOTDONE;
> }
>
> @@ -140,6 +149,10 @@ sasl_listmech(sasl_conn_t *conn,
> g_assert_nonnull(prefix);
> g_assert_nonnull(sep);
> g_assert_nonnull(suffix);
> + g_assert(!mechlist_called);
> + g_assert(!start_called);
> + g_assert(!step_called);
> + mechlist_called = true;
>
> g_free(mechlist);
> mechlist = g_strjoin("", prefix, "ONE", sep, "TWO", sep, "THREE", suffix, NULL);
> @@ -157,6 +170,10 @@ sasl_server_start(sasl_conn_t *conn,
> {
> check_sasl_conn(conn);
> g_assert_nonnull(serverout);
> + g_assert(mechlist_called);
> + g_assert(!start_called);
> + g_assert(!step_called);
> + start_called = true;
>
> *serverout = "foo";
> *serveroutlen = 3;
> @@ -172,6 +189,8 @@ sasl_server_step(sasl_conn_t *conn,
> {
> check_sasl_conn(conn);
> g_assert_nonnull(serverout);
> + g_assert(start_called);
> + step_called = true;
>
> *serverout = "foo";
> *serveroutlen = 3;
> --
> 2.14.3
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20180104/7219f872/attachment.sig>
More information about the Spice-devel
mailing list