0
$\begingroup$

Suppose i want to trace an algorithm (think of it as a flowchart) to understand how it works, i need an input(s) for this algorithm, the question is: how can i determine the right input(s) that goes through all the cases ? Is there any "scientific" method to determine this input?

$\endgroup$
  • $\begingroup$ This seems way too broad to me. Community votes, please! $\endgroup$ – Raphael Jan 12 '17 at 18:38
  • 1
    $\begingroup$ That said, the exact problem is probably not solvable, or at least we don't know how. We don't even know how to solve it for finite automata! $\endgroup$ – Raphael Jan 12 '17 at 18:39
  • $\begingroup$ Also, remember that there may be many cases. A simple sequence of $n$ ifconditionals can have up to $2^n$ paths -- and that's a harmless case! See also here. $\endgroup$ – Raphael Jan 12 '17 at 18:41
1
$\begingroup$

If you want to automatically explore the state space of a program, you could try a fuzzer like AFL. But usually programmers do this by running the program under a debugger and thinking a bit about how the input needs to look to take a particular path through the code.

$\endgroup$
1
$\begingroup$

To achieve 100% coverage of all the cases, you'll probably need many test cases.

You might want to do some reading on "test case generation". Typically, software developers think through the possibilities and manually write test cases that they think will exercise each code path. However, another option is to use automated tools, like symbolic execution or concolic execution. You can do some searching on those terms and you'll find lots of material on how they work.

$\endgroup$
  • $\begingroup$ I said input (s) with 's', thank's anyway $\endgroup$ – Maykel Jakson Jan 12 '17 at 19:38
  • $\begingroup$ @MaykelJakson, OK. I read too fast and was misled by the other part of the question that mentioned "i need an input". Sorry about that. You can focus on the last paragraph of my answer. $\endgroup$ – D.W. Jan 12 '17 at 19:51
  • $\begingroup$ @MaykelJakson You may want to edit your question, in particular its title. $\endgroup$ – Raphael Jan 12 '17 at 20:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.