File: testutils.h

package info (click to toggle)
glib2.0 2.84.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 66,144 kB
  • sloc: ansic: 538,877; python: 9,624; sh: 1,572; xml: 1,482; perl: 1,222; cpp: 535; makefile: 316; javascript: 11
file content (50 lines) | stat: -rw-r--r-- 1,698 bytes parent folder | download | duplicates (4)
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
/*
 * Copyright 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
 * Copyright 2023 Collabora Ltd.
 *
 * SPDX-License-Identifier: LicenseRef-old-glib-tests
 *
 * This work is provided "as is"; redistribution and modification
 * in whole or in part, in any medium, physical or electronic is
 * permitted without restriction.
 *
 * This work 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.
 *
 * In no event shall the authors or contributors be liable for any
 * direct, indirect, incidental, special, exemplary, or consequential
 * damages (including, but not limited to, procurement of substitute
 * goods or services; loss of use, data, or profits; or business
 * interruption) however caused and on any theory of liability, whether
 * in contract, strict liability, or tort (including negligence or
 * otherwise) arising in any way out of the use of this software, even
 * if advised of the possibility of such damage.
 */

#include "config.h"

#include <errno.h>

#include "glib-private.h"
#include "gstdio.h"

static inline void
assert_fd_was_closed (int fd)
{
  /* We can't tell a fd was really closed without behaving as though it
   * was still valid */
  if (g_test_undefined ())
    {
      int result, errsv;
      GWin32InvalidParameterHandler handler;

      GLIB_PRIVATE_CALL (g_win32_push_empty_invalid_parameter_handler) (&handler);
      result = g_fsync (fd);
      errsv = errno;
      GLIB_PRIVATE_CALL (g_win32_pop_invalid_parameter_handler) (&handler);

      g_assert_cmpint (result, !=, 0);
      g_assert_cmpint (errsv, ==, EBADF);
    }
}