Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils: Add new design for generator script #44

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b9c82b6
utils: Add new design for generator script
razvand Jun 20, 2024
9037b2a
Document new class design
razvand Jul 19, 2024
77efe14
Improve tester config
razvand Aug 17, 2024
9ec6873
utils: Generate target configs for new design
razvand Aug 20, 2024
a27ce67
utils/new-design: Add initial generator logic
razvand Aug 20, 2024
cf917e7
new-design: Add Kraftfile generator
razvand Aug 21, 2024
3a60bc1
new-design: Add Makefile generator
razvand Aug 21, 2024
f758ebe
new-design: Add generators for build scripts
razvand Aug 21, 2024
bd5d767
new-design: Complete build scripts
razvand Aug 21, 2024
630ea66
new-design: Separate build variants from run variants
razvand Aug 31, 2024
4d9fc47
new-design: Add support for Clang
razvand Aug 31, 2024
39e186d
new-design: Add support for building Xen
razvand Aug 31, 2024
1b8f089
new-desing: Add run scripts
razvand Sep 11, 2024
2c9025a
new-design: Add support for ports for NAT networking
razvand Sep 14, 2024
b47d398
new-design: Consistent naming for networking types
razvand Sep 14, 2024
b8bd606
new-design: Add Firecracker run support
razvand Sep 14, 2024
69ec39b
new-design: Add common directory
razvand Sep 15, 2024
6ee2656
new-design: Use machine variable for non-arch runs
razvand Sep 15, 2024
4cd04b6
library/nginx/1.15: Add setup for new design scripts
razvand Sep 15, 2024
54dad81
library/nginx/1.15: Add test scripts
razvand Sep 15, 2024
3b4efbb
library/nginx/1.15: Ignore .tests/ directory
razvand Sep 15, 2024
0cf9a63
native/http-c: Add testing scripts
razvand Sep 19, 2024
4fa5aec
utils/new-design: Remove run configs when rootfs is not present
razvand Sep 19, 2024
1a785fa
utils/new-design: Pass configuration file as argument
razvand Sep 19, 2024
529944f
utils/new-design: Fixes for when rootfs is absent
razvand Sep 20, 2024
e3e56c7
utils/new-design: Fixes for base build
razvand Nov 11, 2024
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
1 change: 1 addition & 0 deletions library/nginx/1.15/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.tests/
44 changes: 44 additions & 0 deletions library/nginx/1.15/.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/sh

. .tests/common/common.sh

run_script=""
default_host=172.44.0.2
default_port=80

if test $# -eq 1; then
echo "Host and port unspecified." 1>&2
host="$default_host"
port="$default_port"
elif test $# -eq 3; then
host="$2"
port="$3"
else
echo "Unknown arguments." 1>&2
echo "Usage: $0 [<port>]" 1>&2
exit 1
fi
echo "Using as remote $host:$port" 1>&2

# Clean up previous instances.
clean_up

# Start instance.
start_instance

# Wait for start.
sleep 3

# Query non-localhost (NAT networking) instance.
if test ! "$host" = "localhost" -a ! "$host" = "127.0.0.1"; then
test_ping "$host"
fi

# Connect via HTTP.
test_curl_connect "$host" "$port"

# Connect via HTTP and check reply.
test_curl_check_reply "$host" "$port" "Hello from Unikraft!"

# Stop instance.
end_with_success
2 changes: 2 additions & 0 deletions library/nginx/1.15/Kraftfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ targets:
- qemu/arm64
- fc/x86_64
- fc/arm64
- xen/x86_64
- xen/arm64

libraries:
musl: staging
Expand Down
4 changes: 4 additions & 0 deletions library/nginx/1.15/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
networking: True
memory: 32
exposed_port: 80
public_port: 8080
14 changes: 14 additions & 0 deletions library/nginx/1.15/test_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

. ./test_common.sh

