summaryrefslogtreecommitdiff
path: root/test/unit/utils.py
blob: eaeb29d42024985ac7502cba8ca8dfa9df134e8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import os
from scripts.test.shared import WASM_OPT, run_process, options


def input_path(filename):
  return os.path.join(options.binaryen_test, 'unit', 'input', filename)


def roundtrip(testcase, filename, opts=[]):
  path = input_path(filename)
  p = run_process(WASM_OPT + ['-g', '-o', '-', path] + opts, check=False,
                  capture_output=True)
  testcase.assertEqual(p.returncode, 0)
  testcase.assertEqual(p.stderr, '')
  with open(path, 'rb') as f:
    testcase.assertEqual(str(p.stdout), str(f.read()))