Changeset 7551706b in mainline
- Timestamp:
- 2010-12-17T23:26:53Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3ca3430
- Parents:
- 47a7174f
- Location:
- uspace
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tester/hw/misc/virtchar1.c
r47a7174f r7551706b 48 48 #include "../../tester.h" 49 49 50 #define DEVICE_PATH "/dev/devices/\\virt\\null" 50 #define DEVICE_PATH_NORMAL "/dev/devices/\\virt\\null" 51 #define DEVICE_PATH_CLASSES "/dev/class/virt-null\\1" 51 52 #define BUFFER_SIZE 64 52 53 53 const char *test_virtchar1(void)54 static const char *test_virtchar1_internal(const char *path) 54 55 { 55 TPRINTF("Opening %s...\n", DEVICE_PATH);56 int fd = open( DEVICE_PATH, O_RDONLY);56 TPRINTF("Opening `%s'...\n", path); 57 int fd = open(path, O_RDONLY); 57 58 if (fd < 0) { 58 TPRINTF(" ...error: %s\n", str_error(fd));59 TPRINTF(" ...error: %s\n", str_error(fd)); 59 60 if (fd == ENOENT) { 60 TPRINTF(" (error was ENOENT: " \61 TPRINTF(" (error was ENOENT: " \ 61 62 "have you compiled test drivers?)\n"); 62 63 } 63 return "Failed opening " DEVICE_PATH "for reading";64 return "Failed opening devman driver device for reading"; 64 65 } 65 66 66 TPRINTF(" ...file handle %d\n", fd);67 TPRINTF(" ...file handle %d\n", fd); 67 68 68 TPRINTF(" Asking for phone...\n");69 TPRINTF(" Asking for phone...\n"); 69 70 int phone = fd_phone(fd); 70 71 if (phone < 0) { 71 72 close(fd); 72 TPRINTF(" ...error: %s\n", str_error(phone));73 TPRINTF(" ...error: %s\n", str_error(phone)); 73 74 return "Failed to get phone to device"; 74 75 } 75 TPRINTF(" ...phone is %d\n", phone);76 TPRINTF(" ...phone is %d\n", phone); 76 77 77 TPRINTF(" Will try to read...\n");78 TPRINTF(" Will try to read...\n"); 78 79 size_t i; 79 80 char buffer[BUFFER_SIZE]; … … 85 86 } 86 87 } 87 TPRINTF(" ...data read okay\n");88 TPRINTF(" ...data read okay\n"); 88 89 89 90 /* Clean-up. */ 90 TPRINTF(" Closing phones and file descriptors");91 TPRINTF(" Closing phones and file descriptors\n"); 91 92 ipc_hangup(phone); 92 93 close(fd); … … 95 96 } 96 97 98 const char *test_virtchar1(void) 99 {; 100 const char *res; 101 102 res = test_virtchar1_internal(DEVICE_PATH_NORMAL); 103 if (res != NULL) { 104 return res; 105 } 106 107 res = test_virtchar1_internal(DEVICE_PATH_CLASSES); 108 if (res != NULL) { 109 return res; 110 } 111 112 return NULL; 113 } 114 97 115 /** @} 98 116 */ -
uspace/drv/test1/test1.c
r47a7174f r7551706b 98 98 if (str_cmp(dev->name, "null") == 0) { 99 99 dev->ops = &char_device_ops; 100 add_device_to_class(dev, "virt-null"); 100 101 } else if (dev->parent == NULL) { 101 102 register_child_verbose(dev, "cloning myself ;-)", "clone",
Note:
See TracChangeset
for help on using the changeset viewer.