Cross Translation Unit Test Case Reduction Rka Kovcs / - - PowerPoint PPT Presentation

cross translation unit test case reduction
SMART_READER_LITE
LIVE PREVIEW

Cross Translation Unit Test Case Reduction Rka Kovcs / - - PowerPoint PPT Presentation

Cross Translation Unit Test Case Reduction Rka Kovcs / rekanikolett@gmail.com Etvs Lornd University / Ericsson Hungary Test Case Reduction magic big file with property of interest small file with the same (e.g. triggers crash)


slide-1
SLIDE 1

Cross Translation Unit Test Case Reduction

Réka Kovács / rekanikolett@gmail.com Eötvös Loránd University / Ericsson Hungary

slide-2
SLIDE 2

Test Case Reduction

big file with property of interest (e.g. triggers crash) small file with the same property of interest magic

Delta Debugging: remove contiguous regions from the file, test & repeat

slide-3
SLIDE 3

Generalized Delta Debugging: C-Reduce

“Compiler-like” transformations (~74 of them): Clang-Delta e.g. remove a parameter from a function, move a parameter to a global variable, scalar replacement of aggregates, etc. https://embed.cs.utah.edu/creduce/ Works on one translation unit at a time

slide-4
SLIDE 4

Cross Translation Unit Analysis in the Clang Static Analyzer

Developers need minimal tests for crashes and bugs that range across TU boundaries llvm.org/devmtg/2017-03/

slide-5
SLIDE 5

Cross TU Analysis: Importing ASTs

analyzed file dependent files You have 72 preprocessed files with ~100 000 average LOC ASTs

slide-6
SLIDE 6

Cross TU Analysis: Importing ASTs

analyzed file dependent files You have 72 preprocessed files with ~100 000 average LOC Cross TU analysis crashes ASTs

slide-7
SLIDE 7

Cross TU Analysis: Importing ASTs

analyzed file dependent files You have 72 preprocessed files with ~100 000 average LOC Cross TU analysis crashes Find the bug! ASTs

slide-8
SLIDE 8

Reduction Across Translation Units

void f(int) { __builtin_trap(); } void f(int); int main() { f(5); } b.cpp a.cpp

$ clang++ a.cpp b.cpp $ ./a.out Illegal instruction (core dumped)

slide-9
SLIDE 9

Reduction Across Translation Units

void f(int) { __builtin_trap(); }

void f(int); int main() { f(5); } b.cpp a.cpp

void f(void) { __builtin_trap(); }

a.cpp

$ clang_delta --transformation=param-to-global a.cpp

slide-10
SLIDE 10

Reduction Across Translation Units

b.cpp a.cpp

$ clang++ a.cpp b.cpp /tmp/b-ef5998.o: In function `main': b.cpp:(.text+0xa): undefined reference to `f(int)' clang-8: error: linker command failed with exit code 1 (use -v to see invocation)

void f(int); int main() { f(5); } void f(void) { __builtin_trap(); }

slide-11
SLIDE 11

Reduction Across Translation Units

void f(void) { __builtin_trap(); } b.cpp a.cpp

We need to do the same transformation

  • n the other file

What is the same transformation?

void f(int); int main() { f(5); }

slide-12
SLIDE 12

Reduction Across Translation Units

void f(int) { __builtin_trap(); } void f(int); int main() { f(5); } b.cpp a.cpp

Clang-Delta has no notion of the same transformation across files It works with a counter of available transformation instances

Transformation: param-to-global Available instances: 0 Transformation: param-to-global Available instances: 1 1

slide-13
SLIDE 13

Reduction Across Translation Units

void f(int) { __builtin_trap(); } void f(int); int main() { f(5); } b.cpp a.cpp

param-to-global would handle all uses of f() if they were in one TU Unified Symbol Resolution (USR) ?

Transformation: param-to-global Available instances: 0 Transformation: param-to-global Available instances: 1 1

slide-14
SLIDE 14

Thanks!

Réka Kovács / rekanikolett@gmail.com

Would this be useful to you? Get in touch!