Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
develop:
strategy:
matrix:
os: [macos-latest, ubuntu-latest]
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand Down
5 changes: 4 additions & 1 deletion pywasm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import platform

from . import core
from . import leb128
from . import log
from . import opcode
from . import wasi
if platform.system().lower() in ['darwin', 'linux']:
from . import wasi
from .core import *
26 changes: 10 additions & 16 deletions pywasm/wasi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import dataclasses
import fcntl
import os
import pywasm.core
import random
Expand Down Expand Up @@ -654,24 +655,17 @@ def fd_fdstat_set_flags(self, _: pywasm.core.Machine, args: typing.List[int]) ->
if file.wasm_flag ^ args[1] | fyes != fyes:
# Only support changing the NONBLOCK or APPEND flags.
return [self.ERRNO_INVAL]
host_flag = file.host_flag
host_flag &= ~os.O_APPEND
host_flag &= ~os.O_APPEND
wasm_flag = file.wasm_flag
wasm_flag &= ~self.FDFLAGS_APPEND
wasm_flag &= ~self.FDFLAGS_NONBLOCK
file.host_flag &= ~os.O_APPEND
file.host_flag &= ~os.O_APPEND
file.wasm_flag &= ~self.FDFLAGS_APPEND
file.wasm_flag &= ~self.FDFLAGS_NONBLOCK
if args[1] & self.FDFLAGS_APPEND:
host_flag |= os.O_APPEND
wasm_flag |= self.FDFLAGS_APPEND
file.host_flag |= os.O_APPEND
file.wasm_flag |= self.FDFLAGS_APPEND
if args[1] & self.FDFLAGS_NONBLOCK:
host_flag |= os.O_NONBLOCK
wasm_flag |= self.FDFLAGS_NONBLOCK
ocur = os.lseek(file.host_fd, 0, os.SEEK_CUR)
os.close(file.host_fd)
file.host_fd = os.open(file.host_name, host_flag)
os.lseek(file.host_fd, ocur, os.SEEK_SET)
file.host_flag = host_flag
file.wasm_flag = wasm_flag
file.host_flag |= os.O_NONBLOCK
file.wasm_flag |= self.FDFLAGS_NONBLOCK
fcntl.fcntl(file.host_fd, fcntl.F_SETFL, file.host_flag)
return [self.ERRNO_SUCCESS]

def fd_fdstat_set_rights(self, _: pywasm.core.Machine, args: typing.List[int]) -> typing.List[int]:
Expand Down
11 changes: 5 additions & 6 deletions test/wasi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
import io
import json
import os
import platform
import pywasm
import shutil
import subprocess
import sys
import typing


def call(cmd: str) -> subprocess.CompletedProcess[bytes]:
print(f'$ {cmd}')
return subprocess.run(cmd, shell=True, check=True)


@contextlib.contextmanager
def cd(dst: str) -> typing.Generator[None, typing.Any, None]:
cwd = os.getcwd()
Expand All @@ -22,6 +18,9 @@ def cd(dst: str) -> typing.Generator[None, typing.Any, None]:
os.chdir(cwd)


if platform.system().lower() in ['windows']:
sys.exit(0)

with cd('res/wasi-testsuite'):
for e in glob.glob('**/*/*.cleanup', recursive=True):
if os.path.islink(e):
Expand Down
Loading