Skip to content
Open
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
56 changes: 56 additions & 0 deletions python3.10-http-server/scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Scripts for Python3.10-http-server on Unikraft

These are companions instruction to the main instructions in the [`README`](README.md).

Use scripts as quick actions for building and running Python3.10-http-server on Unikraft.

**Note**: Run scripts from the application directory.

## Build for <plat> / <arch>:

```console
./scripts/build/<plat>.<arch>
```

e.g.:

```console
./scripts/build/qemu.x86_64
./scripts/build/qemu.arm64
./scripts/build/fc.x86_64
./scripts/build/xen.arm64
```

## Build for <plat> / <arch> using a different compiler

```console
CC=/path/to/compiler ./scripts/build/<plat>.<arch>
```

e.g.

```console
CC=/usr/bin/gcc-12 ./scripts/build/qemu.x86_64
CC=/usr/bin/aarch64-linux-gnu-gcc-12 ./scripts/build/qemu.arm64
CC=/usr/bin/clang ./scripts/build/qemu.x86_64
CC=/usr/bin/clang ./scripts/build/qemu.arm64
CC=/usr/bin/gcc-12 ./scripts/build/fc.x86_64
CC=/usr/bin/aarch64-linux-gnu-gcc-12 ./scripts/build/fc.arm64
CC=/usr/bin/clang ./scripts/build/fc.x86_64
CC=/usr/bin/clang ./scripts/build/fc.arm64
```

## Run on <plat> / <arch>

```console
./scripts/run/<plat>.<arch>
```

e.g.

```console
./scripts/run/qemu.x86_64
./scripts/run/qemu.arm64
./scripts/run/fc.x86_64
./scripts/run/xen.arm64
```
11 changes: 11 additions & 0 deletions python3.10-http-server/scripts/build/fc.arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

make distclean
UK_DEFCONFIG=$(pwd)/scripts/defconfig/fc.arm64 make defconfig
touch Makefile.uk
make prepare
if test -z "$CC"; then
make -j $(nproc)
else
make CC="$CC" -j $(nproc)
fi
11 changes: 11 additions & 0 deletions python3.10-http-server/scripts/build/fc.x86_64
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

make distclean
UK_DEFCONFIG=$(pwd)/scripts/defconfig/fc.x86_64 make defconfig
touch Makefile.uk
make prepare
if test -z "$CC"; then
make -j $(nproc)
else
make CC="$CC" -j $(nproc)
fi
11 changes: 11 additions & 0 deletions python3.10-http-server/scripts/build/qemu.arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

make distclean
UK_DEFCONFIG=$(pwd)/scripts/defconfig/qemu.arm64 make defconfig
touch Makefile.uk
make prepare
if test -z "$CC"; then
make -j $(nproc)
else
make CC="$CC" -j $(nproc)
fi
11 changes: 11 additions & 0 deletions python3.10-http-server/scripts/build/qemu.x86_64
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

make distclean
UK_DEFCONFIG=$(pwd)/scripts/defconfig/qemu.x86_64 make defconfig
touch Makefile.uk
make prepare
if test -z "$CC"; then
make -j $(nproc)
else
make CC="$CC" -j $(nproc)
fi
11 changes: 11 additions & 0 deletions python3.10-http-server/scripts/build/xen.arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

make distclean
UK_DEFCONFIG=$(pwd)/scripts/defconfig/xen.arm64 make defconfig
touch Makefile.uk
make prepare
if test -z "$CC"; then
make -j $(nproc)
else
make CC="$CC" -j $(nproc)
fi
11 changes: 11 additions & 0 deletions python3.10-http-server/scripts/build/xen.x86_64
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

