On Friday, May 3, 2019, Vojtech Juranek <vjuranek@redhat.com> wrote:
> Previous patch switched from accepting align and sector flags to values.
> Exposing internal sanlock flags doesn't make sense now. Tuples with
> supported sector size and alignment values should be exposed instead.
> ---
> python/sanlock.c | 18 ++++++++++++++++++
> tests/python_test.py | 8 ++++----
> 2 files changed, 22 insertions(+), 4 deletions(-)
>
> diff --git a/python/sanlock.c b/python/sanlock.c
> index 3cd91f2..a1215bd 100644
> --- a/python/sanlock.c
> +++ b/python/sanlock.c
> @@ -1729,4 +1729,22 @@ initsanlock(void)
> PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_ALIGN8M, "ALIGN8M");
>
> #undef PYSNLK_INIT_ADD_CONSTANT
> +
> + /* Tuples with supported sector size and alignment values */
> + PyObject *sector = Py_BuildValue("ii", SECTOR_SIZE_512, SECTOR_SIZE_4K);
> + if (!sector)
> + return;
> + if (PyModule_AddObject(py_module, "SECTOR_SIZE", sector)) {
> + Py_DECREF(sector);
> + return;
> + }
> +
> + PyObject *align = Py_BuildValue("llll", ALIGNMENT_1M, ALIGNMENT_2M, ALIGNMENT_4M, ALIGNMENT_8M);
> + if (!align)
> + return;
> + if (PyModule_AddObject(py_module, "ALIGN_SIZE", align)) {
> + Py_DECREF(align);
> + return;
> + }
> +
> }
> diff --git a/tests/python_test.py b/tests/python_test.py
> index 5b1bb43..a0474f1 100644
> --- a/tests/python_test.py
> +++ b/tests/python_test.py
> @@ -256,9 +256,9 @@ def test_acquire_release_resource(tmpdir, sanlock_daemon, size, offset):
>
> @pytest.mark.parametrize("align, sector", [
> # Invalid alignment
> - (1024, 512),
> + (1024, sanlock.SECTOR_SIZE[0]),
> # Invalid sector size
> - (1048576, 8192),
> + (sanlock.ALIGN_SIZE[0], 8192),
> ])
> def test_write_lockspace_invalid_align_sector(
> tmpdir, sanlock_daemon, align, sector):
> @@ -271,9 +271,9 @@ def test_write_lockspace_invalid_align_sector(
>
> @pytest.mark.parametrize("align, sector", [
> # Invalid alignment
> - (1024, 512),
> + (1024, sanlock.SECTOR_SIZE[0]),
> # Invalid sector size
> - (1048576, 8192),
> + (sanlock.ALIGN_SIZE[0], 8192),
> ])
> def test_write_resource_invalid_align_sector(
> tmpdir, sanlock_daemon, align, sector):
> --
> 2.20.1
>
>
Looks good