Changeset 2d11a7d8 in mainline for uspace/app/tester/ipc/connect.c


Ignore:
Timestamp:
2009-06-30T15:54:14Z (16 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9c40f883
Parents:
db24058
Message:

tester framework rewrite (go from a menu-driven interface to command-line interface)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tester/ipc/connect.c

    rdb24058 r2d11a7d8  
    2929#include <stdio.h>
    3030#include <unistd.h>
     31#include <atomic.h>
    3132#include "../tester.h"
    3233
    33 char * test_connect(bool quiet)
     34static atomic_t finish;
     35
     36static void callback(void *priv, int retval, ipc_call_t *data)
    3437{
    35         char c;
    36         int svc;
    37         int phid;
     38        atomic_set(&finish, 1);
     39}
    3840
    39         printf("Choose one service: 0:10000....9:10009 (q to skip)\n");
    40         do {
    41                 c = getchar();
    42                 if ((c == 'Q') || (c == 'q'))
    43                         return TEST_SKIPPED;
    44         } while (c < '0' || c > '9');
     41char *test_connect(void)
     42{
     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);
     47        } else {
     48                TPRINTF("\n");
     49                return "ipc_connect_me_to() failed";
     50        }
    4551       
    46         svc = IPC_TEST_START + c - '0';
    47         if (svc == myservice)
    48                 return "Currently cannot connect to myself, update test";
     52        printf("Sending synchronous message...\n");
     53        int retval = ipc_call_sync_0_0(phone, IPC_TEST_METHOD);
     54        TPRINTF("Received response to synchronous message\n");
    4955       
    50         printf("Connecting to %d..", svc);
    51         phid = ipc_connect_me_to(PHONE_NS, svc, 0, 0);
    52         if (phid > 0) {
    53                 printf("phoneid: %d\n", phid);
    54                 phones[phid] = 1;
    55         } else
    56                 return "Error";
     56        TPRINTF("Sending asynchronous message...\n");
     57        atomic_set(&finish, 0);
     58        ipc_call_async_0(phone, IPC_TEST_METHOD, NULL, callback, 1);
     59        while (atomic_get(&finish) != 1)
     60                TPRINTF(".");
     61        TPRINTF("Received response to asynchronous message\n");
     62       
     63        TPRINTF("Hanging up...");
     64        retval = ipc_hangup(phone);
     65        if (retval == 0) {
     66                TPRINTF("OK\n");
     67        } else {
     68                TPRINTF("\n");
     69                return "ipc_hangup() failed";
     70        }
    5771       
    5872        return NULL;
Note: See TracChangeset for help on using the changeset viewer.