mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-08 07:22:12 +00:00
unifying: Ignore spaces in the version prefix
This commit is contained in:
parent
7a7591a99a
commit
2bdc588112
@ -68,7 +68,14 @@ lu_dump_raw (const gchar *title, const guint8 *data, gsize len)
|
|||||||
gchar *
|
gchar *
|
||||||
lu_format_version (const gchar *name, guint8 major, guint8 minor, guint16 build)
|
lu_format_version (const gchar *name, guint8 major, guint8 minor, guint16 build)
|
||||||
{
|
{
|
||||||
return g_strdup_printf ("%s%02x.%02x_B%04x", name, major, minor, build);
|
GString *str = g_string_new (NULL);
|
||||||
|
for (guint i = 0; i < 3; i++) {
|
||||||
|
if (g_ascii_isspace (name[i]))
|
||||||
|
continue;
|
||||||
|
g_string_append_c (str, name[i]);
|
||||||
|
}
|
||||||
|
g_string_append_printf (str, "%02x.%02x_B%04x", major, minor, build);
|
||||||
|
return g_string_free (str, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
56
plugins/unifying/lu-self-test.c
Normal file
56
plugins/unifying/lu-self-test.c
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017 Richard Hughes <richard@hughsie.com>
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License Version 2
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <fwupd.h>
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#include "lu-common.h"
|
||||||
|
|
||||||
|
static void
|
||||||
|
lu_common_func (void)
|
||||||
|
{
|
||||||
|
guint8 u8;
|
||||||
|
guint16 u16;
|
||||||
|
g_autofree gchar *ver1 = NULL;
|
||||||
|
|
||||||
|
u8 = lu_buffer_read_uint8 ("12");
|
||||||
|
g_assert_cmpint (u8, ==, 0x12);
|
||||||
|
u16 = lu_buffer_read_uint16 ("1234");
|
||||||
|
g_assert_cmpint (u16, ==, 0x1234);
|
||||||
|
|
||||||
|
ver1 = lu_format_version (" A ", 0x87, 0x65, 0x4321);
|
||||||
|
g_assert_cmpstr (ver1, ==, "A87.65_B4321");
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
g_test_init (&argc, &argv, NULL);
|
||||||
|
|
||||||
|
/* only critical and error are fatal */
|
||||||
|
g_log_set_fatal_mask (NULL, G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL);
|
||||||
|
|
||||||
|
/* tests go here */
|
||||||
|
g_test_add_func ("/unifying/common", lu_common_func);
|
||||||
|
return g_test_run ();
|
||||||
|
}
|
@ -53,3 +53,26 @@ executable(
|
|||||||
],
|
],
|
||||||
c_args : cargs,
|
c_args : cargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if get_option('enable-tests')
|
||||||
|
e = executable(
|
||||||
|
'unifying-self-test',
|
||||||
|
sources : [
|
||||||
|
'lu-self-test.c',
|
||||||
|
'lu-common.c',
|
||||||
|
],
|
||||||
|
include_directories : [
|
||||||
|
include_directories('../..'),
|
||||||
|
include_directories('../../libfwupd'),
|
||||||
|
],
|
||||||
|
dependencies : [
|
||||||
|
plugin_deps,
|
||||||
|
gudev,
|
||||||
|
],
|
||||||
|
link_with : [
|
||||||
|
fwupd,
|
||||||
|
],
|
||||||
|
c_args : cargs,
|
||||||
|
)
|
||||||
|
test('unifying-self-test', e)
|
||||||
|
endif
|
||||||
|
Loading…
Reference in New Issue
Block a user