add test cases
This commit is contained in:
parent
c47c3e36c7
commit
0934bf917d
|
@ -32,5 +32,9 @@ aclocal.m4
|
||||||
u6ac
|
u6ac
|
||||||
u6a
|
u6a
|
||||||
|
|
||||||
|
# DejaGnu
|
||||||
|
*.sum
|
||||||
|
site.*
|
||||||
|
|
||||||
# others
|
# others
|
||||||
*.log
|
*.log
|
||||||
|
|
|
@ -10,6 +10,14 @@ compiler:
|
||||||
- gcc
|
- gcc
|
||||||
- clang
|
- clang
|
||||||
|
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- dejagnu
|
||||||
|
homebrew:
|
||||||
|
packages:
|
||||||
|
- dejagnu
|
||||||
|
|
||||||
branches:
|
branches:
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
|
|
|
@ -18,6 +18,8 @@ Building:
|
||||||
```bash
|
```bash
|
||||||
# (If not already) Install the required build tools.
|
# (If not already) Install the required build tools.
|
||||||
sudo apt install build-essential automake
|
sudo apt install build-essential automake
|
||||||
|
# (If you want to run tests) Install DejaGnu.
|
||||||
|
sudo apt install dejagnu
|
||||||
# Generate configuration script.
|
# Generate configuration script.
|
||||||
autoreconf --install
|
autoreconf --install
|
||||||
# Execute configuration script with desired options.
|
# Execute configuration script with desired options.
|
||||||
|
|
|
@ -1,4 +1,11 @@
|
||||||
|
AUTOMAKE_OPTIONS = dejagnu
|
||||||
|
|
||||||
bin_PROGRAMS = u6ac u6a
|
bin_PROGRAMS = u6ac u6a
|
||||||
|
|
||||||
u6ac_SOURCES = logging.c lexer.c parser.c codegen.c u6ac.c
|
u6ac_SOURCES = logging.c lexer.c parser.c codegen.c u6ac.c
|
||||||
u6a_SOURCES = logging.c vm_stack.c vm_pool.c runtime.c u6a.c
|
u6a_SOURCES = logging.c vm_stack.c vm_pool.c runtime.c u6a.c
|
||||||
|
|
||||||
|
TEST_DIR = ${srcdir}/../tests
|
||||||
|
DEJAGNU_GLOBALS = U6A_BIN=${srcdir}/u6a U6AC_BIN=${srcdir}/u6ac U6A_RUN=${TEST_DIR}/u6a_run
|
||||||
|
RUNTESTDEFAULTFLAGS = --srcdir=${TEST_DIR} --tool default ${DEJAGNU_GLOBALS}
|
||||||
|
EXTRA_DEJAGNU_SITE_CONFIG = ../tests/init.exp
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
##
|
||||||
|
## cat.exp - Test whether a "cat" program works on this u6a build
|
||||||
|
##
|
||||||
|
## Copyright (C) 2020 CismonX <admin@cismon.net>
|
||||||
|
##
|
||||||
|
## This program is free software: you can redistribute it and/or modify
|
||||||
|
## it under the terms of the GNU General Public License as published by
|
||||||
|
## the Free Software Foundation, either version 3 of the License, or
|
||||||
|
## (at your option) any later version.
|
||||||
|
##
|
||||||
|
## This program is distributed in the hope that it will be useful,
|
||||||
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
## GNU General Public License for more details.
|
||||||
|
##
|
||||||
|
## You should have received a copy of the GNU General Public License
|
||||||
|
## along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
##
|
||||||
|
|
||||||
|
set tool "default"
|
||||||
|
set timeout 1
|
||||||
|
|
||||||
|
set rand_str_list { }
|
||||||
|
for { set i 100 } { $i < 200 } { incr i } {
|
||||||
|
lappend rand_str_list [ exec head -c $i /dev/urandom | base64 -w 0 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
u6a_run "```s`d`@|i`ci" - - 1
|
||||||
|
for { set i 0 } { $i < [ llength $rand_str_list ] } { incr i } {
|
||||||
|
set rand_str [ lindex $rand_str_list $i ]
|
||||||
|
send -- "$rand_str\r"
|
||||||
|
expect {
|
||||||
|
$rand_str {
|
||||||
|
pass "case $i ok!"
|
||||||
|
}
|
||||||
|
default {
|
||||||
|
fail "case $i fails!"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
u6a_stop 1
|
|
@ -0,0 +1,43 @@
|
||||||
|
##
|
||||||
|
## square.exp - Test whether a "square" program works on this u6a build
|
||||||
|
##
|
||||||
|
## Copyright (C) 2020 CismonX <admin@cismon.net>
|
||||||
|
##
|
||||||
|
## This program is free software: you can redistribute it and/or modify
|
||||||
|
## it under the terms of the GNU General Public License as published by
|
||||||
|
## the Free Software Foundation, either version 3 of the License, or
|
||||||
|
## (at your option) any later version.
|
||||||
|
##
|
||||||
|
## This program is distributed in the hope that it will be useful,
|
||||||
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
## GNU General Public License for more details.
|
||||||
|
##
|
||||||
|
## You should have received a copy of the GNU General Public License
|
||||||
|
## along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
##
|
||||||
|
|
||||||
|
set tool "default"
|
||||||
|
set timeout 1
|
||||||
|
|
||||||
|
# The following code is a modified version of ftp://ftp.madore.org/pub/madore/unlambda/CUAN/Square.unl
|
||||||
|
# Written by Panu Kalliokoski <Panu.Kalliokoski@nokia.com>
|
||||||
|
set src_stub "`r```si`k``s``s`kk`si``s``si`k``s`k`s`k``sk``sr`k.oir``si%s`k`ki"
|
||||||
|
set src_segment ""
|
||||||
|
set expected "\n"
|
||||||
|
for { set i 0 } { $i < 20 } { incr i } {
|
||||||
|
set src_segment "$src_segment``si"
|
||||||
|
set line [ string repeat "o" [ expr $i + 1 ] ]
|
||||||
|
set square [ string repeat "$line\n" [ expr $i + 1 ] ]
|
||||||
|
set expected "$expected\n$square"
|
||||||
|
u6a_run [ format $src_stub $src_segment ] - - 0
|
||||||
|
expect {
|
||||||
|
$expected {
|
||||||
|
pass "case $i ok!"
|
||||||
|
}
|
||||||
|
default {
|
||||||
|
fail "case $i fails!"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
u6a_stop 0
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
##
|
||||||
|
## init.exp - u6a test init script
|
||||||
|
##
|
||||||
|
## Copyright (C) 2020 CismonX <admin@cismon.net>
|
||||||
|
##
|
||||||
|
## This program is free software: you can redistribute it and/or modify
|
||||||
|
## it under the terms of the GNU General Public License as published by
|
||||||
|
## the Free Software Foundation, either version 3 of the License, or
|
||||||
|
## (at your option) any later version.
|
||||||
|
##
|
||||||
|
## This program is distributed in the hope that it will be useful,
|
||||||
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
## GNU General Public License for more details.
|
||||||
|
##
|
||||||
|
## You should have received a copy of the GNU General Public License
|
||||||
|
## along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
##
|
||||||
|
|
||||||
|
proc u6a_run { src_code u6ac_opts u6a_opts has_input } {
|
||||||
|
global U6A_BIN U6AC_BIN U6A_RUN
|
||||||
|
set u6ac "$U6AC_BIN $u6ac_opts"
|
||||||
|
set u6a "$U6A_BIN $u6a_opts"
|
||||||
|
set run_cmd [ list $U6A_RUN $u6ac $u6a $src_code ]
|
||||||
|
if $has_input {
|
||||||
|
lappend run_cmd -
|
||||||
|
set stty_init -echo
|
||||||
|
} else {
|
||||||
|
set stty_init { raw -echo }
|
||||||
|
}
|
||||||
|
global spawn_id
|
||||||
|
spawn {*}$run_cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
proc u6a_stop { send_eof } {
|
||||||
|
global spawn_id
|
||||||
|
if $send_eof {
|
||||||
|
send \x04
|
||||||
|
expect eof
|
||||||
|
}
|
||||||
|
catch wait result
|
||||||
|
if [ set exit_code [ lindex $result 3 ] ] {
|
||||||
|
fail "program exited with code $exit_code"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
##
|
||||||
|
## u6a_run - helper script for running tests for u6a
|
||||||
|
##
|
||||||
|
## Copyright (C) 2020 CismonX <admin@cismon.net>
|
||||||
|
##
|
||||||
|
## This program is free software: you can redistribute it and/or modify
|
||||||
|
## it under the terms of the GNU General Public License as published by
|
||||||
|
## the Free Software Foundation, either version 3 of the License, or
|
||||||
|
## (at your option) any later version.
|
||||||
|
##
|
||||||
|
## This program is distributed in the hope that it will be useful,
|
||||||
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
## GNU General Public License for more details.
|
||||||
|
##
|
||||||
|
## You should have received a copy of the GNU General Public License
|
||||||
|
## along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
##
|
||||||
|
|
||||||
|
U6A_BYTECODE=`echo $3 | $1 - | base64 -w 0`
|
||||||
|
if [ -z $U6A_BYTECODE ]; then exit -1; fi
|
||||||
|
cat <(echo $U6A_BYTECODE | base64 -d) <(test $4 && cat $4) | $2 -
|
||||||
|
|
||||||
|
# Usage: ./u6a_run /path/to/u6ac/bin /path/to/u6a/bin source_code [input]
|
Loading…
Reference in New Issue