LCOV - code coverage report
Current view: top level - lib/gltests - test-sys_wait.h (source / functions) Hit Total Coverage
Test: GNU SASL Lines: 7 8 87.5 %
Date: 2010-09-27 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 7 8 87.5 %

           Branch data     Line data    Source code
       1                 :            : /* Test of macros shared between <sys/wait.h> and <stdlib.h>.
       2                 :            :    Copyright (C) 2010 Free Software Foundation, Inc.
       3                 :            : 
       4                 :            :    This program is free software: you can redistribute it and/or modify
       5                 :            :    it under the terms of the GNU General Public License as published by
       6                 :            :    the Free Software Foundation; either version 3 of the License, or
       7                 :            :    (at your option) any later version.
       8                 :            : 
       9                 :            :    This program is distributed in the hope that it will be useful,
      10                 :            :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      11                 :            :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12                 :            :    GNU General Public License for more details.
      13                 :            : 
      14                 :            :    You should have received a copy of the GNU General Public License
      15                 :            :    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
      16                 :            : 
      17                 :            : /* Written by Eric Blake <ebb9@byu.net>, 2010.  */
      18                 :            : 
      19                 :            : static int
      20                 :          2 : test_sys_wait_macros (void)
      21                 :            : {
      22                 :            :   /* Check subset of <sys/wait.h> macros that must be visible here.
      23                 :            :      Note that some of these macros are only portable when operating
      24                 :            :      on an lvalue.  */
      25                 :            :   int i;
      26 [ +  + ][ +  + ]:         34 :   for (i = 0; i < 0x8000; i = (i ? i << 1 : 1))
      27                 :            :     {
      28                 :            :       /* POSIX requires that for all valid process statuses, that
      29                 :            :          exactly one of these three macros is true.  But not all
      30                 :            :          possible 16-bit values map to valid process status.
      31                 :            :          Traditionally, 8 of the bits are for WIFEXITED, 7 of the bits
      32                 :            :          to tell between WIFSIGNALED and WIFSTOPPED, and either 0x80
      33                 :            :          or 0x8000 to flag that core was also dumped.  Since we don't
      34                 :            :          know which byte is WIFEXITED, we skip the both possible bits
      35                 :            :          that can signal core dump.  */
      36         [ +  + ]:         32 :       if (i == 0x80)
      37                 :          2 :         continue;
      38         [ -  + ]:         30 :       if (!!WIFSIGNALED (i) + !!WIFEXITED (i) + !!WIFSTOPPED (i) != 1)
      39                 :          0 :         return 1;
      40                 :            :     }
      41                 :          2 :   i = WEXITSTATUS (i) + WSTOPSIG (i) + WTERMSIG (i);
      42                 :            : 
      43                 :            :   switch (i)
      44                 :            :     {
      45                 :            : #if 0
      46                 :            :   /* Gnulib doesn't guarantee these, yet.  */
      47                 :            :     case WNOHANG:
      48                 :            :     case WUNTRACED:
      49                 :            : #endif
      50                 :            :       break;
      51                 :            :     }
      52                 :          2 :   return 0;
      53                 :            : }

Generated by: LCOV version 1.8