File: test_cvise.py

package info (click to toggle)
cvise 2.12.0-3
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 3,772 kB
  • sloc: cpp: 26,284; python: 4,807; ansic: 1,215; lex: 441; makefile: 42
file content (27 lines) | stat: -rw-r--r-- 904 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import os
import shutil
import stat
import subprocess
import unittest


class TestCvise(unittest.TestCase):
    @classmethod
    def check_cvise(cls, testcase, arguments, expected):
        current = os.path.dirname(__file__)
        binary = os.path.join(current, '../cvise.py')
        shutil.copy(os.path.join(current, 'sources', testcase), '.')
        os.chmod(testcase, 0o644)
        cmd = f'{binary} {testcase} {arguments}'
        subprocess.check_output(cmd, shell=True, encoding='utf8')
        with open(testcase) as f:
            content = f.read()
        assert content in expected
        assert stat.filemode(os.stat(testcase).st_mode) == '-rw-r--r--'

    def test_simple_reduction(self):
        self.check_cvise(
            'blocksort-part.c',
            '-c "gcc -c blocksort-part.c && grep nextHi blocksort-part.c"',
            ['#define nextHi', '#define  nextHi '],
        )