1/* GLib testing framework examples and tests
2 *
3 * Copyright © 2017 Endless Mobile, Inc.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library 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 GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include <glib.h>
20
21#ifndef G_OS_UNIX
22#error This is a Unix-specific test
23#endif
24
25#include <errno.h>
26#include <locale.h>
27#include <glib/gstdio.h>
28#include <gio/gio.h>
29#include <gio/gunixmounts.h>
30
31static void
32test_is_system_fs_type (void)
33{
34 g_assert_true (g_unix_is_system_fs_type ("tmpfs"));
35 g_assert_false (g_unix_is_system_fs_type ("ext4"));
36
37 /* Check that some common network file systems aren’t considered ‘system’. */
38 g_assert_false (g_unix_is_system_fs_type ("cifs"));
39 g_assert_false (g_unix_is_system_fs_type ("nfs"));
40 g_assert_false (g_unix_is_system_fs_type ("nfs4"));
41 g_assert_false (g_unix_is_system_fs_type ("smbfs"));
42}
43
44static void
45test_is_system_device_path (void)
46{
47 g_assert_true (g_unix_is_system_device_path ("devpts"));
48 g_assert_false (g_unix_is_system_device_path ("/"));
49}
50
51int
52main (int argc,
53 char *argv[])
54{
55 setlocale (LC_ALL, locale: "");
56
57 g_test_init (argc: &argc, argv: &argv, NULL);
58
59 g_test_add_func (testpath: "/unix-mounts/is-system-fs-type", test_func: test_is_system_fs_type);
60 g_test_add_func (testpath: "/unix-mounts/is-system-device-path", test_func: test_is_system_device_path);
61
62 return g_test_run ();
63}
64

source code of gtk/subprojects/glib/gio/tests/unix-mounts.c