def test_other_flasher_running_return_true(self, mocked_getpid,
                                            mocked_glob, mocked_open):
     read_data = [
         b"python\x00/usr/local/bin/psu-update-delta.py\x00",
         b"jbi\x00-i\x00/tmp/WEDGE100_SYSCPLD_v6_101.jbc\x00",
     ]
     for datum in read_data:
         mocked_open.return_value = mock_open(read_data=datum).return_value
         self.assertEqual(system.other_flasher_running(self.logger), True)
 def test_other_flasher_running_return_false(self, mocked_getpid,
                                             mocked_glob, mocked_open):
     read_data = [
         b"runsv\x00/etc/sv/restapi\x00",
         b"/usr/bin/mTerm_server\x00wedge\x00/dev/ttyS1\x00",
         b"/usr/sbin/ntpd\x00-p\x00/var/run/ntpd.pid\x00-g\x00",
         b"\x00",
     ]
     # Return the full list of /proc/$pid/cmdline from a single glob() call
     mocked_glob.return_value = [
         "/proc/{}/cmdline".format(200 + i) for i in range(len(read_data))
     ]
     # Return just one cmdline from each open().read()
     mocked_open.side_effect = [
         mock_open(read_data=datum).return_value for datum in read_data
     ]
     self.assertEqual(system.other_flasher_running(self.logger), False)
 def test_other_flasher_running_skip_self(self, mocked_getpid, mocked_glob,
                                          mocked_open):
     self.assertEqual(system.other_flasher_running(self.logger), False)
     mocked_open.assert_not_called()
Exemple #4
0
 def test_other_flasher_running_flashy_exists(self, mocked_exists):
     self.assertEqual(system.other_flasher_running(self.logger), True)