Rev 2925 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2925 | Rev 4692 | ||
---|---|---|---|
Line 26... | Line 26... | ||
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | #include <stdio.h> |
29 | #include <stdio.h> |
30 | #include <unistd.h> |
30 | #include <unistd.h> |
- | 31 | #include <atomic.h> |
|
31 | #include "../tester.h" |
32 | #include "../tester.h" |
32 | 33 | ||
33 | char * test_connect(bool quiet) |
34 | static atomic_t finish; |
- | 35 | ||
- | 36 | static void callback(void *priv, int retval, ipc_call_t *data) |
|
34 | { |
37 | { |
35 | char c; |
- | |
36 | int svc; |
38 | atomic_set(&finish, 1); |
37 | int phid; |
39 | } |
38 | 40 | ||
- | 41 | char *test_connect(void) |
|
- | 42 | { |
|
39 | printf("Choose one service: 0:10000....9:10009 (q to skip)\n"); |
43 | TPRINTF("Connecting to %u...", IPC_TEST_SERVICE); |
- | 44 | int phone = ipc_connect_me_to(PHONE_NS, IPC_TEST_SERVICE, 0, 0); |
|
- | 45 | if (phone > 0) { |
|
- | 46 | TPRINTF("phoneid %d\n", phone); |
|
40 | do { |
47 | } else { |
41 | c = getchar(); |
48 | TPRINTF("\n"); |
42 | if ((c == 'Q') || (c == 'q')) |
49 | return "ipc_connect_me_to() failed"; |
- | 50 | } |
|
- | 51 | ||
- | 52 | printf("Sending synchronous message...\n"); |
|
43 | return TEST_SKIPPED; |
53 | int retval = ipc_call_sync_0_0(phone, IPC_TEST_METHOD); |
44 | } while (c < '0' || c > '9'); |
54 | TPRINTF("Received response to synchronous message\n"); |
45 | 55 | ||
- | 56 | TPRINTF("Sending asynchronous message...\n"); |
|
- | 57 | atomic_set(&finish, 0); |
|
46 | svc = IPC_TEST_START + c - '0'; |
58 | ipc_call_async_0(phone, IPC_TEST_METHOD, NULL, callback, 1); |
47 | if (svc == myservice) |
59 | while (atomic_get(&finish) != 1) |
- | 60 | TPRINTF("."); |
|
48 | return "Currently cannot connect to myself, update test"; |
61 | TPRINTF("Received response to asynchronous message\n"); |
49 | 62 | ||
50 | printf("Connecting to %d..", svc); |
63 | TPRINTF("Hanging up..."); |
51 | phid = ipc_connect_me_to(PHONE_NS, svc, 0, 0); |
64 | retval = ipc_hangup(phone); |
52 | if (phid > 0) { |
65 | if (retval == 0) { |
53 | printf("phoneid: %d\n", phid); |
- | |
54 | phones[phid] = 1; |
66 | TPRINTF("OK\n"); |
55 | } else |
67 | } else { |
- | 68 | TPRINTF("\n"); |
|
56 | return "Error"; |
69 | return "ipc_hangup() failed"; |
- | 70 | } |
|
57 | 71 | ||
58 | return NULL; |
72 | return NULL; |
59 | } |
73 | } |