summaryrefslogtreecommitdiffstats
path: root/tests/info
diff options
context:
space:
mode:
Diffstat (limited to 'tests/info')
-rw-r--r--tests/info/info-cleanup-test.txt19
-rw-r--r--tests/info/meson.build21
-rw-r--r--tests/info/test-info-cleanup.c81
3 files changed, 121 insertions, 0 deletions
diff --git a/tests/info/info-cleanup-test.txt b/tests/info/info-cleanup-test.txt
new file mode 100644
index 0000000..a0e25fb
--- /dev/null
+++ b/tests/info/info-cleanup-test.txt
@@ -0,0 +1,19 @@
+Intel(R) Core(TM) i5-4590T CPU @ 2.00GHz Intel® Core™ i5-4590T
+Intel(R) Ivybridge Mobile Intel® Ivybridge Mobile
+Intel(R) Ivybridge Mobile Intel® Ivybridge Mobile
+Gallium 0.4 on AMD KAVERI AMD KAVERI
+AMD KAVERI (DRM 2.48.0 / 4.9.0-0.rc4.git2.2.fc26.x86_64, LLVM3) AMD KAVERI
+AMD KAVERI (DRM 2.48.0 / 4.9.0-0.rc4.git2.2.fc26.x86_64, LLVM3 AMD KAVERI
+Gallium 0.4 on AMD KAVERI (DRM 2.48.0 / 4.9.0-0.rc4.git2.2.fc26.x86_64, LLVM3) AMD KAVERI
+Gallium 0.4 on AMD KAVERI (DRM 2.48.0 / 4.9.0-0.rc4.git2.2.fc26.x86_64, LLVM3 AMD KAVERI
+AMD Ryzen Threadripper 1950X 16-Core Processor AMD Ryzen™ Threadripper™ 1950X
+AMD Radeon RX 580 Series (POLARIS10, DRM 3.42.0, 5.15.13-1-ck-generic-v3, LLVM 13.0.0) AMD Radeon™ RX 580 Series
+AMD EPYC 7251 8-Core Processor AMD EPYC™ 7251
+Gallium 0.4 on SVGA3D SVGA3D
+Gallium 0.4 on llvmpipe (LLVM 3.4, 128 bits) Software Rendering
+llvmpipe (LLVM 12.0.1, 256 bits) Software Rendering
+AMD FX(tm)-8350 Eight-Core Processor AMD FX™-8350
+AMD Athlon(tm) II X3 435 Processor AMD Athlon™ II X3 435
+NVIDIA GeForce GT 710/PCIe/SSE2 NVIDIA GeForce GT 710
+Mesa DRI Intel(R) 965GM x86/MMX/SSE2 Intel® 965GM
+NVIDIA GeForce RTX 3090/PCIe/SSE2 NVIDIA GeForce RTX™ 3090
diff --git a/tests/info/meson.build b/tests/info/meson.build
new file mode 100644
index 0000000..0f5d7a9
--- /dev/null
+++ b/tests/info/meson.build
@@ -0,0 +1,21 @@
+
+test_units = [
+ 'test-info-cleanup'
+]
+
+includes = [top_inc, include_directories('../../panels/info-overview')]
+cflags = '-DTEST_SRCDIR="@0@"'.format(meson.current_source_dir())
+
+foreach unit: test_units
+ exe = executable(
+ unit,
+ [unit + '.c'],
+ include_directories : includes,
+ dependencies : common_deps,
+ link_with : [info_panel_lib],
+ c_args : cflags
+ )
+
+ test(unit, exe)
+endforeach
+
diff --git a/tests/info/test-info-cleanup.c b/tests/info/test-info-cleanup.c
new file mode 100644
index 0000000..3e6bebd
--- /dev/null
+++ b/tests/info/test-info-cleanup.c
@@ -0,0 +1,81 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2010 Red Hat, Inc
+ * Copyright (C) 2008 William Jon McCann <jmccann@redhat.com>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <config.h>
+
+#include <glib.h>
+#include <locale.h>
+#include "info-cleanup.h"
+
+static void
+test_info (void)
+{
+ g_autofree gchar *contents = NULL;
+ guint i;
+ g_auto(GStrv) lines = NULL;
+
+ if (g_file_get_contents (TEST_SRCDIR "/info-cleanup-test.txt", &contents, NULL, NULL) == FALSE) {
+ g_warning ("Failed to load '%s'", TEST_SRCDIR "/info-cleanup-test.txt");
+ g_test_fail ();
+ return;
+ }
+
+ lines = g_strsplit (contents, "\n", -1);
+ if (lines == NULL) {
+ g_warning ("Test file is empty");
+ g_test_fail ();
+ return;
+ }
+
+ for (i = 0; lines[i] != NULL; i++) {
+ g_auto(GStrv) items = NULL;
+ g_autofree gchar *utf8 = NULL;
+ g_autofree gchar *result = NULL;
+
+ if (*lines[i] == '#')
+ continue;
+ if (*lines[i] == '\0')
+ break;
+
+ items = g_strsplit (lines[i], "\t", -1);
+ utf8 = g_locale_from_utf8 (items[0], -1, NULL, NULL, NULL);
+ result = info_cleanup (items[0]);
+ if (g_strcmp0 (result, items[1]) != 0) {
+ g_error ("Result for '%s' doesn't match '%s' (got: '%s')",
+ utf8, items[1], result);
+ g_test_fail ();
+ } else {
+ g_debug ("Result for '%s' matches '%s'",
+ utf8, result);
+ }
+ }
+}
+
+int main (int argc, char **argv)
+{
+ setlocale (LC_ALL, "");
+ g_test_init (&argc, &argv, NULL);
+
+ g_setenv ("G_DEBUG", "fatal_warnings", FALSE);
+
+ g_test_add_func ("/info/info", test_info);
+
+ return g_test_run ();
+}