make distclean
UK_DEFCONFIG=$(pwd)/scripts/defconfig/xen.x86_64 make defconfig
touch Makefile.uk
make prepare
if test -z "$CC"; then
make -j $(nproc)
else
make CC="$CC" -j $(nproc)
fi
13 changes: 13 additions & 0 deletions python3.10-http-server/scripts/defconfig/fc.arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CONFIG_ARCH_ARM64=y
CONFIG_PLAT_FC=y
CONFIG_APPPYHTON3_HTTP_SERVER=y
CONFIG_LIBPYTHON3=y
CONFIG_LIBPYTHON3_MAIN_FUNCTION=y
CONFIG_LIBPOSIX_VFS_FSTAB=y
CONFIG_LIBPOSIX_VFS_FSTAB_BUILTIN_RAMFS=y
CONFIG_LIBRAMFS=y
CONFIG_LIBUKCPIO=y
CONFIG_LIBLWIP=y
CONFIG_LIBUKRANDOM=y
CONFIG_LIBUKRANDOM_GETRANDOM=y
CONFIG_STACK_SIZE_PAGE_ORDER=10
14 changes: 14 additions & 0 deletions python3.10-http-server/scripts/defconfig/fc.x86_64
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
CONFIG_ARCH_X86_64=y
CONFIG_PLAT_KVM=y
CONFIG_KVM_PLAT_FC=y
CONFIG_APPPYTHON3_HTTP_SERVER=y
CONFIG_LIBPYTHON3=y
CONFIG_LIBPYTHON3_MAIN_FUNCTION=y
CONFIG_LIBPOSIX_VFS_FSTAB=y
CONFIG_LIBPOSIX_VFS_FSTAB_BUILTIN_RAMFS=y
CONFIG_LIBRAMFS=y
CONFIG_LIBUKCPIO=y
CONFIG_LIBLWIP=y
CONFIG_LIBUKRANDOM=y
CONFIG_LIBUKRANDOM_GETRANDOM=y
CONFIG_STACK_SIZE_PAGE_ORDER=10
13 changes: 13 additions & 0 deletions python3.10-http-server/scripts/defconfig/qemu.arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CONFIG_ARCH_ARM64=y
CONFIG_PLAT_KVM=y
CONFIG_APPPYTHON3_HTTP_SERVER=y
CONFIG_LIBPYTHON3=y
CONFIG_LIBPYTHON3_MAIN_FUNCTION=y
CONFIG_LIBPOSIX_VFS_FSTAB=y
CONFIG_LIBPOSIX_VFS_FSTAB_BUILTIN_RAMFS=y
CONFIG_LIBRAMFS=y
CONFIG_LIBUKCPIO=y
CONFIG_LIBLWIP=y
CONFIG_LIBUKRANDOM=y
CONFIG_LIBUKRANDOM_GETRANDOM=y
CONFIG_STACK_SIZE_PAGE_ORDER=10
13 changes: 13 additions & 0 deletions python3.10-http-server/scripts/defconfig/qemu.x86_64
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CONFIG_ARCH_X86_64=y
CONFIG_PLAT_KVM=y
CONFIG_APPPYTHON3_HTTP_SERVER=y
CONFIG_LIBPYTHON3=y
CONFIG_LIBPYTHON3_MAIN_FUNCTION=y
CONFIG_LIBPOSIX_VFS_FSTAB=y
CONFIG_LIBPOSIX_VFS_FSTAB_BUILTIN_RAMFS=y
CONFIG_LIBRAMFS=y
CONFIG_LIBUKCPIO=y
CONFIG_LIBLWIP=y
CONFIG_LIBUKRANDOM=y
CONFIG_LIBUKRANDOM_GETRANDOM=y
CONFIG_STACK_SIZE_PAGE_ORDER=10
13 changes: 13 additions & 0 deletions python3.10-http-server/scripts/defconfig/xen.arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CONFIG_ARCH_ARM64=y
CONFIG_PLAT_XEN=y
CONFIG_APP_PYHTON3_HTTP_SERVER=y
CONFIG_LIBPYTHON3=y
CONFIG_LIBPYTHON3_MAIN_FUNCTION=y
CONFIG_LIBPOSIX_VFS_FSTAB=y
CONFIG_LIBPOSIX_VFS_FSTAB_BUILTIN_RAMFS=y
CONFIG_LIBRAMFS=y
CONFIG_LIBUKCPIO=y
CONFIG_LIBLWIP=y
CONFIG_LIBUKRANDOM=y
CONFIG_LIBUKRANDOM_GETRANDOM=y
CONFIG_STACK_SIZE_PAGE_ORDER=10
13 changes: 13 additions & 0 deletions python3.10-http-server/scripts/defconfig/xen.x86_64
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CONFIG_ARCH_X86_64=y
CONFIG_PLAT_XEN=y
CONFIG_APP_PYHTON3_HTTP_SERVER=y
CONFIG_LIBPYTHON3=y
CONFIG_LIBPYTHON3_MAIN_FUNCTION=y
CONFIG_LIBPOSIX_VFS_FSTAB=y
CONFIG_LIBPOSIX_VFS_FSTAB_BUILTIN_RAMFS=y
CONFIG_LIBRAMFS=y
CONFIG_LIBUKCPIO=y
CONFIG_LIBLWIP=y
CONFIG_LIBUKRANDOM=y
CONFIG_LIBUKRANDOM_GETRANDOM=y
CONFIG_STACK_SIZE_PAGE_ORDER=10
22 changes: 22 additions & 0 deletions python3.10-http-server/scripts/run/fc.arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

