compatible with macos base64 impl in tests

This commit is contained in:
CismonX 2020-03-15 05:08:01 +08:00
parent 3a02883fbe
commit 236cdc7cf3
No known key found for this signature in database
GPG Key ID: 315D6652268C5007
5 changed files with 14 additions and 10 deletions

View File

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

View File

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

View File

@ -19,10 +19,11 @@
set tool "default" set tool "default"
set timeout 1 set timeout 1
global B64_FLAGS
set rand_str_list { } set rand_str_list { }
for { set i 100 } { $i < 200 } { incr i } { 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 u6a_run "```s`d`@|i`ci" - - 1

View File

@ -18,10 +18,11 @@
## ##
proc u6a_run { src_code u6ac_opts u6a_opts has_input } { 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 u6ac "$U6AC_BIN $u6ac_opts"
set u6a "$U6A_BIN $u6a_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 { if $has_input {
lappend run_cmd - lappend run_cmd -
set stty_init -echo set stty_init -echo

View File

@ -18,8 +18,8 @@
## along with this program. If not, see <https://www.gnu.org/licenses/>. ## along with this program. If not, see <https://www.gnu.org/licenses/>.
## ##
U6A_BYTECODE=`echo $3 | $1 - | base64 -w 0` U6A_BYTECODE=`echo $4 | $1 - | $3`
if [ -z $U6A_BYTECODE ]; then exit -1; fi test -z $U6A_BYTECODE && exit -1
cat <(echo $U6A_BYTECODE | base64 -d) <(test $4 && cat $4) | $2 - 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]