Debian Codegraph @

subprojects/libglnx/tests/libglnx-testlib.c

raw symbols SCIP
1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
2 *
3 * Copyright 2019 Collabora Ltd.
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #include "libglnx-config.h"cxx . . $ `<file>/build/subprojects/libglnx/libglnx-config.h`/
23 #include "libglnx-testlib.h"cxx . . $ `<file>/subprojects/libglnx/tests/libglnx-testlib.h`/
24
25 #include <errno.h>
26
27 #include <glib/gstdio.h>
28
29 #include "libglnx.h"cxx . . $ `<file>/subprojects/libglnx/libglnx.h`/
30
31 struct _GLnxTestAutoTempDircxx . . $ _GLnxTestAutoTempDir#
32 {
33 gcharcxx . . $ gchar# *old_cwdcxx . . $ _GLnxTestAutoTempDir#old_cwd.;
34 int old_cwd_fdcxx . . $ _GLnxTestAutoTempDir#old_cwd_fd.;
35 GLnxTmpDircxx . . $ GLnxTmpDir# temp_dircxx . . $ _GLnxTestAutoTempDir#temp_dir.;
36 };
37
38 _GLnxTestAutoTempDircxx . . $ _GLnxTestAutoTempDir# *
39 _glnx_test_auto_temp_dir_entercxx . . $ _glnx_test_auto_temp_dir_enter(7a13244e50b9041d). (void)
40 {
41 GErrorcxx . . $ GError# *error = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
42 _GLnxTestAutoTempDircxx . . $ _GLnxTestAutoTempDir# *ret = g_new0cxx . . $ `<external>/1123956534522462559/gmem.h:335:9`! (_GLnxTestAutoTempDir, 1);
43
44 glnx_mkdtempcxx . . $ glnx_mkdtemp(a9f251f616dfa564). ("glnx-test-XXXXXX", 0700, &ret->temp_dircxx . . $ _GLnxTestAutoTempDir#temp_dir., &error);
45 g_assert_no_errorcxx . . $ `<external>/15287032793271088244/gtestutils.h:217:9`! (error);
46
47 /* just for better diagnostics */
48 ret->old_cwdcxx . . $ _GLnxTestAutoTempDir#old_cwd. = g_get_current_dircxx . . $ g_get_current_dir(41208ce6ca65dd58). ();
49
50 glnx_opendiratcxx . . $ glnx_opendirat(eb9f38a2463f19dd). (-1, ".", TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!, &ret->old_cwd_fdcxx . . $ _GLnxTestAutoTempDir#old_cwd_fd., &error);
51 g_assert_no_errorcxx . . $ `<external>/15287032793271088244/gtestutils.h:217:9`! (error);
52
53 if (fchdircxx . . $ fchdir(7864480464b09eea). (ret->temp_dircxx . . $ _GLnxTestAutoTempDir#temp_dir..fdcxx . . $ $anonymous_type_a217104d0ce37183_0#fd.) != 0)
54 g_errorcxx . . $ `<external>/5169755362661750954/gmessages.h:353:9`! ("fchdir(<fd for \"%s\">): %s", ret->temp_dir.path, g_strerror (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
55
56 return ret;
57 }
58
59 void
60 _glnx_test_auto_temp_dir_leavecxx . . $ _glnx_test_auto_temp_dir_leave(caeb283f8b203b48). (_GLnxTestAutoTempDircxx . . $ _GLnxTestAutoTempDir# *dir)
61 {
62 GErrorcxx . . $ GError# *error = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
63
64 if (fchdircxx . . $ fchdir(7864480464b09eea). (dir->old_cwd_fdcxx . . $ _GLnxTestAutoTempDir#old_cwd_fd.) != 0)
65 g_errorcxx . . $ `<external>/5169755362661750954/gmessages.h:353:9`! ("fchdir(<fd for \"%s\">): %s", dir->old_cwd, g_strerror (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
66
67 glnx_tmpdir_deletecxx . . $ glnx_tmpdir_delete(44da3ec24a796a35). (&dir->temp_dircxx . . $ _GLnxTestAutoTempDir#temp_dir., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, &error);
68 g_assert_no_errorcxx . . $ `<external>/15287032793271088244/gtestutils.h:217:9`! (error);
69
70 glnx_close_fdcxx . . $ glnx_close_fd(11b0e290e57a7e53). (&dir->old_cwd_fdcxx . . $ _GLnxTestAutoTempDir#old_cwd_fd.);
71
72 g_freecxx . . $ g_free(5d22bdacc48458e8). (dir->old_cwdcxx . . $ _GLnxTestAutoTempDir#old_cwd.);
73 g_freecxx . . $ g_free(5d22bdacc48458e8). (dir);
74 }