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

15102
}  // namespace node