You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
20
-
exit 255
21
-
fi
22
-
echo"In ''$humanReadable_test_pathname'', using ''$P4C'' as the path to the driver of the P4 compiler.">& 2
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
20
-
exit 255
21
-
fi
22
-
echo"In ''$humanReadable_test_pathname'', using ''$P4C'' as the path to the driver of the P4 compiler.">& 2
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
20
-
exit 255
21
-
fi
22
-
echo"In ''$humanReadable_test_pathname'', using ''$P4C'' as the path to the driver of the P4 compiler.">& 2
Copy file name to clipboardExpand all lines: tools/driver/test_scripts/driver_inputs_test_4___two_good_pathnames___check_for_no_misleading_error_messages.bash
+15-9Lines changed: 15 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -12,13 +12,26 @@
12
12
###
13
13
### ... or if “p4include/core.p4” and/or “p4include/pna.p4” will ever _not_ be present at the top level of a valid build directory [of a built build].
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
51
-
exit 255
52
-
fi
53
-
echo"In ''$humanReadable_test_pathname'', using ''$P4C'' as the path to the driver of the P4 compiler.">& 2
54
-
55
-
56
62
57
-
if [ !-x"$P4C" ] ;then
63
+
if [ !-x"$driver_path" ] ;then
58
64
echo"Test ''$humanReadable_test_pathname'' failed due to not being able to execute ''$P4C''.">& 2
Copy file name to clipboardExpand all lines: tools/driver/test_scripts/driver_inputs_test___shared_code.bash
+23-89Lines changed: 23 additions & 89 deletions
Original file line number
Diff line number
Diff line change
@@ -62,99 +62,33 @@ function report___num_failures___and_clamp_it_to_an_inclusive_maximum_of_255 {
62
62
if [ $num_failures-gt 255 ];then num_failures=255;fi
63
63
}
64
64
65
-
66
-
67
-
### requires a single arg./param., which had better be a pathname [doesn`t need to be absolute]
68
-
functioncheck_if_this_seems_to_be_our_driver {
69
-
echo"INFO: searching for the P4 compiler driver at ''$1''...">& 2 ### reminder: “>& 2” is equivalent to “> /dev/stderr”
70
-
71
-
if [ -L"$1" ];then
72
-
### NOTE: is “-L” a GNUism? “-h” might be the POSIX “spelling”.
73
-
### Either way, it should work OK in {Bash on non-GNU OS} as long as I use Bash`s built-in ‘[’/“test”,
74
-
### not e.g. “/bin/[” or “/bin/test” or “/usr/bin/[” or “/usr/bin/test”.
75
-
76
-
echo"INFO: detected a symlink at ''$1'' [starting at ''$PWD'', if that is a relative pathname], so checking the target of the symlink.">& 2
77
-
if realpath --version | grep --quiet GNU;then### happy-happy-joy-joy: GNU realpath is available and is the default “realpath”
78
-
### try the “logical” interpretation first, i.e. give “../” components priority over symlink components
79
-
if next_turtle=`realpath --canonicalize-existing --logical "$1"`;then check_if_this_seems_to_be_our_driver "$next_turtle";return;fi### please see Knuth`s definition of recursion ;-)
80
-
if next_turtle=`realpath --canonicalize-existing --physical "$1"`;then check_if_this_seems_to_be_our_driver "$next_turtle";return;fi
81
-
### If we are “still here”, then canonicalization failed. :-(
82
-
echo"ERROR: failed to canonicalize the symlink ''$1'' while using GNU ''realpath''.">& 2
83
-
return 1
84
-
fi
85
-
86
-
if readlink --version | grep --quiet GNU;then### second-best: GNU readlink is available and is the default “readlink”
87
-
if next_turtle=`readlink --canonicalize-existing "$1"`;then check_if_this_seems_to_be_our_driver "$next_turtle";return;fi
88
-
### If we are “still here”, then canonicalization failed. :-(
89
-
echo"ERROR: failed to canonicalize the symlink ''$1'' while using GNU ''readlink''.">& 2
90
-
return 2
65
+
# Function: Check if the driver binary exists
66
+
# Arguments: $1 - path to the file
67
+
check_driver_binary_exists() {
68
+
local file_path="$1"
69
+
if [ !-e"$file_path" ];then
70
+
echo"Error: The driver binary '$file_path' does not exist."
71
+
show_usage
72
+
exit 1
91
73
fi
74
+
}
92
75
93
-
if realpath / > /dev/null;then### I hope that the “realpath” implementations in e.g. BSD all do symlink-cycle detection, as GNU realpath does (at least as of GNU coreutils version 8.30)
94
-
if next_turtle=`realpath "$1"`;then check_if_this_seems_to_be_our_driver "$next_turtle";return;fi
95
-
### If we are “still here”, then canonicalization failed. :-(
96
-
echo"ERROR: failed to canonicalize the symlink ''$1'' while using [presumed non-GNU] ''realpath''.">& 2
97
-
return 3
76
+
# Function: Check if the driver binary is executable
77
+
# Arguments: $1 - path to the file
78
+
check_driver_is_executable() {
79
+
local file_path="$1"
80
+
if [ !-x"$file_path" ];then
81
+
echo"Error: The driver binary '$file_path' is not executable."
82
+
exit 1
98
83
fi
84
+
}
99
85
100
-
### The “readlink” in BSD [well, at least the one I _know_ of ;-)] is _extremely_ minimal, and AFAIK can`t do cycle detection,
101
-
### so I`m not even going to _try_ non-GNU readlink... mainly because I don`t want to get
102
-
### “INFO: searching for the P4 compiler driver”[...] until Bash runs out of function-call stack and crashes,
103
-
### in the case of a symlink cycle. At this point, I will just pretend I never detected a symlink and let it go forward.
104
-
### This way, if the symlink _is_ part of a cycle, this whole process should crash in a way that is “nicer”
105
-
### than flooding the output with “INFO: searching for the P4 compiler driver”[...] lines.
106
-
107
-
fi### Done checking for a symlink. At this point, "$1" is either (1) _not_ a symlink or (2) a symlink we couldn`t canonicalize.
108
-
109
-
if [ !-e"$1" ];thenecho"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
110
-
if [ !-x"$1" ];thenecho"INFO: not using ''$1'', because it is not executable.">& 2;return 2;fi
111
-
if [ -d"$1" ];thenecho"INFO: not using ''$1'', because it is a directory.">& 2;return 3;fi
112
-
if [ !-s"$1" ];thenecho"INFO: not using ''$1'', because either it does not exist [starting at ''$PWD'', if that is a relative pathname] or it exists but is empty.">& 2;return 4;fi
113
-
114
-
### NOTE on the following: I _could_ be more strict, e.g. requiring that the output of “$foo --version” start with “p4c” or “p4c ”,
115
-
### but that might be a bad idea in the long run, e.g. if the output of the driver`s version report will be changed,
116
-
### e.g. to start with “P4C ” or “Version of P4C: ” instead of with “p4c ” as it is as of this writing
117
-
### [and has been for some time, TTBOMK].
118
-
if!"$1" --version > /dev/null;thenecho"INFO: not using ''$1'', because it did not accept the arg./flag/param. ''--version''">& 2;return 5;fi
119
-
120
-
### OK; at this point, we have given up on finding “reasons” to reject "$1" as a supposedly-good P4 compiler driver. ;-)
121
-
echo"INFO: accepting ''$1'' as a presumed P4 compiler driver.">& 2
122
-
return 0
123
-
} ### end of function “check_if_this_seems_to_be_our_driver”
124
-
125
-
126
-
127
-
### IMPORTANT: do _not_ include any human-oriented “fluff” in this function`s standard-out output
128
-
functiontry_to_find_the_driver {
129
-
### NOTES re "$GITHUB_WORKSPACE", "$RUNNER_TEMP", and "$RUNNER_WORKSPACE":
130
-
### these were all found by Abe in the GitHub CI/CD environment on April 14 2022
131
-
###
132
-
### here are the values they had at that time [which explains why I am not checking "$RUNNER_TEMP" by itself]:
133
-
###
134
-
### GITHUB_WORKSPACE=/__w/p4c/p4c
135
-
### RUNNER_TEMP=/__w/_temp
136
-
### RUNNER_WORKSPACE=/__w/p4c
137
-
138
-
### IMPORTANT: the ordering in the following *_IS_* important, and may need to be changed at a later time due to e.g. changes in the GitHub CI/CD
0 commit comments