コード例 #1
0
TEST_F( SystemInformation_TEST
      , SetUsageSwapAfterSettingTotalSwap__ReturnsTrue )
{
    std::string memory_total( "1060252k" );
    std::string memory_usage( "860252k" );
    EXPECT_TRUE( sys_info__.setTotalSwap( memory_total ) );

    EXPECT_TRUE( sys_info__.setSwapUsage( memory_usage ) );
}
コード例 #2
0
TEST_F( SystemInformation_TEST
      , SetUsageSwapToEmptyString__ReturnsFalse )
{
    std::string memory_total( "1060252k" );
    std::string memory_usage( "" );
    EXPECT_TRUE( sys_info__.setTotalSwap( memory_total ) );

    EXPECT_FALSE( sys_info__.setSwapUsage( memory_usage ) );
}
コード例 #3
0
TEST_F( SystemInformation_TEST
      , GetTotalSwap__ReturnsTotalInMegabytes )
{
    std::string memory_total( "1060252k" );
    int memory_rxed( 1035 );
    EXPECT_TRUE( sys_info__.setTotalSwap( memory_total ) );

    EXPECT_EQ( memory_rxed
             , sys_info__.getTotalSwap() );
}
コード例 #4
0
TEST_F( SystemInformation_TEST
      , GetTotalMemory__ReturnsTotalInMegabytes )
{
    std::string memory_total( "513184k" );
    int memory_rxed( 501 );
    EXPECT_TRUE( sys_info__.setTotalMemory( memory_total ) );

    EXPECT_EQ( memory_rxed
             , sys_info__.getTotalMemory() );
}
コード例 #5
0
TEST_F( SystemInformation_TEST
      , GetSwapUsage__ReturnsPercentageOfTotalSwapInUse )
{
    std::string memory_total( "1060252k" );
    std::string memory_usage( "860252k" );
    int memory_rxed( 81 );
    EXPECT_TRUE( sys_info__.setTotalSwap( memory_total ) );
    EXPECT_TRUE( sys_info__.setSwapUsage( memory_usage ) );

    EXPECT_EQ( memory_rxed
             , sys_info__.getSwapUsage() );
}
コード例 #6
0
ファイル: procfs.c プロジェクト: Razi007/toaruos
uint32_t meminfo_func(fs_node_t *node, uint32_t offset, uint32_t size, uint8_t *buffer) {
	char buf[1024];
	unsigned int total = memory_total();
	unsigned int free  = total - memory_use();
	sprintf(buf, "MemTotal: %d kB\nMemFree: %d kB\n", total, free);

	size_t _bsize = strlen(buf);
	if (offset > _bsize) return 0;
	if (size > _bsize - offset) size = _bsize - offset;

	memcpy(buffer, buf, size);
	return size;
}
コード例 #7
0
TEST_F( SystemInformation_TEST
      , DISABLED_SetTotalSwapWithWrongFigures__ReturnsFalse )
{
    std::string memory_total( "4k 101318" );
    EXPECT_FALSE( sys_info__.setTotalSwap( memory_total ) );
}
コード例 #8
0
TEST_F( SystemInformation_TEST
      , SetTotalSwap__ReturnsTrue )
{
    std::string memory_total( "1060252k" );
    EXPECT_TRUE( sys_info__.setTotalSwap( memory_total ) );
}
コード例 #9
0
TEST_F( SystemInformation_TEST
      , SetTotalMemory__ReturnsTrue )
{
    std::string memory_total( "513184k" );
    EXPECT_TRUE( sys_info__.setTotalMemory( memory_total ) );
}