GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage-daily/nodes/benchmark/out/../src/node_metadata.cc Lines: 46 46 100.0 %
Date: 2021-05-26 04:16:18 Branches: 6 10 60.0 %

Line Branch Exec Source
1
#include "node_metadata.h"
2
#include "ares.h"
3
#include "brotli/encode.h"
4
#include "llhttp.h"
5
#include "nghttp2/nghttp2ver.h"
6
#include "node.h"
7
#include "util.h"
8
#include "uv.h"
9
#include "v8.h"
10
#include "zlib.h"
11
12
#if HAVE_OPENSSL
13
#include <openssl/opensslv.h>
14
#endif  // HAVE_OPENSSL
15
16
#ifdef OPENSSL_INFO_QUIC
17
#include <ngtcp2/version.h>
18
#include <nghttp3/version.h>
19
#endif
20
21
#ifdef NODE_HAVE_I18N_SUPPORT
22
#include <unicode/timezone.h>
23
#include <unicode/ulocdata.h>
24
#include <unicode/uvernum.h>
25
#include <unicode/uversion.h>
26
#endif  // NODE_HAVE_I18N_SUPPORT
27
28
namespace node {
29
30
namespace per_process {
31
4840
Metadata metadata;
32
}
33
34
#if HAVE_OPENSSL
35
96800
constexpr int search(const char* s, int n, int c) {
36
96800
  return *s == c ? n : search(s + 1, n + 1, c);
37
}
38
39
4840
std::string GetOpenSSLVersion() {
40
  // sample openssl version string format
41
  // for reference: "OpenSSL 1.1.0i 14 Aug 2018"
42
  char buf[128];
43
4840
  const char* etext = OPENSSL_VERSION_TEXT;
44
4840
  const int start = search(etext, 0, ' ') + 1;
45
4840
  etext += start;
46
4840
  const int end = search(etext, start, ' ');
47
4840
  const int len = end - start;
48
4840
  snprintf(buf, sizeof(buf), "%.*s", len, &OPENSSL_VERSION_TEXT[start]);
49
4840
  return std::string(buf);
50
}
51
#endif  // HAVE_OPENSSL
52
53
#ifdef NODE_HAVE_I18N_SUPPORT
54
4788
void Metadata::Versions::InitializeIntlVersions() {
55
4788
  UErrorCode status = U_ZERO_ERROR;
56
57
4788
  const char* tz_version = icu::TimeZone::getTZDataVersion(status);
58
4788
  if (U_SUCCESS(status)) {
59
4788
    tz = tz_version;
60
  }
61
62
  char buf[U_MAX_VERSION_STRING_LENGTH];
63
  UVersionInfo versionArray;
64
4788
  ulocdata_getCLDRVersion(versionArray, &status);
65
4788
  if (U_SUCCESS(status)) {
66
4788
    u_versionToString(versionArray, buf);
67
4788
    cldr = buf;
68
  }
69
4788
}
70
#endif  // NODE_HAVE_I18N_SUPPORT
71
72
4840
Metadata::Versions::Versions() {
73
4840
  node = NODE_VERSION_STRING;
74
4840
  v8 = v8::V8::GetVersion();
75
4840
  uv = uv_version_string();
76
4840
  zlib = ZLIB_VERSION;
77
4840
  ares = ARES_VERSION_STR;
78
4840
  modules = NODE_STRINGIFY(NODE_MODULE_VERSION);
79
4840
  nghttp2 = NGHTTP2_VERSION;
80
4840
  napi = NODE_STRINGIFY(NAPI_VERSION);
81
  llhttp =
82
      NODE_STRINGIFY(LLHTTP_VERSION_MAJOR)
83
      "."
84
      NODE_STRINGIFY(LLHTTP_VERSION_MINOR)
85
      "."
86
4840
      NODE_STRINGIFY(LLHTTP_VERSION_PATCH);
87
88
  brotli =
89
9680
    std::to_string(BrotliEncoderVersion() >> 24) +
90
9680
    "." +
91
19360
    std::to_string((BrotliEncoderVersion() & 0xFFF000) >> 12) +
92
9680
    "." +
93
14520
    std::to_string(BrotliEncoderVersion() & 0xFFF);
94
95
#if HAVE_OPENSSL
96
4840
  openssl = GetOpenSSLVersion();
97
#endif
98
99
#ifdef NODE_HAVE_I18N_SUPPORT
100
4840
  icu = U_ICU_VERSION;
101
4840
  unicode = U_UNICODE_VERSION;
102
#endif  // NODE_HAVE_I18N_SUPPORT
103
104
#ifdef OPENSSL_INFO_QUIC
105
4840
  ngtcp2 = NGTCP2_VERSION;
106
4840
  nghttp3 = NGHTTP3_VERSION;
107
#endif
108
4840
}
109
110
4840
Metadata::Release::Release() : name(NODE_RELEASE) {
111
#if NODE_VERSION_IS_LTS
112
  lts = NODE_VERSION_LTS_CODENAME;
113
#endif  // NODE_VERSION_IS_LTS
114
115
#ifdef NODE_HAS_RELEASE_URLS
116
#define NODE_RELEASE_URLPFX NODE_RELEASE_URLBASE "v" NODE_VERSION_STRING "/"
117
#define NODE_RELEASE_URLFPFX NODE_RELEASE_URLPFX "node-v" NODE_VERSION_STRING
118
119
  source_url = NODE_RELEASE_URLFPFX ".tar.gz";
120
  headers_url = NODE_RELEASE_URLFPFX "-headers.tar.gz";
121
#ifdef _WIN32
122
  lib_url = strcmp(NODE_ARCH, "ia32") ? NODE_RELEASE_URLPFX "win-" NODE_ARCH
123
                                                           "/node.lib"
124
                                     : NODE_RELEASE_URLPFX "win-x86/node.lib";
125
#endif  // _WIN32
126
127
#endif  // NODE_HAS_RELEASE_URLS
128
4840
}
129
130
4840
Metadata::Metadata() : arch(NODE_ARCH), platform(NODE_PLATFORM) {}
131
132

14520
}  // namespace node