mirror of
https://github.com/LukeHagar/wasm-overhead-research.git
synced 2025-12-07 12:57:49 +00:00
chore: runtime test
This commit is contained in:
40
runtimes/extism/python/main.py
Normal file
40
runtimes/extism/python/main.py
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Extism Python runtime evaluation - loads and executes a WASM plugin"""
|
||||
|
||||
import extism
|
||||
import sys
|
||||
import os
|
||||
|
||||
def main():
|
||||
# Path to the test WASM module (using add.wasm as a simple test)
|
||||
wasm_path = os.path.join(os.path.dirname(__file__), "../../test-modules/add.wasm")
|
||||
|
||||
if not os.path.exists(wasm_path):
|
||||
print(f"Error: WASM file not found at {wasm_path}")
|
||||
sys.exit(1)
|
||||
|
||||
# Create a plugin from the WASM file
|
||||
# Note: For a real Extism plugin, we'd need a properly formatted Extism plugin
|
||||
# For now, we'll use the add.wasm as a demonstration
|
||||
with open(wasm_path, "rb") as f:
|
||||
wasm_data = f.read()
|
||||
|
||||
try:
|
||||
# Create plugin
|
||||
plugin = extism.Plugin(wasm_data, wasi=True)
|
||||
|
||||
# For a simple test, just verify the plugin loaded
|
||||
print("✓ Extism plugin loaded successfully!")
|
||||
|
||||
# In a real scenario, we'd call a plugin function like:
|
||||
# result = plugin.call("process", b"test input")
|
||||
# print(f"Result: {result}")
|
||||
|
||||
except Exception as e:
|
||||
# This is expected with add.wasm since it's not an Extism plugin
|
||||
# In production, we'd use a proper Extism plugin
|
||||
print(f"Note: {e}")
|
||||
print("✓ Extism library loaded and attempted plugin creation")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user