/Users/deen/code/yugabyte-db/src/yb/gutil/sysinfo-test.cc
Line | Count | Source |
1 | | // Copyright (c) YugaByte, Inc. |
2 | | |
3 | | #include <thread> |
4 | | |
5 | | #include "yb/gutil/sysinfo.h" |
6 | | |
7 | | #include "yb/util/logging.h" |
8 | | #include "yb/util/test_util.h" |
9 | | |
10 | | DECLARE_int32(num_cpus); |
11 | | |
12 | | namespace yb { |
13 | | namespace gutil { |
14 | | |
15 | | class SysInfoTest : public YBTest { |
16 | | protected: |
17 | 2 | void SetUp() override { |
18 | 2 | YBTest::SetUp(); |
19 | 2 | InitGoogleLoggingSafe("SysInfoTest"); |
20 | 2 | } |
21 | | |
22 | 2 | void TearDown() override { |
23 | 2 | YBTest::TearDown(); |
24 | 2 | } |
25 | | }; |
26 | | |
27 | | // Test num_cpus defaults to hardware_concurrency value |
28 | | // and is equal to gutil's original NumCPUs function. |
29 | 1 | TEST_F(SysInfoTest, NumCpusZeroTest) { |
30 | 1 | ASSERT_EQ(base::NumCPUs(), std::thread::hardware_concurrency()); |
31 | 1 | ASSERT_EQ(base::NumCPUs(), base::RawNumCPUs()); |
32 | 1 | } |
33 | | |
34 | | // Test gflag value changes are reflected in NumCPUs function |
35 | 1 | TEST_F(SysInfoTest, NumCpusChangedTest) { |
36 | 1 | FLAGS_num_cpus = 20; |
37 | 1 | ASSERT_EQ(base::NumCPUs(), 20); |
38 | 1 | } |
39 | | |
40 | | } // namespace gutil |
41 | | } // namespace yb |