aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxen/test
diff options
context:
space:
mode:
authorEwan Mellor <ewan@xensource.com>2007-03-26 00:08:13 +0100
committerEwan Mellor <ewan@xensource.com>2007-03-26 00:08:13 +0100
commit9c052c30d622e56b466870e0084d943508676e3f (patch)
tree49e641759b3a988eead407751fd85f919067256d /tools/libxen/test
parent231f7bf638ac8c7349000f942065b2bb6eadaa3d (diff)
downloadxen-9c052c30d622e56b466870e0084d943508676e3f.tar.gz
xen-9c052c30d622e56b466870e0084d943508676e3f.tar.bz2
xen-9c052c30d622e56b466870e0084d943508676e3f.zip
Implement session.last_active, session.this_host, session.get_record,
session.get_uuid. Signed-off-by: Ewan Mellor <ewan@xensource.com>
Diffstat (limited to 'tools/libxen/test')
-rw-r--r--tools/libxen/test/test_bindings.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/tools/libxen/test/test_bindings.c b/tools/libxen/test/test_bindings.c
index 922518fe8a..bc4d875160 100644
--- a/tools/libxen/test/test_bindings.c
+++ b/tools/libxen/test/test_bindings.c
@@ -17,6 +17,7 @@
*/
#define _GNU_SOURCE
+#include <assert.h>
#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
@@ -61,6 +62,7 @@ typedef struct
static xen_vm create_new_vm(xen_session *session, bool hvm);
+static void print_session_info(xen_session *session);
static void print_vm_power_state(xen_session *session, xen_vm vm);
static void print_vm_metrics(xen_session *session, xen_vm vm);
@@ -144,6 +146,14 @@ int main(int argc, char **argv)
xen_session *session =
xen_session_login_with_password(call_func, NULL, username, password);
+ print_session_info(session);
+ if (!session->ok)
+ {
+ /* Error has been logged, just clean up. */
+ CLEANUP;
+ return 1;
+ }
+
xen_vm vm;
if (!xen_vm_get_by_uuid(session, &vm,
"00000000-0000-0000-0000-000000000000"))
@@ -184,7 +194,7 @@ int main(int argc, char **argv)
}
xen_host host;
- if (!xen_session_get_this_host(session, &host))
+ if (!xen_session_get_this_host(session, &host, session))
{
print_error(session);
xen_vm_record_free(vm_record);
@@ -583,6 +593,44 @@ static size_t my_strftime(char *s, size_t max, const char *fmt,
/**
+ * Print some session details.
+ */
+static void print_session_info(xen_session *session)
+{
+ xen_session_record *record;
+ if (!xen_session_get_record(session, &record, session))
+ {
+ print_error(session);
+ return;
+ }
+
+ printf("Session UUID: %s.\n", record->uuid);
+ printf("Session user: %s.\n", record->this_user);
+ char time[256];
+ struct tm *tm = localtime(&record->last_active);
+ my_strftime(time, 256, "Session last active: %c, local time.\n", tm);
+ printf(time);
+
+ char *uuid = NULL;
+ char *this_user = NULL;
+ xen_session_get_uuid(session, &uuid, session);
+ xen_session_get_this_user(session, &this_user, session);
+
+ if (!session->ok)
+ {
+ xen_session_record_free(record);
+ print_error(session);
+ return;
+ }
+
+ assert(!strcmp(record->uuid, uuid));
+ assert(!strcmp(record->this_user, this_user));
+
+ xen_session_record_free(record);
+}
+
+
+/**
* Print the metrics for the given VM.
*/
static void print_vm_metrics(xen_session *session, xen_vm vm)