Skip to content

Commit

Permalink
Initial commit of new xapi unit test suite
Browse files Browse the repository at this point in the history
Signed-off-by: Mike McClurg <mike.mcclurg@citrix.com>
  • Loading branch information
Mike McClurg committed Jul 16, 2012
1 parent 341dcc5 commit 1fba502
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -216,3 +216,5 @@ ocaml/fhs.*
/ocaml/xenops/cancel_utils_test /ocaml/xenops/cancel_utils_test
ocaml/xapi/storage_impl_test ocaml/xapi/storage_impl_test
ocaml/xenops/domain_sethandle ocaml/xenops/domain_sethandle

ocaml/test/suite
3 changes: 2 additions & 1 deletion ocaml/OMakefile
Expand Up @@ -41,7 +41,8 @@ OCamlLibrary(fhs, fhs)
network \ network \
xenops-cli \ xenops-cli \
network \ network \
rrdd rrdd \
test


clean: clean:
rm -f fhs.* rm -f fhs.*
20 changes: 20 additions & 0 deletions ocaml/test/OMakefile
@@ -0,0 +1,20 @@
OCAMLPACKS = oUnit sexpr log xmlm stunnel xml-light2 http-svr

OCAMLINCLUDES = \
../database \
../xapi \
../idl \
../idl/ocaml_backend

OCAML_LIBS = \
../fhs \
../util/version \
../idl/ocaml_backend/common \
../idl/ocaml_backend/client \
../idl/ocaml_backend/server

OCAML_OBJS = \
../idl/api_lowlevel \
../idl/datamodel_schema

OCamlProgram(suite, suite $(OCAML_OBJS) )
48 changes: 48 additions & 0 deletions ocaml/test/suite.ml
@@ -0,0 +1,48 @@
(*
* Copyright (C) 2006-2012 Citrix Systems Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; version 2.1 only. with the special
* exception on linking described in file LICENSE.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*)

open OUnit

module MockDatabase= struct

let schema = ref (Datamodel_schema.of_datamodel ())
let db_ref = ref (Db_cache_types.Database.make !schema)
let make_db () = Db_ref.in_memory (ref db_ref)

end (* MockDatabase *)

let skip str = skip_if true str

let test_always_pass () = assert_equal 1 1
let test_always_fail () = skip "This will fail" ; assert_equal 1 0

let test_mock_db () =
let open MockDatabase in
let db = make_db () in
let __context = Context.make
~database:db
"Mock context"
in
ignore __context ;
ignore (Db.VM.get_all_records ~__context) ;
assert_equal 0 0

let test_suite = "test_suit" >:::
[
"test_always_pass" >:: test_always_pass ;
"test_always_fail" >:: test_always_fail ;
"test_mock_db" >:: test_mock_db ;
]

let _ = run_test_tt_main test_suite

0 comments on commit 1fba502

Please sign in to comment.