-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add document to p4c repo explaining to developers a little bit of what they need to know to add new tests #32
Comments
@jafingerhut I would like to work on this issue. Can you assign this to me. This is what i was thinking for the positive test part [Adding New Tests to the P4C Repository This document provides a guide for developers who want to add new tests to the P4C repository. It explains where to place test files, how to manage expected output files, and how to handle tests that are expected to fail (Xfail).
Positive tests are those where the P4 compiler should process the input without any errors. Steps for Adding Positive Tests Source File Location: Place the source file in the p4c/testdata/p4_16_samples directory. Ensure the file is named descriptively to reflect its purpose (e.g., example_positive_test.p4). Expected Output Files: Run the P4 compiler on the source file using the command: ./build/p4test path/to/source_file.p4 This generates expected output files. Place the generated expected output files in the p4c/testdata/p4_16_samples_outputs directory. Updating Expected Outputs: If a change to the P4 compiler modifies the expected outputs, you can regenerate them by rerunning the tests with: ./build/p4test path/to/source_file.p4 --update-outputs Replace the old expected output files with the newly generated ones. Verifying the Test Use the CI system or run the test locally to verify that it passes as expected.](url) |
That is a good start. There is no need to have all of the details before starting such a document, but here are some things that would be nice to add to that start:
|
Adding New Tests to the P4C RepositoryThis document provides a guide for developers who want to add new tests to the P4C repository. It explains where to place test files, how to manage expected output files, and how to handle tests that are expected to fail (Xfail). 1. Adding "Positive" TestsPositive tests are those where the P4 compiler should process the input without any errors. Steps for Adding Positive Tests
Verifying the Test
2. Adding "Negative" TestsNegative tests are those where the P4 compiler is expected to catch a syntax or semantic error in the input source file. Steps for Adding Negative Tests
3. Handling Different Backends and Tools
Refer to the repository documentation and existing test examples to understand these variations better. 4. Marking Tests as "Expected to Fail" (Xfail)An Xfail test is one that is expected to fail due to a known issue or limitation in the P4 compiler. The CI system handles these tests differently based on their type (positive or negative). Marking a Test as Xfail
5. Running TestsTests in the P4C repository can be executed in two main ways:
Differences Between Bash Scripts and CTest
ConclusionThis document serves as a starting point for adding new tests to the P4C repository. It is recommended to follow these guidelines to ensure consistency and reliability in the testing process. If you encounter issues or ambiguities, consult the repository maintainers or create a GitHub issue for clarification. |
Hey @jafingerhut have a look at this and if you need any further things to add i can add into it and then i will generate the pr |
I think it is a good start from which to create a PR in the https://github.com/p4lang/p4c repository, but please note that by saying that, I fully expect that others (or perhaps even I) will still have more suggestions for changes before we approve it. For example, if you want to write a test on which the BMv2 back end is run, with packets, I believe that the file name must match the pattern |
At the very least, it should explain:
for "positive" tests, i.e. ones where there is no error from the P4 compiler, what directory should you put the source file in, and what expected output files should be added (and in what directory for those)? Also how to update those if a change to p4c changes the expected outputs.
for "negative" tests, i.e. the ones where you expect the P4 compiler to catch a syntax or semantic error, what directory should you put the source file in, and what expected output files should be added?
How to mark a test as "expected to fail" (Xfail), and what does that mean? Note: At least for some existing CI tests, marking a positive test as Xfail means that it must fail, or else the overall CI run will fail. Marking a negative test as Xfail means that it must not give an error, or else the overall CI run will fail. However, because this is a confusing and subtle point, maybe not all p4c CI tests treat negative tests this way. It would be nice to make them all consistent, but at least we should document how they operate now, even if there is a TODO indicating the desire to change it in the future.
The text was updated successfully, but these errors were encountered: