Re: [parted-devel] [PATCH v2 4/4] libparted/dasd: add test cases for the new fdasd functions

2017-04-20 Thread Phil Susi
On 4/20/2017 4:20 AM, Wang Dong wrote:
> The test case uses a temporary file in libparted/tests under
> Check framwork.It can be issued by "make check" in the test dir.

I get a number of errors like this:

volser.c:78:14: error: unused variable 'vol' [-Werror=unused-variable]
 char vol[7] = {0};




[parted-devel] [PATCH v2 4/4] libparted/dasd: add test cases for the new fdasd functions

2017-04-20 Thread Wang Dong
The test case uses a temporary file in libparted/tests under
Check framwork.It can be issued by "make check" in the test dir.

Signed-off-by: Wang Dong 
Signed-off-by: Hendrik Brueckner 
---
 libparted/tests/t4000-volser.sh |  20 +
 libparted/tests/volser.c| 188 
 2 files changed, 208 insertions(+)
 create mode 100755 libparted/tests/t4000-volser.sh
 create mode 100644 libparted/tests/volser.c

diff --git a/libparted/tests/t4000-volser.sh b/libparted/tests/t4000-volser.sh
new file mode 100755
index 000..89688ba
--- /dev/null
+++ b/libparted/tests/t4000-volser.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see .
+
+. "${top_srcdir=../..}/tests/init.sh"; path_prepend_ .
+
+volser || fail=1
+
+Exit $fail
diff --git a/libparted/tests/volser.c b/libparted/tests/volser.c
new file mode 100644
index 000..9063821
--- /dev/null
+++ b/libparted/tests/volser.c
@@ -0,0 +1,188 @@
+/*
+ * Author: Wang Dong 
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include "../arch/linux.h"
+#include "common.h"
+#include "progname.h"
+
+/* set dasd first */
+static char vol_devno[7] = {0};
+static char *tmp_disk;
+static int fd;
+
+static PedDisk *disk;
+static struct fdasd_anchor anc;
+static fdasd_anchor_t *anchor = &anc;
+static LinuxSpecific *arch_specific;
+
+/* set the enviroment */
+static void set_test (void)
+{
+PedDevice *dev;
+PedDiskType *type;
+type = ped_disk_type_get ("dasd");
+
+tmp_disk = _create_disk (20*1024*1024);
+fail_if (tmp_disk == NULL, "Failed to create temporary disk");
+dev = ped_device_get (tmp_disk);
+if (dev == NULL)
+return;
+
+disk = _create_disk_label (dev, type);
+if (!ped_device_open (disk->dev))
+return;
+
+fdasd_initialize_anchor (anchor);
+arch_specific = LINUX_SPECIFIC (disk->dev);
+fd = arch_specific->fd;
+if (!fdasd_get_geometry (dev, anchor, fd))
+return;
+
+fdasd_check_volume (anchor, fd);
+sprintf (vol_devno, "0X%04x", anchor->devno);
+ck_assert (strlen (vol_devno) == VOLSER_LENGTH);
+}
+
+static void free_test (void)
+{
+ped_device_close (disk->dev);
+ped_device_destroy (disk->dev);
+unlink (tmp_disk);
+free (tmp_disk);
+fdasd_cleanup (anchor);
+}
+
+/* Test with default volser */
+START_TEST (test_get_volser)
+{
+char volser[7] = {0};
+fdasd_change_volser (anchor, vol_devno);
+fdasd_write_labels (anchor, fd);
+
+fdasd_get_volser (anchor, volser, fd);
+ck_assert (!strcmp (volser, vol_devno));
+}
+END_TEST
+
+START_TEST (test_check_volser)
+{
+char vol[7] = {0};
+char vol_long[] = "abcdefg";
+char vol_short[] = "ab_c   ";
+char vol_null[] = "  ";
+char *vol_input = NULL;
+
+vol_input = vol_long;
+fdasd_check_volser (vol_input, anchor->devno);
+ck_assert(!strcmp (vol_input, "ABCDEF"));
+
+vol_input = vol_short;
+fdasd_check_volser (vol_input, anchor->devno);
+ck_assert (!strcmp (vol_input, "ABC"));
+
+vol_input = vol_null;
+fdasd_check_volser (vol_input, anchor->devno);
+ck_assert (!strcmp (vol_input, vol_devno));
+}
+END_TEST
+
+START_TEST (test_change_volser)
+{
+
+char vol[] = "00";
+char volser[7] = {0};
+
+fdasd_change_volser (anchor, vol);
+fdasd_write_labels (anchor, fd);
+
+fdasd_get_volser (anchor, volser, fd);
+ck_assert (!strcmp (volser, vol));
+}
+END_TEST
+
+/*
+ * fdsad_recreate_vtoc recreate the VTOC with existing one.
+ * So the partition information should be not changed after recreating
+ * VTOC.
+*/
+START_TEST (test_reuse_vtoc)
+{
+ds5ext_t before;
+ds5ext_t after;
+
+memcpy (&before, &anchor->f5->DS5AVEXT, sizeof(ds5ext_t));
+
+if (anchor->fspace_trk) {
+fdasd_reuse_vtoc (anchor);
+memcpy (&after, &anchor->f5->DS5AVEXT, sizeof(ds5ext_t));
+if ((before.t != after.t) && (before.fc != after.fc) && 
(before.ft != after.ft))
+ck_abort ();
+} else {
+fdasd_reuse_vtoc (anchor);
+memcpy (&after, &anchor->f5->

Re: [parted-devel] [PATCH v2 4/4] libparted/dasd: add test cases for the new fdasd functions

2017-04-19 Thread Phil Susi
On 4/18/2017 11:32 PM, Wang Dong wrote:
> Yes, but I have not get the access to master branch.
> I think only maintainer can do this.
> I thought you were a maintainer. I will contact the maintainer then.
> Thanks for your catch.

Everyone has access to the master branch.  You just can't push to it.
You need to git pull --rebase.



Re: [parted-devel] [PATCH v2 4/4] libparted/dasd: add test cases for the new fdasd functions

2017-04-18 Thread Wang Dong



On 04/18/2017 09:12 PM, Phil Susi wrote:

On 4/18/2017 12:23 AM, Wang Dong wrote:

The test case uses a temporary file in libparted/tests under
Check framwork.It can be issued by "make check" in the test dir.

Signed-off-by: Wang Dong 
Signed-off-by: Hendrik Brueckner 

The previous patch with the missing file was already pushed back in
December.  Please rebase it onto the current master.

Yes, but I have not get the access to master branch.
I think only maintainer can do this.
I thought you were a maintainer. I will contact the maintainer then.
Thanks for your catch.




--
Best regards. Wang Dong




Re: [parted-devel] [PATCH v2 4/4] libparted/dasd: add test cases for the new fdasd functions

2017-04-18 Thread Phil Susi
On 4/18/2017 12:23 AM, Wang Dong wrote:
> The test case uses a temporary file in libparted/tests under
> Check framwork.It can be issued by "make check" in the test dir.
> 
> Signed-off-by: Wang Dong 
> Signed-off-by: Hendrik Brueckner 

The previous patch with the missing file was already pushed back in
December.  Please rebase it onto the current master.





Re: [parted-devel] [PATCH v2 4/4] libparted/dasd: add test cases for the new fdasd functions

2017-04-17 Thread Wang Dong

Please ignore last mail. I missed some in haste.

This is the one.


On 04/18/2017 12:23 PM, Wang Dong wrote:

The test case uses a temporary file in libparted/tests under
Check framwork.It can be issued by "make check" in the test dir.

Signed-off-by: Wang Dong 
Signed-off-by: Hendrik Brueckner 
---
  libparted/tests/Makefile.am |   5 +-
  libparted/tests/t4000-volser.sh |  20 +
  libparted/tests/volser.c| 188 
  3 files changed, 211 insertions(+), 2 deletions(-)
  create mode 100755 libparted/tests/t4000-volser.sh
  create mode 100644 libparted/tests/volser.c

diff --git a/libparted/tests/Makefile.am b/libparted/tests/Makefile.am
index c7c10a9..9689fb3 100644
--- a/libparted/tests/Makefile.am
+++ b/libparted/tests/Makefile.am
@@ -3,9 +3,9 @@
  #
  # This file may be modified and/or distributed without restriction.

-TESTS = t1000-label.sh t2000-disk.sh t2100-zerolen.sh t3000-symlink.sh
+TESTS = t1000-label.sh t2000-disk.sh t2100-zerolen.sh t3000-symlink.sh 
t4000-volser.sh
  EXTRA_DIST = $(TESTS)
-check_PROGRAMS = label disk zerolen symlink
+check_PROGRAMS = label disk zerolen symlink volser
  AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)

  LDADD = \
@@ -23,6 +23,7 @@ label_SOURCES = common.h common.c label.c
  disk_SOURCES  = common.h common.c disk.c
  zerolen_SOURCES = common.h common.c zerolen.c
  symlink_SOURCES = common.h common.c symlink.c
+volser_SOURCES = common.h common.c volser.c

  # Arrange to symlink to tests/init.sh.
  CLEANFILES = init.sh
diff --git a/libparted/tests/t4000-volser.sh b/libparted/tests/t4000-volser.sh
new file mode 100755
index 000..89688ba
--- /dev/null
+++ b/libparted/tests/t4000-volser.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see .
+
+. "${top_srcdir=../..}/tests/init.sh"; path_prepend_ .
+
+volser || fail=1
+
+Exit $fail
diff --git a/libparted/tests/volser.c b/libparted/tests/volser.c
new file mode 100644
index 000..9063821
--- /dev/null
+++ b/libparted/tests/volser.c
@@ -0,0 +1,188 @@
+/*
+ * Author: Wang Dong 
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include "../arch/linux.h"
+#include "common.h"
+#include "progname.h"
+
+/* set dasd first */
+static char vol_devno[7] = {0};
+static char *tmp_disk;
+static int fd;
+
+static PedDisk *disk;
+static struct fdasd_anchor anc;
+static fdasd_anchor_t *anchor = &anc;
+static LinuxSpecific *arch_specific;
+
+/* set the enviroment */
+static void set_test (void)
+{
+PedDevice *dev;
+PedDiskType *type;
+type = ped_disk_type_get ("dasd");
+
+tmp_disk = _create_disk (20*1024*1024);
+fail_if (tmp_disk == NULL, "Failed to create temporary disk");
+dev = ped_device_get (tmp_disk);
+if (dev == NULL)
+return;
+
+disk = _create_disk_label (dev, type);
+if (!ped_device_open (disk->dev))
+return;
+
+fdasd_initialize_anchor (anchor);
+arch_specific = LINUX_SPECIFIC (disk->dev);
+fd = arch_specific->fd;
+if (!fdasd_get_geometry (dev, anchor, fd))
+return;
+
+fdasd_check_volume (anchor, fd);
+sprintf (vol_devno, "0X%04x", anchor->devno);
+ck_assert (strlen (vol_devno) == VOLSER_LENGTH);
+}
+
+static void free_test (void)
+{
+ped_device_close (disk->dev);
+ped_device_destroy (disk->dev);
+unlink (tmp_disk);
+free (tmp_disk);
+fdasd_cleanup (anchor);
+}
+
+/* Test with default volser */
+START_TEST (test_get_volser)
+{
+char volser[7] = {0};
+fdasd_change_volser (anchor, vol_devno);
+fdasd_write_labels (anchor, fd);
+
+fdasd_get_volser (anchor, volser, fd);
+ck_assert (!strcmp (volser, vol_devno));
+}
+END_TEST
+
+START_TEST (test_check_volser)
+{
+char vol[7] = {0};
+char vol_long[] = "abcdefg";
+char vol_short[] = "ab_c   ";
+char vol_null[] = "  ";
+char *vol_input = NULL;
+
+vol_input = vol_long;
+fdasd_check_volser (vol_input, anchor->devno);
+ck_assert(!strcmp (vol_input, "ABCDEF"));
+
+vol_input = vol_short;
+fdasd_check_volser (vol_input, anchor->devno);
+ck_assert (!strcmp (vol_input, "ABC"));
+
+vol_input = vol_null;
+fdasd_check_volser (vol_input, an

[parted-devel] [PATCH v2 4/4] libparted/dasd: add test cases for the new fdasd functions

2017-04-17 Thread Wang Dong
The test case uses a temporary file in libparted/tests under
Check framwork.It can be issued by "make check" in the test dir.

Signed-off-by: Wang Dong 
Signed-off-by: Hendrik Brueckner 
---
 libparted/tests/Makefile.am |   5 +-
 libparted/tests/t4000-volser.sh |  20 +
 libparted/tests/volser.c| 188 
 3 files changed, 211 insertions(+), 2 deletions(-)
 create mode 100755 libparted/tests/t4000-volser.sh
 create mode 100644 libparted/tests/volser.c

diff --git a/libparted/tests/Makefile.am b/libparted/tests/Makefile.am
index c7c10a9..9689fb3 100644
--- a/libparted/tests/Makefile.am
+++ b/libparted/tests/Makefile.am
@@ -3,9 +3,9 @@
 #
 # This file may be modified and/or distributed without restriction.
 
-TESTS = t1000-label.sh t2000-disk.sh t2100-zerolen.sh t3000-symlink.sh
+TESTS = t1000-label.sh t2000-disk.sh t2100-zerolen.sh t3000-symlink.sh 
t4000-volser.sh
 EXTRA_DIST = $(TESTS)
-check_PROGRAMS = label disk zerolen symlink
+check_PROGRAMS = label disk zerolen symlink volser
 AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
 
 LDADD = \
@@ -23,6 +23,7 @@ label_SOURCES = common.h common.c label.c
 disk_SOURCES  = common.h common.c disk.c
 zerolen_SOURCES = common.h common.c zerolen.c
 symlink_SOURCES = common.h common.c symlink.c
+volser_SOURCES = common.h common.c volser.c
 
 # Arrange to symlink to tests/init.sh.
 CLEANFILES = init.sh
diff --git a/libparted/tests/t4000-volser.sh b/libparted/tests/t4000-volser.sh
new file mode 100755
index 000..89688ba
--- /dev/null
+++ b/libparted/tests/t4000-volser.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see .
+
+. "${top_srcdir=../..}/tests/init.sh"; path_prepend_ .
+
+volser || fail=1
+
+Exit $fail
diff --git a/libparted/tests/volser.c b/libparted/tests/volser.c
new file mode 100644
index 000..9063821
--- /dev/null
+++ b/libparted/tests/volser.c
@@ -0,0 +1,188 @@
+/*
+ * Author: Wang Dong 
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include "../arch/linux.h"
+#include "common.h"
+#include "progname.h"
+
+/* set dasd first */
+static char vol_devno[7] = {0};
+static char *tmp_disk;
+static int fd;
+
+static PedDisk *disk;
+static struct fdasd_anchor anc;
+static fdasd_anchor_t *anchor = &anc;
+static LinuxSpecific *arch_specific;
+
+/* set the enviroment */
+static void set_test (void)
+{
+PedDevice *dev;
+PedDiskType *type;
+type = ped_disk_type_get ("dasd");
+
+tmp_disk = _create_disk (20*1024*1024);
+fail_if (tmp_disk == NULL, "Failed to create temporary disk");
+dev = ped_device_get (tmp_disk);
+if (dev == NULL)
+return;
+
+disk = _create_disk_label (dev, type);
+if (!ped_device_open (disk->dev))
+return;
+
+fdasd_initialize_anchor (anchor);
+arch_specific = LINUX_SPECIFIC (disk->dev);
+fd = arch_specific->fd;
+if (!fdasd_get_geometry (dev, anchor, fd))
+return;
+
+fdasd_check_volume (anchor, fd);
+sprintf (vol_devno, "0X%04x", anchor->devno);
+ck_assert (strlen (vol_devno) == VOLSER_LENGTH);
+}
+
+static void free_test (void)
+{
+ped_device_close (disk->dev);
+ped_device_destroy (disk->dev);
+unlink (tmp_disk);
+free (tmp_disk);
+fdasd_cleanup (anchor);
+}
+
+/* Test with default volser */
+START_TEST (test_get_volser)
+{
+char volser[7] = {0};
+fdasd_change_volser (anchor, vol_devno);
+fdasd_write_labels (anchor, fd);
+
+fdasd_get_volser (anchor, volser, fd);
+ck_assert (!strcmp (volser, vol_devno));
+}
+END_TEST
+
+START_TEST (test_check_volser)
+{
+char vol[7] = {0};
+char vol_long[] = "abcdefg";
+char vol_short[] = "ab_c   ";
+char vol_null[] = "  ";
+char *vol_input = NULL;
+
+vol_input = vol_long;
+fdasd_check_volser (vol_input, anchor->devno);
+ck_assert(!strcmp (vol_input, "ABCDEF"));
+
+vol_input = vol_short;
+fdasd_check_volser (vol_input, anchor->devno);
+ck_assert (!strcmp (vol_input, "ABC"));
+
+vol_input = vol_null;
+fdasd_check_volser (vol_input, anchor->devno);
+ck_assert (!strcmp (vol_input, vol_devno));
+}
+END_TEST
+
+START_TEST (test_change_volser)
+{
+
+

Re: [parted-devel] [PATCH v2 4/4] libparted/dasd: add test cases for the new fdasd functions

2017-04-17 Thread Wang Dong



On 04/18/2017 03:00 AM, Phil Susi wrote:

On 10/25/2016 10:22 PM, Wang Dong wrote:

The test case uses a temporary file in libparted/tests under
Check framwork. It can be issued by "make check" in the test dir.

Signed-off-by: Wang Dong 
Signed-off-by: Hendrik Brueckner 

This commit broke the check build by adding a new program to
libparted/tests/Makefile.am without adding the corresponding volser.c
file to build it.


I have checked it. Yes, you are right. Sorry for the silly mistake.
I will add it with another commit.

--
Best regards. Wang Dong




Re: [parted-devel] [PATCH v2 4/4] libparted/dasd: add test cases for the new fdasd functions

2017-04-17 Thread Phil Susi
On 10/25/2016 10:22 PM, Wang Dong wrote:
> The test case uses a temporary file in libparted/tests under
> Check framwork. It can be issued by "make check" in the test dir.
> 
> Signed-off-by: Wang Dong 
> Signed-off-by: Hendrik Brueckner 

This commit broke the check build by adding a new program to
libparted/tests/Makefile.am without adding the corresponding volser.c
file to build it.




[parted-devel] [PATCH v2 4/4] libparted/dasd: add test cases for the new fdasd functions

2016-10-25 Thread Wang Dong
The test case uses a temporary file in libparted/tests under
Check framwork. It can be issued by "make check" in the test dir.

Signed-off-by: Wang Dong 
Signed-off-by: Hendrik Brueckner 
---
 libparted/tests/Makefile.am | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libparted/tests/Makefile.am b/libparted/tests/Makefile.am
index c7c10a9..9689fb3 100644
--- a/libparted/tests/Makefile.am
+++ b/libparted/tests/Makefile.am
@@ -3,9 +3,9 @@
 #
 # This file may be modified and/or distributed without restriction.
 
-TESTS = t1000-label.sh t2000-disk.sh t2100-zerolen.sh t3000-symlink.sh
+TESTS = t1000-label.sh t2000-disk.sh t2100-zerolen.sh t3000-symlink.sh 
t4000-volser.sh
 EXTRA_DIST = $(TESTS)
-check_PROGRAMS = label disk zerolen symlink
+check_PROGRAMS = label disk zerolen symlink volser
 AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
 
 LDADD = \
@@ -23,6 +23,7 @@ label_SOURCES = common.h common.c label.c
 disk_SOURCES  = common.h common.c disk.c
 zerolen_SOURCES = common.h common.c zerolen.c
 symlink_SOURCES = common.h common.c symlink.c
+volser_SOURCES = common.h common.c volser.c
 
 # Arrange to symlink to tests/init.sh.
 CLEANFILES = init.sh
-- 
2.8.4