Example #1
0
    def test_logged_call(self):
        if os.path.exists(
                os.path.join(_Config.ROOT_DIR, 'log.tmp')
        ):
            os.remove(
                os.path.join(_Config.ROOT_DIR, 'log.tmp')
            )

        e1 = Executor(
            _Config.ROOT_DIR
        )

        e1.logged_call(
            'echo THOR',
            logfile='log.tmp'
        )

        with open(os.path.join(_Config.ROOT_DIR, 'log.tmp'), 'r') as f:
            self.assertEqual(
                f.readline().strip('\n'),
                'THOR'
            )

        os.remove(
            os.path.join(_Config.ROOT_DIR, 'log.tmp')
        )
Example #2
0
    def test_is_running(self):
        e2 = Executor(
            _Config.ROOT_DIR
        )

        e2.call('ls')

        self.assertFalse(e2.is_running())
Example #3
0
File: UNIX.py Project: adyasha/dune
    def optimize(self) -> int:
        executor = Executor(
            cwd=self.work_dir
        )

        executor.logged_call(
            cmd='strip ./main.native',
            logfile='strip.log'
        )

        return executor.pid
Example #4
0
    def test_pid(self):
        e4 = Executor(
            _Config.ROOT_DIR
        )

        e4.call('ls')

        self.assertTrue(
            type(e4.pid),
            int
        )
Example #5
0
File: UNIX.py Project: adyasha/dune
    def compile(self) -> int:
        # TODO: Need better exception handling
        executor = Executor(
            cwd=self.work_dir
        )

        executor.logged_call(
            cmd='make',
            logfile='compile.log'
        )

        return executor.pid
Example #6
0
File: UNIX.py Project: adyasha/dune
    def configure(self) -> int:
        # TODO: Need better exception handling
        executor = Executor(
            cwd=self.work_dir
        )

        executor.logged_call(
            cmd='mirage configure --unix',
            logfile='configure.log'
        )

        return executor.pid
Example #7
0
File: UNIX.py Project: adyasha/dune
    def start(self) -> int:
        executor = Executor(
            cwd=self.work_dir
        )

        executor.logged_call(
            cmd='./main.native',
            logfile='stdout.log',
            stderr=True  # FIXME: Mirage console prints to stderr by default
        )

        Status.set(
            self._id,
            executor.probe_status()
        )

        return executor.pid
Example #8
0
    def test_terminate(self):
        e3 = Executor(
            _Config.ROOT_DIR
        )

        # Represents an expensive task
        e3.call('sleep 100')

        self.assertTrue(e3.is_running())

        e3.terminate()

        self.assertTrue(e3.was_terminated())