1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
/*
* Copyright (C) 2022 The Phosh Developers
*
* SPDX-License-Identifier: GPL-3-or-later
*
* Author: Guido Günther <agx@sigxcpu.org>
*/
#define GMOBILE_USE_UNSTABLE_API
#include "gmobile.h"
#include "gio/gio.h"
static void
test_gm_device_tree_get_compatibles (void)
{
g_auto (GStrv) compatibles = NULL;
GError *err = NULL;
/* nonexistent */
compatibles = gm_device_tree_get_compatibles (TEST_DATA_DIR "/doesnotexist", &err);
g_assert_null (compatibles);
g_assert_error (err, G_IO_ERROR, G_IO_ERROR_NOT_FOUND);
g_clear_error (&err);
/* nonexistent, don't store error */
compatibles = gm_device_tree_get_compatibles (TEST_DATA_DIR "/doesnotexist", NULL);
g_assert_null (compatibles);
/* Regular format */
compatibles = gm_device_tree_get_compatibles (TEST_DATA_DIR "/compatibles1", &err);
g_assert_no_error (err);
g_assert_nonnull (compatibles);
g_assert_cmpstr (compatibles[0], ==, "purism,librem5r4");
g_assert_cmpstr (compatibles[1], ==, "purism,librem5");
g_assert_cmpstr (compatibles[2], ==, "fsl,imx8mq");
g_assert_null (compatibles[3]);
g_strfreev (compatibles);
/* empty file */
compatibles = gm_device_tree_get_compatibles (TEST_DATA_DIR "/compatibles2", &err);
g_assert_no_error (err);
g_assert_nonnull (compatibles);
}
gint
main (gint argc, gchar *argv[])
{
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/Gm/device-tree/get-compatibles", test_gm_device_tree_get_compatibles);
return g_test_run ();
}
|