Fix 11 of 12 test cases for x86 and FlexPRET backends#13
Merged
Conversation
Address multiple issues preventing tests from passing on Linux with the x86 backend: dependency compatibility, KLEE integration, code generation bugs, and test file issues. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
This PR fixes multiple issues that prevented tests from passing on Linux with the x86 backend. After these changes, 11 of 12 tests pass; the remaining test (
bitmask) is not a code bug but a computational scalability issue.Passing tests (11)
bsort, if_statements, deg2rad, bitcount, ext_func, loops, binarysearch, insertsort, modexp, countnegative, prime
Failing test (1)
bitmask — The test has 49 basis paths and 22,465 possible paths through the unrolled CFG. The vast majority of candidate paths are infeasible, requiring thousands of KLEE invocations (each taking several seconds). After 1,000+ KLEE attempts over ~1 hour, only 2 of 49 basis paths were found feasible. The test infrastructure works correctly (those 2 paths produced valid measurements), but completing the full analysis would take many hours. This is an inherent scalability limitation of the basis-path search for programs with highly constrained, deeply unrolled loops — not a code bug.
WCET Results (x86 backend)
testdeg2rad_mainbitcount_bitcounttesttestbinarysearch_binary_searchinsertsort_mainmodexpcountnegative_sumprime_primebubble_sortWCET Results (FlexPRET backend)
Changes
1. PuLP 3.3.0 compatibility (
src/pulp_helper.py)pulp.COINwas renamed topulp.COIN_CMDin PuLP 3.x.2. Safe
shutil.rmtreecalls (src/analyzer.py)Added
os.path.exists()checks beforeshutil.rmtree()to preventFileNotFoundErrorwhen the temp directory doesn't exist yet.3. KLEE timeout and
modify_bitcodepath fix (src/smt_solver/smt.py)--max-time=30flag and Python-leveltimeout=60to KLEE subprocess calls, with proper exception handling forTimeoutExpiredandCalledProcessError. Without this, KLEE could run indefinitely on complex paths.modify_bitcodecompilation output from the sharedsmt_solver/directory to per-test output directories, fixingOSError: [Errno 26] Text file busywhen multiple tests run concurrently.4. Dynamic KLEE include path + duplicate
main()removal (src/smt_solver/to_klee_format.py)/opt/homebrew/include/klee/klee.h) withKLEE_INCLUDE_PATHenvironment variable for cross-platform support.main()definitions and forward declarations before inserting the KLEE-generatedmain(), fixing duplicate symbol errors for test programs that already contain amain().5. Driver generation fixes (
src/backend/generate_executable.py)#include <stdio.h>and#include <stdint.h>for the x86 backend driver (needed forprintfanduint32_t).main()removal: Same brace-matching approach as the KLEE formatter.typedef int matrix[20][20]), and generates proper flat initializer lists (matrix Array = {0x00000000, 0xffffffff, ...}) instead of the invalidmatrix Array = 0x....6. KLEE stub header (
klee_stubs/klee/klee.h)Created a stub
klee.hwith no-op implementations ofklee_make_symbolic,klee_assert, andklee_rangefor compilation without the full KLEE installation.7. Test file fixes
test/countnegative/countnegative.c: Removed_Pragma()directives that pycparser cannot parse. Changed config to analyzecountnegative_sumdirectly instead ofmain.test/ext_func/ext_func.c: Created proper test file (config referenced a non-existent file).8. Fix array type check ordering (generate_executable.py)
Reordered the type checks in gen_arguments so that regular array parameters (e.g., int arr[SIZE]) are handled by generate_array_declaration before typedef-resolved arrays, preventing an AttributeError when running with the FlexPRET backend.
Prerequisites (not in this PR)
These changes assume the following environment setup:
kleeonPATHKLEE_INCLUDE_PATHenvironment variable pointing to KLEE's include directorypycparser-fake-libcPython package installed (pip install pycparser-fake-libc)gametimeenvironment with clang-16/llvm-16Test plan
gametime test/<name> --backend x86result.txtwith WCET analysis🤖 Generated with Claude Code