Commit d525bf36 authored by Sergio Costas's avatar Sergio Costas

Removed the __crust_disable__ statement in nearly all unitests

Better explanations in some unitests
parent 97c2a599
This diff is collapsed.
......@@ -10,5 +10,4 @@ void main(crust_t param1, crust_t param2) {
param1 = function();
param2 = function();
} // All fine
__crust_disable__
}
......@@ -10,5 +10,4 @@ void main(crust_t param1, crust_t param2) {
param1 = function();
param2 = function();
} // All fine
__crust_disable__
}
......@@ -7,5 +7,5 @@ void main(crust_t param) {
while(param == NULL) {
param = (crust_t) 1;
}
main(param);
main(param); // All fine: since param will be assigned only as long as it is NULL, there are no errors
}
......@@ -12,5 +12,5 @@ void main(int b) {
param = (crust_t) 1;
break;
}
function(param);
function(param); // ERROR: the while can be run zero times, so param can be uninitialized
}
......@@ -12,5 +12,5 @@ void main(int b) {
param = (crust_t) 1;
break;
}
function(param);
function(param); // All fine: thanks to __crust_no_0__, the while is executed at least once, so param is always assigned
}
......@@ -8,5 +8,4 @@ int function(int);
void main() {
prueba test1 = function; // this is legal for CRUST because there are no crust-type parameters involved
__crust_disable__
}
......@@ -8,5 +8,4 @@ crust_t function(int);
void main() {
prueba test1 = function; // ERROR: the number of parameters is different, and there are crust-type parameters involved (the return values)
__crust_disable__
}
......@@ -8,5 +8,4 @@ int function(crust_t, int);
void main() {
prueba test1 = function; // ERROR: the number of parameters is different, and there are crust-type parameters involved (the first parameter)
__crust_disable__
}
......@@ -8,5 +8,4 @@ int function(crust_t, int);
void main() {
prueba test1 = function; // ERROR: the first parameter doesn't match between both function definitions
__crust_disable__
}
......@@ -8,5 +8,4 @@ crust_t function(crust_t, int);
void main() {
prueba test1 = function; // ERROR: the first parameter doesn't match between both function definitions
__crust_disable__
}
......@@ -8,5 +8,4 @@ int function(crust_t, int);
void main() {
prueba test1 = function; // All fine, because both function signatures match
__crust_disable__
}
......@@ -9,6 +9,5 @@ void main() {
crust_t param;
int b;
param = (b=6, function());
__crust_disable__
param = (b=6, function()); // this is legal, because the return value of function is being assigned to "param"
}
......@@ -9,6 +9,5 @@ void main() {
crust_t param;
int b;
param = (function(), b=6);
__crust_disable__
param = (function(), b=6); // ERROR: function returns a crust-type value, but it is discarded
}
......@@ -9,6 +9,5 @@ void main() {
crust_t param;
int b;
param = function(), b=6;
__crust_disable__
param = function(), b=6; // this is legal
}
......@@ -11,5 +11,5 @@ void main() {
b |= 7;
b ^= 9;
b >>= 2;
b <<= 3;
b <<= 3; // all fine, just a check for these ops
}
......@@ -8,6 +8,5 @@ void main(crust_t param) {
function(param,1);
function(param,1,2);
function(NULL,1,param);
__crust_disable__
function(NULL,1,param); // ERROR: crust-type params can't be used in variable lengh parameters
}
......@@ -3,5 +3,5 @@ typedef __crust_t__ unsigned char *crust_t;
int function() {
crust_t retval = function(); // Error: assigning non-crust return value to a crust variable
__crust_disable__
return 5;
}
......@@ -3,5 +3,5 @@ typedef __crust_t__ unsigned char *crust_t;
crust_t function() {
int retval = function(); // Error: assigning crust return value to a non-crust variable
__crust_disable__
return NULL;
}
......@@ -7,10 +7,9 @@ void main(crust_t param) {
crust_t __crust_alias__ alias1;
crust_t __crust_alias__ alias2;
__crust_debug__
__crust_debug__ // here, 'param' must be NOT_NULL_OR_NULL, and 'alias1' and 'alias2' must be UNINITIALIZED
alias1 = param;
__crust_debug__
alias2 = alias1; // All this is legal
__crust_debug__
__crust_disable__
__crust_debug__ // here, 'param' and 'alias1' must be NOT_NULL_OR_NULL, and 'alias2' must be UNINITIALIZED
alias2 = alias1;
__crust_debug__ // here, 'param', 'alias1' and 'alias2' must be NOT_NULL_OR_NULL
}
......@@ -2,17 +2,21 @@ typedef __crust_t__ unsigned char *crust_t;
#define NULL ((void *)0)
void main(crust_t param1, crust_t param2) {
void function(crust_t);
void main(crust_t param1, crust_t __crust_not_null__ param2) {
crust_t __crust_alias__ alias1;
crust_t __crust_alias__ alias2;
__crust_debug__
__crust_debug__ // here, 'param1' must be NOT_NULL_OR_NULL, 'param2' must be NOT_NULL, 'alias1', 'alias2' must be UNINITIALIZED
alias1 = param1;
__crust_debug__
__crust_debug__ // here, 'param1', 'alias1' must be NOT_NULL_OR_NULL and share UID, 'param2' must be NOT_NULL, 'alias2' must be UNINITIALIZED
alias2 = alias1;
__crust_debug__
alias1 = param2; // All this is legal
__crust_debug__
__crust_disable__
__crust_debug__ // here, 'param1', 'alias1', 'alias2' must be NOT_NULL_OR_NULL and share UID, 'param2' must be NOT_NULL
alias1 = param2;
__crust_debug__ // here, 'param1', 'alias2' must be NOT_NULL_OR_NULL and share UID, 'param2', 'alias1' must be NOT_NULL and share UID
function(param1);
function(param2);
__crust_debug__ // here, 'param1', 'param2', 'alias1', 'alias2' must be FREED
}
......@@ -7,22 +7,23 @@ typedef struct t_crust_t *crust_t;
#define NULL ((void *)0)
void function(crust_t);
void main(crust_t param) {
crust_t __crust_alias__ alias1;
crust_t __crust_alias__ alias2;
__crust_debug__
__crust_debug__ // here, 'param' must be NOT_NULL_OR_NULL, 'alias1', 'alias2' must be UNINITIALIZED
alias1 = param;
__crust_debug__
__crust_debug__ // here, 'param', 'alias1' must be NOT_NULL_OR_NULL and share UID, 'alias2' must be UNINITIALIZED
alias2 = alias1;
__crust_debug__
__crust_debug__ // here, 'param', 'alias1', 'alias2' must be NOT_NULL_OR_NULL and share UID
alias1 = param->next;
__crust_debug__
__crust_debug__ // here, 'param', 'alias2' must be NOT_NULL_OR_NULL and share UID, 'alias1' must be NOT_NULL_OR_NULL
if (alias2 != NULL) {
alias2->next = alias1; // All this is legal
__crust_debug__
__crust_debug__ // here, 'param', 'alias2' must be NOT_NULL_OR_NULL and share UID, 'alias1' must be FREED
}
__crust_disable__
function(param);
}
......@@ -12,15 +12,13 @@ void main(crust_t param) {
crust_t __crust_alias__ alias1;
crust_t __crust_alias__ alias2;
__crust_debug__
__crust_debug__ // here, 'param' must be NOT_NULL_OR_NULL, 'alias1', 'alias2' must be UNINITIALIZED
alias1 = param;
__crust_debug__
__crust_debug__ // here, 'param', 'alias1' must be NOT_NULL_OR_NULL and share UID, 'alias2' must be UNINITIALIZED
alias2 = alias1;
__crust_debug__
__crust_debug__ // here, 'param', 'alias1', 'alias2' must be NOT_NULL_OR_NULL and share UID
if (alias2 != NULL) {
alias2->next = alias1; // All this is legal
__crust_debug__
alias2->next = alias1;
__crust_debug__ // here, 'param', 'alias1', 'alias2' must be FREED
}
__crust_disable__
}
......@@ -7,19 +7,21 @@ typedef struct t_crust_t *crust_t;
#define NULL ((void *)0)
void main(crust_t param1, crust_t param2) {
void function(crust_t);
void main(crust_t param1, crust_t __crust_not_null__ param2) {
crust_t __crust_alias__ alias1;
crust_t __crust_alias__ alias2;
__crust_debug__
__crust_debug__ // here, 'param1' must be NOT_NULL_OR_NULL, 'param2' must be NOT_NULL, 'alias1', 'alias2' must be UNINITIALIZED
alias1 = param1;
__crust_debug__
__crust_debug__ // here, 'param1', 'alias1' must be NOT_NULL_OR_NULL and share UID, 'param2' must be NOT_NULL, 'alias2' must be UNINITIALIZED
alias2 = param2;
__crust_debug__
if (alias2 != NULL) {
alias2->next = alias1; // All this is legal
__crust_debug__
}
__crust_disable__
__crust_debug__ // here, 'param1', 'alias1' must be NOT_NULL_OR_NULL and share UID, 'param2', 'alias2' must be NOT_NULL and share UID
alias2->next = alias1;
__crust_debug__ // here 'param1', 'alias1' must be FREED, 'param2', 'alias2' must be NOT_NULL and share UID
function(param2);
__crust_debug__ // here 'param1', 'alias1', 'param2', 'alias2' must be FREED
}
......@@ -11,12 +11,12 @@ void main(crust_t param1, crust_t param2, crust_t param3) {
for __crust_no_0__ (int c = 0; c < 4; b++) {
break;
for __crust_no_0__ (int d = 0; d < 4; d++) {
function(param1); // this never should be called
function(param1); // this never should be called due to the break at line 12
}
function(param2); // this also never should be called
function(param2); // this also should never be called
}
function(param3); // this must be called
function(param3); // this must be called always
break;
}
// here, param3 must be freed, but neither param1 or param2
// here, param3 must be freed, but not param1, neither param2
}
......@@ -23,5 +23,5 @@ void main(crust_t param1, crust_t param2, crust_t param3, int a) {
function(param2);
function(param3);
break;
}
} // ERROR: if 'a' is 0, only 'param1' is freed; if 'a' is 1 only 'param2' is freed; if 'a' is 3 only 'param3' is freed
}
......@@ -6,8 +6,6 @@ void function(crust_t param);
void main(crust_t param1, int a) {
switch (a) {
case 0:
function(param1);
......@@ -22,5 +20,5 @@ void main(crust_t param1, int a) {
function(param1);
break;
}
function(param1);
function(param1); // ERROR: 'param1' has been freed in all previous cases
}
......@@ -10,9 +10,9 @@ void main(crust_t param1, int a) {
case 0:
function(param1);
case 1:
function(param1);
function(param1); // ERROR: when 'a' is 0, 'param1' will be freed at line 11, so when the execution reachs line 13 (because there is no 'break') 'param1' will be freed
case 3:
function(param1);
function(param1); // ERROR: the same when 'a' is 0 or 1
break;
default:
function(param1);
......
......@@ -4,7 +4,7 @@ typedef __crust_t__ unsigned char *crust_t;
void main(crust_t);
void main(crust_t param1, int) { // ERROR: number of parameters differ from previous definition
void main(crust_t param1, int) { // ERROR: number of parameters differ from previous definition in line 5
int a = 5;
main(param1);
......
......@@ -4,7 +4,7 @@ typedef __crust_t__ unsigned char *crust_t;
void main(crust_t);
void main(int param1) { // ERROR: the type of the parameters differ from the previous definition
void main(int param1) { // ERROR: the type of the parameters differ from the previous definition in line 5
int a = 5;
}
......@@ -10,8 +10,10 @@ typedef __crust_t__ struct {
crust_t function();
void function2(crust_t);
void main(tmp param1) {
param1->function_p = function;
param1->function_p();
__crust_disable__
param1->function_p = function; // WARNING: using param1 when it is possible to it to be NULL
param1->function_p(); // WARNING: using param1 when it is possible to it to be NULL
function2(param1);
}
......@@ -13,5 +13,4 @@ crust_t function();
void main(crust2_t param1) {
main(param1);
param1->function_p = function; // ERROR: param1 has been freed
__crust_disable__
}
......@@ -13,5 +13,4 @@ crust_t function();
void main() {
crust2_t param1;
param1->function_p = function; // ERROR: param1 has not been initialized
__crust_disable__
}
......@@ -9,8 +9,8 @@ void main(crust_t param1, crust_t param2) {
crust_t __crust_alias__ an_alias = param1;
an_alias = param2;
function(param1); // this must work, and 'an_alias' must remain as NULL_OR_NOT_NULL
__crust_debug__ // deep 0
function(param2); // this must work, but now "an_alias" must be marked as "freed"
__crust_debug__ // deep 1
function(param1); // this must work
__crust_debug__ // deep 0; 'an_alias' must remain as NULL_OR_NOT_NULL
function(param2); // this must work
__crust_debug__ // deep 1; now 'an_alias' must be marked as "freed"
}
......@@ -4,8 +4,9 @@ typedef char* (*prueba)(crust_t);
#define NULL ((void *)0)
char* main(crust_t param1) {
prueba test1 = main;
char* function(crust_t);
void main() {
prueba test1 = function;
(*test1)(NULL,NULL); // ERROR: calling a function pointer with an incorrect number of parameters
__crust_disable__
}
......@@ -2,8 +2,9 @@ typedef __crust_t__ unsigned char *crust_t;
#define NULL ((void *)0)
char* main(crust_t param1) {
char* (*test1)(crust_t) = main;
char* function(crust_t);
void main() {
char* (*test1)(crust_t) = function;
(*test1)(NULL,NULL); // ERROR: calling a function pointer with incorrect number of parameters
__crust_disable__
}
......@@ -4,9 +4,10 @@ typedef char* (*prueba)(crust_t);
#define NULL ((void *)0)
char* main(crust_t param1) {
prueba test1 = main;
char* function(crust_t);
void main() {
prueba test1 = function;
int b = 1;
(*test1)(b); // ERROR: calling a function pointer with an incorrect type of parameters
__crust_disable__
}
......@@ -2,9 +2,10 @@ typedef __crust_t__ unsigned char *crust_t;
#define NULL ((void *)0)
char* main(crust_t param1) {
char* (*test1)(crust_t) = main;
char* function(crust_t);
void main() {
char* (*test1)(crust_t) = function;
int b = 1;
(*test1)(b); // ERROR: calling a function pointer with incorrect type of parameters
__crust_disable__
}
......@@ -9,5 +9,4 @@ void function(int);
void main(crust_t param1) {
prueba test1 = function;
(*test1)(param1); // ERROR: calling a function pointer with an incorrect type of parameters
__crust_disable__
}
......@@ -7,5 +7,4 @@ void function(int);
void main(crust_t param1) {
void (*test1)(int) = function;
(*test1)(param1); // ERROR: calling a function pointer with incorrect type of parameters
__crust_disable__
}
......@@ -8,7 +8,8 @@ void main() {
{
crust_t tmp1 = NULL;
__crust_debug__
__crust_debug__ // here tmp1 must be at state NULL
}
__crust_debug__
__crust_debug__ // but here it must be at state UNINITIALIZED, because it is outside the block
// And all fine
}
......@@ -9,5 +9,4 @@ void function();
void main() {
prueba test1 = function;
(*test1)(); // all fine
__crust_disable__
}
......@@ -7,5 +7,4 @@ void function();
void main() {
void (*test1)() = function;
(*test1)(); // all fine
__crust_disable__
}
......@@ -9,5 +9,4 @@ crust_t function();
void main() {
prueba test1 = function;
(*test1)(); // ERROR: doesn't store the return value
__crust_disable__
}
......@@ -7,5 +7,4 @@ crust_t function();
void main() {
crust_t (*test1)() = function;
(*test1)(); // ERROR: doesn't store the return value
__crust_disable__
}
void main() {
break;
}
} // all fine
......@@ -9,6 +9,5 @@ void main(crust_t param1, crust_t param2) {
if ((param1 == NULL) && (param2 == NULL)) {
param1 = function();
param2 = function();
} // All fine
__crust_disable__
} // ERROR: param1 and param2 aren't freed, nor when initialized at line 7, neither at lines 10 and 11
}
......@@ -10,5 +10,4 @@ void main(crust_t param1, crust_t param2) {
param1 = function();
param2 = function();
} // All fine
__crust_disable__
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment