All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ronald Rojas <ronladred@gmail.com>
To: xen-devel@lists.xen.org, george.dunlap@citrix.com,
	ian.jackson@eu.citrix.com, wei.liu2@citrix.com
Cc: Ronald Rojas <ronladred@gmail.com>
Subject: [PATCH RFC 5/8] golang/xenlight: Add tests host related functinality functions
Date: Mon, 23 Jan 2017 11:43:34 -0500	[thread overview]
Message-ID: <20170123164337.4205-5-ronladred@gmail.com> (raw)
In-Reply-To: <20170123164337.4205-1-ronladred@gmail.com>

Create tests for the following functions:
- GetVersionInfo
- GetPhysinfo
- GetDominfo
- GetMaxCpus
- GetOnlineCpus
- GetMaxNodes
- GetFreeMemory

Signed-off-by: Ronald Rojas <ronladred@gmail.com>
---
 tools/golang/xenlight/test/dominfo/Makefile        | 18 ++++++++
 tools/golang/xenlight/test/dominfo/dominfo.c       | 29 +++++++++++++
 tools/golang/xenlight/test/dominfo/dominfo.go      | 48 ++++++++++++++++++++++
 tools/golang/xenlight/test/freememory/Makefile     | 19 +++++++++
 tools/golang/xenlight/test/freememory/freememory.c | 25 +++++++++++
 .../golang/xenlight/test/freememory/freememory.go  | 35 ++++++++++++++++
 tools/golang/xenlight/test/maxcpu/Makefile         | 19 +++++++++
 tools/golang/xenlight/test/maxcpu/maxcpu.c         | 21 ++++++++++
 tools/golang/xenlight/test/maxcpu/maxcpu.go        | 34 +++++++++++++++
 tools/golang/xenlight/test/maxnodes/Makefile       | 19 +++++++++
 tools/golang/xenlight/test/maxnodes/maxnodes.c     | 21 ++++++++++
 tools/golang/xenlight/test/maxnodes/maxnodes.go    | 34 +++++++++++++++
 tools/golang/xenlight/test/onlinecpu/Makefile      | 19 +++++++++
 tools/golang/xenlight/test/onlinecpu/onlinecpu.c   | 21 ++++++++++
 tools/golang/xenlight/test/onlinecpu/onlinecpu.go  | 34 +++++++++++++++
 tools/golang/xenlight/test/physinfo/Makefile       | 19 +++++++++
 tools/golang/xenlight/test/physinfo/physinfo.c     | 31 ++++++++++++++
 tools/golang/xenlight/test/physinfo/physinfo.go    | 36 ++++++++++++++++
 tools/golang/xenlight/test/versioninfo/Makefile    | 18 ++++++++
 .../golang/xenlight/test/versioninfo/versioninfo.c | 18 ++++++++
 .../xenlight/test/versioninfo/versioninfo.go       | 33 +++++++++++++++
 21 files changed, 551 insertions(+)
 create mode 100644 tools/golang/xenlight/test/dominfo/Makefile
 create mode 100644 tools/golang/xenlight/test/dominfo/dominfo.c
 create mode 100644 tools/golang/xenlight/test/dominfo/dominfo.go
 create mode 100644 tools/golang/xenlight/test/freememory/Makefile
 create mode 100644 tools/golang/xenlight/test/freememory/freememory.c
 create mode 100644 tools/golang/xenlight/test/freememory/freememory.go
 create mode 100644 tools/golang/xenlight/test/maxcpu/Makefile
 create mode 100644 tools/golang/xenlight/test/maxcpu/maxcpu.c
 create mode 100644 tools/golang/xenlight/test/maxcpu/maxcpu.go
 create mode 100644 tools/golang/xenlight/test/maxnodes/Makefile
 create mode 100644 tools/golang/xenlight/test/maxnodes/maxnodes.c
 create mode 100644 tools/golang/xenlight/test/maxnodes/maxnodes.go
 create mode 100644 tools/golang/xenlight/test/onlinecpu/Makefile
 create mode 100644 tools/golang/xenlight/test/onlinecpu/onlinecpu.c
 create mode 100644 tools/golang/xenlight/test/onlinecpu/onlinecpu.go
 create mode 100644 tools/golang/xenlight/test/physinfo/Makefile
 create mode 100644 tools/golang/xenlight/test/physinfo/physinfo.c
 create mode 100644 tools/golang/xenlight/test/physinfo/physinfo.go
 create mode 100644 tools/golang/xenlight/test/versioninfo/Makefile
 create mode 100644 tools/golang/xenlight/test/versioninfo/versioninfo.c
 create mode 100644 tools/golang/xenlight/test/versioninfo/versioninfo.go