if test ! -f "workdir/build/python3.10-http-server_fc-arm64"; then
echo "No kernel file workdir/build/python3.10-http-server_fc-arm64." 1>&2
echo "Did you run ./build.fc.arm64 ?" 1>&2
exit 1
fi

# Generate root filesystem from Dockerfile.
rm -fr ./rootfs
docker build -o ./rootfs -f Dockerfile .

# Pack filesystem as an initial ramdisk CPIO file.
rm -f initrd.cpio
../repos/unikraft/support/scripts/mkcpio initrd.cpio ./rootfs/

# Remove previously created files.
rm -f firecracker.socket

firecracker-aarch64 \
--api-sock firecracker.socket \
--config-file fc.arm64.json
22 changes: 22 additions & 0 deletions python3.10-http-server/scripts/run/fc.x86_64
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

if test ! -f "workdir/build/python3.10-http-server_fc-x86_64"; then
echo "No kernel file workdir/build/python3.10-http-server_fc-x86_64." 1>&2
echo "Did you run ./build.fc.x86_64 ?" 1>&2
exit 1
fi

# Generate root filesystem from Dockerfile.
rm -fr ./rootfs
docker build -o ./rootfs -f Dockerfile .

# Pack filesystem as an initial ramdisk CPIO file.
rm -f initrd.cpio
../repos/unikraft/support/scripts/mkcpio initrd.cpio ./rootfs/

# Remove previously created files.
rm -f firecracker.socket

firecracker-x86_64 \
--api-sock firecracker.socket \
--config-file fc.x86_64.json
28 changes: 28 additions & 0 deletions python3.10-http-server/scripts/run/qemu.arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

if test ! -f "workdir/build/python3.10-http-server_qemu-arm64"; then
echo "No kernel file workdir/build/python3.10-http-server_qemu-arm64." 1>&2
echo "Did you run ./build.qemu.arm64 ?" 1>&2
exit 1
fi

# Generate root filesystem from Dockerfile.
rm -fr ./rootfs
docker build -o ./rootfs -f Dockerfile .

# Pack filesystem as an initial ramdisk CPIO file.
rm -f initrd.cpio
../repos/unikraft/support/scripts/mkcpio initrd.cpio ./rootfs/

qemu-system-aarch64 \
-machine virt -cpu max \
-m 256M \
-nographic \
-netdev user,id=net0,hostfwd=tcp:127.0.0.1:18080-:8080 \
-device virtio-net-device,netdev=net0 \
-kernel workdir/build/python3.10-http-server_qemu-arm64 \
-initrd ./initrd.cpio \
-append 'rootfstype=ramfs console=ttyAMA0 \
vfs.fstab=["initrd0:/:extract::ramfs=1"] \
env.vars=[PYTHONHOME="/usr/local/lib/python3.10" PYTHONPATH="/usr/local/lib/python3.10"] \
-- /app/http-server.py'
28 changes: 28 additions & 0 deletions python3.10-http-server/scripts/run/qemu.x86_64
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

