From 236cdc7cf3318fa46251e7a9271c2960d6713801 Mon Sep 17 00:00:00 2001 From: CismonX Date: Sun, 15 Mar 2020 05:08:01 +0800 Subject: [PATCH] compatible with macos base64 impl in tests --- configure.ac | 2 ++ src/Makefile.am | 6 +++--- tests/default/cat.exp | 3 ++- tests/init.exp | 5 +++-- tests/u6a_run | 8 ++++---- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index 067021e..1997587 100644 --- a/configure.ac +++ b/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}"]) diff --git a/src/Makefile.am b/src/Makefile.am index ab278fd..5496339 100644 --- a/src/Makefile.am +++ b/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 diff --git a/tests/default/cat.exp b/tests/default/cat.exp index 841208c..6e7bb05 100644 --- a/tests/default/cat.exp +++ b/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 diff --git a/tests/init.exp b/tests/init.exp index fba5f2e..d934d2c 100644 --- a/tests/init.exp +++ b/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 diff --git a/tests/u6a_run b/tests/u6a_run index de3d7b9..d85f7fe 100755 --- a/tests/u6a_run +++ b/tests/u6a_run @@ -18,8 +18,8 @@ ## along with this program. If not, see . ## -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]