LCOV - code coverage report
Current view: top level - libc/test - run-snprintf-test.c (source / functions) Hit Total Coverage
Test: skiboot.info Lines: 10 11 90.9 %
Date: 2024-01-02 21:04:04 Functions: 2 2 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : // SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
       2                 :            : /*
       3                 :            :  * Copyright 2013-2015 IBM Corp.
       4                 :            :  *
       5                 :            :  * This file is run with the skiboot libc files rather than system libc.
       6                 :            :  * This means we have a bit of "fun" with actually executing the tests on
       7                 :            :  * the host.
       8                 :            :  * Patches to make this less ugly are very welcome.
       9                 :            :  */
      10                 :            : 
      11                 :            : #include <config.h>
      12                 :            : #include <stdarg.h>
      13                 :            : 
      14                 :            : #include "../stdio/snprintf.c"
      15                 :            : #include "../stdio/vsnprintf.c"
      16                 :            : 
      17                 :            : int test1(void);
      18                 :            : 
      19                 :          5 : int test1(void)
      20                 :            : {
      21                 :          5 :         return snprintf(NULL, 1, "Hello");
      22                 :            : }
      23                 :            : 
      24                 :            : int skiboot_snprintf(char *buf, size_t bufsz, size_t l, const char* format, ...);
      25                 :            : 
      26                 :       1630 : int skiboot_snprintf(char *buf, size_t bufsz, size_t l, const char* format, ...)
      27                 :            : {
      28                 :            :         va_list ar;
      29                 :            :         int count;
      30                 :            : 
      31                 :       1630 :         if (buf)
      32                 :       1630 :                 memset(buf, 0, bufsz);
      33                 :            : 
      34                 :       1630 :         if ((buf==NULL) || (format==NULL))
      35                 :          0 :                 return(-1);
      36                 :            : 
      37                 :       1630 :         va_start(ar, format);
      38                 :       1630 :         count = vsnprintf(buf, l, format, ar);
      39                 :       1630 :         va_end(ar);
      40                 :            : 
      41                 :       1630 :         return(count);
      42                 :            : }

Generated by: LCOV version 1.14