v.erase(found + 1);
}
std::replace(v.begin(), v.end(), ' ', '_');
+
+ // remove "__", which seems to come up on by ubuntu box for some reason.
+ while (true) {
+ auto p = v.find("__");
+ if (p == std::string::npos) break;
+ v.replace(p, 2, "_");
+ }
+
return v;
}
udev_device_unref(dev);
udev_unref(udev);
+ cout << " vendor '" << id_vendor << "'" << std::endl;
+ cout << " model '" << id_model << "'" << std::endl;
+ cout << " serial_short '" << id_serial_short << "'" << std::endl;
+ cout << " scsi_serial '" << id_scsi_serial << "'" << std::endl;
+ cout << " serial '" << id_serial << "'" << std::endl;
+
// ID_SERIAL is usually $vendor_$model_$serial, but not always
// ID_SERIAL_SHORT is mostly always just the serial
// ID_MODEL is sometimes $vendor_$model, but
ASSERT_EQ(std::string(foo[i][1]), d);
}
}
+
+TEST(blkdev, get_device_id)
+{
+ // this doesn't really test anything; it's just a way to exercise the
+ // get_device_id() code.
+ for (char c = 'a'; c < 'z'; ++c) {
+ char devname[4] = {'s', 'd', c, 0};
+ std::string err;
+ auto i = get_device_id(devname, &err);
+ cout << "devname " << devname << " -> '" << i
+ << "' (" << err << ")" << std::endl;
+ }
+}