Browse Source

compatible with macos base64 impl in tests

master
CismonX 2 years ago
parent
commit
236cdc7cf3
No known key found for this signature in database GPG Key ID: 315D6652268C5007
  1. 2
      configure.ac
  2. 6
      src/Makefile.am
  3. 3
      tests/default/cat.exp
  4. 5
      tests/init.exp
  5. 8
      tests/u6a_run

2
configure.ac

@ -11,10 +11,12 @@ case "${host_os}" in
linux*)
AC_SUBST([MANPATH_CONF], [/etc/manpath.config])
AC_SUBST([REBUILD_MANDB], [mandb])
AC_SUBST([BASE64_FLAGS], [-w0])
;;
darwin*)
AC_SUBST([MANPATH_CONF], [/private/etc/man.conf])
AC_SUBST([REBUILD_MANDB], [/usr/libexec/makewhatis])
AC_SUBST([BASE64_FLAGS], [-b0])
;;
*)
AC_MSG_ERROR(["Unsupported OS: ${host_os}"])

6
src/Makefile.am

@ -5,7 +5,7 @@ bin_PROGRAMS = u6ac u6a
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
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}
TEST_DIR = ${srcdir}/../tests
DEJAGNU_GLOBALS = U6A_BIN=${srcdir}/u6a U6AC_BIN=${srcdir}/u6ac U6A_RUN=${TEST_DIR}/u6a_run B64_FLAGS=${BASE64_FLAGS}
RUNTESTDEFAULTFLAGS = --srcdir=${TEST_DIR} --tool default ${DEJAGNU_GLOBALS}
EXTRA_DEJAGNU_SITE_CONFIG = ../tests/init.exp

3
tests/default/cat.exp

@ -19,10 +19,11 @@
set tool "default"
set timeout 1
global B64_FLAGS
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 ]
lappend rand_str_list [ exec head -c $i /dev/urandom | base64 $B64_FLAGS ]
}
u6a_run "```s`d`@|i`ci" - - 1

5
tests/init.exp

@ -18,10 +18,11 @@
##
proc u6a_run { src_code u6ac_opts u6a_opts has_input } {
global U6A_BIN U6AC_BIN U6A_RUN
global U6A_BIN U6AC_BIN U6A_RUN B64_FLAGS
set u6ac "$U6AC_BIN $u6ac_opts"
set u6a "$U6A_BIN $u6a_opts"
set run_cmd [ list $U6A_RUN $u6ac $u6a $src_code ]
set base64 "base64 $B64_FLAGS"
set run_cmd [ list $U6A_RUN $u6ac $u6a $base64 $src_code ]
if $has_input {
lappend run_cmd -
set stty_init -echo

8
tests/u6a_run

@ -18,8 +18,8 @@
## 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 -
U6A_BYTECODE=`echo $4 | $1 - | $3`
test -z $U6A_BYTECODE && exit -1
cat <(echo $U6A_BYTECODE | base64 -d) <(test $5 && cat $5) | $2 -
# Usage: ./u6a_run /path/to/u6ac/bin /path/to/u6a/bin source_code [input]
# Usage: ./u6a_run /path/to/u6ac/bin /path/to/u6a/bin /path/to/base64/bin source_code [input]

Loading…
Cancel
Save