Permalink
Browse files

Move existing unit tests over to the OUnit suite.

Signed-off-by: John Else <john.else@citrix.com>
  • Loading branch information...
1 parent db6019d commit 9edfeaba652f4c54cbb6b0e5b2bc48cb2b96b0c1 @johnelse johnelse committed Oct 23, 2012
View
@@ -63,8 +63,6 @@ test:
# Pipe ugly bash output to /dev/null
@echo @ xapi unit test suite
@./ocaml/test/suite
- @echo @ xapi_unit_test
- @./ocaml/xapi/xapi_unit_test
@echo @ xenops-cli unit test
@./ocaml/xenops-cli/runtest.sh 2> /dev/null
@echo
View
@@ -154,7 +154,6 @@ JAVA_PHASE3_TARGETS = $(if $(COMPILE_JAVA), $(JAVA_PHASE3))
# Phase 3 targets divided into two depending on whether we're building the Xen stuff or not:
OCAML_PHASE3_XEN = \
ocaml/xapi/xapi \
- ocaml/xapi/xapi_unit_test \
ocaml/xstest/xstest \
ocaml/xstest/xsbench \
ocaml/xstest/xscheckperms \
View
@@ -1,11 +1,13 @@
OCAMLPACKS = oUnit sexpr log xmlm stunnel xml-light2 http-svr uuid netdev \
- tapctl rss xenctrl xenctrlext xenstore xenstoreext cpuid
+ tapctl rss xenctrl xenctrlext xenstore xenstoreext cpuid pciutil
OCAMLINCLUDES = \
../database \
../xapi \
+ ../xenops \
../idl \
../idl/ocaml_backend \
+ ../autogen \
OCAML_LIBS = \
../fhs \
@@ -23,5 +25,7 @@ OCAML_OBJS = \
mock \
test_common \
test_basic \
+ pool_db_backup_test \
+ xapi_db_upgrade_test \
OCamlProgram(suite, suite $(OCAML_OBJS) )
@@ -12,7 +12,7 @@
* GNU Lesser General Public License for more details.
*)
-open Xapi_test_common
+open Test_common
let test_prepare_restore () =
let make_context mac1 mac2 host_uuid dom0_uuid =
@@ -52,8 +52,3 @@ let test_prepare_restore () =
if dom0_uuid <> my_control_uuid
then failwith "test_prepare_restore: master dom0 uuid wrong";
Printf.printf "test_prepare_restore OK \n"
-
-let all () =
- test_prepare_restore ()
-
-
View
@@ -24,10 +24,26 @@ let test_basic =
"test_assert_licensed_storage_motion" >:: test_assert_licensed_storage_motion ;
]
+let test_db_backup =
+ "test_db_backup" >:::
+ [
+ "test_prepare_restore" >:: Pool_db_backup_test.test_prepare_restore;
+ ]
+
+let test_db_upgrade =
+ "test_db_upgrade" >:::
+ [
+ "upgrade_vm_memory_for_dmc" >:: Xapi_db_upgrade_test.upgrade_vm_memory_for_dmc;
+ "upgrade_bios" >:: Xapi_db_upgrade_test.upgrade_bios;
+ "update_snapshots" >:: Xapi_db_upgrade_test.update_snapshots;
+ ]
+
let base_suite =
"base_suite" >:::
[
- test_basic
+ test_basic;
+ test_db_backup;
+ test_db_upgrade;
]
let _ = run_test_tt_main base_suite
View
@@ -12,7 +12,74 @@
* GNU Lesser General Public License for more details.
*)
+open API
open OUnit
let skip str = skip_if true str
+(** Make a simple in-memory database containing a single host and dom0 VM record. *)
+let make_test_database () =
+ let __context = Mock.make_context_with_new_db "Mock context" in
+
+ let host_info = {
+ Create_misc.name_label = "test host";
+ xen_verstring = "unknown";
+ linux_verstring = "something";
+ hostname = "localhost";
+ uuid = Xapi_inventory.lookup Xapi_inventory._installation_uuid;
+ dom0_uuid = "dom0-uuid";
+ oem_manufacturer = None;
+ oem_model = None;
+ oem_build_number = None;
+ machine_serial_number = None;
+ machine_serial_name = None;
+ total_memory_mib = 1024L;
+ dom0_static_max = Memory.bytes_of_mib 512L;
+ } in
+ Dbsync_slave.create_localhost ~__context host_info;
+ Create_misc.ensure_domain_zero_records ~__context host_info;
+ Dbsync_master.create_pool_record ~__context;
+ __context
+
+let make_vm ~__context ?(name_label="name_label") ?(name_description="description")
+ ?(user_version=1L) ?(is_a_template=false) ?(affinity=Ref.null)
+ ?(memory_target=500L) ?(memory_static_max=1000L) ?(memory_dynamic_max=500L)
+ ?(memory_dynamic_min=500L) ?(memory_static_min=0L) ?(vCPUs_params=[])
+ ?(vCPUs_max=1L) ?(vCPUs_at_startup=1L) ?(actions_after_shutdown=`destroy)
+ ?(actions_after_reboot=`restart) ?(actions_after_crash=`destroy)
+ ?(pV_bootloader="") ?(pV_kernel="") ?(pV_ramdisk="") ?(pV_args="")
+ ?(pV_bootloader_args="") ?(pV_legacy_args="") ?(hVM_boot_policy="BIOS order")
+ ?(hVM_boot_params=[]) ?(hVM_shadow_multiplier=1.) ?(platform=[]) ?(pCI_bus="")
+ ?(other_config=[]) ?(xenstore_data=[]) ?(recommendations="") ?(ha_always_run=false)
+ ?(ha_restart_priority="") ?(tags=[]) ?(blocked_operations=[]) ?(protection_policy=Ref.null)
+ ?(is_snapshot_from_vmpp=false) ?(appliance=Ref.null) ?(start_delay=0L)
+ ?(shutdown_delay=0L) ?(order=0L) ?(suspend_SR=Ref.null) ?(version=0L) () =
+ Xapi_vm.create ~__context ~name_label ~name_description ~user_version ~is_a_template
+ ~affinity ~memory_target ~memory_static_max ~memory_dynamic_max ~memory_dynamic_min
+ ~memory_static_min ~vCPUs_params ~vCPUs_max ~vCPUs_at_startup ~actions_after_shutdown
+ ~actions_after_reboot ~actions_after_crash ~pV_bootloader ~pV_kernel ~pV_ramdisk
+ ~pV_args ~pV_bootloader_args ~pV_legacy_args ~hVM_boot_policy ~hVM_boot_params
+ ~hVM_shadow_multiplier ~platform ~pCI_bus ~other_config ~xenstore_data ~recommendations
+ ~ha_always_run ~ha_restart_priority ~tags ~blocked_operations ~protection_policy
+ ~is_snapshot_from_vmpp ~appliance ~start_delay ~shutdown_delay ~order ~suspend_SR ~version
+
+let make_host ~__context ?(uuid=Uuid.string_of_uuid (Uuid.make_uuid ())) ?(name_label="host")
+ ?(name_description="description") ?(hostname="localhost") ?(address="127.0.0.1")
+ ?(external_auth_type="") ?(external_auth_service_name="") ?(external_auth_configuration=[])
+ ?(license_params=[]) ?(edition="free") ?(license_server=[]) ?(local_cache_sr=Ref.null) ?(chipset_info=[]) () =
+
+ Xapi_host.create ~__context ~uuid ~name_label ~name_description ~hostname ~address ~external_auth_type ~external_auth_service_name ~external_auth_configuration ~license_params ~edition ~license_server ~local_cache_sr ~chipset_info
+
+let make_pif ~__context ~network ~host ?(device="eth0") ?(mAC="C0:FF:EE:C0:FF:EE") ?(mTU=1500L)
+ ?(vLAN=(-1L)) ?(physical=true) ?(ip_configuration_mode=`None) ?(iP="") ?(netmask="")
+ ?(gateway="") ?(dNS="") ?(bond_slave_of=Ref.null) ?(vLAN_master_of=Ref.null)
+ ?(management=false) ?(other_config=[]) ?(disallow_unplug=false)
+ ?(ipv6_configuration_mode=`None) ?(iPv6=[""]) ?(ipv6_gateway="") ?(primary_address_type=`IPv4) () =
+ Xapi_pif.pool_introduce ~__context
+ ~device ~network ~host ~mAC ~mTU ~vLAN ~physical ~ip_configuration_mode
+ ~iP ~netmask ~gateway ~dNS ~bond_slave_of ~vLAN_master_of ~management ~other_config ~disallow_unplug
+ ~ipv6_configuration_mode ~iPv6 ~ipv6_gateway ~primary_address_type
+
+let make_network ~__context ?(name_label="net") ?(name_description="description") ?(mTU=1500L)
+ ?(other_config=[]) ?(bridge="xenbr0") () =
+ Xapi_network.pool_introduce ~__context ~name_label ~name_description ~mTU ~other_config ~bridge
@@ -12,7 +12,7 @@
* GNU Lesser General Public License for more details.
*)
-open Xapi_test_common
+open Test_common
open Xapi_db_upgrade
let upgrade_vm_memory_for_dmc () =
@@ -99,8 +99,3 @@ let update_snapshots () =
then failwith "b_snap2.parent <> b_snap";
Printf.printf "update_snapshots: OK\n"
-
-let all () =
- upgrade_vm_memory_for_dmc ();
- upgrade_bios ();
- update_snapshots ()
View
@@ -280,8 +280,6 @@ OCamlDocProgram(xapi, xapi $(XAPI_MODULES))
OCamlLibrary(xapi, xapi $(XAPI_MODULES))
-OCamlProgram(xapi_unit_test, xapi_unit_test xapi_db_upgrade_test pool_db_backup_test xapi_test_common $(XAPI_MODULES))
-
OCamlProgram(bootloader, bootloader bootloader_test)
OCamlProgram(binpack, binpack binpack_test xapi_fist)
@@ -1,86 +0,0 @@
-(*
- * Copyright (C) 2011 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.
- *)
-
-(** Make a simple in-memory database containing a single host and dom0 VM record. *)
-let make_test_database () =
- let db = Db_upgrade.generic_database_upgrade (Db_cache_types.Database.make (Datamodel_schema.of_datamodel ())) in
- let db_ref = Db_ref.in_memory (ref (ref db)) in
- let __context = Context.make ~database:db_ref "upgrade_vm_memory_for_dmc" in
-
- (* Db_xml.To.file "/tmp/new3.db" (Db_ref.get_database (Context.database_of __context)); *)
-
- let host_info = {
- Create_misc.name_label = "test host";
- xen_verstring = "unknown";
- linux_verstring = "something";
- hostname = "localhost";
- uuid = Xapi_inventory.lookup Xapi_inventory._installation_uuid;
- dom0_uuid = "dom0-uuid";
- oem_manufacturer = None;
- oem_model = None;
- oem_build_number = None;
- machine_serial_number = None;
- machine_serial_name = None;
- total_memory_mib = 1024L;
- dom0_static_max = Memory.bytes_of_mib 512L;
- } in
- Dbsync_slave.create_localhost ~__context host_info;
- Create_misc.ensure_domain_zero_records ~__context host_info;
- Dbsync_master.create_pool_record ~__context;
- __context
-
-let make_vm ~__context ?(name_label="name_label") ?(name_description="description")
- ?(user_version=1L) ?(is_a_template=false) ?(affinity=Ref.null)
- ?(memory_target=500L) ?(memory_static_max=1000L) ?(memory_dynamic_max=500L)
- ?(memory_dynamic_min=500L) ?(memory_static_min=0L) ?(vCPUs_params=[])
- ?(vCPUs_max=1L) ?(vCPUs_at_startup=1L) ?(actions_after_shutdown=`destroy)
- ?(actions_after_reboot=`restart) ?(actions_after_crash=`destroy)
- ?(pV_bootloader="") ?(pV_kernel="") ?(pV_ramdisk="") ?(pV_args="")
- ?(pV_bootloader_args="") ?(pV_legacy_args="") ?(hVM_boot_policy="BIOS order")
- ?(hVM_boot_params=[]) ?(hVM_shadow_multiplier=1.) ?(platform=[]) ?(pCI_bus="")
- ?(other_config=[]) ?(xenstore_data=[]) ?(recommendations="") ?(ha_always_run=false)
- ?(ha_restart_priority="") ?(tags=[]) ?(blocked_operations=[]) ?(protection_policy=Ref.null)
- ?(is_snapshot_from_vmpp=false) ?(appliance=Ref.null) ?(start_delay=0L)
- ?(shutdown_delay=0L) ?(order=0L) ?(suspend_SR=Ref.null) ?(version=0L) () =
- Xapi_vm.create ~__context ~name_label ~name_description ~user_version ~is_a_template
- ~affinity ~memory_target ~memory_static_max ~memory_dynamic_max ~memory_dynamic_min
- ~memory_static_min ~vCPUs_params ~vCPUs_max ~vCPUs_at_startup ~actions_after_shutdown
- ~actions_after_reboot ~actions_after_crash ~pV_bootloader ~pV_kernel ~pV_ramdisk
- ~pV_args ~pV_bootloader_args ~pV_legacy_args ~hVM_boot_policy ~hVM_boot_params
- ~hVM_shadow_multiplier ~platform ~pCI_bus ~other_config ~xenstore_data ~recommendations
- ~ha_always_run ~ha_restart_priority ~tags ~blocked_operations ~protection_policy
- ~is_snapshot_from_vmpp ~appliance ~start_delay ~shutdown_delay ~order ~suspend_SR ~version
-
-let make_host ~__context ?(uuid=Uuid.string_of_uuid (Uuid.make_uuid ())) ?(name_label="host")
- ?(name_description="description") ?(hostname="localhost") ?(address="127.0.0.1")
- ?(external_auth_type="") ?(external_auth_service_name="") ?(external_auth_configuration=[])
- ?(license_params=[]) ?(edition="free") ?(license_server=[]) ?(local_cache_sr=Ref.null) ?(chipset_info=[]) () =
-
- Xapi_host.create ~__context ~uuid ~name_label ~name_description ~hostname ~address ~external_auth_type ~external_auth_service_name ~external_auth_configuration ~license_params ~edition ~license_server ~local_cache_sr ~chipset_info
-
-let make_pif ~__context ~network ~host ?(device="eth0") ?(mAC="C0:FF:EE:C0:FF:EE") ?(mTU=1500L)
- ?(vLAN=(-1L)) ?(physical=true) ?(ip_configuration_mode=`None) ?(iP="") ?(netmask="")
- ?(gateway="") ?(dNS="") ?(bond_slave_of=Ref.null) ?(vLAN_master_of=Ref.null)
- ?(management=false) ?(other_config=[]) ?(disallow_unplug=false)
- ?(ipv6_configuration_mode=`None) ?(iPv6=[""]) ?(ipv6_gateway="") ?(primary_address_type=`IPv4) () =
- Xapi_pif.pool_introduce ~__context
- ~device ~network ~host ~mAC ~mTU ~vLAN ~physical ~ip_configuration_mode
- ~iP ~netmask ~gateway ~dNS ~bond_slave_of ~vLAN_master_of ~management ~other_config ~disallow_unplug
- ~ipv6_configuration_mode ~iPv6 ~ipv6_gateway ~primary_address_type
-
-let make_network ~__context ?(name_label="net") ?(name_description="description") ?(mTU=1500L)
- ?(other_config=[]) ?(bridge="xenbr0") () =
- Xapi_network.pool_introduce ~__context ~name_label ~name_description ~mTU ~other_config ~bridge
-
-
@@ -1,20 +0,0 @@
-(*
- * Copyright (C) 2011 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.
- *)
-
-let _ =
- Xapi_db_upgrade_test.all ();
- Pool_db_backup_test.all ()
-
-
-

0 comments on commit 9edfeab

Please sign in to comment.