-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugs: test functions have no arguments
This test was created for/with input from issue avast/retdec#155
- Loading branch information
Peter Kubov
committed
Aug 1, 2020
1 parent
0bd6623
commit 1082936
Showing
7 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
int g = 100; | ||
|
||
int f1(); | ||
int f2(); | ||
int f3(); | ||
|
||
int main() { | ||
g = 100; | ||
f1(); | ||
f2(); | ||
f3(); | ||
return 0; | ||
} | ||
|
||
int f1() { | ||
int i; | ||
for (i = 0; i < g; ++i) { | ||
printf("looping"); | ||
} | ||
return 0; | ||
} | ||
|
||
int f2() { | ||
int i; | ||
for (i = 0; i < rand(); ++i) { | ||
printf("looping %d", i); | ||
} | ||
return 0; | ||
} | ||
|
||
int f3() { | ||
int i; | ||
for (i = 0; i < rand(); ++i) { | ||
printf("looping"); | ||
} | ||
return 0; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from regression_tests import * | ||
|
||
class Test(Test): | ||
settings = TestSettings( | ||
input=files_in_dir('2020-07-31') | ||
) | ||
|
||
def test_check_function_have_no_args(self): | ||
f1 = 'f1' if self.out_c.has_func('f1') else '_f1' | ||
assert self.out_c.has_func(f1) | ||
assert self.out_c.funcs[f1].param_count == 0 | ||
assert self.out_c.funcs[f1].return_type.is_int(32) | ||
|
||
f2 = 'f2' if self.out_c.has_func('f2') else '_f2' | ||
assert self.out_c.has_func(f2) | ||
assert self.out_c.funcs[f2].param_count == 0 | ||
assert self.out_c.funcs[f2].return_type.is_int(32) | ||
|
||
f3 = 'f3' if self.out_c.has_func('f3') else '_f3' | ||
assert self.out_c.has_func(f3) | ||
assert self.out_c.funcs[f3].param_count == 0 | ||
assert self.out_c.funcs[f3].return_type.is_int(32) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
char bar(void) { | ||
return 'a'; | ||
} | ||
|
||
int foo(void) { | ||
int x = 5; | ||
return x; | ||
} | ||
|
||
int main(int argc, char **argv) { | ||
if(argc < 4) { | ||
int i = foo(); | ||
while(i > 0) { | ||
; | ||
i--; | ||
} | ||
} else { | ||
do { | ||
continue; | ||
} while(0); | ||
} | ||
|
||
while(1) { | ||
bar(); | ||
break; | ||
} | ||
|
||
return 0; | ||
} |
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from regression_tests import * | ||
|
||
class Test(Test): | ||
settings = TestSettings( | ||
input='test.elf' | ||
) | ||
|
||
def test_check_function_have_no_args(self): | ||
assert self.out_c.has_func('foo') | ||
assert self.out_c.funcs['foo'].param_count == 0 | ||
# TODO: currently RetDec returns int32_t for every | ||
# unkown type. | ||
# assert self.out_c.funcs['foo'].return_type.is_int(8) | ||
|
||
assert self.out_c.has_func('bar') | ||
assert self.out_c.funcs['bar'].param_count == 0 | ||
# test.elf binary is 32 bit -> int is 32 bit. | ||
assert self.out_c.funcs['foo'].return_type.is_int(32) |