Ejemplo n.º 1
0
    def test_ptracer_basic(self):
        syscalls = []

        with ptracer.context(syscalls.append):
            f = open('/dev/zero', 'r')
            f.close()

        self.assertGreater(len(syscalls), 0)
Ejemplo n.º 2
0
        def _trace(pattern):
            syscalls[:] = []

            with ptracer.context(syscalls.append, filter=pattern):
                f = open('/dev/null', 'w')
                f.close()
                f = open('/dev/zero', 'r')
                f.close()
                try:
                    open('/dev/nonexistent', 'r')
                except IOError:
                    pass
Ejemplo n.º 3
0
    def test_ptracer_threading(self):
        syscalls = []

        def _thread():
            f = open('/dev/zero', 'r')
            f.close()

        flt = ptracer.SysCallPattern(name='open', args=[b'/dev/zero'])

        with ptracer.context(syscalls.append, filter=flt):
            thread = threading.Thread(target=_thread)
            thread.start()
            thread.join()

        self.assertEqual(len(syscalls), 1)
Ejemplo n.º 4
0
 def test_ptracer__fail_04(self):
     with self.assertRaisesRegexp(ptracer.PtracerError,
                                  'Operation not permitted'):
         with ptracer.context(lambda s: None):
             f = open('/dev/zero', 'r')
             f.close()