mirror of
https://git.proxmox.com/git/fwupd
synced 2025-07-25 21:57:47 +00:00
trivial: Show the caps as letters when listing sectors as a string
This commit is contained in:
parent
79d2b93771
commit
8e480bff54
@ -190,6 +190,19 @@ dfu_sector_has_cap (DfuSector *sector, DfuSectorCap cap)
|
|||||||
return (priv->cap & cap) > 0;
|
return (priv->cap & cap) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gchar *
|
||||||
|
dfu_sector_cap_to_string (DfuSectorCap cap)
|
||||||
|
{
|
||||||
|
GString *str = g_string_new (NULL);
|
||||||
|
if (cap & DFU_SECTOR_CAP_READABLE)
|
||||||
|
g_string_append (str, "R");
|
||||||
|
if (cap & DFU_SECTOR_CAP_ERASEABLE)
|
||||||
|
g_string_append (str, "E");
|
||||||
|
if (cap & DFU_SECTOR_CAP_WRITEABLE)
|
||||||
|
g_string_append (str, "W");
|
||||||
|
return g_string_free (str, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dfu_sector_to_string:
|
* dfu_sector_to_string:
|
||||||
* @sector: a #DfuSector
|
* @sector: a #DfuSector
|
||||||
@ -205,14 +218,16 @@ dfu_sector_to_string (DfuSector *sector)
|
|||||||
{
|
{
|
||||||
DfuSectorPrivate *priv = GET_PRIVATE (sector);
|
DfuSectorPrivate *priv = GET_PRIVATE (sector);
|
||||||
GString *str;
|
GString *str;
|
||||||
|
g_autofree gchar *caps_str = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (DFU_IS_SECTOR (sector), NULL);
|
g_return_val_if_fail (DFU_IS_SECTOR (sector), NULL);
|
||||||
|
|
||||||
str = g_string_new ("");
|
str = g_string_new ("");
|
||||||
|
caps_str = dfu_sector_cap_to_string (priv->cap);
|
||||||
g_string_append_printf (str,
|
g_string_append_printf (str,
|
||||||
"Zone:%i, Sec#:%i, Addr:0x%08x, "
|
"Zone:%i, Sec#:%i, Addr:0x%08x, "
|
||||||
"Size:0x%04x, Caps:0x%01x",
|
"Size:0x%04x, Caps:0x%01x [%s]",
|
||||||
priv->zone, priv->number, priv->address,
|
priv->zone, priv->number, priv->address,
|
||||||
priv->size, priv->cap);
|
priv->size, priv->cap, caps_str);
|
||||||
return g_string_free (str, FALSE);
|
return g_string_free (str, FALSE);
|
||||||
}
|
}
|
||||||
|
@ -700,8 +700,12 @@ dfu_target_dfuse_func (void)
|
|||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
g_assert (ret);
|
g_assert (ret);
|
||||||
tmp = dfu_target_sectors_to_string (target);
|
tmp = dfu_target_sectors_to_string (target);
|
||||||
g_assert_cmpstr (tmp, ==, "Zone:0, Sec#:0, Addr:0x08000000, Size:0x0400, Caps:0x1\n"
|
ret = dfu_test_compare_lines (tmp,
|
||||||
"Zone:0, Sec#:0, Addr:0x08000400, Size:0x0400, Caps:0x1");
|
"Zone:0, Sec#:0, Addr:0x08000000, Size:0x0400, Caps:0x1 [R]\n"
|
||||||
|
"Zone:0, Sec#:0, Addr:0x08000400, Size:0x0400, Caps:0x1 [R]",
|
||||||
|
&error);
|
||||||
|
g_assert_no_error (error);
|
||||||
|
g_assert (ret);
|
||||||
g_free (tmp);
|
g_free (tmp);
|
||||||
|
|
||||||
/* multiple sectors */
|
/* multiple sectors */
|
||||||
@ -710,12 +714,12 @@ dfu_target_dfuse_func (void)
|
|||||||
g_assert (ret);
|
g_assert (ret);
|
||||||
tmp = dfu_target_sectors_to_string (target);
|
tmp = dfu_target_sectors_to_string (target);
|
||||||
ret = dfu_test_compare_lines (tmp,
|
ret = dfu_test_compare_lines (tmp,
|
||||||
"Zone:0, Sec#:0, Addr:0x08000000, Size:0x0400, Caps:0x1\n"
|
"Zone:0, Sec#:0, Addr:0x08000000, Size:0x0400, Caps:0x1 [R]\n"
|
||||||
"Zone:0, Sec#:0, Addr:0x08000400, Size:0x0400, Caps:0x1\n"
|
"Zone:0, Sec#:0, Addr:0x08000400, Size:0x0400, Caps:0x1 [R]\n"
|
||||||
"Zone:0, Sec#:1, Addr:0x08000800, Size:0x0400, Caps:0x7\n"
|
"Zone:0, Sec#:1, Addr:0x08000800, Size:0x0400, Caps:0x7 [REW]\n"
|
||||||
"Zone:0, Sec#:1, Addr:0x08000c00, Size:0x0400, Caps:0x7\n"
|
"Zone:0, Sec#:1, Addr:0x08000c00, Size:0x0400, Caps:0x7 [REW]\n"
|
||||||
"Zone:0, Sec#:1, Addr:0x08001000, Size:0x0400, Caps:0x7\n"
|
"Zone:0, Sec#:1, Addr:0x08001000, Size:0x0400, Caps:0x7 [REW]\n"
|
||||||
"Zone:0, Sec#:1, Addr:0x08001400, Size:0x0400, Caps:0x7",
|
"Zone:0, Sec#:1, Addr:0x08001400, Size:0x0400, Caps:0x7 [REW]",
|
||||||
&error);
|
&error);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
g_assert (ret);
|
g_assert (ret);
|
||||||
@ -727,15 +731,15 @@ dfu_target_dfuse_func (void)
|
|||||||
g_assert (ret);
|
g_assert (ret);
|
||||||
tmp = dfu_target_sectors_to_string (target);
|
tmp = dfu_target_sectors_to_string (target);
|
||||||
ret = dfu_test_compare_lines (tmp,
|
ret = dfu_test_compare_lines (tmp,
|
||||||
"Zone:0, Sec#:0, Addr:0x0000f000, Size:0x0064, Caps:0x1\n"
|
"Zone:0, Sec#:0, Addr:0x0000f000, Size:0x0064, Caps:0x1 [R]\n"
|
||||||
"Zone:0, Sec#:0, Addr:0x0000f064, Size:0x0064, Caps:0x1\n"
|
"Zone:0, Sec#:0, Addr:0x0000f064, Size:0x0064, Caps:0x1 [R]\n"
|
||||||
"Zone:0, Sec#:0, Addr:0x0000f0c8, Size:0x0064, Caps:0x1\n"
|
"Zone:0, Sec#:0, Addr:0x0000f0c8, Size:0x0064, Caps:0x1 [R]\n"
|
||||||
"Zone:0, Sec#:0, Addr:0x0000f12c, Size:0x0064, Caps:0x1\n"
|
"Zone:0, Sec#:0, Addr:0x0000f12c, Size:0x0064, Caps:0x1 [R]\n"
|
||||||
"Zone:1, Sec#:0, Addr:0x0000e000, Size:0x2000, Caps:0x7\n"
|
"Zone:1, Sec#:0, Addr:0x0000e000, Size:0x2000, Caps:0x7 [REW]\n"
|
||||||
"Zone:1, Sec#:0, Addr:0x00010000, Size:0x2000, Caps:0x7\n"
|
"Zone:1, Sec#:0, Addr:0x00010000, Size:0x2000, Caps:0x7 [REW]\n"
|
||||||
"Zone:1, Sec#:0, Addr:0x00012000, Size:0x2000, Caps:0x7\n"
|
"Zone:1, Sec#:0, Addr:0x00012000, Size:0x2000, Caps:0x7 [REW]\n"
|
||||||
"Zone:2, Sec#:0, Addr:0x00080000, Size:0x6000, Caps:0x7\n"
|
"Zone:2, Sec#:0, Addr:0x00080000, Size:0x6000, Caps:0x7 [REW]\n"
|
||||||
"Zone:2, Sec#:0, Addr:0x00086000, Size:0x6000, Caps:0x7",
|
"Zone:2, Sec#:0, Addr:0x00086000, Size:0x6000, Caps:0x7 [REW]",
|
||||||
&error);
|
&error);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
g_assert (ret);
|
g_assert (ret);
|
||||||
|
Loading…
Reference in New Issue
Block a user