1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

Fix ImagePoolTest::persistence test

This commit is contained in:
Carlos Martín 2012-01-26 17:47:13 +01:00
parent 498f6aa2ba
commit a0d0bd1dbb

View File

@ -145,8 +145,7 @@ class ImagePoolTest : public PoolTest
CPPUNIT_TEST ( wrong_templates );
CPPUNIT_TEST ( target_generation );
CPPUNIT_TEST ( bus_source_assignment );
// CPPUNIT_TEST ( public_attribute );
// CPPUNIT_TEST ( persistence );
CPPUNIT_TEST ( persistence );
CPPUNIT_TEST ( imagepool_disk_attribute );
CPPUNIT_TEST ( dump );
CPPUNIT_TEST ( dump_where );
@ -659,7 +658,7 @@ public:
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/*
void persistence()
{
int oid;
@ -672,44 +671,32 @@ public:
{
"NAME = \"Image 1\"\n"
"PERSISTENT = NO\n"
"PUBLIC = NO\n"
"PATH = /dev/null\n",
"NAME = \"Image 2\"\n"
"PERSISTENT = NO\n"
"PUBLIC = YES\n"
"PATH = /dev/null\n",
"NAME = \"Image 3\"\n"
"PERSISTENT = YES\n"
"PUBLIC = NO\n"
"PATH = /dev/null\n",
"NAME = \"Image 4\"\n"
"PERSISTENT = YES\n"
"PUBLIC = YES\n"
"PATH = /dev/null\n",
"END"
};
bool results[] = { true, true, true, false };
bool persistent[] = { false, false, true };
int i = 0;
while( templates[i] != "END" )
{
imp->allocate(0, templates[i], &oid);
//cout << endl << i << " : exp. " << results[i] << " got " << (oid >= 0);
CPPUNIT_ASSERT( (oid >= 0) == results[i] );
if( oid >= 0 )
{
img = imp->get( oid, false );
CPPUNIT_ASSERT( img != 0 );
CPPUNIT_ASSERT( oid >= 0 );
CPPUNIT_ASSERT( img->isPersistent() == persistent[i] );
}
img = imp->get( oid, false );
CPPUNIT_ASSERT( img != 0 );
CPPUNIT_ASSERT( img->isPersistent() == persistent[i] );
i++;
}
@ -724,12 +711,12 @@ public:
CPPUNIT_ASSERT( img->isPersistent() == true );
// it isn't public, try to unpublish
success = img->publish(false);
success = img->set_permissions(1,1,0, 0,0,0, 0,0,0, error_msg);
CPPUNIT_ASSERT( success == 0 );
CPPUNIT_ASSERT( img->isPublic() == false );
// try to publish, should fail because it is persistent
success = img->publish(true);
success = img->set_permissions(1,1,0, 1,0,0, 0,0,0, error_msg);
CPPUNIT_ASSERT( success == -1 );
CPPUNIT_ASSERT( img->isPublic() == false );
@ -740,16 +727,16 @@ public:
CPPUNIT_ASSERT( img->isPersistent() == false );
// it isn't public, try to unpublish
success = img->publish(false);
success = img->set_permissions(1,1,0, 0,0,0, 0,0,0, error_msg);
CPPUNIT_ASSERT( success == 0 );
CPPUNIT_ASSERT( img->isPublic() == false );
// try to publish, now it should be possible
success = img->publish(true);
success = img->set_permissions(1,1,0, 1,0,0, 0,0,0, error_msg);
CPPUNIT_ASSERT( success == 0 );
CPPUNIT_ASSERT( img->isPublic() == true );
}
*/
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */