def test_stack_restore(self):
    if (self.get_setting('WASM') or self.is_wasm_backend()):
        self.skipTest('generated code not available in wasm')
    self.emcc_args += ['-g3']
    self.do_run_in_out_file_test('tests', 'core', 'test_stack_restore')
    generated = open('src.c.o.js').read()

    def ensure_stack_restore_count(function_name, expected_count):
        code = generated[generated.find(function_name):]
        code = code[:(code.find('\n}') + 2)]
        actual_count = code.count('STACKTOP = sp')
        assert (actual_count == expected_count), ((('Expected %d stack restorations, got %d' % (expected_count, actual_count)) + ': ') + code)
    ensure_stack_restore_count('function _no_stack_usage', 0)
    ensure_stack_restore_count('function _alloca_gets_restored', 1)
    ensure_stack_restore_count('function _stack_usage', 1)
def test_stack_restore(self):
    if (self.get_setting('WASM') or self.is_wasm_backend()):
        self.skipTest('generated code not available in wasm')
    self.emcc_args += ['-g3']
    self.do_run_in_out_file_test('tests', 'core', 'test_stack_restore')
    generated = open('src.c.o.js').read()

    def ensure_stack_restore_count(function_name, expected_count):
        code = generated[generated.find(function_name):]
        code = code[:(code.find('\n}') + 2)]
        actual_count = code.count('STACKTOP = sp')
        assert (actual_count == expected_count), ((('Expected %d stack restorations, got %d' % (expected_count, actual_count)) + ': ') + code)
    ensure_stack_restore_count('function _no_stack_usage', 0)
    ensure_stack_restore_count('function _alloca_gets_restored', 1)
    ensure_stack_restore_count('function _stack_usage', 1)