spec/unit/plugins/linux/memory_spec.rb in ohai-14.15.0 vs spec/unit/plugins/linux/memory_spec.rb in ohai-15.0.35
- old
+ new
@@ -12,11 +12,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
-require_relative "../../../spec_helper.rb"
+require "spec_helper"
describe Ohai::System, "Linux memory plugin" do
before(:each) do
@plugin = get_plugin("linux/memory")
allow(@plugin).to receive(:collect_os).and_return(:linux)
@@ -54,10 +54,15 @@
.and_yield("HugePages_Total: 11542")
.and_yield("HugePages_Free: 11235")
.and_yield("HugePages_Rsvd: 11226")
.and_yield("HugePages_Surp: 0")
.and_yield("Hugepagesize: 2048 kB")
+ .and_yield("Hugetlb: 0 kB")
+ .and_yield("DirectMap4k: 3720736 kB")
+ .and_yield("DirectMap2M: 12795904 kB")
+ .and_yield("DirectMap1G: 0 kB")
+
allow(File).to receive(:open).with("/proc/meminfo").and_return(@double_file)
end
it "should get total memory" do
@plugin.run
@@ -225,7 +230,27 @@
end
it "should get hugepage size" do
@plugin.run
expect(@plugin[:memory][:hugepage_size]).to eql("2048kB")
+ end
+
+ it "should get hugetlb memory" do
+ @plugin.run
+ expect(@plugin[:memory][:hugetlb]).to eql("0kB")
+ end
+
+ it "should get directmap 4k memory" do
+ @plugin.run
+ expect(@plugin[:memory][:directmap][:'4k']).to eql("3720736kB")
+ end
+
+ it "should get directmap 2M memory" do
+ @plugin.run
+ expect(@plugin[:memory][:directmap][:'2M']).to eql("12795904kB")
+ end
+
+ it "should get directmap 1G memory" do
+ @plugin.run
+ expect(@plugin[:memory][:directmap][:'1G']).to eql("0kB")
end
end