diff --git a/tools/golang/xenlight/test/dominfo/Makefile b/tools/golang/xenlight/test/dominfo/Makefile
new file mode 100644
index 0000000..a7351cf
--- /dev/null
+++ b/tools/golang/xenlight/test/dominfo/Makefile
@@ -0,0 +1,18 @@
+
+test: clean build
+	./dominfo.out >> c.output
+	go run dominfo.go >> go.output
+	if cmp -s "c.output" "go.output"; then\
+		echo "GetDominfo PASSED";\
+	else \
+		echo "GetDominfo FAILED";\
+	fi\
+
+build:
+	go build -o dominfo.a dominfo.go 
+	gcc dominfo.c -lxenlight -lyajl -o dominfo.out
+
+clean:
+	rm -f *.a
+	rm -f *.out
+	rm -f *.output
diff --git a/tools/golang/xenlight/test/dominfo/dominfo.c b/tools/golang/xenlight/test/dominfo/dominfo.c
new file mode 100644
index 0000000..ebe18c3
--- /dev/null
+++ b/tools/golang/xenlight/test/dominfo/dominfo.c
@@ -0,0 +1,29 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <libxl.h>
+
+char * bool_to_string(bool b);
+int main(){
+
+    libxl_ctx *context;
+    libxl_ctx_alloc(&context,LIBXL_VERSION, 0, NULL);
+    libxl_dominfo info;
+    int err = libxl_domain_info(context, &info, 0);
+    if(err != 0){
+        return err;
+    }
+    
+    
+	printf("%d\n%d\n", info.domid, info.ssidref);
+	printf("%s\n%s\n%s\n%s\n%s\n%s\n", bool_to_string(info.running), bool_to_string(info.blocked ), bool_to_string(info.paused ),bool_to_string(info.shutdown ),bool_to_string(info.dying), bool_to_string(info.never_stop));
+	long cpu_time = info.cpu_time/((long)1<<35);
+	printf("%d\n%lu\n%lu\n%lu\n%lu\n%lu\n%lu\n%d\n%d\n%d\n", info.shutdown_reason, info.outstanding_memkb, info.current_memkb, info.shared_memkb, info.paged_memkb, info.max_memkb, cpu_time, info.vcpu_max_id, info.vcpu_online, info.cpupool);
+	printf("%d\n", info.domain_type);
+
+
+    libxl_ctx_free(context);
+
+}
+char * bool_to_string(bool b){
+    return b ? "true": "false";
+}
diff --git a/tools/golang/xenlight/test/dominfo/dominfo.go b/tools/golang/xenlight/test/dominfo/dominfo.go
new file mode 100644
index 0000000..e6c6a64
--- /dev/null
+++ b/tools/golang/xenlight/test/dominfo/dominfo.go
@@ -0,0 +1,48 @@
+
+package main
+
+/*
+#cgo LDFLAGS: -lxenlight -lyajl
+#include <stdlib.h>
+#include <libxl.h>
+*/
+import "C"
+import (
+	"fmt"
+	"xenproject.org/xenlight"
+	"os"
+)
+
+func main() {
+	ctx := xenlight.Ctx
+	err := ctx.Open()
+	if err != nil{
+		os.Exit(-1)
+	}
+	defer ctx.Close()
+	info, err:= ctx.DomainInfo(0)
+	if err != nil{
+		os.Exit(-1)
+	}
+
+	fmt.Printf("%d\n%d\n", info.Domid, info.Ssidref)
+	//fmt.Printf("%s\n", info.SsidLabel)
+	fmt.Printf("%t\n%t\n%t\n%t\n%t\n%t\n", info.Running, info.Blocked, info.Paused, info.Shutdown, info.Dying, info.NeverStop)
+	cpuTime := info.CpuTime/(1<<35)
+	fmt.Printf("%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n", info.ShutdownReason, info.OutstandingMemkb, info.CurrentMemkb, info.SharedMemkb, info.PagedMemkb, info.MaxMemkb, cpuTime, info.VcpuMaxId, info.VcpuOnline, info.Cpupool)
+	fmt.Printf("%d\n", info.DomainType)
+
+}
+
+func replaceDomainType(n int32)(ret string){
+	switch n{
+	case -1:
+		ret = "invalid"
+	case 1:
+		ret = "hvm"
+	case 2:
+		ret = "pv"
+	}
+	return
+
+}
diff --git a/tools/golang/xenlight/test/freememory/Makefile b/tools/golang/xenlight/test/freememory/Makefile
new file mode 100644
index 0000000..9548e50
--- /dev/null
+++ b/tools/golang/xenlight/test/freememory/Makefile
@@ -0,0 +1,19 @@
+
+test: clean build
+	./func.out >> c.output
+	go run func.go >> go.output
+	if cmp -s "c.output" "go.output"; then\
+		echo "GetFreeMemory PASSED";\
+	else \
+		echo "GetFreeMemory FAILED"; \
+	fi\
+
+build:
+	go build -o func.a func.go
+	gcc func.c -lxenlight -lyajl -o func.out
+
+clean:
+	rm -f *.a
+	rm -f *.out
+	rm -f *.output
+
diff --git a/tools/golang/xenlight/test/freememory/freememory.c b/tools/golang/xenlight/test/freememory/freememory.c
new file mode 100644
index 0000000..9ff8444
--- /dev/null
+++ b/tools/golang/xenlight/test/freememory/freememory.c
@@ -0,0 +1,25 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <libxl.h>
+
+int main(){
+
+    libxl_ctx *context;
+    libxl_ctx_alloc(&context,LIBXL_VERSION, 0, NULL);
+    libxl_physinfo info ;
+    int err= libxl_get_physinfo(context,&info);
+    if(err != 0){
+        return err;
+    }
+
+   uint64_t free_memory;
+    err = libxl_get_free_memory(context, &free_memory);
+    if(err < 0){
+        printf("%d\n", err);
+    }else{
+        printf("%lu\n", free_memory);
+    }
+    libxl_ctx_free(context);
+
+}
+
diff --git a/tools/golang/xenlight/test/freememory/freememory.go b/tools/golang/xenlight/test/freememory/freememory.go
new file mode 100644
index 0000000..19501e7
--- /dev/null
+++ b/tools/golang/xenlight/test/freememory/freememory.go
@@ -0,0 +1,35 @@
+
+package main
+
+/*
+#cgo LDFLAGS: -lxenlight -lyajl
+#include <stdlib.h>
+#include <libxl.h>
+*/
+import "C"
+import (
+	"fmt"
+	"xenproject.org/xenlight"
+	"os"
+)
+
+func main() {
+	ctx := xenlight.Ctx
+	err := ctx.Open()
+	if err != nil{
+		os.Exit(-1)
+	}
+	defer ctx.Close()
+	if err != nil{
+		os.Exit(-1)
+	}
+
+
+	free_memory, err := ctx.GetFreeMemory()
+	if err != nil{
+		fmt.Printf("%d\n", err)
+	}else{
+		fmt.Printf("%d\n", free_memory)
+	}
+
+}
diff --git a/tools/golang/xenlight/test/maxcpu/Makefile b/tools/golang/xenlight/test/maxcpu/Makefile
new file mode 100644
index 0000000..17aa19a
--- /dev/null
+++ b/tools/golang/xenlight/test/maxcpu/Makefile
@@ -0,0 +1,19 @@
+
+test: clean build
+	./maxcpu.out >> c.output
+	go run maxcpu.go >> go.output
+	if cmp -s "c.output" "go.output"; then\
+		echo "GetMaxCpu PASSED";\
+	else \
+		echo "GetMaxCpu FAILED"; \
+	fi\
+
+build:
+	go build -o maxcpu.a maxcpu.go
+	gcc maxcpu.c -lxenlight -lyajl -o maxcpu.out
+
+clean:
+	rm -f *.a
+	rm -f *.out
+	rm -f *.output
+
diff --git a/tools/golang/xenlight/test/maxcpu/maxcpu.c b/tools/golang/xenlight/test/maxcpu/maxcpu.c
new file mode 100644
index 0000000..60ef7ce
--- /dev/null
+++ b/tools/golang/xenlight/test/maxcpu/maxcpu.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <libxl.h>
+
+int main(){
+
+    libxl_ctx *context;
+    libxl_ctx_alloc(&context,LIBXL_VERSION, 0, NULL);
+    libxl_physinfo info ;
+    int err= libxl_get_physinfo(context,&info);
+    if(err != 0){
+        return err;
+    }
+
+    int max_cpus = libxl_get_max_cpus(context);
+    printf("%d\n", max_cpus);
+
+    libxl_ctx_free(context);
+
+}
+
diff --git a/tools/golang/xenlight/test/maxcpu/maxcpu.go b/tools/golang/xenlight/test/maxcpu/maxcpu.go
new file mode 100644
index 0000000..eef575f
--- /dev/null
+++ b/tools/golang/xenlight/test/maxcpu/maxcpu.go
@@ -0,0 +1,34 @@
+
+package main
+
+/*
+#cgo LDFLAGS: -lxenlight -lyajl
+#include <stdlib.h>
+#include <libxl.h>
+*/
+import "C"
+import (
+	"fmt"
+	"xenproject.org/xenlight"
+	"os"
+)
+
+func main() {
+	ctx := xenlight.Ctx
+	err := ctx.Open()
+	if err != nil{
+		os.Exit(-1)
+	}
+	defer ctx.Close()
+	if err != nil{
+		os.Exit(-1)
+	}
+
+	max_cpus, err := ctx.GetMaxCpus()
+	if err != nil{
+		fmt.Printf("%d\n", err )
+	}else{
+		fmt.Printf("%d\n", max_cpus)
+	}
+
+}
diff --git a/tools/golang/xenlight/test/maxnodes/Makefile b/tools/golang/xenlight/test/maxnodes/Makefile
new file mode 100644
index 0000000..7535efe
--- /dev/null
+++ b/tools/golang/xenlight/test/maxnodes/Makefile
@@ -0,0 +1,19 @@
+
+test: clean build
+	./maxnodes.out >> c.output
+	go run maxnodes.go >> go.output
+	if cmp -s "c.output" "go.output"; then\
+		echo "GetMaxNodes PASSED";\
+	else \
+		echo "GetMaxNodes FAILED"; \
+	fi\
+
+build:
+	go build -o maxnodes.a maxnodes.go
+	gcc maxnodes.c -lxenlight -lyajl -o maxnodes.out
+
+clean:
+	rm -f *.a
+	rm -f *.out
+	rm -f *.output
+
diff --git a/tools/golang/xenlight/test/maxnodes/maxnodes.c b/tools/golang/xenlight/test/maxnodes/maxnodes.c
new file mode 100644
index 0000000..8f7ce9c
--- /dev/null
+++ b/tools/golang/xenlight/test/maxnodes/maxnodes.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <libxl.h>
+
+int main(){
+
+    libxl_ctx *context;
+    libxl_ctx_alloc(&context,LIBXL_VERSION, 0, NULL);
+    libxl_physinfo info ;
+    int err= libxl_get_physinfo(context,&info);
+    if(err != 0){
+        return err;
+    }
+
+    int max_nodes = libxl_get_max_nodes(context);
+    printf("%d\n", max_nodes);
+
+   libxl_ctx_free(context);
+
+}
+
diff --git a/tools/golang/xenlight/test/maxnodes/maxnodes.go b/tools/golang/xenlight/test/maxnodes/maxnodes.go
new file mode 100644
index 0000000..5f619ff
--- /dev/null
+++ b/tools/golang/xenlight/test/maxnodes/maxnodes.go
@@ -0,0 +1,34 @@
+
+package main
+
+/*
+#cgo LDFLAGS: -lxenlight -lyajl
+#include <stdlib.h>
+#include <libxl.h>
+*/
+import "C"
+import (
+	"fmt"
+	"xenproject.org/xenlight"
+	"os"
+)
+
+func main() {
+	ctx := xenlight.Ctx
+	err := ctx.Open()
+	if err != nil{
+		os.Exit(-1)
+	}
+	defer ctx.Close()
+	if err != nil{
+		os.Exit(-1)
+	}
+
+	max_nodes, err := ctx.GetMaxNodes()
+	if err != nil{
+		fmt.Printf("%d\n", err)
+	}else{
+		fmt.Printf("%d\n", max_nodes)
+	}
+
+}
diff --git a/tools/golang/xenlight/test/onlinecpu/Makefile b/tools/golang/xenlight/test/onlinecpu/Makefile
new file mode 100644
index 0000000..9df2256
--- /dev/null
+++ b/tools/golang/xenlight/test/onlinecpu/Makefile
@@ -0,0 +1,19 @@
+
+test: clean build
+	./onlinecpu.out >> c.output
+	go run onlinecpu.go >> go.output
+	if cmp -s "c.output" "go.output"; then\
+		echo "GetOnlineCpus PASSED";\
+	else \
+		echo "GetOnline FAILED"; \
+	fi\
+
+build:
+	go build -o onlinecpu.a onlinecpu.go
+	gcc onlinecpu.c -lxenlight -lyajl -o onlinecpu.out
+
+clean:
+	rm -f *.a
+	rm -f *.out
+	rm -f *.output
+
diff --git a/tools/golang/xenlight/test/onlinecpu/onlinecpu.c b/tools/golang/xenlight/test/onlinecpu/onlinecpu.c
new file mode 100644
index 0000000..a56ff71
--- /dev/null
+++ b/tools/golang/xenlight/test/onlinecpu/onlinecpu.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <libxl.h>
+
+int main(){
+
+    libxl_ctx *context;
+    libxl_ctx_alloc(&context,LIBXL_VERSION, 0, NULL);
+    libxl_physinfo info ;
+    int err= libxl_get_physinfo(context,&info);
+    if(err != 0){
+        return err;
+    }
+
+    int online_cpus = libxl_get_online_cpus(context);
+    printf("%d\n", online_cpus);
+
+    libxl_ctx_free(context);
+
+}
+
diff --git a/tools/golang/xenlight/test/onlinecpu/onlinecpu.go b/tools/golang/xenlight/test/onlinecpu/onlinecpu.go
new file mode 100644
index 0000000..2c4968e
--- /dev/null
+++ b/tools/golang/xenlight/test/onlinecpu/onlinecpu.go
@@ -0,0 +1,34 @@
+
+package main
+
+/*
+#cgo LDFLAGS: -lxenlight -lyajl
+#include <stdlib.h>
+#include <libxl.h>
+*/
+import "C"
+import (
+	"fmt"
+	"xenproject.org/xenlight"
+	"os"
+)
+
+func main() {
+	ctx := xenlight.Ctx
+	err := ctx.Open()
+	if err != nil{
+		os.Exit(-1)
+	}
+	defer ctx.Close()
+	if err != nil{
+		os.Exit(-1)
+	}
+
+	online_cpus, err := ctx.GetOnlineCpus()
+	if err != nil{
+		fmt.Printf("%d\n", err)
+	}else{
+		fmt.Printf("%d\n", online_cpus)
+	}
+
+}
diff --git a/tools/golang/xenlight/test/physinfo/Makefile b/tools/golang/xenlight/test/physinfo/Makefile
new file mode 100644
index 0000000..87fd171
--- /dev/null
+++ b/tools/golang/xenlight/test/physinfo/Makefile
@@ -0,0 +1,19 @@
+
+test: clean build
+	./physinfo.out >> c.output
+	go run physinfo.go >> go.output
+	if cmp -s "c.output" "go.output"; then\
+		echo "GetPhysinfo PASSED";\
+	else \
+		echo "GetPhysinfo FAILED"; \
+	fi\
+
+build:
+	go build -o physinfo.a physinfo.go 
+	gcc physinfo.c -lxenlight -lyajl -o physinfo.out
+
+clean:
+	rm -f *.a
+	rm -f *.out
+	rm -f *.output
+
diff --git a/tools/golang/xenlight/test/physinfo/physinfo.c b/tools/golang/xenlight/test/physinfo/physinfo.c
new file mode 100644
index 0000000..92c8f47
--- /dev/null
+++ b/tools/golang/xenlight/test/physinfo/physinfo.c
@@ -0,0 +1,31 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <libxl.h>
+
+char *bool_to_string(bool b);
+int main(){
+
+    libxl_ctx *context;
+    libxl_ctx_alloc(&context,LIBXL_VERSION, 0, NULL);
+    libxl_physinfo info ;
+    int err= libxl_get_physinfo(context,&info);
+    if(err != 0){
+        return err;
+    }
+
+    printf("%d\n%d\n%d\n%d\n%d\n", info.threads_per_core, info.cores_per_socket, info.max_cpu_id, info.nr_cpus, info.cpu_khz);
+    printf("%lu\n%lu\n%lu\n%lu\n%lu\n%lu\n", info.total_pages, info.free_pages, info.scrub_pages, info.outstanding_pages, info.sharing_freed_pages, info.sharing_used_frames);
+    printf("%u\n",info.nr_nodes);
+    printf("%s\n%s\n", bool_to_string(info.cap_hvm), bool_to_string(info.cap_hvm_directio));
+
+    for(int i = 0; i < 8; i++){
+        printf("%u\n", info.hw_cap[i]);
+    }
+
+    libxl_ctx_free(context);
+
+}
+
+char * bool_to_string(bool b){
+    return b ? "true": "false";
+}
diff --git a/tools/golang/xenlight/test/physinfo/physinfo.go b/tools/golang/xenlight/test/physinfo/physinfo.go
new file mode 100644
index 0000000..039da59
--- /dev/null
+++ b/tools/golang/xenlight/test/physinfo/physinfo.go
@@ -0,0 +1,36 @@
+
+package main
+
+/*
+#cgo LDFLAGS: -lxenlight -lyajl
+#include <stdlib.h>
+#include <libxl.h>
+*/
+import "C"
+import (
+	"fmt"
+	"xenproject.org/xenlight"
+	"os"
+)
+
+func main() {
+	ctx := xenlight.Ctx
+	err := ctx.Open()
+	if err != nil{
+		os.Exit(-1)
+	}
+	defer ctx.Close()
+	info, err:= ctx.GetPhysinfo()
+	if err != nil{
+		os.Exit(-1)
+	}
+
+	fmt.Printf("%d\n%d\n%d\n%d\n%d\n", info.ThreadsPerCore, info.CoresPerSocket, info.MaxCpuId, info.NrCpus, info.CpuKhz)
+	fmt.Printf("%d\n%d\n%d\n%d\n%d\n%d\n", info.TotalPages, info.FreePages, info.ScrubPages, info.OutstandingPages, info.SharingFreedPages, info.SharingUsedFrames)
+	fmt.Printf("%d\n",info.NrNodes)
+	fmt.Printf("%t\n%t\n", info.CapHvm, info.CapHvmDirectio)
+
+	for i := 0; i < 8; i++ {
+	fmt.Printf("%d\n", info.HwCap[i]);
+	}
+}
diff --git a/tools/golang/xenlight/test/versioninfo/Makefile b/tools/golang/xenlight/test/versioninfo/Makefile
new file mode 100644
index 0000000..0ad1527
--- /dev/null
+++ b/tools/golang/xenlight/test/versioninfo/Makefile
@@ -0,0 +1,18 @@
+
+test: clean build
+	./versioninfo.out >> c.output
+	go run versioninfo.go >> go.output
+	if cmp -s "c.output" "go.output"; then\
+		echo "GetVersionInfo PASSED";\
+	else \
+		echo "GetVersionInfo FAILED"; \
+	fi\
+
+build:
+	go build -o versioninfo.a versioninfo.go 
+	gcc versioninfo.c -lxenlight -lyajl -o versioninfo.out
+
+clean:
+	rm -f *.a
+	rm -f *.out
+	rm -f *.output
diff --git a/tools/golang/xenlight/test/versioninfo/versioninfo.c b/tools/golang/xenlight/test/versioninfo/versioninfo.c
new file mode 100644
index 0000000..f40495d
--- /dev/null
+++ b/tools/golang/xenlight/test/versioninfo/versioninfo.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <libxl.h>
+
+main(){
+
+    libxl_ctx *context;
+    libxl_ctx_alloc(&context,LIBXL_VERSION, 0, NULL);
+    libxl_version_info* info = libxl_get_version_info(context);
+
+    printf("%d\n%d\n", info->xen_version_major, info->xen_version_minor);
+    printf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n", info->xen_version_extra, info->compiler, info->compile_by, info->compile_domain, info->compile_date, info->capabilities, info->changeset);
+    printf("%lu\n%d\n", info->virt_start, info->pagesize);
+    printf("%s\n%s\n", info->commandline, info->build_id);
+
+    libxl_ctx_free(context);
+
+}
diff --git a/tools/golang/xenlight/test/versioninfo/versioninfo.go b/tools/golang/xenlight/test/versioninfo/versioninfo.go
new file mode 100644
index 0000000..cad8391
--- /dev/null
+++ b/tools/golang/xenlight/test/versioninfo/versioninfo.go
@@ -0,0 +1,33 @@
+
+package main
+
+/*
+#cgo LDFLAGS: -lxenlight -lyajl
+#include <stdlib.h>
+#include <libxl.h>
+*/
+import "C"
+import (
+	"fmt"
+	"xenproject.org/xenlight"
+	"os"
+)
+
+func main() {
+	ctx := xenlight.Ctx
+	err := ctx.Open()
+	if err != nil{
+		os.Exit(-1)
+	}
+	defer ctx.Close()
+	info, err:= ctx.GetVersionInfo()
+	if err != nil{
+		os.Exit(-1)
+	}
+
+	fmt.Printf("%d\n%d\n", info.XenVersionMajor, info.XenVersionMinor);
+	fmt.Printf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n", info.XenVersionExtra, info.Compiler, info.CompileBy, info.CompileDomain, info.CompileDate, info.Capabilities, info.Changeset);
+	fmt.Printf("%d\n%d\n", info.VirtStart, info.Pagesize);
+	fmt.Printf("%s\n%s\n", info.Commandline, info.BuildId);
+
+}
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2017-01-23 16:43 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-23 16:43 [PATCH RFC 1/8] golang/xenlight: Create stub package Ronald Rojas
2017-01-23 16:43 ` [PATCH RFC 2/8] golang/xenlight: Add error constants and standard handling Ronald Rojas
2017-01-27 12:22   ` George Dunlap
2017-01-23 16:43 ` [PATCH RFC 3/8] golang/xenlight: Add host-related functionality Ronald Rojas
2017-02-01 15:53   ` George Dunlap
2017-02-01 15:58   ` George Dunlap
2017-02-01 16:05   ` George Dunlap
2017-01-23 16:43 ` [PATCH RFC 4/8] golang/xenlight: Implement libxl_domain_info and libxl_domain_unpause Ronald Rojas
2017-02-01 16:16   ` George Dunlap
2017-01-23 16:43 ` Ronald Rojas [this message]
2017-02-01 17:39   ` [PATCH RFC 5/8] golang/xenlight: Add tests host related functinality functions George Dunlap
2017-01-23 16:43 ` [PATCH RFC 6/8] golang/xenlight: Implement libxl_bitmap and helper operations Ronald Rojas
2017-02-01 17:59   ` George Dunlap
2017-01-23 16:43 ` [PATCH RFC 7/8] golang/xenlight: Implement libxl_scheduler enumeration Ronald Rojas
2017-02-01 18:13   ` George Dunlap
2017-01-23 16:43 ` [PATCH RFC 8/8] golang/xenlight: Implement cpupool operations Ronald Rojas
2017-01-25 16:55 ` [PATCH RFC 1/8] golang/xenlight: Create stub package Wei Liu
2017-01-26  8:13   ` Ronald Rojas
2017-01-25 17:16 ` George Dunlap
2017-01-26  8:26   ` Ronald Rojas
2017-01-26 10:44   ` Ian Jackson
2017-01-26 11:26     ` George Dunlap
2017-01-27 11:43 ` George Dunlap
2017-01-27 19:40 ` George Dunlap

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=20170123164337.4205-5-ronladred@gmail.com \
    --to=ronladred@gmail.com \
    --cc=george.dunlap@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=wei.liu2@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.