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

make-based: Add sqlite read test #49

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
11 changes: 11 additions & 0 deletions make-based/app-sqlite/rootfs/script.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CREATE TABLE tab (d1 int, d2 text);
INSERT INTO tab VALUES (random(), cast(random() as text)),
(random(), cast(random() as text)),
(random(), cast(random() as text)),
(random(), cast(random() as text)),
(random(), cast(random() as text)),
(random(), cast(random() as text)),
(random(), cast(random() as text)),
(random(), cast(random() as text)),
(random(), cast(random() as text)),
(123456, "abcdef");
22 changes: 20 additions & 2 deletions make-based/run-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ test_common_errors()

test_booting()
{
echo -n "Running $app... "

/bin/bash "do.sh" run > "$tmp_file" 2>&1 &

sleep 5
Expand All @@ -60,6 +62,8 @@ test_booting()

test_elfloader()
{
echo -n "Running $app... "

# The elfloader should be tested separately from the automated tested
# applications, since you need to run multiple apps with it.
# Maybe we can find a way to automate testing the alfloader too, by
Expand All @@ -70,6 +74,8 @@ test_elfloader()

test_python3()
{
echo -n "Running $app... "

# HACK: Clearly not the best way to do this.
# Find a way to capture the output of an application when ran using the
# `./do.sh` files.
Expand All @@ -89,6 +95,8 @@ test_python3()

test_nginx()
{
echo -n "Running $app... "

/bin/bash "do.sh" run < /dev/null > "$tmp_file" 2>&1 &
sleep 2

Expand All @@ -104,6 +112,8 @@ test_nginx()

test_httpreply()
{
echo -n "Running $app... "

/bin/bash "do.sh" run < /dev/null > "$tmp_file" 2>&1 &
sleep 2

Expand All @@ -118,6 +128,8 @@ test_httpreply()

test_redis()
{
echo -n "Running $app... "

/bin/bash "do.sh" run < /dev/null > "$tmp_file" 2>&1 &
sleep 2

Expand All @@ -137,7 +149,7 @@ test_sqlite()
# HACK: Clearly not the best way to do this.
# Find a way to capture the output of an application when ran using the
# `./do.sh` files.
(sleep 4; echo -e '.open chinook.db\nselect * from Album;\n.exit') | /bin/bash "do.sh" run > "$tmp_file" 2>&1 &
(sleep 4; echo -e '.open chinook.db\nselect * from Album;\n.read script.sql\nselect * from tab;\n.exit') | /bin/bash "do.sh" run > "$tmp_file" 2>&1 &

sleep 10
sudo kill -KILL $(pgrep -f "qemu-system.*$app") > /dev/null 2>&1
Expand All @@ -147,12 +159,19 @@ test_sqlite()
return
fi

echo -n "Running $app .open test ... "
grep -E "^346\|Mozart: Chamber Music\|274" < "$tmp_file" > /dev/null 2>&1 && echo "PASSED" || echo "FAILED"

echo -n "Running $app .read test ... "
grep -E "^123456|abcdef" < "$tmp_file" > /dev/null 2>&1 && echo "PASSED" || echo "FAILED"

rm -f "$tmp_file"
}

test_micropython()
{
echo -n "Running $app... "

# HACK: Clearly not the best way to do this.
# Find a way to capture the output of an application when ran using the
# `./do.sh` files.
Expand All @@ -178,7 +197,6 @@ test_automated()
app=$(echo "$script" | cut -d'-' -f2-)
pushd "$script" > /dev/null || exit 1

echo -n "Running $app... "
if test "$(type -t "test_$app")" = "function"; then
( test_"$app" )
else
Expand Down