From 498f6aa2bacde85596fac295da81bd28a182f535 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Thu, 26 Jan 2012 17:26:57 +0100 Subject: [PATCH] Fix core tests in master --- src/image/test/ImagePoolTest.cc | 106 ++------------------------ src/test/NebulaTest.cc | 8 +- src/vm/test/VirtualMachinePoolTest.cc | 11 ++- 3 files changed, 22 insertions(+), 103 deletions(-) diff --git a/src/image/test/ImagePoolTest.cc b/src/image/test/ImagePoolTest.cc index 818454324b..5e56e25485 100644 --- a/src/image/test/ImagePoolTest.cc +++ b/src/image/test/ImagePoolTest.cc @@ -87,13 +87,15 @@ public: class ImagePoolFriend : public ImagePool { public: - ImagePoolFriend(SqlDB * db, - const string& _default_type, - const string& _default_dev_prefix): + ImagePoolFriend(SqlDB * db, + const string& _default_type, + const string& _default_dev_prefix, + vector _restricted_attrs): ImagePool( db, _default_type, - _default_dev_prefix){}; + _default_dev_prefix, + _restricted_attrs){}; int allocate(const int& uid, const std::string& stemplate, int* oid) @@ -251,7 +253,8 @@ public: // Create a new pool, using the same DB. This new pool should read the // allocated images. - imp = new ImagePool(db,"OS", "hd"); + vector restricted_attrs; + imp = new ImagePool(db,"OS", "hd", restricted_attrs); img = imp->get(0, false); CPPUNIT_ASSERT( img != 0 ); @@ -654,99 +657,6 @@ public: delete disk; } -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ -/* - void public_attribute() - { - int oid; - ImagePoolFriend * imp = static_cast(pool); - Image * img; - - string templates[] = - { - // false - "NAME = \"name A\"\n" - "PATH = \"/tmp/nothing\"\n", - - // true - "NAME = \"name B\"\n" - "PATH = \"/tmp/nothing\"\n" - "PUBLIC = YES", - - // false - "NAME = \"name C\"\n" - "PATH = \"/tmp/nothing\"\n" - "PUBLIC = NO", - - // false - "NAME = \"name D\"\n" - "PATH = \"/tmp/nothing\"\n" - "PUBLIC = 1", - - // true - "NAME = \"name E\"\n" - "PATH = \"/tmp/nothing\"\n" - "PUBLIC = Yes", - - // false - "NAME = \"name F\"\n" - "PATH = \"/tmp/nothing\"\n" - "PUBLIC = TRUE", - - // true - "NAME = \"name G\"\n" - "PATH = \"/tmp/nothing\"\n" - "PUBLIC = yes", - - // false - "NAME = \"name H\"\n" - "PATH = \"/tmp/nothing\"\n" - "PUBLIC = 'YES'", - - // true - "NAME = \"name I\"\n" - "PATH = \"/tmp/nothing\"\n" - "PUBLIC = \"YES\"", - - "END" - }; - - bool results[] = { false, true, false, false, - true, false, true, false, true }; - - int i = 0; - while( templates[i] != "END" ) - { - - imp->allocate(0, templates[i], &oid); - - CPPUNIT_ASSERT( oid >= 0 ); - - img = imp->get( oid, false ); - CPPUNIT_ASSERT( img != 0 ); -//cout << endl << i << " : exp. " << results[i] << " got " << img->is_public(); - - CPPUNIT_ASSERT( img->isPublic() == results[i] ); - - i++; - } - - int success; - - // img 0 is not public. - img = imp->get( 0, false ); - CPPUNIT_ASSERT( img != 0 ); - - success = img->publish(false); - CPPUNIT_ASSERT( success == 0 ); - CPPUNIT_ASSERT( img->isPublic() == false ); - - success = img->publish(true); - CPPUNIT_ASSERT( success == 0 ); - CPPUNIT_ASSERT( img->isPublic() == true ); - } -*/ /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ /* diff --git a/src/test/NebulaTest.cc b/src/test/NebulaTest.cc index e3cf978463..eda496815d 100644 --- a/src/test/NebulaTest.cc +++ b/src/test/NebulaTest.cc @@ -22,7 +22,9 @@ VirtualMachinePool* NebulaTest::create_vmpool(SqlDB* db, string hook_location, string vloc) { vector hooks; - return new VirtualMachinePool(db, hooks, hook_location, vloc); + vector restricted_attrs; + + return new VirtualMachinePool(db, hooks, hook_location, vloc, restricted_attrs); } HostPool* NebulaTest::create_hpool(SqlDB* db, string hook_location, string vloc) @@ -45,7 +47,9 @@ ImagePool* NebulaTest::create_ipool( SqlDB* db, string default_image_type, string default_device_prefix) { - return new ImagePool(db,default_image_type,default_device_prefix); + vector restricted_attrs; + + return new ImagePool(db, default_image_type, default_device_prefix, restricted_attrs); } VMTemplatePool* NebulaTest::create_tpool(SqlDB* db) diff --git a/src/vm/test/VirtualMachinePoolTest.cc b/src/vm/test/VirtualMachinePoolTest.cc index ae6ecd8b1d..d74ecfbc3d 100644 --- a/src/vm/test/VirtualMachinePoolTest.cc +++ b/src/vm/test/VirtualMachinePoolTest.cc @@ -74,8 +74,11 @@ const string xml_history_dump = class VirtualMachinePoolFriend : public VirtualMachinePool { public: - VirtualMachinePoolFriend(SqlDB * db, vector hook_mads): - VirtualMachinePool(db, hook_mads, "./", "./") + VirtualMachinePoolFriend( + SqlDB * db, + vector hook_mads, + vector restricted_attrs): + VirtualMachinePool(db, hook_mads, "./", "./", restricted_attrs) {}; @@ -138,7 +141,9 @@ protected: { // The VM pool needs a vector containing the vm hooks vector vm_hooks; - return new VirtualMachinePoolFriend(db, vm_hooks); + vector restricted_attrs; + + return new VirtualMachinePoolFriend(db, vm_hooks, restricted_attrs); }; int allocate(int index)