<commit_before>#[PROTEXCAT]
#\License: ALL RIGHTS RESERVED

"""Memory consumption for system idle"""
import os
import time
from oeqa.oetest import oeRuntimeTest
from oeqa.runtime.helper import collect_pnp_log

class MemTest(oeRuntimeTest):
    
    def _reboot(self):
        """reboot device for clean env"""
        (status, output) = self.target.run("reboot")
        time.sleep(120)
        self.assertEqual(status, 0, output)

    def _setup(self):
        """First set sleep time to 180s (default 300s)"""
        (status,output) = self.target.run("sleep 180")
        self.assertEqual(status, 0, output)

    def test_mem(self):
        #self._reboot()
        self._setup()
        filename=os.path.basename(__file__)
        casename=os.path.splitext(filename)[0]
        (status,output) = self.target.run("cat /proc/meminfo | grep 'MemAvailable' | awk '{print $2}'")
        output=output + "KB"
        collect_pnp_log(casename, output)        
        print "\n%s:%s\n" %(casename, output)
        self.assertEqual(status, 0, output)
  <commit_msg>Provide used memory instead of available memory<commit_after>#[PROTEXCAT]
#\License: ALL RIGHTS RESERVED

import os
import time
from oeqa.oetest import oeRuntimeTest
from oeqa.runtime.helper import collect_pnp_log


class MemTest(oeRuntimeTest):

    """Memory consumption for system idle"""

    def _reboot(self):
        """reboot device for clean env"""
        (status, output) = self.target.run("reboot")
        time.sleep(120)
        self.assertEqual(status, 0, output)

    def _setup(self):
        """First set sleep time to 180s (default 300s)"""
        (status, output) = self.target.run("sleep 180")
        self.assertEqual(status, 0, output)

    def test_mem(self):
        """Mem_Used = Mem_Total - Mem_Available"""
        # self._reboot()
        self._setup()
        filename = os.path.basename(__file__)
        casename = os.path.splitext(filename)[0]
        (status, output) = self.target.run(
            "cat /proc/meminfo" " | grep 'MemTotal' | awk '{print $2}'")
        mem_total = int(output)
        (status, output) = self.target.run(
            "cat /proc/meminfo" " | grep 'MemAvailable' | awk '{print $2}'")
        mem_available = int(output)
        mem_used = str(mem_total - mem_available) + "KB"
        collect_pnp_log(casename, mem_used)
        print "\n%s:%s\n" % (casename, mem_used)
        self.assertEqual(status, 0, mem_used)
{'fraction_non_alphanumeric': 0.13202132021320212, 'fraction_numerical': 0.014350143501435014, 'mean_word_length': 2.84251968503937, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4136388', 'n_tokens_mistral': 814, 'n_tokens_neox': 769, 'n_words': 188}