Discussion:
[Libstoragemgmt-devel] [PATCH 2/3] plugin_test.py: Call fs_child_dependency_rm regardless
Tony Asleson
2014-12-04 03:55:07 UTC
Permalink
In the case where it really isn't necessary we will check for a None
response which is expected in this case.

Signed-off-by: Tony Asleson <***@redhat.com>
---
test/plugin_test.py | 3 +++
1 file changed, 3 insertions(+)

diff --git a/test/plugin_test.py b/test/plugin_test.py
index 2adcd7b..c5e505d 100755
--- a/test/plugin_test.py
+++ b/test/plugin_test.py
@@ -1225,6 +1225,9 @@ class TestPlugin(unittest.TestCase):

if self.c.fs_child_dependency(fs, None):
self.c.fs_child_dependency_rm(fs, None)
+ else:
+ self.assertTrue(self.c.fs_child_dependency_rm(fs)
+ is None)

self._fs_delete(fs)
if fs_child:
--
1.8.2.1
Tony Asleson
2014-12-04 03:55:08 UTC
Permalink
Plugin IPC for C plugins wasn't allowing some of the parameters to be NULL,
which they can be according to the header documentation. Fixed up code to
accomodate this valie use case. Also fixed a bug in ss_restore, we were
checking v_files twice instead of v_files and v_restore_file.

