Skip to content

Commit

Permalink
optionally ignore stderr in p4test
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Dodd committed Mar 8, 2017
1 parent 24280ae commit 28beeac
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
10 changes: 8 additions & 2 deletions backends/p4test/run-p4-sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Options(object):
def __init__(self):
self.binary = "" # this program's name
self.cleanupTmp = True # if false do not remote tmp folder created
self.p4Filename = "" # file that is being compiled
self.p4filename = "" # file that is being compiled
self.compilerSrcDir = "" # path to compiler source tree
self.verbose = False
self.replace = False # replace previous outputs
Expand All @@ -58,6 +58,12 @@ def isError(p4filename):
# True if the filename represents a p4 program that should fail
return "_errors" in p4filename

def ignoreStderr(options):
for line in open(self.p4filename):
if "P4TEST_IGNORE_STDERR" in line:
return True
return False

class Local(object):
# object to hold local vars accessable to nested functions
pass
Expand Down Expand Up @@ -134,7 +140,7 @@ def check_generated_files(options, tmpdir, expecteddir):
shutil.copy2(produced, expected)
else:
result = compare_files(options, produced, expected)
if result != SUCCESS: # and file[-7:] != "-stderr":
if result != SUCCESS and (file[-7:] != "-stderr" or not ignoreStderr(options)):
return result
return SUCCESS

Expand Down
1 change: 1 addition & 0 deletions testdata/p4_16_errors/key-name.p4
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ control compute(inout hdr h) {
}
}

/* P4TEST_IGNORE_STDERR */
#include "arith-inline-skeleton.p4"
2 changes: 2 additions & 0 deletions testdata/p4_16_samples/string_anno.p4
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

/* P4TEST_IGNORE_STDERR */

@name("original") const bit b = 1;
@name("string \" with \" quotes") const bit c = 1;
@name("string with
Expand Down

0 comments on commit 28beeac

Please sign in to comment.