Example #1
0
    def _installApp(cls):
        """ install app 
        @fn _installApp
        @param cls
        @return
        """
        (status, output) = cls.tc.target.run("mkdir %s" % cls.test_dir)
        test_app_paths = glob.glob(
            os.path.join(get_files_dir(), cls.test_app_pkg))
        app_pkg_path = None
        if test_app_paths:
            app_pkg_path = test_app_paths[-1]
        assert app_pkg_path is not None, "No app rpm packages named like %s found!" % cls.test_app_pkg

        (status, output) = cls.tc.target.copy_to(app_pkg_path, cls.test_dir)
        if status != 0:
            return False
        (status,
         output) = cls.tc.target.run("su -l %s -c 'iotpm -L | grep %s'" %
                                     (cls.test_app_user, cls.test_app_name))
        if status == 0:
            return True
        else:
            app_user_pkg_paths = glob.glob(
                os.path.join(get_files_dir(), cls.test_app_user_pkg))
            if app_user_pkg_paths:
                app_user_pkg_path = app_user_pkg_paths[-1]
            cls.tc.target.copy_to(app_user_pkg_path, cls.test_dir)
            (status, output) = cls.tc.target.run("rpm -ivh %s" %
                                                 cls.test_app_user_pkg_path)
            (status, output) = cls.tc.target.run("rpm -qa | grep %s" %
                                                 cls.test_app_user)
            if status != 0:
                return False

            cls._prepare_file_for_user(cls.test_app_user,
                                       cls.test_app_pkg_path)

            (status,
             output) = cls.tc.target.run("su -l %s -c 'iotpm -i %s'" %
                                         (cls.test_app_user, cls.test_app_pkg))
            if status != 0:
                return False
            else:
                return True
 def test_ros_helloworld(self):
     self.target.connection.copy_dir_to(
         os.path.join(get_files_dir(), "opt"), "/opt")
     with tempfile.NamedTemporaryFile() as testcmd:
         testcmd.write(TESTCMD)
         testcmd.flush()
         self.target.copy_to(testcmd.name, TESTCMD_PATH)
     (status, output) = self.target.run("sh %s" % TESTCMD_PATH)
     self.assertEqual(status, 0, msg="Error messages: %s" % output)
 def setUpClass(cls):
     """
     Copy gatttool to /tmp/ folder
     """
     bt1 = bluetooth.BTFunction(cls.tc.targets[0])
     bt2 = bluetooth.BTFunction(cls.tc.targets[1])
     copy_to_path = os.path.join(get_files_dir(), 'gatttool')
     cls.tc.targets[0].copy_to(copy_to_path, "/tmp/")
     bt1.target.run('chmod +x /tmp/gatttool')
     bt2.target.run('chmod +x /tmp/gatttool')
 def setUpClass(cls):
     '''Copy gatttool to /tmp/ folder
     @fn setUpClass
     @param cls
     @return
     '''
     bt1=bluetooth.BTFunction(cls.tc.targets[0])
     bt2=bluetooth.BTFunction(cls.tc.targets[1])
     copy_to_path = os.path.join(get_files_dir(), 'gatttool')
     cls.tc.targets[0].copy_to(copy_to_path, "/tmp/")
     bt1.target.run('chmod +x /tmp/gatttool')
     bt2.target.run('chmod +x /tmp/gatttool')
Example #5
0
    def _installApp(cls):
        """ install app 
        @fn _installApp
        @param cls
        @return
        """
        (status,output) = cls.tc.target.run("mkdir %s" % cls.test_dir)
        test_app_paths = glob.glob(os.path.join(get_files_dir(), cls.test_app_pkg))
        app_pkg_path = None
        if test_app_paths :
            app_pkg_path = test_app_paths[-1]
        assert app_pkg_path is not None, "No app rpm packages named like %s found!" % cls.test_app_pkg
        
        (status,output) = cls.tc.target.copy_to(app_pkg_path, cls.test_dir)
        if status !=0 :
            return False 
        (status,output) = cls.tc.target.run("su -l %s -c 'iotpm -L | grep %s'" % 
                                         (cls.test_app_user,cls.test_app_name))
        if status == 0 :
            return True
        else:
            app_user_pkg_paths = glob.glob(os.path.join(get_files_dir(), cls.test_app_user_pkg))
            if app_user_pkg_paths :
                app_user_pkg_path = app_user_pkg_paths[-1]
            cls.tc.target.copy_to(app_user_pkg_path, cls.test_dir)
            (status,output) = cls.tc.target.run("rpm -ivh %s" % cls.test_app_user_pkg_path)
            (status,output) = cls.tc.target.run("rpm -qa | grep %s" % cls.test_app_user)
            if status !=0 :
                return False 

            cls._prepare_file_for_user(cls.test_app_user, cls.test_app_pkg_path)
            
            (status,output) = cls.tc.target.run("su -l %s -c 'iotpm -i %s'" % 
                                             (cls.test_app_user, cls.test_app_pkg))
            if status !=0 :
                return False 
            else:
                return True
