Kristian Høgsberg | 915b7f8 | 2012-04-26 10:08:01 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2012 Intel Corporation |
| 3 | * |
| 4 | * Permission to use, copy, modify, distribute, and sell this software and |
| 5 | * its documentation for any purpose is hereby granted without fee, provided |
| 6 | * that the above copyright notice appear in all copies and that both that |
| 7 | * copyright notice and this permission notice appear in supporting |
| 8 | * documentation, and that the name of the copyright holders not be used in |
| 9 | * advertising or publicity pertaining to distribution of the software |
| 10 | * without specific, written prior permission. The copyright holders make |
| 11 | * no representations about the suitability of this software for any |
| 12 | * purpose. It is provided "as is" without express or implied warranty. |
| 13 | * |
| 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS |
| 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER |
| 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF |
| 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 21 | */ |
| 22 | |
| 23 | #include <stdlib.h> |
Kristian Høgsberg | dd90921 | 2012-04-27 11:15:58 -0400 | [diff] [blame] | 24 | #include <stdarg.h> |
Kristian Høgsberg | 915b7f8 | 2012-04-26 10:08:01 -0400 | [diff] [blame] | 25 | #include <stdio.h> |
| 26 | #include <assert.h> |
Kristian Høgsberg | dd90921 | 2012-04-27 11:15:58 -0400 | [diff] [blame] | 27 | #include <unistd.h> |
Kristian Høgsberg | 915b7f8 | 2012-04-26 10:08:01 -0400 | [diff] [blame] | 28 | |
| 29 | #include "test-runner.h" |
| 30 | |
Kristian Høgsberg | dd90921 | 2012-04-27 11:15:58 -0400 | [diff] [blame] | 31 | |
Kristian Høgsberg | 915b7f8 | 2012-04-26 10:08:01 -0400 | [diff] [blame] | 32 | struct context { |
Kristian Høgsberg | 915b7f8 | 2012-04-26 10:08:01 -0400 | [diff] [blame] | 33 | struct weston_compositor *compositor; |
Kristian Høgsberg | dd90921 | 2012-04-27 11:15:58 -0400 | [diff] [blame] | 34 | struct test_client *client; |
Kristian Høgsberg | 915b7f8 | 2012-04-26 10:08:01 -0400 | [diff] [blame] | 35 | struct wl_listener compositor_destroy_listener; |
| 36 | int status; |
Kristian Høgsberg | 915b7f8 | 2012-04-26 10:08:01 -0400 | [diff] [blame] | 37 | int done; |
| 38 | }; |
| 39 | |
| 40 | static void |
Kristian Høgsberg | 915b7f8 | 2012-04-26 10:08:01 -0400 | [diff] [blame] | 41 | compositor_destroy(struct wl_listener *listener, void *data) |
| 42 | { |
| 43 | struct context *context = |
| 44 | container_of(listener, struct context, |
| 45 | compositor_destroy_listener); |
| 46 | |
| 47 | fprintf(stderr, "notify compositor destroy, status %d, done %d\n", |
Kristian Høgsberg | dd90921 | 2012-04-27 11:15:58 -0400 | [diff] [blame] | 48 | context->client->status, context->client->done); |
Kristian Høgsberg | 915b7f8 | 2012-04-26 10:08:01 -0400 | [diff] [blame] | 49 | |
Kristian Høgsberg | dd90921 | 2012-04-27 11:15:58 -0400 | [diff] [blame] | 50 | assert(context->client->status == 0); |
| 51 | assert(context->client->done); |
Kristian Høgsberg | 915b7f8 | 2012-04-26 10:08:01 -0400 | [diff] [blame] | 52 | } |
| 53 | |
Kristian Høgsberg | dd90921 | 2012-04-27 11:15:58 -0400 | [diff] [blame] | 54 | |
Kristian Høgsberg | 915b7f8 | 2012-04-26 10:08:01 -0400 | [diff] [blame] | 55 | TEST(client_test) |
| 56 | { |
| 57 | struct context *context; |
Kristian Høgsberg | 915b7f8 | 2012-04-26 10:08:01 -0400 | [diff] [blame] | 58 | |
| 59 | context = malloc(sizeof *context); |
| 60 | assert(context); |
| 61 | context->compositor = compositor; |
| 62 | context->done = 0; |
Kristian Høgsberg | dd90921 | 2012-04-27 11:15:58 -0400 | [diff] [blame] | 63 | context->client = test_client_launch(compositor); |
| 64 | context->client->terminate = 1; |
Kristian Høgsberg | 915b7f8 | 2012-04-26 10:08:01 -0400 | [diff] [blame] | 65 | |
| 66 | context->compositor_destroy_listener.notify = compositor_destroy; |
| 67 | wl_signal_add(&compositor->destroy_signal, |
| 68 | &context->compositor_destroy_listener); |
Kristian Høgsberg | dd90921 | 2012-04-27 11:15:58 -0400 | [diff] [blame] | 69 | |
| 70 | test_client_send(context->client, "bye\n"); |
Kristian Høgsberg | 915b7f8 | 2012-04-26 10:08:01 -0400 | [diff] [blame] | 71 | } |