if test ! -f "workdir/build/python3.10-http-server_qemu-x86_64"; then
echo "No kernel file workdir/build/python3.10-http-server_qemu-x86_64." 1>&2
echo "Did you run ./build.qemu.x86_64 ?" 1>&2
exit 1
fi

# Generate root filesystem from Dockerfile.
rm -fr ./rootfs
docker build -o ./rootfs -f Dockerfile .

# Pack filesystem as an initial ramdisk CPIO file.
rm -f initrd.cpio
../repos/unikraft/support/scripts/mkcpio initrd.cpio ./rootfs/

qemu-system-x86_64 \
-machine accel=tcg -cpu max \
-m 256M \
-nographic \
-netdev user,id=net0,hostfwd=tcp:127.0.0.1:8080-:8080 \
-device virtio-net-pci,netdev=net0 \
-kernel workdir/build/python3.10-http-server_qemu-x86_64 \
-initrd ./initrd.cpio \
-append 'rootfstype=ramfs console=ttyS0 \
vfs.fstab=["initrd0:/:extract::ramfs=1"] \
env.vars=[PYTHONHOME="/usr/local/lib/python3.10" PYTHONPATH="/usr/local/lib/python3.10"] \
-- /app/http-server.py'
17 changes: 17 additions & 0 deletions python3.10-http-server/scripts/run/xen.arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

if test ! -f "workdir/build/python3.10-http-server_xen-arm64"; then
echo "No kernel file workdir/build/python3.10-http-server_xen-arm64." 1>&2
echo "Did you run ./build.xen.arm64 ?" 1>&2
exit 1
fi

# Generate root filesystem from Dockerfile.
rm -fr ./rootfs
docker build -o ./rootfs -f Dockerfile .

# Pack filesystem as an initial ramdisk CPIO file.
rm -f initrd.cpio
../repos/unikraft/support/scripts/mkcpio initrd.cpio ./rootfs/

sudo xl create -c xen.arm64.cfg
17 changes: 17 additions & 0 deletions python3.10-http-server/scripts/run/xen.x86_64
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

if test ! -f "workdir/build/python3.10-http-server_xen-x86_64"; then
echo "No kernel file workdir/build/python3.10-http-server_xen-x86_64." 1>&2
echo "Did you run ./build.xen.x86_64 ?" 1>&2
exit 1
fi

# Generate root filesystem from Dockerfile.
rm -fr ./rootfs
docker build -o ./rootfs -f Dockerfile .

# Pack filesystem as an initial ramdisk CPIO file.
rm -f initrd.cpio
../repos/unikraft/support/scripts/mkcpio initrd.cpio ./rootfs/

sudo xl create -c xen.x86_64.cfg
1 change: 1 addition & 0 deletions python3.10-http-server/scripts/test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/log/
31 changes: 31 additions & 0 deletions python3.10-http-server/scripts/test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Testing Python3.10 Http Server on Unikraft

These are companion instructions to the main instructions in the [`README`](../../README.md) and to the scripted run instructions in the [`scripts/README`](../README.md).
Use these scripts to test Python3.10 Http Server on Unikraft.

**Note**: Run scripts from the application directory.

Use the `all.sh` script to test all builds and all available runs:

```console
./scripts/test/all.sh
```

The command prints out a summary of the passed or failed tests.

Logs are stored in the `./scripts/test/log/` directory.

Use the `single.sh` script to only run a query test for a running instance.
That is, first run the instance, e.g:

```console
./scripts/run/qemu.x86_64
```

And then query it with the `single.sh` script:

```console
./single.sh

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include the path from the application directory:

./scripts/test/single.sh

Running single.sh from the test drectory will fail because it will not find the auxiliary script common.sh, it uses a relative path.

```

The command prints out the output of the commands that query the instance.
Loading