Example #6
0
 def _setup(self):
     """Please make sure your network Env is Gigabit network
     @fn _setup
     @param self
     @return
     """
     (status, output) = self.target.copy_to(
         os.path.join(get_files_dir(), 'netperf'), "/tmp/netperf")
     self.assertEqual(status,
                      0,
                      msg="netperf could not be copied. Output: %s" %
                      output)
     (status, output) = self.target.run(" ls -la /tmp/netperf")
     self.assertEqual(status, 0, msg="Failed to find netperf command")
Example #7
0
    def setUp(self):
        """
        @fn setUp
        @param self
        @return
        """
        self.bt = bluetooth.BTFunction(self.target)
        self.bt.target_hciconfig_init()
        self.bt.host_hciconfig_init()

        (status, output) = self.target.run('which gatttool')
        if (status != 0):
            copy_to_path = os.path.join(get_files_dir(), 'gatttool')
            (status, output) = self.target.copy_to(copy_to_path, "/usr/bin/")
Example #8
0
 def _setup(self):
     """
     @fn _setup
     @param self
     @return
     """
     (status,
      output) = self.target.copy_to(os.path.join(get_files_dir(), 'iozone'),
                                    "/tmp/iozone")
     self.assertEqual(status,
                      0,
                      msg="iozone could not be copied. Output: %s" % output)
     (status, output) = self.target.run(" ls -la /tmp/iozone")
     self.assertEqual(status, 0, msg="Failed to find iozone command")
Example #9
0
    def setUp(self):
        """
        @fn setUp
        @param self
        @return
        """
        self.bt = bluetooth.BTFunction(self.target)
        self.bt.target_hciconfig_init()
        self.bt.host_hciconfig_init()

        (status, output) = self.target.run('which gatttool')
        if (status != 0):
            copy_to_path = os.path.join(get_files_dir(), 'gatttool')
            (status, output) = self.target.copy_to(copy_to_path, "/usr/bin/")
Example #10
0
    def test_read_map(self):
        """
        checks that a process cannot read memory that has not been mapped to it
        """
        status, output = self.target.run("ls /tmp/read-map")
        if status != 0:
            self.target.copy_to(
                    os.path.join(get_files_dir(), "read-map"),
                    "/tmp/read-map")

        status, output = self.target.run("/tmp/read-map")
        # expected to exit with segmentation fault (signal 11 - SEGV)
        # exit code: 128 + 11(SEGV)
        self.assertEqual(status, 139, "Process did not exit with segfault")
Example #11
0
 def test_mraa_hello(self):
     '''Prepare test binaries to image
     @fn test_mraa_hello
     @param self
     @return
     '''
     (status, output) = self.target.run('mkdir -p /opt/mraa-test/apps/')
     (status, output) = self.target.run('ls /opt/mraa-test/apps/hello_mraa')
     (status,output) = self.target.copy_to(os.path.join(get_files_dir(),
                       'hello_mraa'), "/opt/mraa-test/apps/")
     '''run test mraa app to get the platform information'''
     client_cmd = "/opt/mraa-test/apps/hello_mraa"
     (status, output) = self.target.run(client_cmd)
     ##
     # TESTPOINT: #1, test_mraa_hello
     #
     self.assertEqual(status, 0, msg="Error messages: %s" % output)
Example #12
0
 def _setup(self):
     """Copy systemd-analyze to target device
     @fn _setup
     @param self
     @return
     """
     (status, output) = self.target.copy_to(
         os.path.join(get_files_dir(), 'systemd-analyze'),
         "/tmp/systemd-analyze")
     self.assertEqual(
         status,
         0,
         msg="systemd-analyze could not be copied. Output: %s" % output)
     (status, output) = self.target.run(" ls -la /tmp/systemd-analyze")
     self.assertEqual(status,
                      0,
                      msg="Failed to find systemd-analyze command")
