Skip to content

Commit

Permalink
Merge pull request #1 from ChrisDodd/option-ignore-stderr
Browse files Browse the repository at this point in the history
optionally ignore stderr in p4test
  • Loading branch information
Mihai Budiu authored Mar 8, 2017
2 parents f22aead + 868213e commit 0858f39
Show file tree
Hide file tree
Showing 2 changed files with 10 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
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 0858f39

Please sign in to comment.