From 105746f40724d94499a04a0d7036380aaa41c1f5 Mon Sep 17 00:00:00 2001 From: John Paul Adrian Glaubitz Date: Sun, 4 Dec 2016 17:12:45 +0100 Subject: [PATCH 64/75] libparted:tests: Move get_sector_size() to common.c Moving get_sector_size() from disk.c to common.c allows us to use it in _implemented_disk_label() to test for 512-byte sectors. This change is required to be able to enable this test for atari partition tables for which support is added in a follow-up patch. Signed-off-by: John Paul Adrian Glaubitz Signed-off-by: Brian C. Lane --- 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 a0be997..9115686 100644 --- a/libparted/tests/common.c +++ b/libparted/tests/common.c @@ -7,9 +7,23 @@ #include #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 +/* 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