Example #13
0
 def _setup(self):
     """Copy systemd-analyze to target device
     @fn _setup
     @param self
     @return
     """
     (status, output) = self.target.copy_to(
         os.path.join(get_files_dir(),
                      'systemd-analyze'), "/tmp/systemd-analyze")
     self.assertEqual(
         status,
         0,
         msg="systemd-analyze could not be copied. Output: %s" %
         output)
     (status, output) = self.target.run(" ls -la /tmp/systemd-analyze")
     self.assertEqual(
         status,
         0,
         msg="Failed to find systemd-analyze command")
Example #14
0
 def _setup(self):
     """Please make sure your network Env is Gigabit network
     @fn _setup
     @param self
     @return
     """
     (status, output) = self.target.copy_to(
         os.path.join(get_files_dir(),'netperf'),
         "/tmp/netperf")
     self.assertEqual(
         status,
         0,
         msg="netperf could not be copied. Output: %s" %
         output)
     (status, output) = self.target.run(" ls -la /tmp/netperf")
     self.assertEqual(
         status,
         0,
         msg="Failed to find netperf command")
Example #15
0
 def setUp(self):
     """
     @fn setUp
     @param self
     @return
     """
     # un-block software rfkill lock
     self.target.run('rfkill unblock all')
     self.target.run('hciconfig hci0 reset')
     time.sleep(1)
     self.target.run('hciconfig hci0 up')
     self.target.run('hciconfig hci0 piscan')
     self.target.run('hciconfig hci0 noleadv')
     time.sleep(1)
     shell_cmd_timeout('hciconfig hci0 reset', timeout=200)
     time.sleep(1)
     shell_cmd_timeout('hciconfig hci0 up', timeout=100)
     shell_cmd_timeout('hciconfig hci0 piscan', timeout=100)
     shell_cmd_timeout('hciconfig hci0 noleadv', timeout=100)
     time.sleep(1)
     (status, output) = self.target.run('which gatttool')
     if (status != 0):
         copy_to_path = os.path.join(get_files_dir(), 'gatttool')
         (status, output) = self.target.copy_to(copy_to_path, "/usr/bin/")
Example #16
0
    def test_shmem_protection(self):
        """
        Uses shm-util as an alternative to ipcmk, ipcrm
        If ipcmk, ipcrm, ipcs becomes available, they could be used instead
        """
        status, output = self.target.run("ls /tmp/shm-util")
        if status != 0:
            self.target.copy_to(
                    os.path.join(get_files_dir(), "shm-util"),
                    "/tmp/shm-util")

        # need 2 users
        # right now we can add them
        # in the future, we might need 2 apps pre-installed
        user1 = "test-app1"
        user2 = "test-app2"
        self._add_user(user1)
        self._add_user(user2)

        shm_create_cmd = "/tmp/shm-util -m 2048 -p 0600"
        status, shm_id = self.target.run("su %s -c -- sh -c '%s'" \
                                            %(user1, shm_create_cmd))
        shm_id = shm_id.split(":")[1]
        self.assertEqual(status, 0, "Unable to create shared memory segment")

        shm_remove_cmd = "/tmp/shm-util -r %s" %shm_id
        status, output = self.target.run("su %s -c -- sh -c '%s'" \
                                            %(user2, shm_remove_cmd))

        self.assertNotEqual(
                        status, 0,
                        "Shared memory segment could be access by another user")

        # clean up
        self.target.run("su %s -c -- sh -c '/tmp/shm-util -r %s" \
                        %(user1, shm_id))
Example #17
0
 def setUp(self):
     """
     @fn setUp
     @param self
     @return
     """
     # un-block software rfkill lock
     self.target.run('rfkill unblock all')
     self.target.run('hciconfig hci0 reset')
     time.sleep(1)
     self.target.run('hciconfig hci0 up')
     self.target.run('hciconfig hci0 piscan')
     self.target.run('hciconfig hci0 noleadv')
     time.sleep(1)
     shell_cmd_timeout('hciconfig hci0 reset', timeout=200)
     time.sleep(1)
     shell_cmd_timeout('hciconfig hci0 up', timeout=100)
     shell_cmd_timeout('hciconfig hci0 piscan', timeout=100)
     shell_cmd_timeout('hciconfig hci0 noleadv', timeout=100)
     time.sleep(1)
     (status, output) = self.target.run('which gatttool')
     if (status != 0):
         copy_to_path = os.path.join(get_files_dir(), 'gatttool')
         (status, output) = self.target.copy_to(copy_to_path, "/usr/bin/")
Example #18
0
 def setUp(self):
     (status, output) = self.target.run('mkdir -p /opt/upm-test')
     (status, output) = self.target.copy_to(
         os.path.join(get_files_dir(), 'upm_test'), "/opt/upm-test/")