LCOV - code coverage report
Current view: top level - glib/glib/tests - testutils.h (source / functions) Hit Total Coverage
Test: unnamed Lines: 9 9 100.0 %
Date: 2024-04-23 05:16:05 Functions: 1 1 100.0 %
Branches: 1 2 50.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
       3                 :            :  * Copyright 2023 Collabora Ltd.
       4                 :            :  *
       5                 :            :  * SPDX-License-Identifier: LicenseRef-old-glib-tests
       6                 :            :  *
       7                 :            :  * This work is provided "as is"; redistribution and modification
       8                 :            :  * in whole or in part, in any medium, physical or electronic is
       9                 :            :  * permitted without restriction.
      10                 :            :  *
      11                 :            :  * This work 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.
      14                 :            :  *
      15                 :            :  * In no event shall the authors or contributors be liable for any
      16                 :            :  * direct, indirect, incidental, special, exemplary, or consequential
      17                 :            :  * damages (including, but not limited to, procurement of substitute
      18                 :            :  * goods or services; loss of use, data, or profits; or business
      19                 :            :  * interruption) however caused and on any theory of liability, whether
      20                 :            :  * in contract, strict liability, or tort (including negligence or
      21                 :            :  * otherwise) arising in any way out of the use of this software, even
      22                 :            :  * if advised of the possibility of such damage.
      23                 :            :  */
      24                 :            : 
      25                 :            : #include "config.h"
      26                 :            : 
      27                 :            : #include <errno.h>
      28                 :            : 
      29                 :            : #include "glib-private.h"
      30                 :            : #include "gstdio.h"
      31                 :            : 
      32                 :            : static inline void
      33                 :         14 : assert_fd_was_closed (int fd)
      34                 :            : {
      35                 :            :   /* We can't tell a fd was really closed without behaving as though it
      36                 :            :    * was still valid */
      37         [ +  - ]:         14 :   if (g_test_undefined ())
      38                 :            :     {
      39                 :            :       int result, errsv;
      40                 :            :       GWin32InvalidParameterHandler handler;
      41                 :            : 
      42                 :         14 :       GLIB_PRIVATE_CALL (g_win32_push_empty_invalid_parameter_handler) (&handler);
      43                 :         14 :       result = g_fsync (fd);
      44                 :         14 :       errsv = errno;
      45                 :         14 :       GLIB_PRIVATE_CALL (g_win32_pop_invalid_parameter_handler) (&handler);
      46                 :            : 
      47                 :         14 :       g_assert_cmpint (result, !=, 0);
      48                 :         14 :       g_assert_cmpint (errsv, ==, EBADF);
      49                 :            :     }
      50                 :         14 : }

Generated by: LCOV version 1.14