libxl: ocaml: add simple test case for xentoollog

Add a simple noddy test case (tools/ocaml/test) for the the Xentoollog OCaml
module.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
Acked-by: David Scott <dave.scott@eu.citrix.com>
This commit is contained in:
Rob Hoes authored and Ian Campbell committed 2013-12-11 13:17:24 +00:00
1 parent 91082d7b87
commit 49269dd31e
5 files changed
+71 -1

No files matched your search

+1
View File
@@ -385,6 +385,7 @@ tools/ocaml/libs/xentoollog/_xtl_levels.*
tools/ocaml/libs/xentoollog/xentoollog.ml
tools/ocaml/libs/xentoollog/xentoollog.mli
tools/ocaml/xenstored/oxenstored
tools/ocaml/test/xtl
tools/debugger/kdd/kdd
tools/firmware/etherboot/ipxe.tar.gz
+1
View File
@@ -308,6 +308,7 @@
^tools/ocaml/libs/xl/xenlight\.ml$
^tools/ocaml/libs/xl/xenlight\.mli$
^tools/ocaml/xenstored/oxenstored$
^tools/ocaml/test/xtl$
^tools/autom4te\.cache$
^tools/config\.h$
^tools/config\.log$
+1 -1
View File
@@ -1,7 +1,7 @@
XEN_ROOT = $(CURDIR)/../..
include $(XEN_ROOT)/tools/Rules.mk
SUBDIRS_PROGRAMS = xenstored
SUBDIRS_PROGRAMS = xenstored test
SUBDIRS = libs $(SUBDIRS_PROGRAMS)
+28
View File
@@ -0,0 +1,28 @@
XEN_ROOT = $(CURDIR)/../../..
OCAML_TOPLEVEL = $(CURDIR)/..
include $(OCAML_TOPLEVEL)/common.make
OCAMLINCLUDE += \
-I $(OCAML_TOPLEVEL)/libs/xentoollog
OBJS = xtl
PROGRAMS = xtl
xtl_LIBS = \
-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/xentoollog $(OCAML_TOPLEVEL)/libs/xentoollog/xentoollog.cmxa \
-cclib $(LDLIBS_libxenctrl)
xtl_OBJS = xtl
OCAML_PROGRAM = xtl
all: $(PROGRAMS)
bins: $(PROGRAMS)
install: all
$(INSTALL_DIR) $(DESTDIR)$(BINDIR)
$(INSTALL_PROG) $(PROGRAMS) $(DESTDIR)$(BINDIR)
include $(OCAML_TOPLEVEL)/Makefile.rules
+40
View File
@@ -0,0 +1,40 @@
open Arg
open Printf
open Xentoollog
let stdio_vmessage min_level level errno ctx msg =
let level_str = level_to_string level
and errno_str = match errno with None -> "" | Some s -> sprintf ": errno=%d" s
and ctx_str = match ctx with None -> "" | Some s -> sprintf ": %s" s in
if compare min_level level <= 0 then begin
printf "%s%s%s: %s\n" level_str ctx_str errno_str msg;
flush stdout;
end
let stdio_progress ctx what percent dne total =
let nl = if dne = total then "\n" else "" in
printf "\rProgress %s %d%% (%Ld/%Ld)%s" what percent dne total nl;
flush stdout
let create_stdio_logger ?(level=Info) () =
let cbs = {
vmessage = stdio_vmessage level;
progress = stdio_progress; } in
create "Xentoollog.stdio_logger" cbs
let do_test level =
let lgr = create_stdio_logger ~level:level () in
begin
test lgr;
end
let () =
let debug_level = ref Info in
let speclist = [
("-v", Arg.Unit (fun () -> debug_level := Debug), "Verbose");
("-q", Arg.Unit (fun () -> debug_level := Critical), "Quiet");
] in
let usage_msg = "usage: xtl [OPTIONS]" in
Arg.parse speclist (fun s -> ()) usage_msg;
do_test !debug_level
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.