Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial commit of new xapi unit test suite

Signed-off-by: Mike McClurg <mike.mcclurg@citrix.com>
  • Loading branch information...
commit 1fba5028770994f6e07a958bba5023b3adc5a6c5 1 parent 341dcc5
Mike McClurg authored
View
2  .gitignore
@@ -216,3 +216,5 @@ ocaml/fhs.*
/ocaml/xenops/cancel_utils_test
ocaml/xapi/storage_impl_test
ocaml/xenops/domain_sethandle
+
+ocaml/test/suite
View
3  ocaml/OMakefile
@@ -41,7 +41,8 @@ OCamlLibrary(fhs, fhs)
network \
xenops-cli \
network \
- rrdd
+ rrdd \
+ test
clean:
rm -f fhs.*
View
20 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) )
View
48 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
Please sign in to comment.
Something went wrong with that request. Please try again.