Signed-off-by: Tony Asleson <***@redhat.com>
---
.../libstoragemgmt/libstoragemgmt_plug_interface.h | 2 ++
c_binding/lsm_plugin_ipc.cpp | 21 +++++++++++++--------
2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_plug_interface.h b/c_binding/include/libstoragemgmt/libstoragemgmt_plug_interface.h
index dc42f23..e7874f7 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_plug_interface.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_plug_interface.h
@@ -573,6 +573,7 @@ typedef int (*lsm_plug_fs_clone)(lsm_plugin_ptr c, lsm_fs *src_fs,
* Determine if a file system has child dependencies, callback function signature
* @param[in] c Valid lsm plug-in pointer
* @param[in] fs File system to check
+ * @param[in] files Specific files to check
* @param[out] yes Boolean
* @return LSM_ERR_OK, else error reason
*/
@@ -584,6 +585,7 @@ typedef int (*lsm_plug_fs_child_dependency)(lsm_plugin_ptr c, lsm_fs *fs,
* Remove dependencies from a file system, callback function signature
* @param[in] c Valid lsm plug-in pointer
* @param[in] fs File system to remove dependencies for
+ * @param[in] files Specific files to remove dependencies for
* @param[out] job Job ID
* @param[out] flags Reserved
* @return LSM_ERR_OK, else error reason
diff --git a/c_binding/lsm_plugin_ipc.cpp b/c_binding/lsm_plugin_ipc.cpp
index 2539d4a..ced64d3 100644
--- a/c_binding/lsm_plugin_ipc.cpp
+++ b/c_binding/lsm_plugin_ipc.cpp
@@ -1653,12 +1653,14 @@ static int fs_child_dependency(lsm_plugin_ptr p, Value &params, Value &response)
Value v_files = params["files"];

if( Value::object_t == v_fs.valueType() &&
- Value::array_t == v_files.valueType() ) {
+ (Value::array_t == v_files.valueType() ||
+ Value::null_t == v_files.valueType()) &&
+ LSM_FLAG_EXPECTED_TYPE(params)) {

lsm_fs *fs = value_to_fs(v_fs);
lsm_string_list *files = value_to_string_list(v_files);

- if( fs && files ) {
+ if( fs ) {
uint8_t yes = 0;

rc = p->fs_ops->fs_child_dependency(p, fs, files, &yes);
@@ -1689,13 +1691,14 @@ static int fs_child_dependency_rm(lsm_plugin_ptr p, Value &params, Value &respon
Value v_files = params["files"];

if( Value::object_t == v_fs.valueType() &&
- Value::array_t == v_files.valueType() &&
- LSM_FLAG_EXPECTED_TYPE(params) ) {
+ (Value::array_t == v_files.valueType() ||
+ Value::null_t == v_files.valueType()) &&
+ LSM_FLAG_EXPECTED_TYPE(params) ) {

lsm_fs *fs = value_to_fs(v_fs);
lsm_string_list *files = value_to_string_list(v_files);

- if( fs && files ) {
+ if( fs ) {
char *job = NULL;

rc = p->fs_ops->fs_child_dependency_rm(p, fs, files, &job,
@@ -1857,8 +1860,10 @@ static int ss_restore(lsm_plugin_ptr p, Value &params, Value &response)

if( Value::object_t == v_fs.valueType() &&
Value::object_t == v_ss.valueType() &&
- Value::array_t == v_files.valueType() &&
- Value::array_t == v_files.valueType() &&
+ (Value::array_t == v_files.valueType() ||
+ Value::null_t == v_files.valueType() ) &&
+ (Value::array_t == v_restore_files.valueType() ||
+ Value::null_t == v_restore_files.valueType()) &&
Value::boolean_t == v_all_files.valueType() &&
LSM_FLAG_EXPECTED_TYPE(params) ) {

@@ -1870,7 +1875,7 @@ static int ss_restore(lsm_plugin_ptr p, Value &params, Value &response)
value_to_string_list(v_restore_files);
int all_files = (v_all_files.asBool()) ? 1 : 0;

- if( fs && ss && files && restore_files ) {
+ if( fs && ss ) {
rc = p->fs_ops->fs_ss_restore(p, fs, ss, files, restore_files,
all_files, &job,
LSM_FLAG_GET_VALUE(params));
--
1.8.2.1
Tony Asleson
2014-12-04 05:53:03 UTC
Permalink
In the case where it really isn't necessary we will check for a None
response which is expected in this case.

V2: Fix call arguments, doh!

Signed-off-by: Tony Asleson <***@redhat.com>
---
test/plugin_test.py | 3 +++
1 file changed, 3 insertions(+)

diff --git a/test/plugin_test.py b/test/plugin_test.py
index 2adcd7b..c5e505d 100755
--- a/test/plugin_test.py
+++ b/test/plugin_test.py
@@ -1225,6 +1225,9 @@ class TestPlugin(unittest.TestCase):

if self.c.fs_child_dependency(fs, None):
self.c.fs_child_dependency_rm(fs, None)
+ else:
+ self.assertTrue(self.c.fs_child_dependency_rm(fs)
+ is None)

self._fs_delete(fs)
if fs_child:
--
1.8.2.1
Tony Asleson
2014-12-04 05:57:32 UTC
Permalink
Disregard this one...not the updated one, /sigh

Getting too tired.

-Tony
Post by Tony Asleson
In the case where it really isn't necessary we will check for a None
response which is expected in this case.
V2: Fix call arguments, doh!
---
test/plugin_test.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/test/plugin_test.py b/test/plugin_test.py
index 2adcd7b..c5e505d 100755
--- a/test/plugin_test.py
+++ b/test/plugin_test.py
self.c.fs_child_dependency_rm(fs, None)
+ self.assertTrue(self.c.fs_child_dependency_rm(fs)
+ is None)
self._fs_delete(fs)
Tony Asleson
2014-12-04 05:56:55 UTC
Permalink
In the case where it really isn't necessary we will check for a None
response which is expected in this case.

V2: Fix call arguments, doh!

Signed-off-by: Tony Asleson <***@redhat.com>
---
test/plugin_test.py | 3 +++
1 file changed, 3 insertions(+)

diff --git a/test/plugin_test.py b/test/plugin_test.py
index 2adcd7b..e92497c 100755
--- a/test/plugin_test.py
+++ b/test/plugin_test.py
@@ -1225,6 +1225,9 @@ class TestPlugin(unittest.TestCase):

if self.c.fs_child_dependency(fs, None):
self.c.fs_child_dependency_rm(fs, None)
+ else:
+ self.assertTrue(self.c.fs_child_dependency_rm(fs, None)
+ is None)

self._fs_delete(fs)
if fs_child:
--
1.8.2.1
Loading...