Skip to content

Commit

Permalink
make driver test verbose for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
Han Wang committed Oct 20, 2024
1 parent b8f96b6 commit b0964e9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#!/bin/bash

set -x
### ensure that when _two_ non-existant input pathnames are given, each one results in an error output that mentions that pathname.



source $(dirname "`realpath "${BASH_SOURCE[0]}"`")/driver_inputs_test___shared_code.bash
source $(dirname "$(realpath "${BASH_SOURCE[0]}")")/driver_inputs_test___shared_code.bash

check_for_inadvisable_sourcing; returned=$?
if [ $returned -ne 0 ]; then return $returned; fi ### simulating exception handling for an exception that is not caught at this level



humanReadable_test_pathname="`resolve_symlink_only_of_basename "$0"`"
humanReadable_test_pathname="$(resolve_symlink_only_of_basename "$0")"



if ! P4C=`try_to_find_the_driver`; then
if ! P4C=$(try_to_find_the_driver); then
echo "Unable to find the driver of the P4 compiler. Aborting the test ''$humanReadable_test_pathname'' with a non-zero exit code. This test failed." >& 2
exit 255
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ function check_for_inadvisable_sourcing {
### If you call it withOUT a parameter, I don`t know exactly what will happen, but I don`t think it will be _good_. ;-)

function resolve_symlink_only_of_basename {
echo "`dirname "$1"`"/"$(basename `realpath "$1"`)"
echo "$(dirname "$1")/$(basename $(realpath "$1"))"
}



function check_for_pathname_error_in_P4_compiler_driver_output {
### required arg. #1: pathname _of_ the driver [can be relative]
### required arg. #2: pathname to give _to_ the driver [can be relative]
Expand All @@ -34,7 +33,7 @@ function check_for_pathname_error_in_P4_compiler_driver_output {
"$1" "$2" 2>& 1 | grep --ignore-case --quiet "error.*$2"
exit_status_from_grep=$?

echo -n "Subtest #$3 (out of $4) in the test script ''`resolve_symlink_only_of_basename "$0"`'' " ### DRY
echo -n "Subtest #$3 (out of $4) in the test script ''$(resolve_symlink_only_of_basename "$0")'' " ### DRY
if [ $exit_status_from_grep -eq 0 ]; then
echo 'succeeded.'
return 0
Expand Down Expand Up @@ -105,6 +104,7 @@ function check_if_this_seems_to_be_our_driver {
### than flooding the output with “INFO: searching for the P4 compiler driver”[...] lines.

fi ### Done checking for a symlink. At this point, "$1" is either (1) _not_ a symlink or (2) a symlink we couldn`t canonicalize.
printf "INFO: '$1' is a symlink to '%s'\n" "$(realpath "$1")" >& 2

if [ ! -e "$1" ]; then echo "INFO: not using ''$1'', because it is not found in the filesystem [starting at ''$PWD'', if that is a relative pathname]." >& 2; return 1; fi
if [ ! -x "$1" ]; then echo "INFO: not using ''$1'', because it is not executable." >& 2; return 2; fi
Expand Down

0 comments on commit b0964e9

Please sign in to comment.