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: 44 44 100.0 %
Date: 2020-09-06 22:14:11 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
#if defined(NODE_EXPERIMENTAL_QUIC) && NODE_EXPERIMENTAL_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
4473
Metadata metadata;
32
}
33
34
#if HAVE_OPENSSL
35
67095
constexpr int search(const char* s, int n, int c) {
36
67095
  return *s == c ? n : search(s + 1, n + 1, c);
37
}
38
39
4473
std::string GetOpenSSLVersion() {
40
  // sample openssl version string format
41
  // for reference: "OpenSSL 1.1.0i 14 Aug 2018"
42
  char buf[128];
43
4473
  const char* etext = OPENSSL_VERSION_TEXT;
44
4473
  const int start = search(etext, 0, ' ') + 1;
45
4473
  etext += start;
46
4473
  const int end = search(etext, start, ' ');
47
4473
  const int len = end - start;
48
4473
  snprintf(buf, sizeof(buf), "%.*s", len, &OPENSSL_VERSION_TEXT[start]);
49
4473
  return std::string(buf);
50
}
51
#endif  // HAVE_OPENSSL
52
53
#ifdef NODE_HAVE_I18N_SUPPORT
54
4417
void Metadata::Versions::InitializeIntlVersions() {
55
4417
  UErrorCode status = U_ZERO_ERROR;
56
57
4417
  const char* tz_version = icu::TimeZone::getTZDataVersion(status);
58
4417
  if (U_SUCCESS(status)) {
59
4417
    tz = tz_version;
60
  }
61
62
  char buf[U_MAX_VERSION_STRING_LENGTH];
63
  UVersionInfo versionArray;
64
4417
  ulocdata_getCLDRVersion(versionArray, &status);
65
4417
  if (U_SUCCESS(status)) {
66
4417
    u_versionToString(versionArray, buf);
67
4417
    cldr = buf;
68
  }
69
4417
}
70
#endif  // NODE_HAVE_I18N_SUPPORT
71
72
4473
Metadata::Versions::Versions() {
73
4473
  node = NODE_VERSION_STRING;
74
4473
  v8 = v8::V8::GetVersion();
75
4473
  uv = uv_version_string();
76
4473
  zlib = ZLIB_VERSION;
77
4473
  ares = ARES_VERSION_STR;
78
4473
  modules = NODE_STRINGIFY(NODE_MODULE_VERSION);
79
4473
  nghttp2 = NGHTTP2_VERSION;
80
4473
  napi = NODE_STRINGIFY(NAPI_VERSION);
81
  llhttp =
82
      NODE_STRINGIFY(LLHTTP_VERSION_MAJOR)
83
      "."
84
      NODE_STRINGIFY(LLHTTP_VERSION_MINOR)
85
      "."
86
4473
      NODE_STRINGIFY(LLHTTP_VERSION_PATCH);
87
88
  brotli =
89
8946
    std::to_string(BrotliEncoderVersion() >> 24) +
90
8946
    "." +
91
17892
    std::to_string((BrotliEncoderVersion() & 0xFFF000) >> 12) +
92
8946
    "." +
93
13419
    std::to_string(BrotliEncoderVersion() & 0xFFF);
94
95
#if HAVE_OPENSSL
96
4473
  openssl = GetOpenSSLVersion();
97
#endif
98
99
#if defined(NODE_EXPERIMENTAL_QUIC) && NODE_EXPERIMENTAL_QUIC
100
  ngtcp2 = NGTCP2_VERSION;
101
  nghttp3 = NGHTTP3_VERSION;
102
#endif
103
104
#ifdef NODE_HAVE_I18N_SUPPORT
105
4473
  icu = U_ICU_VERSION;
106
4473
  unicode = U_UNICODE_VERSION;
107
#endif  // NODE_HAVE_I18N_SUPPORT
108
4473
}
109
110
4473
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
4473
}
129
130
4473
Metadata::Metadata() : arch(NODE_ARCH), platform(NODE_PLATFORM) {}
131
132

13419
}  // namespace node