<commit_before>"""
@file iotvt_integration.py
"""

##
# @addtogroup iotivity iotivity
# @brief This is iotivity component
# @{
# @addtogroup iotvt_integration iotvt_integration
# @brief This is iotvt_integration module
# @{
##

import os
import time
import string
import subprocess
from oeqa.oetest import oeRuntimeTest
from oeqa.utils.helper import get_files_dir
from oeqa.utils.helper import shell_cmd_timeout
from oeqa.utils.decorators import tag

@tag(TestType="FVT", FeatureID="IOTOS-754,IOTOS-1019")
class IOtvtIntegration(oeRuntimeTest):
    """
    @class IOtvtIntegration
    """
    @classmethod
    def setUpClass(cls):
        '''Clean all the server and client firstly
        @fn setUpClass
        @param cls
        @return
        '''
        cls.tc.target.run("killall presenceserver presenceclient devicediscoveryserver devicediscoveryclient")        
        cls.tc.target.run("killall fridgeserver fridgeclient garageserver garageclient groupserver groupclient")
        cls.tc.target.run("killall roomserver roomclient simpleserver simpleclient simpleserverHQ simpleclientHQ")
        cls.tc.target.run("killall simpleclientserver threadingsample")

    def presence_check(self, para):
        '''this is a function used by presence test
        @fn presence_check
        @param self
        @return
        '''
        # start server
        server_cmd = "/opt/iotivity/examples/resource/cpp/presenceserver > /tmp/svr_output &"
        (status, output) = self.target.run(server_cmd, timeout=20)
        time.sleep(1)
        # start client to get info
        client_cmd = "/opt/iotivity/examples/resource/cpp/presenceclient -t %d > /tmp/output &" % para
        self.target.run(client_cmd, timeout=20)
        # Some platform is too slow, it needs more time to sleep. E.g. MinnowMax
        time.sleep(25)
        (status, output) = self.target.run("cat /tmp/output")
        self.target.run("killall presenceserver presenceclient") 
        time.sleep(3)       
        return output.count("Received presence notification from")
<commit_msg>iotivity samples: add iptables rule for iotivity example app test<commit_after>"""
@file iotvt_integration.py
"""

##
# @addtogroup iotivity iotivity
# @brief This is iotivity component
# @{
# @addtogroup iotvt_integration iotvt_integration
# @brief This is iotvt_integration module
# @{
##

import os
import time
import string
import subprocess
from oeqa.oetest import oeRuntimeTest
from oeqa.utils.helper import get_files_dir
from oeqa.utils.helper import shell_cmd_timeout
from oeqa.utils.decorators import tag

@tag(TestType="FVT", FeatureID="IOTOS-754,IOTOS-1019")
class IOtvtIntegration(oeRuntimeTest):
    """
    @class IOtvtIntegration
    """
    @classmethod
    def setUpClass(cls):
        '''Clean all the server and client firstly
        @fn setUpClass
        @param cls
        @return
        '''
        cls.tc.target.run("killall presenceserver presenceclient devicediscoveryserver devicediscoveryclient")        
        cls.tc.target.run("killall fridgeserver fridgeclient garageserver garageclient groupserver groupclient")
        cls.tc.target.run("killall roomserver roomclient simpleserver simpleclient simpleserverHQ simpleclientHQ")
        cls.tc.target.run("killall simpleclientserver threadingsample")
        # Setup firewall accept for multicast
        cls.tc.target.run("/usr/sbin/iptables -w -A INPUT -p udp --dport 5683 -j ACCEPT")
        cls.tc.target.run("/usr/sbin/iptables -w -A INPUT -p udp --dport 5684 -j ACCEPT")

    def presence_check(self, para):
        '''this is a function used by presence test
        @fn presence_check
        @param self
        @return
        '''
        # start server
        server_cmd = "/opt/iotivity/examples/resource/cpp/presenceserver > /tmp/svr_output &"
        (status, output) = self.target.run(server_cmd, timeout=20)
        time.sleep(1)
        # start client to get info
        client_cmd = "/opt/iotivity/examples/resource/cpp/presenceclient -t %d > /tmp/output &" % para
        self.target.run(client_cmd, timeout=20)
        # Some platform is too slow, it needs more time to sleep. E.g. MinnowMax
        time.sleep(25)
        (status, output) = self.target.run("cat /tmp/output")
        self.target.run("killall presenceserver presenceclient") 
        time.sleep(3)       
        return output.count("Received presence notification from")

{'fraction_non_alphanumeric': 0.09700815956482321, 'fraction_numerical': 0.008612873980054397, 'mean_word_length': 3.1089385474860336, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4144567', 'n_tokens_mistral': 1381, 'n_tokens_neox': 1328, 'n_words': 338}