rm -fr .tests/*
python3 ../../../utils/new-design/all.py
for bdir in .tests/*; do
if test ! -d "$bdir"; then
continue
elif test ! -f "$bdir"/build; then
continue
fi
test_one "$bdir"
done
57 changes: 57 additions & 0 deletions library/nginx/1.15/test_common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash

run_build_script()
{
bdir="${1%/}"

if test ! -d "$bdir"; then
echo "$bdir is not a directory"
return
elif test ! -f "$bdir"/build; then
echo "No build script in $bdir"
return
fi
echo -n "Building $bdir ... "
"$bdir"/build > "$bdir"/build.log 2>&1
}

run_run_scripts()
{
bdir="${1%/}"

for rdir in "$bdir"/run-*; do
if test ! -d "$rdir"; then
continue
elif test ! -f "$rdir"/run; then
continue
else
echo -n " Using $rdir ... "
grep "networking: nat" "$rdir"/config.yaml > /dev/null 2>&1
if test $? -eq 0; then
./.test "$rdir"/run 127.0.0.1 8080 2> "$rdir"/run.log
else
./.test "$rdir"/run 172.44.0.2 80 2> "$rdir"/run.log
fi
fi
done
}

test_one()
{
bdir="${1%/}"

# Clean up.
rm -fr "$bdir"/.unikraft

# Run build script.
run_build_script "$bdir"
build_exitcode=$?
if test "$build_exitcode" -eq 0; then
echo "PASSED"
else
echo "FAILED"
fi

# Run run scripts.
run_run_scripts "$bdir"
}
11 changes: 11 additions & 0 deletions library/nginx/1.15/test_one.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

. ./test_common.sh

if test $# -ne 1; then
echo "Wrong arguments." 1>&2
echo "$0 path/to/test/directory" 1>&2
exit 1
fi

test_one "$1"
11 changes: 11 additions & 0 deletions library/nginx/1.15/test_one_runs_only.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

. ./test_common.sh

if test $# -ne 1; then
echo "Wrong arguments." 1>&2
echo "$0 path/to/test/directory" 1>&2
exit 1
fi

run_run_scripts "$1"
43 changes: 43 additions & 0 deletions native/http-c/.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/sh

. .tests/common/common.sh

default_host=172.44.0.2
default_port=8080

if test $# -eq 1; then
echo "Host and port unspecified." 1>&2
host="$default_host"
port="$default_port"
elif test $# -eq 3; then
host="$2"
port="$3"
else
echo "Unknown arguments." 1>&2
echo "Usage: $0 [<port>]" 1>&2
exit 1
fi
echo "Using as remote $host:$port" 1>&2

# Clean up previous instances.
clean_up

# Start instance.
start_instance

# Wait for start.
sleep 3

# Query non-localhost (NAT networking) instance.
if test ! "$host" = "localhost" -a ! "$host" = "127.0.0.1"; then
test_ping "$host"
fi

# Connect via HTTP.
test_curl_connect "$host" "$port"

# Connect via HTTP and check reply.
test_curl_check_reply "$host" "$port" "Hello, World!"

# Stop instance.
end_with_success
4 changes: 4 additions & 0 deletions native/http-c/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
networking: True
memory: 8
exposed_port: 8080
public_port: 8080
14 changes: 14 additions & 0 deletions native/http-c/test_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

. ./test_common.sh

rm -fr .tests/*
python3 ../../../utils/new-design/all.py
for bdir in .tests/*; do
if test ! -d "$bdir"; then
continue
elif test ! -f "$bdir"/build; then
continue
fi
test_one "$bdir"
done
57 changes: 57 additions & 0 deletions native/http-c/test_common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash

run_build_script()
{
bdir="${1%/}"

if test ! -d "$bdir"; then
echo "$bdir is not a directory"
return
elif test ! -f "$bdir"/build; then
echo "No build script in $bdir"
return
fi
echo -n "Building $bdir ... "
"$bdir"/build > "$bdir"/build.log 2>&1
}

run_run_scripts()
{
bdir="${1%/}"

for rdir in "$bdir"/run-*; do
if test ! -d "$rdir"; then
continue
elif test ! -f "$rdir"/run; then
continue
else
echo -n " Using $rdir ... "
grep "networking: nat" "$rdir"/config.yaml > /dev/null 2>&1
if test $? -eq 0; then
./.test "$rdir"/run 127.0.0.1 8080 2> "$rdir"/run.log
else
./.test "$rdir"/run 172.44.0.2 8080 2> "$rdir"/run.log
fi
fi
done
}

test_one()
{
bdir="${1%/}"

# Clean up.
rm -fr "$bdir"/.unikraft

# Run build script.
run_build_script "$bdir"
build_exitcode=$?
if test "$build_exitcode" -eq 0; then
echo "PASSED"
else
echo "FAILED"
fi

# Run run scripts.
run_run_scripts "$bdir"
}
11 changes: 11 additions & 0 deletions native/http-c/test_one.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

. ./test_common.sh

if test $# -ne 1; then
echo "Wrong arguments." 1>&2
echo "$0 path/to/test/directory" 1>&2
exit 1
fi

test_one "$1"
11 changes: 11 additions & 0 deletions native/http-c/test_one_runs_only.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

. ./test_common.sh

if test $# -ne 1; then
echo "Wrong arguments." 1>&2
echo "$0 path/to/test/directory" 1>&2
exit 1
fi

run_run_scripts "$1"
Loading
Loading