Debian Codegraph @

src/libsysprof/tests/test-list-files.c

raw
1 /* test-list-files.c
2 *
3 * Copyright 2023 Christian Hergert <[email protected]>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * SPDX-License-Identifier: GPL-3.0-or-later
19 */
20
21 #include <sysprof.h>
22
23 #include "sysprof-document-private.h"
24
25 int
26 main (int argc,
27 char *argv[])
28 {
29 g_autoptr(SysprofDocumentLoader) loader = NULL;
30 g_autoptr(SysprofDocument) document = NULL;
31 g_autoptr(GListModel) files = NULL;
32 g_autoptr(GError) error = NULL;
33 guint n_items;
34
35 if (argc < 2)
36 {
37 g_printerr ("usage: %s CAPTURE_FILE\n", argv[0]);
38 return 1;
39 }
40
41 loader = sysprof_document_loader_new (argv[1]);
42 sysprof_document_loader_set_symbolizer (loader, sysprof_no_symbolizer_get ());
43
44 if (!(document = sysprof_document_loader_load (loader, NULL, &error)))
45 {
46 g_printerr ("Failed to open capture: %s\n", error->message);
47 return 1;
48 }
49
50 files = sysprof_document_list_files (document);
51 n_items = g_list_model_get_n_items (files);
52
53 for (guint i = 0; i < n_items; i++)
54 {
55 g_autoptr(SysprofDocumentFile) file = g_list_model_get_item (files, i);
56
57 g_print ("%s\n", sysprof_document_file_get_path (file));
58 }
59
60 return 0;
61 }