00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00037 #include <inttypes.h>
00038 #include <errno.h>
00039 #include <str_error.h>
00040 #include <sys/types.h>
00041 #include <async.h>
00042 #include <devman.h>
00043 #include <str.h>
00044 #include <vfs/vfs.h>
00045 #include <sys/stat.h>
00046 #include <fcntl.h>
00047 #include "../tester.h"
00048
00049 #define DEVICE_PATH_NORMAL "/virt/null/a"
00050 #define DEVICE_CLASS "virt-null"
00051 #define DEVICE_CLASS_NAME "1"
00052 #define DEVICE_PATH_CLASSES DEVICE_CLASS "/" DEVICE_CLASS_NAME
00053
00054 const char *test_devman1(void)
00055 {
00056 devman_handle_t handle_primary;
00057 devman_handle_t handle_class;
00058
00059 int rc;
00060
00061 TPRINTF("Asking for handle of `%s'...\n", DEVICE_PATH_NORMAL);
00062 rc = devman_device_get_handle(DEVICE_PATH_NORMAL, &handle_primary, 0);
00063 if (rc != EOK) {
00064 TPRINTF(" ...failed: %s.\n", str_error(rc));
00065 if (rc == ENOENT) {
00066 TPRINTF("Have you compiled the test drivers?\n");
00067 }
00068 return "Failed getting device handle";
00069 }
00070
00071 TPRINTF("Asking for handle of `%s' by class..\n", DEVICE_PATH_CLASSES);
00072 rc = devman_device_get_handle_by_class(DEVICE_CLASS, DEVICE_CLASS_NAME,
00073 &handle_class, 0);
00074 if (rc != EOK) {
00075 TPRINTF(" ...failed: %s.\n", str_error(rc));
00076 return "Failed getting device class handle";
00077 }
00078
00079 TPRINTF("Received handles %" PRIun " and %" PRIun ".\n",
00080 handle_primary, handle_class);
00081 if (handle_primary != handle_class) {
00082 return "Retrieved different handles for the same device";
00083 }
00084
00085 return NULL;
00086 }
00087