Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 7551706b in mainline


Ignore:
Timestamp:
2010-12-17T23:26:53Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master
Children:
3ca3430
Parents:
47a7174f
Message:

Extended virtchar1 test with device classes

The test also tries to connect to the (same) device using its class
interface path (under /dev/class).

Location:
uspace
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tester/hw/misc/virtchar1.c

    r47a7174f r7551706b  
    4848#include "../../tester.h"
    4949
    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"
    5152#define BUFFER_SIZE 64
    5253
    53 const char *test_virtchar1(void)
     54static const char *test_virtchar1_internal(const char *path)
    5455{
    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);
    5758        if (fd < 0) {
    58                 TPRINTF(" ...error: %s\n", str_error(fd));
     59                TPRINTF("   ...error: %s\n", str_error(fd));
    5960                if (fd == ENOENT) {
    60                         TPRINTF(" (error was ENOENT: " \
     61                        TPRINTF("   (error was ENOENT: " \
    6162                            "have you compiled test drivers?)\n");
    6263                }
    63                 return "Failed opening " DEVICE_PATH " for reading";
     64                return "Failed opening devman driver device for reading";
    6465        }
    6566       
    66         TPRINTF(" ...file handle %d\n", fd);
     67        TPRINTF("   ...file handle %d\n", fd);
    6768
    68         TPRINTF("Asking for phone...\n");
     69        TPRINTF(" Asking for phone...\n");
    6970        int phone = fd_phone(fd);
    7071        if (phone < 0) {
    7172                close(fd);
    72                 TPRINTF(" ...error: %s\n", str_error(phone));
     73                TPRINTF("   ...error: %s\n", str_error(phone));
    7374                return "Failed to get phone to device";
    7475        }
    75         TPRINTF(" ...phone is %d\n", phone);
     76        TPRINTF("   ...phone is %d\n", phone);
    7677       
    77         TPRINTF("Will try to read...\n");
     78        TPRINTF(" Will try to read...\n");
    7879        size_t i;
    7980        char buffer[BUFFER_SIZE];
     
    8586                }
    8687        }
    87         TPRINTF(" ...data read okay\n");
     88        TPRINTF("   ...data read okay\n");
    8889       
    8990        /* Clean-up. */
    90         TPRINTF("Closing phones and file descriptors");
     91        TPRINTF(" Closing phones and file descriptors\n");
    9192        ipc_hangup(phone);
    9293        close(fd);
     
    9596}
    9697
     98const 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
    97115/** @}
    98116 */
  • uspace/drv/test1/test1.c

    r47a7174f r7551706b  
    9898        if (str_cmp(dev->name, "null") == 0) {
    9999                dev->ops = &char_device_ops;
     100                add_device_to_class(dev, "virt-null");
    100101        } else if (dev->parent == NULL) {
    101102                register_child_verbose(dev, "cloning myself ;-)", "clone",
Note: See TracChangeset for help on using the changeset viewer.