From 589fa7a87572c1a9c6bae495c60a154c1df4433b Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 9 Jun 2011 10:51:17 +0200 Subject: [PATCH] feature #407: Fixes Image tests. persistent method returns 0 (not true) for successful operations --- include/Image.h | 10 +++++----- src/image/test/ImagePoolTest.cc | 20 ++++++++++---------- src/rm/RequestManagerImage.cc | 6 +++--- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/include/Image.h b/include/Image.h index 00e3d82d30..ad40595233 100644 --- a/include/Image.h +++ b/include/Image.h @@ -207,25 +207,25 @@ public: * @param persistent true to make an image persistent * @return 0 on success */ - bool persistent(bool persis) + int persistent(bool persis) { - bool success = false; + int rc = -1; if (persis == true) { if (!isPublic() && running_vms == 0) { persistent_img = 1; - success = true; + rc = 0; } } else { persistent_img = 0; - success = true; + rc = 0; } - return success; + return rc; } /** diff --git a/src/image/test/ImagePoolTest.cc b/src/image/test/ImagePoolTest.cc index 771fda7b37..d7745bd474 100644 --- a/src/image/test/ImagePoolTest.cc +++ b/src/image/test/ImagePoolTest.cc @@ -779,18 +779,18 @@ public: i++; } - bool success; + int success; // img 0 is not public. img = imp->get( 0, false ); CPPUNIT_ASSERT( img != 0 ); success = img->publish(false); - CPPUNIT_ASSERT( success == true ); + CPPUNIT_ASSERT( success == 0 ); CPPUNIT_ASSERT( img->isPublic() == false ); success = img->publish(true); - CPPUNIT_ASSERT( success == true ); + CPPUNIT_ASSERT( success == 0 ); CPPUNIT_ASSERT( img->isPublic() == true ); } @@ -800,7 +800,7 @@ public: void persistence() { int oid; - bool success; + int success; ImagePoolFriend * imp = static_cast(pool); Image * img; @@ -856,33 +856,33 @@ public: // make it persistent success = img->persistent(true); - CPPUNIT_ASSERT( success == true ); + CPPUNIT_ASSERT( success == 0 ); CPPUNIT_ASSERT( img->isPersistent() == true ); // it isn't public, try to unpublish success = img->publish(false); - CPPUNIT_ASSERT( success == true ); + CPPUNIT_ASSERT( success == 0 ); CPPUNIT_ASSERT( img->isPublic() == false ); // try to publish, should fail because it is persistent success = img->publish(true); - CPPUNIT_ASSERT( success == false ); + CPPUNIT_ASSERT( success == -1 ); CPPUNIT_ASSERT( img->isPublic() == false ); // make it non-persistent success = img->persistent(false); - CPPUNIT_ASSERT( success == true ); + CPPUNIT_ASSERT( success == 0 ); CPPUNIT_ASSERT( img->isPersistent() == false ); // it isn't public, try to unpublish success = img->publish(false); - CPPUNIT_ASSERT( success == true ); + CPPUNIT_ASSERT( success == 0 ); CPPUNIT_ASSERT( img->isPublic() == false ); // try to publish, now it should be possible success = img->publish(true); - CPPUNIT_ASSERT( success == true ); + CPPUNIT_ASSERT( success == 0 ); CPPUNIT_ASSERT( img->isPublic() == true ); } diff --git a/src/rm/RequestManagerImage.cc b/src/rm/RequestManagerImage.cc index 39cb8530a7..25de63586e 100644 --- a/src/rm/RequestManagerImage.cc +++ b/src/rm/RequestManagerImage.cc @@ -64,7 +64,7 @@ void ImagePersistent::request_execute(xmlrpc_c::paramList const& paramList) { int id = xmlrpc_c::value_int(paramList.getInt(1)); bool persistent_flag = xmlrpc_c::value_boolean(paramList.getBoolean(2)); - bool result; + int rc; Image * image; string err_msg; @@ -82,9 +82,9 @@ void ImagePersistent::request_execute(xmlrpc_c::paramList const& paramList) return; } - result = image->persistent(persistent_flag); + rc = image->persistent(persistent_flag); - if ( !result ) + if ( rc != 0 ) { if (persistent_flag == true) {