[parted-devel] [PATCH 2/3] libparted:tests: Move get_sector_size() to common.c

John Paul Adrian Glaubitz glaubitz at physik.fu-berlin.de
Sun Oct 16 10:19:31 UTC 2016


Moving get_sector_size() to common.c allows us to use it
in _implemented_disk_label to test for 512-byte sectors.

Signed-off-by: John Paul Adrian Glaubitz <glaubitz at physik.fu-berlin.de>
---
 libparted/tests/common.c | 14 ++++++++++++++
 libparted/tests/common.h |  5 +++++
 libparted/tests/disk.c   | 15 ---------------
 3 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/libparted/tests/common.c b/libparted/tests/common.c
index 46e029f..8ef3915 100644
--- a/libparted/tests/common.c
+++ b/libparted/tests/common.c
@@ -7,9 +7,23 @@
 #include <check.h>
 
 #include "common.h"
+#include "xstrtol.h"
 
 #define STREQ(a, b) (strcmp (a, b) == 0)
 
+size_t get_sector_size (void)
+{
+  char *p = getenv ("PARTED_SECTOR_SIZE");
+  size_t ss = 512;
+  unsigned long val;
+  if (p
+      && xstrtoul (p, NULL, 10, &val, NULL) == LONGINT_OK
+      && val % 512 == 0)
+    ss = val;
+
+  return ss;
+}
+
 PedExceptionOption
 _test_exception_handler (PedException* e)
 {
diff --git a/libparted/tests/common.h b/libparted/tests/common.h
index 1b1c801..5d7485e 100644
--- a/libparted/tests/common.h
+++ b/libparted/tests/common.h
@@ -1,5 +1,10 @@
 #include <parted/parted.h>
 
+/* Determine sector size from environment
+ *
+ */
+size_t get_sector_size (void);
+
 /* Create an empty disk image
  *
  * filename: file (with full path) where to write the disk image
diff --git a/libparted/tests/disk.c b/libparted/tests/disk.c
index 48561b9..62d20c1 100644
--- a/libparted/tests/disk.c
+++ b/libparted/tests/disk.c
@@ -7,24 +7,9 @@
 
 #include "common.h"
 #include "progname.h"
-#include "xstrtol.h"
 
 static char* temporary_disk;
 
-static
-size_t get_sector_size (void)
-{
-  char *p = getenv ("PARTED_SECTOR_SIZE");
-  size_t ss = 512;
-  unsigned long val;
-  if (p
-      && xstrtoul (p, NULL, 10, &val, NULL) == LONGINT_OK
-      && val % 512 == 0)
-    ss = val;
-
-  return ss;
-}
-
 static void
 create_disk (void)
 {
-- 
2.9.3




More information about the parted-devel mailing list