xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Rob Hoes <rob.hoes@citrix.com>
To: xen-devel@lists.xen.org
Cc: Rob Hoes <rob.hoes@citrix.com>,
	ian.jackson@eu.citrix.com, dave.scott@eu.citrix.com,
	ian.campbell@citrix.com
Subject: [PATCH v6 01/11] libxl: ocaml: add simple test case for xentoollog
Date: Mon, 9 Dec 2013 15:17:20 +0000	[thread overview]
Message-ID: <1386602250-29866-2-git-send-email-rob.hoes@citrix.com> (raw)
In-Reply-To: <1386602250-29866-1-git-send-email-rob.hoes@citrix.com>

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>

---
v5: Add the test case that was omitted from a previous patch, and fixed the
Makefile.
---
 .gitignore                |    1 +
 .hgignore                 |    1 +
 tools/ocaml/Makefile      |    2 +-
 tools/ocaml/test/Makefile |   28 ++++++++++++++++++++++++++++
 tools/ocaml/test/xtl.ml   |   40 ++++++++++++++++++++++++++++++++++++++++
 5 files changed, 71 insertions(+), 1 deletion(-)
 create mode 100644 tools/ocaml/test/Makefile
 create mode 100644 tools/ocaml/test/xtl.ml

diff --git a/.gitignore b/.gitignore
index 93aae71..20f20ed 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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
diff --git a/.hgignore b/.hgignore
index 05cb0de..bb1b67d 100644
--- a/.hgignore
+++ b/.hgignore
@@ -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$
diff --git a/tools/ocaml/Makefile b/tools/ocaml/Makefile
index 6b22bbe..8e4ca36 100644
--- a/tools/ocaml/Makefile
+++ b/tools/ocaml/Makefile
@@ -1,7 +1,7 @@
 XEN_ROOT = $(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-SUBDIRS_PROGRAMS = xenstored
+SUBDIRS_PROGRAMS = xenstored test
 
 SUBDIRS = libs $(SUBDIRS_PROGRAMS)
 
diff --git a/tools/ocaml/test/Makefile b/tools/ocaml/test/Makefile
new file mode 100644
index 0000000..3a35d04
--- /dev/null
+++ b/tools/ocaml/test/Makefile
@@ -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
diff --git a/tools/ocaml/test/xtl.ml b/tools/ocaml/test/xtl.ml
new file mode 100644
index 0000000..db30aae
--- /dev/null
+++ b/tools/ocaml/test/xtl.ml
@@ -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
-- 
1.7.10.4

  reply	other threads:[~2013-12-09 15:17 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-09 15:17 [PATCH v6 00/11] libxl: ocaml: improve the bindings Rob Hoes
2013-12-09 15:17 ` Rob Hoes [this message]
2013-12-09 15:17 ` [PATCH v6 02/11] libxl: ocaml: implement some simple tests Rob Hoes
2013-12-09 15:17 ` [PATCH v6 03/11] libxl: ocaml: event management Rob Hoes
2013-12-10 13:48   ` Ian Campbell
2013-12-10 15:48     ` Rob Hoes
2013-12-10 16:00       ` Ian Campbell
2013-12-10 16:46         ` Rob Hoes
2013-12-10 16:12   ` David Scott
2013-12-09 15:17 ` [PATCH v6 04/11] libxl: ocaml: allow device operations to be called asynchronously Rob Hoes
2013-12-10 13:25   ` Ian Campbell
2013-12-10 13:28     ` Ian Campbell
2013-12-10 14:47     ` Rob Hoes
2013-12-09 15:17 ` [PATCH v6 05/11] libxl: ocaml: add disk and cdrom helper functions Rob Hoes
2013-12-09 15:17 ` [PATCH v6 06/11] libxl: ocaml: add VM lifecycle operations Rob Hoes
2013-12-10 13:29   ` Ian Campbell
2013-12-10 16:13   ` David Scott
2013-12-09 15:17 ` [PATCH v6 07/11] libxl: ocaml: add console reader functions Rob Hoes
2013-12-09 15:17 ` [PATCH v6 08/11] libxl: ocaml: drop the ocaml heap lock before calling into libxl Rob Hoes
2013-12-10 13:34   ` Ian Campbell
2013-12-10 14:51     ` Rob Hoes
2013-12-10 16:01       ` Ian Campbell
2013-12-10 16:13         ` Rob Hoes
2013-12-09 15:17 ` [PATCH v6 09/11] libxl: ocaml: add some missing CAML macros Rob Hoes
2013-12-09 15:17 ` [PATCH v6 10/11] libxl: ocaml: fix memory corruption when converting string and key/values lists Rob Hoes
2013-12-09 15:17 ` [PATCH v6 11/11] libxl: ocaml: remove dead code in xentoollog bindings Rob Hoes
2013-12-10 11:24 ` [PATCH v6 00/11] libxl: ocaml: improve the bindings Rob Hoes
2013-12-10 13:20 ` Ian Campbell
2013-12-10 13:25   ` Andrew Cooper
2013-12-10 13:42     ` Ian Campbell
2013-12-10 14:10   ` George Dunlap
2013-12-10 14:24     ` George Dunlap
2013-12-10 14:34     ` David Scott
2013-12-10 15:42       ` George Dunlap
2013-12-10 15:48         ` David Scott
2013-12-10 15:48     ` Ian Campbell
2013-12-10 15:53       ` Ian Jackson
2013-12-10 16:00       ` George Dunlap
2013-12-10 16:57         ` George Dunlap
2013-12-10 17:01           ` Rob Hoes
2013-12-10 15:50     ` Ian Jackson
2013-12-10 15:57       ` George Dunlap
2013-12-10 16:04         ` Ian Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1386602250-29866-2-git-send-email-rob.hoes@citrix.com \
    --to=rob.hoes@citrix.com \
    --cc=dave.scott@eu.citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).