Commit e4f8214
committed
tests: introduce ffi_cdef_proto_test
LuaJIT has a FFI library which allows calling external C functions
and using C data structures from a pure Lua code, see [1].
According to a FFI API documentation [2] the Lua function
`ffi.cdef(def)` adds multiple C declarations for types or
external symbols (named variables or functions). `def` must be
a Lua string. The contents of the string `def` must be a sequence
of C declarations, separated by semicolons. The C parser complies
to the C99 language standard plus the extensions described in [3].
Note, LuaJIT C parser is not a validating C parser. It expects and
accepts correctly formed C declarations. Therefore without
grammar-aware fuzzing we will face with a false-positive crashes.
The patch adds a grammar-aware test, where C declarations
generated automatically using Protobuf grammar and
LibProtoBuf-mutator and then serialize Protobuf structure to
a string. Note, an implementation is not finished yet.
An example of bug in `src/lj_cparse.c` is LJ#1114.
1. https://luajit.org/ext_ffi.html
2. https://luajit.org/ext_ffi_api.html
3. https://luajit.org/ext_ffi_semantics.html#clang
4. https://luajit.org/ext_ffi_semantics.html#status1 parent 0e60f36 commit e4f8214
File tree
6 files changed
+1747
-0
lines changed- tests/capi
- ffi_cdef_proto
6 files changed
+1747
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
0 commit comments