[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] examples: Update event tests for shutdown event



---
 examples/domain-events/events-c/event-test.c       |   22 ++++++++++++++-----
 examples/domain-events/events-python/event-test.py |    6 +++-
 2 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/examples/domain-events/events-c/event-test.c b/examples/domain-events/events-c/event-test.c
index 648e6ea..f4938c4 100644
--- a/examples/domain-events/events-c/event-test.c
+++ b/examples/domain-events/events-c/event-test.c
@@ -40,7 +40,7 @@ void usage(const char *pname);
 
 const char *eventToString(int event) {
     const char *ret = "";
-    switch(event) {
+    switch ((virDomainEventType) event) {
         case VIR_DOMAIN_EVENT_DEFINED:
             ret ="Defined";
             break;
@@ -59,13 +59,16 @@ const char *eventToString(int event) {
         case VIR_DOMAIN_EVENT_STOPPED:
             ret ="Stopped";
             break;
+        case VIR_DOMAIN_EVENT_SHUTDOWN:
+            ret = "Shutdown";
+            break;
     }
     return ret;
 }
 
 static const char *eventDetailToString(int event, int detail) {
     const char *ret = "";
-    switch(event) {
+    switch ((virDomainEventType) event) {
         case VIR_DOMAIN_EVENT_DEFINED:
             if (detail == VIR_DOMAIN_EVENT_DEFINED_ADDED)
                 ret = "Added";
@@ -77,7 +80,7 @@ static const char *eventDetailToString(int event, int detail) {
                 ret = "Removed";
             break;
         case VIR_DOMAIN_EVENT_STARTED:
-            switch (detail) {
+            switch ((virDomainEventStartedDetailType) detail) {
             case VIR_DOMAIN_EVENT_STARTED_BOOTED:
                 ret = "Booted";
                 break;
@@ -93,7 +96,7 @@ static const char *eventDetailToString(int event, int detail) {
             }
             break;
         case VIR_DOMAIN_EVENT_SUSPENDED:
-            switch (detail) {
+            switch ((virDomainEventSuspendedDetailType) detail) {
             case VIR_DOMAIN_EVENT_SUSPENDED_PAUSED:
                 ret = "Paused";
                 break;
@@ -115,7 +118,7 @@ static const char *eventDetailToString(int event, int detail) {
             }
             break;
         case VIR_DOMAIN_EVENT_RESUMED:
-            switch (detail) {
+            switch ((virDomainEventResumedDetailType) detail) {
             case VIR_DOMAIN_EVENT_RESUMED_UNPAUSED:
                 ret = "Unpaused";
                 break;
@@ -128,7 +131,7 @@ static const char *eventDetailToString(int event, int detail) {
             }
             break;
         case VIR_DOMAIN_EVENT_STOPPED:
-            switch (detail) {
+            switch ((virDomainEventStoppedDetailType) detail) {
             case VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN:
                 ret = "Shutdown";
                 break;
@@ -152,6 +155,13 @@ static const char *eventDetailToString(int event, int detail) {
                 break;
             }
             break;
+        case VIR_DOMAIN_EVENT_SHUTDOWN:
+            switch ((virDomainEventShutdownDetailType) detail) {
+            case VIR_DOMAIN_EVENT_SHUTDOWN_FINISHED:
+                ret = "Finished";
+                break;
+            }
+            break;
     }
     return ret;
 }
diff --git a/examples/domain-events/events-python/event-test.py b/examples/domain-events/events-python/event-test.py
index 60a9c34..0c75091 100644
--- a/examples/domain-events/events-python/event-test.py
+++ b/examples/domain-events/events-python/event-test.py
@@ -430,7 +430,8 @@ def eventToString(event):
                      "Started",
                      "Suspended",
                      "Resumed",
-                     "Stopped" );
+                     "Stopped",
+                     "Shutdown" );
     return eventStrings[event];
 
 def detailToString(event, detail):
@@ -440,7 +441,8 @@ def detailToString(event, detail):
         ( "Booted", "Migrated", "Restored", "Snapshot" ),
         ( "Paused", "Migrated", "IOError", "Watchdog" ),
         ( "Unpaused", "Migrated"),
-        ( "Shutdown", "Destroyed", "Crashed", "Migrated", "Saved", "Failed", "Snapshot")
+        ( "Shutdown", "Destroyed", "Crashed", "Migrated", "Saved", "Failed", "Snapshot"),
+        ( "Finished" )
         )
     return eventStrings[event][detail]
 
-- 
1.7.8


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]