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

14832
}  // namespace node