55 lines
1.5 KiB
Python
55 lines
1.5 KiB
Python
import asyncio
|
|
|
|
from sandbox.session import PodmanSandbox
|
|
from tools.bash import bash
|
|
|
|
|
|
async def main():
|
|
print("Creating sandbox...")
|
|
async with PodmanSandbox() as sb:
|
|
print("✓ Sandbox created\n")
|
|
|
|
# Test 1: Basic command
|
|
print("Test 1: pwd")
|
|
result = await bash("pwd", sb)
|
|
print(f"Result: {result}\n")
|
|
|
|
# Test 2: List workspace
|
|
print("Test 2: ls -la")
|
|
result = await bash("ls -la", sb)
|
|
print(f"Result: {result}\n")
|
|
|
|
# Test 3: Python version
|
|
print("Test 3: python --version")
|
|
result = await bash("python --version", sb)
|
|
print(f"Result: {result}\n")
|
|
|
|
# Test 4: Write a file
|
|
print("Test 4: Write test file")
|
|
result = await bash("echo 'Hello from sandbox' > test.txt", sb)
|
|
print(f"Result: {result}")
|
|
|
|
# Test 5: Read it back
|
|
print("Test 5: Read test file")
|
|
result = await bash("cat test.txt", sb)
|
|
print(f"Result: {result}\n")
|
|
|
|
# Test 6: Check it exists on host
|
|
print("Test 6: Verify file on host")
|
|
import os
|
|
|
|
from agent.config import settings
|
|
|
|
host_file = f"{settings.safedir}/test.txt"
|
|
if os.path.exists(host_file):
|
|
with open(host_file) as f:
|
|
print(f"✓ File exists on host: {f.read()}")
|
|
else:
|
|
print("✗ File NOT found on host")
|
|
|
|
print("\n✓ Sandbox destroyed")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|