Changeset cb41a5e in mainline for uspace/app/tester/devmap/devmap1.c
- Timestamp:
- 2009-05-21T07:03:38Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a095d20
- Parents:
- 2246de6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tester/devmap/devmap1.c
r2246de6 rcb41a5e 120 120 char * test_devmap1(bool quiet) 121 121 { 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 129 124 /* 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 137 131 /* 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); 139 134 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 144 139 /* 145 140 * Get handle for dev2 (Should fail unless device is already registered 146 141 * by someone else). 147 142 */ 143 dev_handle_t handle; 148 144 rc = devmap_device_get_handle(TEST_DEVICE2, &handle, 0); 149 145 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 154 150 /* 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); 156 153 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 161 158 /* 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); 163 161 if (rc == EOK) { 164 return "Error: dev1 registered twice.\n"; 165 } 166 162 retval = "Error: dev1 registered twice.\n"; 163 goto out; 164 } 165 167 166 /* Get handle for dev1. */ 168 167 rc = devmap_device_get_handle(TEST_DEVICE1, &handle, 0); 169 168 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 174 173 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 179 178 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 183 out: 184 devmap_hangup_phone(DEVMAP_DRIVER); 185 devmap_hangup_phone(DEVMAP_CLIENT); 186 188 187 return NULL; 189 188 }
Note:
See TracChangeset
for help on using the changeset viewer.