コード例 #1
0
    def setUp(self):
        for d in self.DIRS:
            if not os.path.exists(d):
                os.makedirs(d)

        if not self.prepared:
            self.prepared = True
            DevMapper.write_one_line(self.DIR_GOOD + '/interface',
                                     self.DESC_GOOD_PORT)
            DevMapper.write_one_line(self.DIR_BAD + '/interface',
                                     self.DESC_BAD_PORT)
            dpath = self.DIR_GOOD + '/' + self.GOOD_PORT
            if not os.path.exists(dpath):
                os.makedirs(dpath)
コード例 #2
0
 def test_interface_name_bad(self):
     exception = False
     try:
         devname = DevMapper.interface_name(self.DESC_BAD_PORT,
                                            base_dir=self.DIR_TEST)
     except DevMapperError:
         exception = True
     finally:
         self.assertTrue(exception)
コード例 #3
0
 def test_interface_name_good(self):
     devname = DevMapper.interface_name(self.DESC_GOOD_PORT,
                                        base_dir=self.DIR_TEST)
     self.assertEqual(devname, '/dev/' + self.GOOD_PORT)
コード例 #4
0
 def test_serial_invalid_path(self):
     try:
         devname = DevMapper.serial('/sys/devices/my/device/path')
     except DevMapperError:
         pass
コード例 #5
0
 def test_serial_dev_file(self):
     # Use: /dev/ttyS0
     devname = DevMapper.serial(self.devname)
     self.assertEqual(self.devname, devname)
コード例 #6
0
 def test_serial_ttyS0_case_2(self):
     # Use: /sys/devices/pnp0/00:08/tty/
     devname = DevMapper.serial(self.devpath + '/')
     self.assertEqual(self.devname, devname)