Changeset 2d11a7d8 in mainline for uspace/app/tester/ipc


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)

Location:
uspace/app/tester/ipc
Files:
7 deleted
3 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;
  • uspace/app/tester/ipc/ping_pong.c

    rdb24058 r2d11a7d8  
    3838#define COUNT_GRANULARITY  100
    3939
    40 char *test_ping_pong(bool quiet)
     40char *test_ping_pong(void)
    4141{
    42         printf("Pinging ns server for %d seconds...\n", DURATION_SECS);
     42        TPRINTF("Pinging ns server for %d seconds...", DURATION_SECS);
    4343       
    4444        struct timeval start;
    45         if (gettimeofday(&start, NULL) != 0)
    46                 return "Failed getting the time.";
     45        if (gettimeofday(&start, NULL) != 0) {
     46                TPRINTF("\n");
     47                return "Failed getting the time";
     48        }
    4749       
    4850        uint64_t count = 0;
    49        
    5051        while (true) {
    5152                struct timeval now;
    52                 if (gettimeofday(&now, NULL) != 0)
    53                         return "Failed getting the time.";
     53                if (gettimeofday(&now, NULL) != 0) {
     54                        TPRINTF("\n");
     55                        return "Failed getting the time";
     56                }
    5457               
    5558                if (tv_sub(&now, &start) >= DURATION_SECS * 1000000L)
     
    6063                        int retval = async_req_0_0(PHONE_NS, NS_PING);
    6164                       
    62                         if (retval != EOK)
    63                                 return "Failed to send ping message.";
     65                        if (retval != EOK) {
     66                                TPRINTF("\n");
     67                                return "Failed to send ping message";
     68                        }
    6469                }
    6570               
     
    6772        }
    6873       
    69         printf("Completed %lu round trips in %u seconds, %lu RT/s.\n",
     74        TPRINTF("OK\nCompleted %llu round trips in %u seconds, %llu rt/s.\n",
    7075            count, DURATION_SECS, count / DURATION_SECS);
    7176       
  • uspace/app/tester/ipc/register.c

    rdb24058 r2d11a7d8  
    3333#include "../tester.h"
    3434
     35#define MAX_CONNECTIONS  50
     36
     37static int connections[MAX_CONNECTIONS];
     38
    3539static void client_connection(ipc_callid_t iid, ipc_call_t *icall)
    3640{
    37         ipc_callid_t callid;
    38         ipc_call_t call;
    39         ipcarg_t phonehash = icall->in_phone_hash;
    40         int retval;
    41         int i;
    42 
    43         printf("Connected phone: %P, accepting\n", icall->in_phone_hash);
     41        unsigned int i;
     42       
     43        TPRINTF("Connected phone %#x accepting\n", icall->in_phone_hash);
    4444        ipc_answer_0(iid, EOK);
    45         for (i = 0; i < 1024; i++)
     45        for (i = 0; i < MAX_CONNECTIONS; i++) {
    4646                if (!connections[i]) {
    47                         connections[i] = phonehash;
     47                        connections[i] = icall->in_phone_hash;
    4848                        break;
    4949                }
     50        }
    5051       
    51         while (1) {
    52                 callid = async_get_call(&call);
     52        while (true) {
     53                ipc_call_t call;
     54                ipc_callid_t callid = async_get_call(&call);
     55                int retval;
     56               
    5357                switch (IPC_GET_METHOD(call)) {
    5458                case IPC_M_PHONE_HUNGUP:
    55                         printf("Phone (%P) hung up.\n", phonehash);
     59                        TPRINTF("Phone %#x hung up\n", icall->in_phone_hash);
    5660                        retval = 0;
    5761                        break;
     62                case IPC_TEST_METHOD:
     63                        TPRINTF("Received well known message from %#x: %#x\n",
     64                            icall->in_phone_hash, callid);
     65                        ipc_answer_0(callid, EOK);
     66                        break;
    5867                default:
    59                         printf("Received message from %P: %X\n", phonehash,
    60                             callid);
    61                         for (i = 0; i < 1024; i++)
    62                                 if (!callids[i]) {
    63                                         callids[i] = callid;
    64                                         break;
    65                                 }
    66                         continue;
     68                        TPRINTF("Received unknown message from %#x: %#x\n",
     69                            icall->in_phone_hash, callid);
     70                        ipc_answer_0(callid, ENOENT);
     71                        break;
    6772                }
    68                 ipc_answer_0(callid, retval);
    6973        }
    7074}
    7175
    72 char * test_register(bool quiet)
     76char *test_register(void)
    7377{
    74         int i;
     78        async_set_client_connection(client_connection);
    7579       
    76         async_set_client_connection(client_connection);
    77 
    78         for (i = IPC_TEST_START; i < IPC_TEST_START + 10; i++) {
    79                 ipcarg_t phonead;
    80                 int res = ipc_connect_to_me(PHONE_NS, i, 0, 0, &phonead);
    81                 if (!res)
    82                         break;
    83                 printf("Failed registering as %d..:%d\n", i, res);
    84         }
    85         printf("Registered as service: %d\n", i);
    86         myservice = i;
     80        ipcarg_t phonead;
     81        int res = ipc_connect_to_me(PHONE_NS, IPC_TEST_SERVICE, 0, 0, &phonead);
     82        if (res != 0)
     83                return "Failed registering IPC service";
     84       
     85        TPRINTF("Registered as service %u, accepting connections\n", IPC_TEST_SERVICE);
     86        async_manager();
    8787       
    8888        return NULL;
Note: See TracChangeset for help on using the changeset viewer.