regression/cbmc/array-constraint/test_json: un-KNOWNBUG, fix expectations#9018
Open
tautschnig wants to merge 1 commit into
Open
regression/cbmc/array-constraint/test_json: un-KNOWNBUG, fix expectations#9018tautschnig wants to merge 1 commit into
tautschnig wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR corrects the array-constraint JSON regression test so it matches CBMC’s actual behavior and can run as a normal CORE test (instead of an unmatchable KNOWNBUG), while being skipped under SMT-backend profiles where the output/exit code differs.
Changes:
- Remove
KNOWNBUGand add solver-profile skip tags (broken-cprover-smt-backend,broken-z3-smt-backend,no-new-smt). - Update expected exit code from
0to10(verification failure). - Fix the expected JSON shape to match scalar counts (e.g.,
"arrayWith": \d+) instead of list values.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #9018 +/- ##
========================================
Coverage 80.60% 80.61%
========================================
Files 1711 1711
Lines 189466 189466
Branches 73 73
========================================
+ Hits 152719 152735 +16
+ Misses 36747 36731 -16 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ions test_json.desc was added as KNOWNBUG in 2020 (commit ecb0a5d) asserting an aspirational JSON shape that cbmc never produced. Two flaws: 1. The exit code assertion '^EXIT=0$' did not match cbmc's actual exit. In main.c, 'size_t array_size' is non-deterministic, so the variable-length array 'a' may have size 0; the write 'a[index] = 1' then violates the 'array 'a' upper bound' check and verification fails, so cbmc exits with 10. (The 'assert(a[index] == 1)' is in turn reported as UNKNOWN.) The two sibling tests, test.desc and test_xml.desc, exercise '--show-array-constraints' without '--json-ui' / with '--xml-ui'; cbmc rejects those combinations and exits 1, which they correctly assert. 2. The regex asserted list-shaped JSON values, e.g. '"arrayWith": [.*]', but the implementation has always emitted scalar counts: '"arrayWith": 2'. The test was therefore unmatchable on day one. Fix both: assert '^EXIT=10$' and rewrite the regex to match the actual JSON, i.e. an 'arrayConstraints' object mapping each constraint kind to a scalar count, plus a 'numOfConstraints' total. The regex pins this shape without hard-coding which constraint kinds appear or the exact total, so it documents the '--show-array-constraints' JSON contract without being brittle to unrelated arrayst flattening changes. Drop the KNOWNBUG tag so the contract is now pinned by an actually-running test. The test only applies to the default SAT backend: under '--cprover-smt2', '--z3' or '--incremental-smt2-solver z3' cbmc bypasses the array theory entirely and emits no 'arrayConstraints' JSON block (and '--cprover-smt2' returns a different exit code). Tag the test 'broken-cprover-smt-backend broken-z3-smt-backend no-new-smt' so it is skipped under those profiles, matching the convention used by other arrayst-dependent tests such as Array_operations2 / Bitfields1 / Computed-Goto1. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
0402bc0 to
cb376ba
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
test_json.desc was added as KNOWNBUG in 2020 (commit ecb0a5d) asserting an aspirational JSON shape that cbmc never produced. Two flaws:
The exit code assertion '^EXIT=0$' did not match cbmc's actual exit. main.c contains 'assert(a[index] == 1)' with a non-deterministic 'index', which fails verification — cbmc exits with 10. (The two sibling tests, test.desc and test_xml.desc, exercise '--show-array- constraints' without '--json-ui' / with '--xml-ui'; cbmc rejects those combinations and exits 1, which they correctly assert.)
The regex asserted list-shaped JSON values, e.g. '"arrayWith": [.*]', but the implementation has always emitted scalar counts: '"arrayWith": 2'. The test was therefore unmatchable on day one.
Fix both: assert '^EXIT=10$' and rewrite the regex to match scalar counts ('\d+'). Drop the KNOWNBUG tag so the JSON contract for '--show-array-constraints' is now pinned by an actually-running test.
The test only applies to the default SAT backend: under '--cprover-smt2' or '--incremental-smt2-solver z3' cbmc bypasses the array theory entirely and emits no 'arrayConstraints' JSON block (and '--cprover-smt2' returns a different exit code). Tag the test 'broken-cprover-smt-backend no-new-smt' so it is skipped under those profiles, matching the convention used by other arrayst-dependent tests such as Array_operations2 / Bitfields1 / Computed-Goto1.