dsh-remote 0.8.47 → 0.8.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/lib/client.js +89 -16
  2. package/lib/ignore.js +46 -0
  3. package/lib/index.js +68 -23
  4. package/lib/remote-shell-child.cjs +305 -0
  5. package/lib/remote-shell.js +518 -0
  6. package/lib/search.js +8 -3
  7. package/package.json +1 -1
  8. package/node_modules/buildcheck/.eslintrc.js +0 -5
  9. package/node_modules/buildcheck/.github/workflows/ci.yml +0 -88
  10. package/node_modules/buildcheck/.github/workflows/lint.yml +0 -27
  11. package/node_modules/buildcheck/.npmignore +0 -3
  12. package/node_modules/buildcheck/LICENSE +0 -19
  13. package/node_modules/buildcheck/README.md +0 -106
  14. package/node_modules/buildcheck/deps/Find-VisualStudio.cs +0 -250
  15. package/node_modules/buildcheck/lib/findvs.js +0 -361
  16. package/node_modules/buildcheck/lib/index.js +0 -738
  17. package/node_modules/buildcheck/package.json +0 -36
  18. package/node_modules/buildcheck/test/test.js +0 -8
  19. package/node_modules/cpu-features/.eslintrc.js +0 -5
  20. package/node_modules/cpu-features/.github/workflows/ci.yml +0 -74
  21. package/node_modules/cpu-features/.github/workflows/lint.yml +0 -27
  22. package/node_modules/cpu-features/LICENSE +0 -19
  23. package/node_modules/cpu-features/README.md +0 -59
  24. package/node_modules/cpu-features/binding.gyp +0 -16
  25. package/node_modules/cpu-features/buildcheck.js +0 -32
  26. package/node_modules/cpu-features/deps/cpu_features/.clang-format +0 -4
  27. package/node_modules/cpu-features/deps/cpu_features/.dockerignore +0 -31
  28. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/Dockerfile +0 -5
  29. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/aarch64_linux_cmake.yml +0 -30
  30. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/amd64_freebsd_cmake.yml +0 -22
  31. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/amd64_linux_bazel.yml +0 -26
  32. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/amd64_linux_cmake.yml +0 -31
  33. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/amd64_macos_cmake.yml +0 -43
  34. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/amd64_windows_cmake.yml +0 -25
  35. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/arm_linux_cmake.yml +0 -31
  36. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/clang_format.yml +0 -24
  37. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/mips_linux_cmake.yml +0 -30
  38. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/power_linux_cmake.yml +0 -29
  39. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/riscv_linux_cmake.yml +0 -28
  40. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/s390x_linux_cmake.yml +0 -27
  41. package/node_modules/cpu-features/deps/cpu_features/.grenrc.yml +0 -21
  42. package/node_modules/cpu-features/deps/cpu_features/BUILD.bazel +0 -329
  43. package/node_modules/cpu-features/deps/cpu_features/CMakeLists.txt +0 -261
  44. package/node_modules/cpu-features/deps/cpu_features/CONTRIBUTING.md +0 -23
  45. package/node_modules/cpu-features/deps/cpu_features/LICENSE +0 -230
  46. package/node_modules/cpu-features/deps/cpu_features/README.md +0 -272
  47. package/node_modules/cpu-features/deps/cpu_features/WORKSPACE +0 -19
  48. package/node_modules/cpu-features/deps/cpu_features/bazel/ci/README.md +0 -5
  49. package/node_modules/cpu-features/deps/cpu_features/bazel/platforms.bzl +0 -11
  50. package/node_modules/cpu-features/deps/cpu_features/cmake/CpuFeaturesConfig.cmake.in +0 -3
  51. package/node_modules/cpu-features/deps/cpu_features/cmake/CpuFeaturesNdkCompatConfig.cmake.in +0 -3
  52. package/node_modules/cpu-features/deps/cpu_features/cmake/README.md +0 -30
  53. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/Makefile +0 -252
  54. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/README.md +0 -40
  55. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/doc/docker.dot +0 -64
  56. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/doc/docker.svg +0 -312
  57. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/doc/generate_image.sh +0 -7
  58. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/docker/amd64/Dockerfile +0 -48
  59. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/docker/toolchain/Dockerfile +0 -34
  60. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/sample/CMakeLists.txt +0 -22
  61. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/sample/main.cpp +0 -11
  62. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/vagrant/freebsd/Vagrantfile +0 -107
  63. package/node_modules/cpu-features/deps/cpu_features/cmake/googletest.CMakeLists.txt.in +0 -15
  64. package/node_modules/cpu-features/deps/cpu_features/cpu_features.gyp +0 -105
  65. package/node_modules/cpu-features/deps/cpu_features/include/cpu_features_cache_info.h +0 -54
  66. package/node_modules/cpu-features/deps/cpu_features/include/cpu_features_macros.h +0 -384
  67. package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_aarch64.h +0 -259
  68. package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_arm.h +0 -121
  69. package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_mips.h +0 -74
  70. package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_ppc.h +0 -149
  71. package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_riscv.h +0 -72
  72. package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_s390x.h +0 -108
  73. package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_x86.h +0 -288
  74. package/node_modules/cpu-features/deps/cpu_features/include/internal/bit_utils.h +0 -40
  75. package/node_modules/cpu-features/deps/cpu_features/include/internal/cpuid_x86.h +0 -37
  76. package/node_modules/cpu-features/deps/cpu_features/include/internal/filesystem.h +0 -39
  77. package/node_modules/cpu-features/deps/cpu_features/include/internal/hwcaps.h +0 -240
  78. package/node_modules/cpu-features/deps/cpu_features/include/internal/stack_line_reader.h +0 -49
  79. package/node_modules/cpu-features/deps/cpu_features/include/internal/string_view.h +0 -110
  80. package/node_modules/cpu-features/deps/cpu_features/include/internal/windows_utils.h +0 -70
  81. package/node_modules/cpu-features/deps/cpu_features/ndk_compat/CMakeLists.txt +0 -60
  82. package/node_modules/cpu-features/deps/cpu_features/ndk_compat/README.md +0 -4
  83. package/node_modules/cpu-features/deps/cpu_features/ndk_compat/cpu-features.c +0 -205
  84. package/node_modules/cpu-features/deps/cpu_features/ndk_compat/cpu-features.h +0 -320
  85. package/node_modules/cpu-features/deps/cpu_features/ndk_compat/ndk-compat-test.c +0 -12
  86. package/node_modules/cpu-features/deps/cpu_features/patches/0001-Add-Apple-Silicon-Support.patch +0 -456
  87. package/node_modules/cpu-features/deps/cpu_features/scripts/generate_badges.d +0 -165
  88. package/node_modules/cpu-features/deps/cpu_features/scripts/make_release.sh +0 -75
  89. package/node_modules/cpu-features/deps/cpu_features/scripts/run_integration.sh +0 -490
  90. package/node_modules/cpu-features/deps/cpu_features/scripts/test_integration.sh +0 -79
  91. package/node_modules/cpu-features/deps/cpu_features/src/copy.inl +0 -19
  92. package/node_modules/cpu-features/deps/cpu_features/src/define_introspection.inl +0 -86
  93. package/node_modules/cpu-features/deps/cpu_features/src/define_introspection_and_hwcaps.inl +0 -26
  94. package/node_modules/cpu-features/deps/cpu_features/src/equals.inl +0 -22
  95. package/node_modules/cpu-features/deps/cpu_features/src/filesystem.c +0 -62
  96. package/node_modules/cpu-features/deps/cpu_features/src/hwcaps.c +0 -169
  97. package/node_modules/cpu-features/deps/cpu_features/src/impl_aarch64__base_implementation.inl +0 -88
  98. package/node_modules/cpu-features/deps/cpu_features/src/impl_aarch64_linux_or_android.c +0 -79
  99. package/node_modules/cpu-features/deps/cpu_features/src/impl_aarch64_macos_or_iphone.c +0 -82
  100. package/node_modules/cpu-features/deps/cpu_features/src/impl_aarch64_windows.c +0 -138
  101. package/node_modules/cpu-features/deps/cpu_features/src/impl_arm_linux_or_android.c +0 -212
  102. package/node_modules/cpu-features/deps/cpu_features/src/impl_mips_linux_or_android.c +0 -93
  103. package/node_modules/cpu-features/deps/cpu_features/src/impl_ppc_linux.c +0 -163
  104. package/node_modules/cpu-features/deps/cpu_features/src/impl_riscv_linux.c +0 -111
  105. package/node_modules/cpu-features/deps/cpu_features/src/impl_s390x_linux.c +0 -120
  106. package/node_modules/cpu-features/deps/cpu_features/src/impl_x86__base_implementation.inl +0 -2055
  107. package/node_modules/cpu-features/deps/cpu_features/src/impl_x86_freebsd.c +0 -68
  108. package/node_modules/cpu-features/deps/cpu_features/src/impl_x86_linux_or_android.c +0 -58
  109. package/node_modules/cpu-features/deps/cpu_features/src/impl_x86_macos.c +0 -57
  110. package/node_modules/cpu-features/deps/cpu_features/src/impl_x86_windows.c +0 -58
  111. package/node_modules/cpu-features/deps/cpu_features/src/stack_line_reader.c +0 -132
  112. package/node_modules/cpu-features/deps/cpu_features/src/string_view.c +0 -192
  113. package/node_modules/cpu-features/deps/cpu_features/src/utils/list_cpu_features.c +0 -461
  114. package/node_modules/cpu-features/deps/cpu_features/test/CMakeLists.txt +0 -114
  115. package/node_modules/cpu-features/deps/cpu_features/test/bit_utils_test.cc +0 -53
  116. package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_aarch64_test.cc +0 -396
  117. package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_arm_test.cc +0 -384
  118. package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_mips_test.cc +0 -176
  119. package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_ppc_test.cc +0 -131
  120. package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_riscv_test.cc +0 -180
  121. package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_s390x_test.cc +0 -82
  122. package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_x86_test.cc +0 -1729
  123. package/node_modules/cpu-features/deps/cpu_features/test/filesystem_for_testing.cc +0 -103
  124. package/node_modules/cpu-features/deps/cpu_features/test/filesystem_for_testing.h +0 -61
  125. package/node_modules/cpu-features/deps/cpu_features/test/hwcaps_for_testing.cc +0 -52
  126. package/node_modules/cpu-features/deps/cpu_features/test/hwcaps_for_testing.h +0 -31
  127. package/node_modules/cpu-features/deps/cpu_features/test/stack_line_reader_test.cc +0 -132
  128. package/node_modules/cpu-features/deps/cpu_features/test/string_view_test.cc +0 -202
  129. package/node_modules/cpu-features/lib/index.js +0 -5
  130. package/node_modules/cpu-features/package.json +0 -40
  131. package/node_modules/cpu-features/src/binding.cc +0 -151
  132. package/node_modules/cpu-features/test/test.js +0 -12
@@ -1,103 +0,0 @@
1
- // Copyright 2017 Google LLC
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- #include "filesystem_for_testing.h"
16
-
17
- #include <cassert>
18
- #include <climits>
19
- #include <cstdio>
20
- #include <cstring>
21
- #include <utility>
22
-
23
- namespace cpu_features {
24
-
25
- FakeFile::FakeFile(int file_descriptor, const char* content)
26
- : file_descriptor_(file_descriptor), content_(content) {}
27
-
28
- FakeFile::~FakeFile() { assert(!opened_); }
29
-
30
- void FakeFile::Open() {
31
- assert(!opened_);
32
- opened_ = true;
33
- }
34
-
35
- void FakeFile::Close() {
36
- assert(opened_);
37
- opened_ = false;
38
- }
39
-
40
- int FakeFile::Read(int fd, void* buf, size_t count) {
41
- assert(count < INT_MAX);
42
- assert(fd == file_descriptor_);
43
- const size_t remainder = content_.size() - head_index_;
44
- const size_t read = count > remainder ? remainder : count;
45
- memcpy(buf, content_.data() + head_index_, read);
46
- head_index_ += read;
47
- assert(read < INT_MAX);
48
- return (int)read;
49
- }
50
-
51
- void FakeFilesystem::Reset() { files_.clear(); }
52
-
53
- FakeFile* FakeFilesystem::CreateFile(const std::string& filename,
54
- const char* content) {
55
- auto& file = files_[filename];
56
- file =
57
- std::unique_ptr<FakeFile>(new FakeFile(next_file_descriptor_++, content));
58
- return file.get();
59
- }
60
-
61
- FakeFile* FakeFilesystem::FindFileOrNull(const std::string& filename) const {
62
- const auto itr = files_.find(filename);
63
- return itr == files_.end() ? nullptr : itr->second.get();
64
- }
65
-
66
- FakeFile* FakeFilesystem::FindFileOrDie(const int file_descriptor) const {
67
- for (const auto& filename_file_pair : files_) {
68
- FakeFile* const file_ptr = filename_file_pair.second.get();
69
- if (file_ptr->GetFileDescriptor() == file_descriptor) {
70
- return file_ptr;
71
- }
72
- }
73
- assert(false);
74
- return nullptr;
75
- }
76
-
77
- static FakeFilesystem* kFilesystem = new FakeFilesystem();
78
-
79
- FakeFilesystem& GetEmptyFilesystem() {
80
- kFilesystem->Reset();
81
- return *kFilesystem;
82
- }
83
-
84
- extern "C" int CpuFeatures_OpenFile(const char* filename) {
85
- auto* const file = kFilesystem->FindFileOrNull(filename);
86
- if (file) {
87
- file->Open();
88
- return file->GetFileDescriptor();
89
- }
90
- return -1;
91
- }
92
-
93
- extern "C" void CpuFeatures_CloseFile(int file_descriptor) {
94
- kFilesystem->FindFileOrDie(file_descriptor)->Close();
95
- }
96
-
97
- extern "C" int CpuFeatures_ReadFile(int file_descriptor, void* buffer,
98
- size_t buffer_size) {
99
- return kFilesystem->FindFileOrDie(file_descriptor)
100
- ->Read(file_descriptor, buffer, buffer_size);
101
- }
102
-
103
- } // namespace cpu_features
@@ -1,61 +0,0 @@
1
- // Copyright 2017 Google LLC
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- // Implements a fake filesystem, useful for tests.
16
- #ifndef CPU_FEATURES_TEST_FILESYSTEM_FOR_TESTING_H_
17
- #define CPU_FEATURES_TEST_FILESYSTEM_FOR_TESTING_H_
18
-
19
- #include <memory>
20
- #include <string>
21
- #include <unordered_map>
22
-
23
- #include "internal/filesystem.h"
24
-
25
- namespace cpu_features {
26
-
27
- class FakeFile {
28
- public:
29
- explicit FakeFile(int file_descriptor, const char* content);
30
- ~FakeFile();
31
-
32
- void Open();
33
- void Close();
34
- int Read(int fd, void* buf, size_t count);
35
-
36
- int GetFileDescriptor() const { return file_descriptor_; }
37
-
38
- private:
39
- const int file_descriptor_;
40
- const std::string content_;
41
- bool opened_ = false;
42
- size_t head_index_ = 0;
43
- };
44
-
45
- class FakeFilesystem {
46
- public:
47
- void Reset();
48
- FakeFile* CreateFile(const std::string& filename, const char* content);
49
- FakeFile* FindFileOrDie(const int file_descriptor) const;
50
- FakeFile* FindFileOrNull(const std::string& filename) const;
51
-
52
- private:
53
- int next_file_descriptor_ = 0;
54
- std::unordered_map<std::string, std::unique_ptr<FakeFile>> files_;
55
- };
56
-
57
- FakeFilesystem& GetEmptyFilesystem();
58
-
59
- } // namespace cpu_features
60
-
61
- #endif // CPU_FEATURES_TEST_FILESYSTEM_FOR_TESTING_H_
@@ -1,52 +0,0 @@
1
- // Copyright 2017 Google LLC
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- #include "hwcaps_for_testing.h"
16
-
17
- #include <string.h>
18
-
19
- #include "internal/string_view.h"
20
-
21
- namespace cpu_features {
22
-
23
- namespace {
24
- static auto* const g_hardware_capabilities = new HardwareCapabilities();
25
- static const char* g_platform_pointer = nullptr;
26
- static const char* g_base_platform_pointer = nullptr;
27
- } // namespace
28
-
29
- void SetHardwareCapabilities(uint32_t hwcaps, uint32_t hwcaps2) {
30
- g_hardware_capabilities->hwcaps = hwcaps;
31
- g_hardware_capabilities->hwcaps2 = hwcaps2;
32
- }
33
- void SetPlatformPointer(const char* string) { g_platform_pointer = string; }
34
- void SetBasePlatformPointer(const char* string) {
35
- g_base_platform_pointer = string;
36
- }
37
-
38
- void ResetHwcaps() {
39
- SetHardwareCapabilities(0, 0);
40
- SetPlatformPointer(nullptr);
41
- SetBasePlatformPointer(nullptr);
42
- }
43
-
44
- HardwareCapabilities CpuFeatures_GetHardwareCapabilities(void) {
45
- return *g_hardware_capabilities;
46
- }
47
- const char* CpuFeatures_GetPlatformPointer(void) { return g_platform_pointer; }
48
- const char* CpuFeatures_GetBasePlatformPointer(void) {
49
- return g_base_platform_pointer;
50
- }
51
-
52
- } // namespace cpu_features
@@ -1,31 +0,0 @@
1
- // Copyright 2017 Google LLC
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- #ifndef CPU_FEATURES_TEST_HWCAPS_FOR_TESTING_H_
16
- #define CPU_FEATURES_TEST_HWCAPS_FOR_TESTING_H_
17
-
18
- #include "internal/hwcaps.h"
19
-
20
- namespace cpu_features {
21
-
22
- void SetHardwareCapabilities(uint32_t hwcaps, uint32_t hwcaps2);
23
- void SetPlatformPointer(const char* string);
24
- void SetBasePlatformPointer(const char* string);
25
-
26
- // To be called before each test.
27
- void ResetHwcaps();
28
-
29
- } // namespace cpu_features
30
-
31
- #endif // CPU_FEATURES_TEST_HWCAPS_FOR_TESTING_H_
@@ -1,132 +0,0 @@
1
- // Copyright 2017 Google LLC
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- #include "internal/stack_line_reader.h"
16
-
17
- #include "filesystem_for_testing.h"
18
- #include "gtest/gtest.h"
19
-
20
- namespace cpu_features {
21
-
22
- bool operator==(const StringView& a, const StringView& b) {
23
- return CpuFeatures_StringView_IsEquals(a, b);
24
- }
25
-
26
- namespace {
27
-
28
- std::string ToString(StringView view) { return {view.ptr, view.size}; }
29
-
30
- TEST(StackLineReaderTest, Empty) {
31
- auto& fs = GetEmptyFilesystem();
32
- auto* file = fs.CreateFile("/proc/cpuinfo", "");
33
- StackLineReader reader;
34
- StackLineReader_Initialize(&reader, file->GetFileDescriptor());
35
- {
36
- const auto result = StackLineReader_NextLine(&reader);
37
- EXPECT_TRUE(result.eof);
38
- EXPECT_TRUE(result.full_line);
39
- EXPECT_EQ(result.line, str(""));
40
- }
41
- }
42
-
43
- TEST(StackLineReaderTest, ManySmallLines) {
44
- auto& fs = GetEmptyFilesystem();
45
- auto* file = fs.CreateFile("/proc/cpuinfo", "a\nb\nc");
46
-
47
- StackLineReader reader;
48
- StackLineReader_Initialize(&reader, file->GetFileDescriptor());
49
- {
50
- const auto result = StackLineReader_NextLine(&reader);
51
- EXPECT_FALSE(result.eof);
52
- EXPECT_TRUE(result.full_line);
53
- EXPECT_EQ(result.line, str("a"));
54
- }
55
- {
56
- const auto result = StackLineReader_NextLine(&reader);
57
- EXPECT_FALSE(result.eof);
58
- EXPECT_TRUE(result.full_line);
59
- EXPECT_EQ(result.line, str("b"));
60
- }
61
- {
62
- const auto result = StackLineReader_NextLine(&reader);
63
- EXPECT_TRUE(result.eof);
64
- EXPECT_TRUE(result.full_line);
65
- EXPECT_EQ(result.line, str("c"));
66
- }
67
- }
68
-
69
- TEST(StackLineReaderTest, TruncatedLine) {
70
- auto& fs = GetEmptyFilesystem();
71
- auto* file = fs.CreateFile("/proc/cpuinfo", R"(First
72
- Second
73
- More than 16 characters, this will be truncated.
74
- last)");
75
-
76
- StackLineReader reader;
77
- StackLineReader_Initialize(&reader, file->GetFileDescriptor());
78
- {
79
- const auto result = StackLineReader_NextLine(&reader);
80
- EXPECT_FALSE(result.eof);
81
- EXPECT_TRUE(result.full_line);
82
- EXPECT_EQ(result.line, str("First"));
83
- }
84
- {
85
- const auto result = StackLineReader_NextLine(&reader);
86
- EXPECT_FALSE(result.eof);
87
- EXPECT_TRUE(result.full_line);
88
- EXPECT_EQ(result.line, str("Second"));
89
- }
90
- {
91
- const auto result = StackLineReader_NextLine(&reader);
92
- EXPECT_FALSE(result.eof);
93
- EXPECT_FALSE(result.full_line);
94
- EXPECT_EQ(result.line, str("More than 16 cha"));
95
- }
96
- {
97
- const auto result = StackLineReader_NextLine(&reader);
98
- EXPECT_TRUE(result.eof);
99
- EXPECT_TRUE(result.full_line);
100
- EXPECT_EQ(result.line, str("last"));
101
- }
102
- }
103
-
104
- TEST(StackLineReaderTest, TruncatedLines) {
105
- auto& fs = GetEmptyFilesystem();
106
- auto* file = fs.CreateFile("/proc/cpuinfo", R"(More than 16 characters
107
- Another line that is too long)");
108
-
109
- StackLineReader reader;
110
- StackLineReader_Initialize(&reader, file->GetFileDescriptor());
111
- {
112
- const auto result = StackLineReader_NextLine(&reader);
113
- EXPECT_FALSE(result.eof);
114
- EXPECT_FALSE(result.full_line);
115
- EXPECT_EQ(result.line, str("More than 16 cha"));
116
- }
117
- {
118
- const auto result = StackLineReader_NextLine(&reader);
119
- EXPECT_FALSE(result.eof);
120
- EXPECT_FALSE(result.full_line);
121
- EXPECT_EQ(result.line, str("Another line tha"));
122
- }
123
- {
124
- const auto result = StackLineReader_NextLine(&reader);
125
- EXPECT_TRUE(result.eof);
126
- EXPECT_TRUE(result.full_line);
127
- EXPECT_EQ(result.line, str(""));
128
- }
129
- }
130
-
131
- } // namespace
132
- } // namespace cpu_features
@@ -1,202 +0,0 @@
1
- // Copyright 2017 Google LLC
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- #include "internal/string_view.h"
16
-
17
- #include "gtest/gtest.h"
18
-
19
- namespace cpu_features {
20
-
21
- bool operator==(const StringView& a, const StringView& b) {
22
- return CpuFeatures_StringView_IsEquals(a, b);
23
- }
24
-
25
- namespace {
26
-
27
- TEST(StringViewTest, Empty) {
28
- EXPECT_EQ(kEmptyStringView.ptr, nullptr);
29
- EXPECT_EQ(kEmptyStringView.size, 0);
30
- }
31
-
32
- TEST(StringViewTest, Build) {
33
- const auto view = str("test");
34
- EXPECT_EQ(view.ptr[0], 't');
35
- EXPECT_EQ(view.size, 4);
36
- }
37
-
38
- TEST(StringViewTest, CpuFeatures_StringView_IndexOfChar) {
39
- // Found.
40
- EXPECT_EQ(CpuFeatures_StringView_IndexOfChar(str("test"), 'e'), 1);
41
- EXPECT_EQ(CpuFeatures_StringView_IndexOfChar(str("test"), 't'), 0);
42
- EXPECT_EQ(CpuFeatures_StringView_IndexOfChar(str("beef"), 'e'), 1);
43
- // Not found.
44
- EXPECT_EQ(CpuFeatures_StringView_IndexOfChar(str("test"), 'z'), -1);
45
- // Empty.
46
- EXPECT_EQ(CpuFeatures_StringView_IndexOfChar(kEmptyStringView, 'z'), -1);
47
- }
48
-
49
- TEST(StringViewTest, CpuFeatures_StringView_IndexOf) {
50
- // Found.
51
- EXPECT_EQ(CpuFeatures_StringView_IndexOf(str("test"), str("es")), 1);
52
- EXPECT_EQ(CpuFeatures_StringView_IndexOf(str("test"), str("test")), 0);
53
- EXPECT_EQ(CpuFeatures_StringView_IndexOf(str("tesstest"), str("test")), 4);
54
- // Not found.
55
- EXPECT_EQ(CpuFeatures_StringView_IndexOf(str("test"), str("aa")), -1);
56
- // Empty.
57
- EXPECT_EQ(CpuFeatures_StringView_IndexOf(kEmptyStringView, str("aa")), -1);
58
- EXPECT_EQ(CpuFeatures_StringView_IndexOf(str("aa"), kEmptyStringView), -1);
59
- }
60
-
61
- TEST(StringViewTest, CpuFeatures_StringView_StartsWith) {
62
- EXPECT_TRUE(CpuFeatures_StringView_StartsWith(str("test"), str("te")));
63
- EXPECT_TRUE(CpuFeatures_StringView_StartsWith(str("test"), str("test")));
64
- EXPECT_FALSE(CpuFeatures_StringView_StartsWith(str("test"), str("st")));
65
- EXPECT_FALSE(CpuFeatures_StringView_StartsWith(str("test"), str("est")));
66
- EXPECT_FALSE(CpuFeatures_StringView_StartsWith(str("test"), str("")));
67
- EXPECT_FALSE(
68
- CpuFeatures_StringView_StartsWith(str("test"), kEmptyStringView));
69
- EXPECT_FALSE(
70
- CpuFeatures_StringView_StartsWith(kEmptyStringView, str("test")));
71
- }
72
-
73
- TEST(StringViewTest, CpuFeatures_StringView_IsEquals) {
74
- EXPECT_TRUE(
75
- CpuFeatures_StringView_IsEquals(kEmptyStringView, kEmptyStringView));
76
- EXPECT_TRUE(CpuFeatures_StringView_IsEquals(kEmptyStringView, str("")));
77
- EXPECT_TRUE(CpuFeatures_StringView_IsEquals(str(""), kEmptyStringView));
78
- EXPECT_TRUE(CpuFeatures_StringView_IsEquals(str("test"), str("test")));
79
- EXPECT_TRUE(CpuFeatures_StringView_IsEquals(str("a"), str("a")));
80
- EXPECT_FALSE(CpuFeatures_StringView_IsEquals(str("a"), str("b")));
81
- EXPECT_FALSE(CpuFeatures_StringView_IsEquals(str("aa"), str("a")));
82
- EXPECT_FALSE(CpuFeatures_StringView_IsEquals(str("a"), str("aa")));
83
- EXPECT_FALSE(CpuFeatures_StringView_IsEquals(str("a"), kEmptyStringView));
84
- EXPECT_FALSE(CpuFeatures_StringView_IsEquals(kEmptyStringView, str("a")));
85
- }
86
-
87
- TEST(StringViewTest, CpuFeatures_StringView_PopFront) {
88
- EXPECT_EQ(CpuFeatures_StringView_PopFront(str("test"), 2), str("st"));
89
- EXPECT_EQ(CpuFeatures_StringView_PopFront(str("test"), 0), str("test"));
90
- EXPECT_EQ(CpuFeatures_StringView_PopFront(str("test"), 4), str(""));
91
- EXPECT_EQ(CpuFeatures_StringView_PopFront(str("test"), 100), str(""));
92
- }
93
-
94
- TEST(StringViewTest, CpuFeatures_StringView_PopBack) {
95
- EXPECT_EQ(CpuFeatures_StringView_PopBack(str("test"), 2), str("te"));
96
- EXPECT_EQ(CpuFeatures_StringView_PopBack(str("test"), 0), str("test"));
97
- EXPECT_EQ(CpuFeatures_StringView_PopBack(str("test"), 4), str(""));
98
- EXPECT_EQ(CpuFeatures_StringView_PopBack(str("test"), 100), str(""));
99
- }
100
-
101
- TEST(StringViewTest, CpuFeatures_StringView_KeepFront) {
102
- EXPECT_EQ(CpuFeatures_StringView_KeepFront(str("test"), 2), str("te"));
103
- EXPECT_EQ(CpuFeatures_StringView_KeepFront(str("test"), 0), str(""));
104
- EXPECT_EQ(CpuFeatures_StringView_KeepFront(str("test"), 4), str("test"));
105
- EXPECT_EQ(CpuFeatures_StringView_KeepFront(str("test"), 6), str("test"));
106
- }
107
-
108
- TEST(StringViewTest, CpuFeatures_StringView_Front) {
109
- EXPECT_EQ(CpuFeatures_StringView_Front(str("apple")), 'a');
110
- EXPECT_EQ(CpuFeatures_StringView_Front(str("a")), 'a');
111
- }
112
-
113
- TEST(StringViewTest, CpuFeatures_StringView_Back) {
114
- EXPECT_EQ(CpuFeatures_StringView_Back(str("apple")), 'e');
115
- EXPECT_EQ(CpuFeatures_StringView_Back(str("a")), 'a');
116
- }
117
-
118
- TEST(StringViewTest, CpuFeatures_StringView_TrimWhitespace) {
119
- EXPECT_EQ(CpuFeatures_StringView_TrimWhitespace(str(" first middle last ")),
120
- str("first middle last"));
121
- EXPECT_EQ(CpuFeatures_StringView_TrimWhitespace(str("first middle last ")),
122
- str("first middle last"));
123
- EXPECT_EQ(CpuFeatures_StringView_TrimWhitespace(str(" first middle last")),
124
- str("first middle last"));
125
- EXPECT_EQ(CpuFeatures_StringView_TrimWhitespace(str("first middle last")),
126
- str("first middle last"));
127
- }
128
-
129
- TEST(StringViewTest, CpuFeatures_StringView_ParsePositiveNumber) {
130
- EXPECT_EQ(CpuFeatures_StringView_ParsePositiveNumber(str("42")), 42);
131
- EXPECT_EQ(CpuFeatures_StringView_ParsePositiveNumber(str("0x2a")), 42);
132
- EXPECT_EQ(CpuFeatures_StringView_ParsePositiveNumber(str("0x2A")), 42);
133
- EXPECT_EQ(CpuFeatures_StringView_ParsePositiveNumber(str("0x2A2a")), 10794);
134
- EXPECT_EQ(CpuFeatures_StringView_ParsePositiveNumber(str("0x2a2A")), 10794);
135
-
136
- EXPECT_EQ(CpuFeatures_StringView_ParsePositiveNumber(str("-10")), -1);
137
- EXPECT_EQ(CpuFeatures_StringView_ParsePositiveNumber(str("-0x2A")), -1);
138
- EXPECT_EQ(CpuFeatures_StringView_ParsePositiveNumber(str("abc")), -1);
139
- EXPECT_EQ(CpuFeatures_StringView_ParsePositiveNumber(str("")), -1);
140
- }
141
-
142
- TEST(StringViewTest, CpuFeatures_StringView_CopyString) {
143
- char buf[4];
144
- buf[0] = 'X';
145
-
146
- // Empty
147
- CpuFeatures_StringView_CopyString(str(""), buf, sizeof(buf));
148
- EXPECT_STREQ(buf, "");
149
-
150
- // Less
151
- CpuFeatures_StringView_CopyString(str("a"), buf, sizeof(buf));
152
- EXPECT_STREQ(buf, "a");
153
-
154
- // exact
155
- CpuFeatures_StringView_CopyString(str("abc"), buf, sizeof(buf));
156
- EXPECT_STREQ(buf, "abc");
157
-
158
- // More
159
- CpuFeatures_StringView_CopyString(str("abcd"), buf, sizeof(buf));
160
- EXPECT_STREQ(buf, "abc");
161
- }
162
-
163
- TEST(StringViewTest, CpuFeatures_StringView_HasWord) {
164
- // Find flags at beginning, middle and end.
165
- EXPECT_TRUE(
166
- CpuFeatures_StringView_HasWord(str("first middle last"), "first", ' '));
167
- EXPECT_TRUE(
168
- CpuFeatures_StringView_HasWord(str("first middle last"), "middle", ' '));
169
- EXPECT_TRUE(
170
- CpuFeatures_StringView_HasWord(str("first middle last"), "last", ' '));
171
- // Find flags at beginning, middle and end with a different separator
172
- EXPECT_TRUE(
173
- CpuFeatures_StringView_HasWord(str("first-middle-last"), "first", '-'));
174
- EXPECT_TRUE(
175
- CpuFeatures_StringView_HasWord(str("first-middle-last"), "middle", '-'));
176
- EXPECT_TRUE(
177
- CpuFeatures_StringView_HasWord(str("first-middle-last"), "last", '-'));
178
- // Do not match partial flags
179
- EXPECT_FALSE(
180
- CpuFeatures_StringView_HasWord(str("first middle last"), "irst", ' '));
181
- EXPECT_FALSE(
182
- CpuFeatures_StringView_HasWord(str("first middle last"), "mid", ' '));
183
- EXPECT_FALSE(
184
- CpuFeatures_StringView_HasWord(str("first middle last"), "las", ' '));
185
- }
186
-
187
- TEST(StringViewTest, CpuFeatures_StringView_GetAttributeKeyValue) {
188
- const StringView line = str(" key : first middle last ");
189
- StringView key, value;
190
- EXPECT_TRUE(CpuFeatures_StringView_GetAttributeKeyValue(line, &key, &value));
191
- EXPECT_EQ(key, str("key"));
192
- EXPECT_EQ(value, str("first middle last"));
193
- }
194
-
195
- TEST(StringViewTest, FailingGetAttributeKeyValue) {
196
- const StringView line = str("key first middle last");
197
- StringView key, value;
198
- EXPECT_FALSE(CpuFeatures_StringView_GetAttributeKeyValue(line, &key, &value));
199
- }
200
-
201
- } // namespace
202
- } // namespace cpu_features
@@ -1,5 +0,0 @@
1
- 'use strict';
2
-
3
- const binding = require('../build/Release/cpufeatures.node');
4
-
5
- module.exports = binding.getCPUInfo;
@@ -1,40 +0,0 @@
1
- {
2
- "name": "cpu-features",
3
- "version": "0.0.10",
4
- "author": "Brian White <mscdex@mscdex.net>",
5
- "description": "A simple binding to Google's cpu_features library for obtaining information about installed CPU(s)",
6
- "main": "./lib/index",
7
- "dependencies": {
8
- "buildcheck": "~0.0.6",
9
- "nan": "^2.19.0"
10
- },
11
- "devDependencies": {
12
- "@mscdex/eslint-config": "^1.1.0",
13
- "eslint": "^7.0.0"
14
- },
15
- "scripts": {
16
- "install": "node buildcheck.js > buildcheck.gypi && node-gyp rebuild",
17
- "test": "node test/test.js",
18
- "lint": "eslint --cache --report-unused-disable-directives --ext=.js .eslintrc.js lib test",
19
- "lint:fix": "npm run lint -- --fix"
20
- },
21
- "engines": {
22
- "node": ">=10.0.0"
23
- },
24
- "keywords": [
25
- "cpu",
26
- "detect",
27
- "detection",
28
- "features"
29
- ],
30
- "licenses": [
31
- {
32
- "type": "MIT",
33
- "url": "https://github.com/mscdex/cpu-features/raw/master/LICENSE"
34
- }
35
- ],
36
- "repository": {
37
- "type": "git",
38
- "url": "https://github.com/mscdex/cpu-features.git"
39
- }
40
- }