Skip to content

Commit

Permalink
Merge pull request xapi-project#770 from psafont/nolog
Browse files Browse the repository at this point in the history
CA-357785: squeezed logs to xensource.log
  • Loading branch information
robhoes authored Oct 1, 2021
2 parents 31dd19d + 283912a commit 2a66192
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 34 deletions.
22 changes: 2 additions & 20 deletions squeezed/lib/squeeze.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,9 @@
commandline *)
let start = Unix.gettimeofday ()

module D = Debug.Make (struct let name = "xenops" end)
module D = Debug.Make (struct let name = "squeeze" end)

let debug_oc = ref stdout

let debug fmt =
Printf.kprintf
(fun x ->
Printf.fprintf !debug_oc "[%.2f] %s\n" (Unix.gettimeofday () -. start) x ;
flush !debug_oc ;
D.debug "%s" x
)
fmt

let error fmt =
Printf.kprintf
(fun x ->
Printf.fprintf !debug_oc "[%.2f] %s\n" (Unix.gettimeofday () -. start) x ;
flush !debug_oc ;
D.error "%s" x
)
fmt
open D

let manage_domain_zero = ref false

Expand Down
6 changes: 2 additions & 4 deletions squeezed/src/squeeze_xen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ open Squeezed_xenstore

open Xapi_stdext_threads.Threadext

module M = Debug.Make (struct let name = "memory" end)
module D = Debug.Make (struct let name = "squeeze_xen" end)

let debug = Squeeze.debug

let error = Squeeze.error
open D

let _domain_type = "/domain-type" (* immutable *)

Expand Down
1 change: 1 addition & 0 deletions squeezed/src/squeezed.ml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ let bind () =
S.get_domain_zero_policy get_domain_zero_policy

let _ =
Debug.set_facility Syslog.Local5 ;
debug "squeezed version %d.%d starting" major_version minor_version ;
configure ~options () ;
bind () ;
Expand Down
3 changes: 3 additions & 0 deletions squeezed/test/dune
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
(test
(name squeeze_test_main)
(package xapi-squeezed)
(flags (:standard -bin-annot))
(libraries
alcotest
xapi-stdext-pervasives
xapi-stdext-unix
xenctrl
unix
squeeze
xapi-idl
)
)
23 changes: 13 additions & 10 deletions squeezed/test/squeeze_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
*)
(** Simulation environment and set of unit tests for the domain memory balancer. *)

open Squeeze
module D = Debug.Make (struct let name = "squeeze_test" end)

open D
open! Squeeze

(** Computes the memory_actual delta for a VM assuming the balloon driver
responds at a given speed. Warning: make sure the balloon_rate * time_passed
Expand Down Expand Up @@ -433,7 +436,6 @@ let simulate scenario =
let out_filename = Printf.sprintf "%s.out" scenario.name in
let dat_oc = open_out dat_filename in
let out_oc = open_out out_filename in
debug_oc := out_oc ;
let cols = [Gnuplot.Memory_actual; Gnuplot.Target] in
Gnuplot.write_header dat_oc cols ;
let i = ref 0 in
Expand Down Expand Up @@ -487,7 +489,6 @@ let simulate scenario =
(fun () ->
close_out dat_oc ;
close_out out_oc ;
debug_oc := stderr ;
Gnuplot.write_gp scenario.name (make_host ()) cols
)

Expand Down Expand Up @@ -519,11 +520,13 @@ let run_test scenario =
List.iter Xapi_stdext_unix.Unixext.unlink_safe
(files_created_by_scenario scenario)

let prepare_tests scenarios =
let prepare_test scenario =
(scenario.description, `Quick, fun () -> run_test scenario)
in
List.map prepare_test scenarios

let go () =
List.iter run_test all_scenarios ;
debug "%d tests executed; %d unexpected results"
(List.length all_scenarios)
(List.length !failed_scenarios) ;
List.iter
(fun (scenario, error) -> debug "%s: %s" scenario.name error)
!scenario_error_table
let suite = [("squeeze test", prepare_tests all_scenarios)] in
Debug.log_to_stdout () ;
Alcotest.run "squeeze suite" suite

0 comments on commit 2a66192

Please sign in to comment.