mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-06 11:15:43 -05:00
New test script.
This commit is contained in:
parent
f1df47c43b
commit
7cd1f38d49
9 changed files with 55 additions and 11 deletions
4
Makefile
4
Makefile
|
|
@ -20,7 +20,9 @@ doc:
|
|||
$(COMP) $(FLAGS) $(DIRS) $(DOC)
|
||||
|
||||
test: $(TEST)
|
||||
./tests/main tests/test-0.d
|
||||
|
||||
test-full: $(TEST)
|
||||
./tests/run
|
||||
|
||||
$(TEST): $(LIB)
|
||||
$(COMP) $(FLAGS) $(DIRS) $(TEST)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,12 @@ module Fsat = struct
|
|||
let max_lit = min max_int (- min_int)
|
||||
let max_index = ref 0
|
||||
|
||||
let make i = if i <> 0 then i else raise Dummy
|
||||
let make i =
|
||||
if i <> 0 then begin
|
||||
max_index := max !max_index (abs i);
|
||||
i
|
||||
end else
|
||||
raise Dummy
|
||||
|
||||
let dummy = 0
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ module Make(Dummy: sig end) : sig
|
|||
|
||||
val make : int -> atom
|
||||
(** Returns the literal corresponding to the integer.
|
||||
@raise bad_atom if given [0] as argument.*)
|
||||
@raise Bad_atom if given [0] as argument.*)
|
||||
|
||||
val neg : atom -> atom
|
||||
(** [neg a] returns the negation of a literal. Involutive, i.e [neg (neg a) = a]. *)
|
||||
|
|
|
|||
19
tests/run
Executable file
19
tests/run
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
#!/bin/bash
|
||||
|
||||
solvertest () {
|
||||
for f in `find $1 -name *.d -type f`
|
||||
do
|
||||
echo -ne "\r\033[K Testing $f "
|
||||
tests/main $f | grep $2 > /dev/null 2> /dev/null
|
||||
RET=$?
|
||||
if [ $RET -ne 0 ];
|
||||
then
|
||||
echo -e "\r\033[K\e[31m[KO]\e[0m $f"
|
||||
exit 2
|
||||
fi
|
||||
done
|
||||
echo -e "\r\033[K\e[32m[OK]\e[0m $2"
|
||||
}
|
||||
|
||||
solvertest "tests/sat/" "Sat"
|
||||
solvertest "tests/unsat/" "Unsat"
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
c First test
|
||||
c Status: SAT
|
||||
p cnf 2 1
|
||||
1 2 0
|
||||
8
tests/unsat/test-001.d
Normal file
8
tests/unsat/test-001.d
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
c First test
|
||||
p cnf 5 6
|
||||
1 2 0
|
||||
-1 3 0
|
||||
-2 3 0
|
||||
4 5 0
|
||||
-4 -3 0
|
||||
-5 -3 0
|
||||
|
|
@ -20,10 +20,11 @@ file:
|
|||
;
|
||||
clause_list:
|
||||
| EOF { [] }
|
||||
| EOL clause_list { $2 }
|
||||
| clause clause_list { $1 :: $2 }
|
||||
;
|
||||
clause:
|
||||
/* Clause always ends with a '0' */
|
||||
/* clauses always ends with a '0' */
|
||||
| LIT EOL { if $1 = 0 then [] else raise (Clause_ending $1) }
|
||||
| LIT clause { $1 :: $2 }
|
||||
;
|
||||
|
|
|
|||
15
util/test.ml
15
util/test.ml
|
|
@ -3,12 +3,15 @@ module S = Sat.Make(struct end)
|
|||
|
||||
(* Arguments parsing *)
|
||||
let file = ref ""
|
||||
let p_assign = ref false
|
||||
|
||||
let input_file = fun s -> file := s
|
||||
let usage = "Usage : main [options] <file>"
|
||||
let argspec = Arg.align [
|
||||
"-v", Arg.Int (fun i -> Log.set_debug i),
|
||||
"<lvl> Sets the debug verbose level";
|
||||
"-model", Arg.Set p_assign,
|
||||
" Outputs the boolean model found if sat";
|
||||
]
|
||||
|
||||
(* Entry file parsing *)
|
||||
|
|
@ -33,7 +36,7 @@ let print_assign fmt () =
|
|||
S.iter_atoms (fun a ->
|
||||
Format.fprintf fmt "%a -> %s,@ "
|
||||
S.print_atom a
|
||||
(if S.eval a then "true" else "false")
|
||||
(if S.eval a then "T" else "F")
|
||||
)
|
||||
|
||||
let main () =
|
||||
|
|
@ -43,8 +46,14 @@ let main () =
|
|||
exit 2
|
||||
end;
|
||||
let cnf = get_cnf () in
|
||||
print_cnf cnf;
|
||||
()
|
||||
S.assume cnf;
|
||||
match S.solve () with
|
||||
| S.Sat ->
|
||||
Format.printf "Sat@.";
|
||||
if !p_assign then
|
||||
print_assign Format.std_formatter ()
|
||||
| S.Unsat ->
|
||||
Format.printf "Unsat@."
|
||||
;;
|
||||
|
||||
main ()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue