Changeset cb41a5e in mainline for uspace/app/tester/devmap/devmap1.c


Ignore:
Timestamp:
2009-05-21T07:03:38Z (16 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a095d20
Parents:
2246de6
Message:

improve devmap interface
remove spared device

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tester/devmap/devmap1.c

    r2246de6 rcb41a5e  
    120120char * test_devmap1(bool quiet)
    121121{
    122         int driver_phone;
    123         int dev1_handle;
    124         int dev2_handle;
    125         int dev3_handle;
    126         int handle;
    127         int rc;
    128 
     122        const char *retval = NULL;
     123       
    129124        /* Register new driver */
    130         driver_phone = devmap_driver_register("TestDriver",
    131             driver_client_connection);
    132 
    133         if (driver_phone < 0) {
    134                 return "Error: Cannot register driver.\n";     
    135         }
    136 
     125        int rc = devmap_driver_register("TestDriver", driver_client_connection);
     126        if (rc < 0) {
     127                retval = "Error: Cannot register driver.\n";
     128                goto out;
     129        }
     130       
    137131        /* Register new device dev1. */
    138         rc = devmap_device_register(driver_phone, TEST_DEVICE1, &dev1_handle);
     132        dev_handle_t dev1_handle;
     133        rc = devmap_device_register(TEST_DEVICE1, &dev1_handle);
    139134        if (rc != EOK) {
    140                 ipc_hangup(driver_phone);
    141                 return "Error: cannot register device.\n";
    142         }
    143 
     135                retval = "Error: cannot register device.\n";
     136                goto out;
     137        }
     138       
    144139        /*
    145140         * Get handle for dev2 (Should fail unless device is already registered
    146141         * by someone else).
    147142         */
     143        dev_handle_t handle;
    148144        rc = devmap_device_get_handle(TEST_DEVICE2, &handle, 0);
    149145        if (rc == EOK) {
    150                 ipc_hangup(driver_phone);
    151                 return "Error: got handle for dev2 before it was registered.\n";
    152         }
    153 
     146                retval = "Error: got handle for dev2 before it was registered.\n";
     147                goto out;
     148        }
     149       
    154150        /* Register new device dev2. */
    155         rc = devmap_device_register(driver_phone, TEST_DEVICE2, &dev2_handle);
     151        dev_handle_t dev2_handle;
     152        rc = devmap_device_register(TEST_DEVICE2, &dev2_handle);
    156153        if (rc != EOK) {
    157                 ipc_hangup(driver_phone);
    158                 return "Error: cannot register device dev2.\n";
    159         }
    160 
     154                retval = "Error: cannot register device dev2.\n";
     155                goto out;
     156        }
     157       
    161158        /* Register device dev1 again. */
    162         rc = devmap_device_register(driver_phone, TEST_DEVICE1, &dev3_handle);
     159        dev_handle_t dev3_handle;
     160        rc = devmap_device_register(TEST_DEVICE1, &dev3_handle);
    163161        if (rc == EOK) {
    164                 return "Error: dev1 registered twice.\n";
    165         }
    166 
     162                retval = "Error: dev1 registered twice.\n";
     163                goto out;
     164        }
     165       
    167166        /* Get handle for dev1. */
    168167        rc = devmap_device_get_handle(TEST_DEVICE1, &handle, 0);
    169168        if (rc != EOK) {
    170                 ipc_hangup(driver_phone);
    171                 return "Error: cannot get handle for 'DEVMAP_DEVICE1'.\n";
    172         }
    173 
     169                retval = "Error: cannot get handle for 'DEVMAP_DEVICE1'.\n";
     170                goto out;
     171        }
     172       
    174173        if (handle != dev1_handle) {
    175                 ipc_hangup(driver_phone);
    176                 return "Error: cannot get handle for 'DEVMAP_DEVICE1'.\n";
    177         }
    178 
     174                retval = "Error: cannot get handle for 'DEVMAP_DEVICE1'.\n";
     175                goto out;
     176        }
     177       
    179178        if (device_client(dev1_handle) != EOK) {
    180                 ipc_hangup(driver_phone);
    181                 return "Error: failed client test for 'DEVMAP_DEVICE1'.\n";
    182         }
    183 
    184         /* TODO: */
    185 
    186         ipc_hangup(driver_phone);
    187 
     179                retval = "Error: failed client test for 'DEVMAP_DEVICE1'.\n";
     180                goto out;
     181        }
     182       
     183out:
     184        devmap_hangup_phone(DEVMAP_DRIVER);
     185        devmap_hangup_phone(DEVMAP_CLIENT);
     186       
    188187        return NULL;
    189188}
Note: See TracChangeset for help on using the changeset viewer.