LCOV - code coverage report
Current view: top level - Modules - getbuildinfo.c (source / functions) Hit Total Coverage
Test: CPython lcov report Lines: 14 16 87.5 %
Date: 2022-07-07 18:19:46 Functions: 3 3 100.0 %

          Line data    Source code
       1             : #include "Python.h"
       2             : 
       3             : #ifndef DONT_HAVE_STDIO_H
       4             : #include <stdio.h>
       5             : #endif
       6             : 
       7             : #ifndef DATE
       8             : #ifdef __DATE__
       9             : #define DATE __DATE__
      10             : #else
      11             : #define DATE "xx/xx/xx"
      12             : #endif
      13             : #endif
      14             : 
      15             : #ifndef TIME
      16             : #ifdef __TIME__
      17             : #define TIME __TIME__
      18             : #else
      19             : #define TIME "xx:xx:xx"
      20             : #endif
      21             : #endif
      22             : 
      23             : /* XXX Only unix build process has been tested */
      24             : #ifndef GITVERSION
      25             : #define GITVERSION ""
      26             : #endif
      27             : #ifndef GITTAG
      28             : #define GITTAG ""
      29             : #endif
      30             : #ifndef GITBRANCH
      31             : #define GITBRANCH ""
      32             : #endif
      33             : 
      34             : const char *
      35        3153 : Py_GetBuildInfo(void)
      36             : {
      37             :     static char buildinfo[50 + sizeof(GITVERSION) +
      38             :                           ((sizeof(GITTAG) > sizeof(GITBRANCH)) ?
      39             :                            sizeof(GITTAG) : sizeof(GITBRANCH))];
      40        3153 :     const char *revision = _Py_gitversion();
      41        3153 :     const char *sep = *revision ? ":" : "";
      42        3153 :     const char *gitid = _Py_gitidentifier();
      43        3153 :     if (!(*gitid)) {
      44           0 :         gitid = "main";
      45             :     }
      46        3153 :     PyOS_snprintf(buildinfo, sizeof(buildinfo),
      47             :                   "%s%s%s, %.20s, %.9s", gitid, sep, revision,
      48             :                   DATE, TIME);
      49        3153 :     return buildinfo;
      50             : }
      51             : 
      52             : const char *
      53        6287 : _Py_gitversion(void)
      54             : {
      55        6287 :     return GITVERSION;
      56             : }
      57             : 
      58             : const char *
      59        6287 : _Py_gitidentifier(void)
      60             : {
      61             :     const char *gittag, *gitid;
      62        6287 :     gittag = GITTAG;
      63        6287 :     if ((*gittag) && strcmp(gittag, "undefined") != 0)
      64        6287 :         gitid = gittag;
      65             :     else
      66           0 :         gitid = GITBRANCH;
      67        6287 :     return gitid;
      68             : }

Generated by: LCOV version 1.14