Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@KunJeong
Copy link
Contributor

This PR adds 248 negative tests and their respective output files to p4_16_errors. These have been generated by fuzzing against a mechanized version of the spec, the details of which @jaehyun1ee shared at the recent August LDWG meeting. The new error programs test violating conditions that are not covered by existing tests.

For example, expr-binary-shift-by-negative.p4 tests the below condition in the spec.

" the right operand of shifts must be either an expression of type bit<S> or a compile-time known value that is a non-negative integer"

// generated from strength5.p4
action a(inout bit<32> x) {
	x = (x >> 3) >> (-2);
}

The program tests when the right operand of a shift is a negative integer, which was not previously covered by any of the existing tests. All 248 added tests cover such conditions.

  • Process: To generate them, promising candidates from p4_16_samples are reduced then mutated, until we find a program that hits a "new violating condition". The source program is specified as a comment at the top of each file. From 1409 generated programs, we manually filtered out conditions covered by other tests under p4_16_errors and purged duplicates. We also only add programs that p4c successfully rejects, as the rest have been reported as separate issues. The remaining 248 programs have been given descriptive names of their root cause. All tests are target-independent.
  • Note: There may be multiple files with the same root cause name. These test slightly different sub-conditions. For instance, expr-last-access-on-non-stack has two versions, one that tries to access last on a tuple expression and the other on a boolean.

@fruffy fruffy added the infrastructure Topics related to code style and build and test infrastructure. label Aug 26, 2025
@fruffy fruffy requested review from ChrisDodd and kfcripps September 1, 2025 21:42
@fruffy fruffy added this pull request to the merge queue Sep 12, 2025
Merged via the queue into p4lang:main with commit b92d75d Sep 12, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

infrastructure Topics related to code style and build and test infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants