Skip to content

Commit

Permalink
Added some extra information logging in the build and build_all scripts.
Browse files Browse the repository at this point in the history
Changed the format of a log message in the JPC codec.
Added -I and -X options to the run_codec_test script in order to allow
explicit inclusion and exclusion of tests.
Disabled the sgn_1 test in the run_test_3 script on Windows.
Added a new script called sysinfo for obtaining platform-specific
information.
  • Loading branch information
mdadams committed Jul 30, 2022
1 parent 5cc343f commit 8ff6459
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 4 deletions.
11 changes: 11 additions & 0 deletions build/build
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ usage()
program_dir=$(dirname "$0") || exit 1
jas_realpath="$program_dir/jas_realpath"
abs_program_dir=$("$jas_realpath" "$program_dir") || panic
sysinfo_program="$program_dir/sysinfo"

################################################################################
# Process command line.
Expand Down Expand Up @@ -395,6 +396,16 @@ if [ -z "$os" ]; then
fi
fi

sysinfo_data="$("$sysinfo_program" -a)" || \
panic "cannot get system information"
cat <<- EOF
================================================================================
System Information
$sysinfo_data
================================================================================
EOF
[ $? -eq 0 ] || panic "cat failed"

################################################################################
# Apply some platform-specific hacks.
################################################################################
Expand Down
10 changes: 10 additions & 0 deletions build/build_all
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ program_dir=$(dirname "$0") || exit 1
jas_realpath="$program_dir/jas_realpath"
abs_program_dir=$("$jas_realpath" "$program_dir") || panic
build_program="$program_dir/build"
sysinfo_program="$program_dir/sysinfo"

list_directory()
{
Expand Down Expand Up @@ -284,6 +285,15 @@ if [ -n "$command_file" ]; then
source "$command_file" || panic "source failed"
fi

sysinfo_data="$("$sysinfo_program" -a)" || \
panic "cannot get system information"
cat <<- EOF
================================================================================
System Information
$sysinfo_data
================================================================================
EOF

os=unknown
if [ -n "$RUNNER_OS" ]; then
case "$RUNNER_OS" in
Expand Down
79 changes: 79 additions & 0 deletions build/sysinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#! /usr/bin/env bash

panic()
{
echo "ERROR: $@" 1>&2
exit 1
}

eecho()
{
echo "$@" 1>&2
}

all_keys=(os kernel release)
verbose=0
keys=()

while getopts avork option; do
case "$option" in
a)
keys=("${all_keys[@]}");;
v)
verbose=$((verbose + 1));;
o)
keys+=(os);;
k)
keys+=(kernel);;
r)
keys+=(release);;
\?)
panic "invalid option $option"
break;;
esac
done
shift $((OPTIND - 1))

if [ "${#keys[@]}" -eq 0 ]; then
exit 0
fi

release="$(uname -r)" || panic
kernel="$(uname)" || panic

if [ "$verbose" -ge 1 ]; then
eecho "uname $name"
eecho "uname -r $release"
fi

os=

case "$release" in
*[Mm]icrosoft*)
os=windows;;
esac

if [ -z "$os" ]; then
case "$kernel" in
*[Ll]inux*)
os=linux;;
esac
fi

if [ -z "$os" ]; then
os=unknown
fi

for key in "${keys[@]}"; do
case "$key" in
os)
value="$os";;
kernel)
value="$kernel";;
release)
value="$release";;
*)
panic;;
esac
echo "$value" || panic
done
5 changes: 3 additions & 2 deletions src/libjasper/jpc/jpc_enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1271,10 +1271,11 @@ assert(jas_image_numcmpts(enc->image) == 3);
}

#if 0
jas_eprintf("mingbits %d\n", mingbits);
jas_eprintf("numgbits %d mingbits %d\n", cp->tccp.numgbits,
mingbits);
#endif
if (mingbits > cp->tccp.numgbits) {
jas_logerrorf("error: too few guard bits (%d not < %d)\n",
jas_logerrorf("error: too few guard bits (%d < %d)\n",
cp->tccp.numgbits, mingbits);
return -1;
}
Expand Down
32 changes: 30 additions & 2 deletions test/bin/run_codec_test
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ tests=()
enc=jasper
dec=jasper
skip_bugs=1
exclude_tests=()

while getopts d:e:i:vBE: opt; do
while getopts d:e:i:vBE:I:X: opt; do
case "$opt" in
d)
dec="$OPTARG";;
Expand Down Expand Up @@ -90,6 +91,10 @@ while getopts d:e:i:vBE: opt; do
;;
esac
;;
I)
tests+=("$OPTARG");;
X)
exclude_tests+=("$OPTARG");;
\?)
usage
break;;
Expand All @@ -98,7 +103,7 @@ done
shift $((OPTIND - 1))

if [ $# -ge 1 ]; then
tests=("$@")
tests+=("$@")
fi

################################################################################
Expand All @@ -110,6 +115,29 @@ if [ "${#tests[@]}" -eq 0 ]; then
tcf_gettestids "$test_file" tests || panic "cannot get tests"
fi

# Remove any excluded tests from the list of tests to be run.
tmp_tests=()
for test in "${tests[@]}"; do
exclude=0
for exclude_test in "${exclude_tests[@]}"; do
if [ "$exclude_test" = "$test" ]; then
exclude=1
break
fi
done
if [ "$exclude" -eq 0 ]; then
tmp_tests+=("$test")
fi
done
tests=("${tmp_tests[@]}")

if [ "$verbose" -ge 1 ]; then
echo "The following tests have been selected:"
for test in "${tests[@]}"; do
echo " $test"
done
fi

[ -d $TMPDIR ] || mkdir -p $TMPDIR
[ -d $DATADIR ] || mkdir -p $DATADIR

Expand Down
19 changes: 19 additions & 0 deletions test/bin/run_test_3
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ fi

cmd_dir=$(dirname "$0") || exit 1
source "$cmd_dir"/utilities || exit 1
top_dir="$cmd_dir/../.."
sysinfo_program="$top_dir/build/sysinfo"

debug_level="${JAS_DEBUG_LEVEL:-0}"
if [ "$debug_level" -ge 1 ]; then
Expand Down Expand Up @@ -51,6 +53,22 @@ fi
###codec_selectors+=(jasper_vm)
###codec_selectors+=(vm_jasper)

exclude_tests=()

os="$("$sysinfo_program" -o)" || \
panic "cannot get OS information"
echo "OS: $os"

if [ "$os" = windows ]; then
eecho "WARNING: some tests disabled"
exclude_tests+=(sgn_1)
fi

base_opts=()
for test in "${exclude_tests[@]}"; do
base_opts+=(-X "$test")
done

echo "STARTING AT `date`"

num_errors=0
Expand All @@ -67,6 +85,7 @@ for codec_selector in "${codec_selectors[@]}"; do
opts+=(-e "$enc")
opts+=(-d "$dec")
opts+=(-E ignore)
opts+=("${base_opts[@]}")
#opts+=(-B)
opts+=("$@")
"$run_test" "${opts[@]}"
Expand Down

0 comments on commit 8ff6459

Please sign in to comment.