Skip to content

Commit 749d92a

Browse files
authored
Merge pull request #795 from goblint/issue-792
Fix ARINC testing
2 parents cfab02b + 3bbaece commit 749d92a

File tree

6 files changed

+17
-7
lines changed

6 files changed

+17
-7
lines changed

src/analyses/arinc.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module Functions = struct
2626
let ret_no_timeout = List.remove ret_any TIMED_OUT
2727
(* abstract value for return codes *)
2828
(* TODO: Check whether Cil.IInt is correct here *)
29-
let vd ret = `Int (ValueDomain.ID.(List.map (of_int Cil.IInt % BI.of_int % return_code_to_enum) ret |> List.fold_left join (bot ()))) (* ana.int.enums should be enabled *)
29+
let vd ret = `Int (ValueDomain.ID.(List.map (of_int Cil.IInt % BI.of_int % return_code_to_enum) ret |> List.fold_left join (bot_of IInt))) (* ana.int.enums should be enabled *)
3030
let effects fname args =
3131
if not (List.mem fname arinc_special) || List.is_empty args then None
3232
else

src/analyses/mutexEventsAnalysis.ml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ struct
7373
ctx.emit (Events.Lock (verifier_atomic, true))
7474

7575
let special (ctx: (unit, _, _, _) ctx) lv f arglist : D.t =
76+
let is_activated a = List.mem a (GobConfig.get_string_list "ana.activated") in (* TODO: proper LibraryFunctions group selection *)
7677
let remove_rw x = x in
7778
let unlock remove_fn =
7879
match f.vname, arglist with
@@ -82,6 +83,11 @@ struct
8283
ctx.split () [Events.Unlock (remove_fn e)]
8384
) (eval_exp_addr (Analyses.ask_of_ctx ctx) arg);
8485
raise Analyses.Deadcode
86+
| "LAP_Se_SignalSemaphore", [Lval arg; _] when is_activated "arinc" || is_activated "extract_arinc" ->
87+
List.iter (fun e ->
88+
ctx.split () [Events.Unlock (remove_fn e)]
89+
) (eval_exp_addr (Analyses.ask_of_ctx ctx) (Cil.mkAddrOf arg));
90+
raise Analyses.Deadcode
8591
| _ -> failwith "unlock has multiple arguments"
8692
in
8793
let desc = LF.find f in
@@ -96,6 +102,9 @@ struct
96102
| "spin_lock_irqsave", [arg; _] ->
97103
(*print_endline @@ "Mutex `Lock "^f.vname;*)
98104
lock ctx rw failing nonzero_return_when_aquired (Analyses.ask_of_ctx ctx) lv arg
105+
| "LAP_Se_WaitSemaphore", [Lval arg; _; _] when is_activated "arinc" || is_activated "extract_arinc" ->
106+
(*print_endline @@ "Mutex `Lock "^f.vname;*)
107+
lock ctx rw failing nonzero_return_when_aquired (Analyses.ask_of_ctx ctx) lv (Cil.mkAddrOf arg)
99108
| _ -> failwith "lock has multiple arguments"
100109
end
101110
| Unlock _, "__raw_read_unlock"

tests/regression/17-arinc/01-sema.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SKIP PARAM: --set ana.activated[+] extract_arinc --set ana.activated[+] thread --set solver slr3 --disable ana.arinc.export
1+
// PARAM: --set ana.activated[+] arinc --set ana.activated[+] thread --set solver slr3 --disable ana.arinc.export
22

33
typedef char * SEMAPHORE_NAME_TYPE;
44
typedef int SEMAPHORE_ID_TYPE;

tests/regression/17-arinc/02-unique_proc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// NOMARSHAL PARAM: --set ana.activated[+] extract_arinc --set ana.activated[+] thread --set solver slr3t --disable ana.arinc.export
1+
// NOMARSHAL PARAM: --set ana.activated[+] arinc --set ana.activated[+] thread --set solver slr3t --disable ana.arinc.export
22

33
typedef char * SEMAPHORE_NAME_TYPE;
44
typedef int SEMAPHORE_ID_TYPE;

tests/regression/17-arinc/03-preemt_lock.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
// SKIP PARAM: --set ana.activated[+] extract_arinc --set ana.activated[+] thread --disable ana.arinc.export
1+
// SKIP PARAM: --set ana.activated[+] arinc --set ana.activated[+] thread --disable ana.arinc.export
2+
// probably doesn't pass because some preemption-based privatization was removed in b2fba1f43c402d3a3811502d6ea1079f22fe8d21
3+
#include <assert.h>
24

35
typedef char * SEMAPHORE_NAME_TYPE;
46
typedef int SEMAPHORE_ID_TYPE;
@@ -60,7 +62,6 @@ extern void LAP_Se_SetPartitionMode (
6062

6163
// -----------------------
6264

63-
extern void assert(int);
6465
int g;
6566

6667
void P1(void){
@@ -69,7 +70,7 @@ void P1(void){
6970
while (1){
7071
LAP_Se_LockPreemption(&ll,&r);
7172
g = 1;
72-
assert(g==1);
73+
assert(g==1); // TODO: privatization by preemption?
7374
LAP_Se_UnlockPreemption(&ll,&r);
7475
}
7576
return;

tests/regression/17-arinc/04-sema-strcpy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SKIP PARAM: --set ana.activated[+] extract_arinc --set ana.activated[+] thread --set solver slr3 --disable ana.arinc.export
1+
// SKIP PARAM: --set ana.activated[+] arinc --set ana.activated[+] thread --set solver slr3 --disable ana.arinc.export
22

33
typedef char * SEMAPHORE_NAME_TYPE;
44
typedef int SEMAPHORE_ID_TYPE;

0 commit comments

Comments
 (0)