types: Remove detail and progress from struct status
[petitboot] / ui / test / discover-test.c
index 5077937d3f17f49e4a0a725c43a47b1c885aeb07..f3e7dd8cfc5b177595fedfd9a1ff9815c1dea3b2 100644 (file)
@@ -3,6 +3,25 @@
 
 #include "ui/common/discover-client.h"
 
+static const char *device_type_string(enum device_type type)
+{
+       switch (type) {
+       case DEVICE_TYPE_DISK:
+               return "disk";
+       case DEVICE_TYPE_USB:
+               return "usb";
+       case DEVICE_TYPE_NETWORK:
+               return "network";
+       case DEVICE_TYPE_OPTICAL:
+               return "optical";
+       case DEVICE_TYPE_ANY:
+               return "any";
+       case DEVICE_TYPE_UNKNOWN:
+               return "unknown";
+       }
+       return "invalid";
+}
+
 static int print_device_add(struct device *device,
        void __attribute__((unused)) *arg)
 {
@@ -10,6 +29,7 @@ static int print_device_add(struct device *device,
 
        printf("new device:\n");
        printf("\tid:   %s\n", device->id);
+       printf("\ttype: %s\n", device_type_string(device->type));
        printf("\tname: %s\n", device->name);
        printf("\tdesc: %s\n", device->description);
        printf("\ticon: %s\n", device->icon_file);
@@ -22,6 +42,7 @@ static int print_device_add(struct device *device,
                printf("\t\ticon: %s\n", opt->icon_file);
                printf("\t\tboot: %s\n", opt->boot_image_file);
                printf("\t\tinit: %s\n", opt->initrd_file);
+               printf("\t\tdtb:  %s\n", opt->dtb_file);
                printf("\t\targs: %s\n", opt->boot_args);
        }
 
@@ -41,6 +62,7 @@ static int print_boot_option_add(struct device *dev,
        printf("\tboot:   %s\n", opt->boot_image_file);
        printf("\tinit:   %s\n", opt->initrd_file);
        printf("\targs:   %s\n", opt->boot_args);
+       printf("\tdefault:%d\n", opt->is_default);
 
        return 0;
 }
@@ -53,22 +75,50 @@ static void print_device_remove(struct device *device,
        printf("\tname: %s\n", device->name);
 }
 
-static void print_status(struct boot_status *status,
+static void print_status(struct status *status,
        void __attribute__((unused)) *arg)
 {
        printf("status:\n");
        printf("\ttype:     %d\n", status->type);
        printf("\tmessage:  %s\n", status->message);
-       printf("\tdetail:   %s\n", status->detail);
-       printf("\tprogress: %d\n", status->progress);
 
 }
 
+static void print_sysinfo(struct system_info *sysinfo,
+       void __attribute__((unused)) *arg)
+{
+       unsigned int i;
+
+       printf("sysinfo:\n");
+       printf("\ttype:     %s\n", sysinfo->type);
+       printf("\tid:       %s\n", sysinfo->identifier);
+
+       if (sysinfo->n_interfaces == 0)
+               printf("\tno interfaces.\n");
+       else
+               printf("\tinterfaces:\n");
+
+       for (i = 0; i < sysinfo->n_interfaces; i++) {
+               struct interface_info *if_info = sysinfo->interfaces[i];
+               uint8_t *m = if_info->hwaddr;
+
+               printf("\t\tname:   %s\n", if_info->name);
+
+               if (if_info->hwaddr_size == 6)
+                       printf("\t\tmac:    %02x:%02x:%02x:%02x:%02x:%02x\n",
+                                       m[0], m[1], m[2], m[3], m[4], m[5]);
+               else
+                       printf("\t\tmac:    unknown hwaddr size %d\n",
+                                       if_info->hwaddr_size);
+       }
+}
+
 static struct discover_client_ops client_ops = {
        .device_add = print_device_add,
        .boot_option_add = print_boot_option_add,
        .device_remove = print_device_remove,
        .update_status = print_status,
+       .update_sysinfo = print_sysinfo,
 };
 
 int main(void)