[Spice-devel] [PATCH spice-server 13/16] tests: Make test-empty-success automated
Christophe Fergeau
cfergeau at redhat.com
Wed Sep 6 15:44:18 UTC 2017
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
On Mon, Sep 04, 2017 at 11:57:21AM +0100, Frediano Ziglio wrote:
> Add some check that something happened during creation/destruction.
> Set as running on "make check".
>
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
> server/tests/Makefile.am | 2 +-
> server/tests/test-empty-success.c | 27 +++++++++++++++++++--------
> 2 files changed, 20 insertions(+), 9 deletions(-)
>
> diff --git a/server/tests/Makefile.am b/server/tests/Makefile.am
> index c35038a8..01e63626 100644
> --- a/server/tests/Makefile.am
> +++ b/server/tests/Makefile.am
> @@ -56,12 +56,12 @@ check_PROGRAMS = \
> test-leaks \
> test-vdagent \
> test-fail-on-null-core-interface \
> + test-empty-success \
> $(NULL)
>
> noinst_PROGRAMS = \
> test-display-no-ssl \
> test-display-streaming \
> - test-empty-success \
> test-just-sockets-no-ssl \
> test-playback \
> test-display-resolution-changes \
> diff --git a/server/tests/test-empty-success.c b/server/tests/test-empty-success.c
> index 0df551df..1079040b 100644
> --- a/server/tests/test-empty-success.c
> +++ b/server/tests/test-empty-success.c
> @@ -18,36 +18,40 @@
> #include <config.h>
> #include <stdlib.h>
> #include <string.h>
> -
> +#include <common/log.h>
> #include <spice.h>
>
> -struct SpiceTimer {
> - int a,b;
> -};
> +static unsigned int watches_created = 0;
> +static unsigned int timers_created = 0;
> +
> +static SpiceWatch *const dummy_watch = (SpiceWatch*)(uintptr_t)0xdeadbeef;
> +static SpiceTimer *const dummy_timer = (SpiceTimer*)(uintptr_t)0xbeefdead;
>
> static SpiceTimer*
> timer_add(SPICE_GNUC_UNUSED SpiceTimerFunc func,
> SPICE_GNUC_UNUSED void *opaque)
> {
> - static struct SpiceTimer t = {0,};
> -
> - return &t;
> + ++timers_created;
> + return dummy_timer;
> }
>
> static void
> timer_start(SPICE_GNUC_UNUSED SpiceTimer *timer,
> SPICE_GNUC_UNUSED uint32_t ms)
> {
> + spice_assert(timer == dummy_timer);
> }
>
> static void
> timer_cancel(SPICE_GNUC_UNUSED SpiceTimer *timer)
> {
> + spice_assert(timer == dummy_timer);
> }
>
> static void
> timer_remove(SPICE_GNUC_UNUSED SpiceTimer *timer)
> {
> + spice_assert(timer == dummy_timer);
> }
>
> static SpiceWatch *
> @@ -56,18 +60,21 @@ watch_add(SPICE_GNUC_UNUSED int fd,
> SPICE_GNUC_UNUSED SpiceWatchFunc func,
> SPICE_GNUC_UNUSED void *opaque)
> {
> - return NULL;
> + ++watches_created;
> + return dummy_watch;
> }
>
> static void
> watch_update_mask(SPICE_GNUC_UNUSED SpiceWatch *watch,
> SPICE_GNUC_UNUSED int event_mask)
> {
> + spice_assert(watch == dummy_watch);
> }
>
> static void
> watch_remove(SPICE_GNUC_UNUSED SpiceWatch *watch)
> {
> + spice_assert(watch == dummy_watch);
> }
>
> static void
> @@ -97,5 +104,9 @@ int main(void)
>
> spice_server_destroy(server);
>
> + // should have created some timers and watch
> + spice_assert(watches_created > 0);
> + spice_assert(timers_created > 0);
> +
> return 0;
> }
> --
> 2.13.5
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
More information about the Spice-devel
mailing list