types: Remove detail and progress from struct status
[petitboot] / ui / test / discover-test.c
index faf1d893677936fc9307b9329df8244ee33260d2..f3e7dd8cfc5b177595fedfd9a1ff9815c1dea3b2 100644 (file)
@@ -8,10 +8,14 @@ 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";
        }
@@ -71,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)