|
|
0cb0b9 |
From 105746f40724d94499a04a0d7036380aaa41c1f5 Mon Sep 17 00:00:00 2001
|
|
|
0cb0b9 |
From: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
|
|
|
0cb0b9 |
Date: Sun, 4 Dec 2016 17:12:45 +0100
|
|
|
0cb0b9 |
Subject: [PATCH 64/75] libparted:tests: Move get_sector_size() to common.c
|
|
|
0cb0b9 |
|
|
|
0cb0b9 |
Moving get_sector_size() from disk.c to common.c allows
|
|
|
0cb0b9 |
us to use it in _implemented_disk_label() to test for
|
|
|
0cb0b9 |
512-byte sectors. This change is required to be able to
|
|
|
0cb0b9 |
enable this test for atari partition tables for which
|
|
|
0cb0b9 |
support is added in a follow-up patch.
|
|
|
0cb0b9 |
|
|
|
0cb0b9 |
Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
|
|
|
0cb0b9 |
Signed-off-by: Brian C. Lane <bcl@redhat.com>
|
|
|
0cb0b9 |
---
|
|
|
0cb0b9 |
libparted/tests/common.c | 14 ++++++++++++++
|
|
|
0cb0b9 |
libparted/tests/common.h | 5 +++++
|
|
|
0cb0b9 |
libparted/tests/disk.c | 15 ---------------
|
|
|
0cb0b9 |
3 files changed, 19 insertions(+), 15 deletions(-)
|
|
|
0cb0b9 |
|
|
|
0cb0b9 |
diff --git a/libparted/tests/common.c b/libparted/tests/common.c
|
|
|
0cb0b9 |
index a0be997..9115686 100644
|
|
|
0cb0b9 |
--- a/libparted/tests/common.c
|
|
|
0cb0b9 |
+++ b/libparted/tests/common.c
|
|
|
0cb0b9 |
@@ -7,9 +7,23 @@
|
|
|
0cb0b9 |
#include <check.h>
|
|
|
0cb0b9 |
|
|
|
0cb0b9 |
#include "common.h"
|
|
|
0cb0b9 |
+#include "xstrtol.h"
|
|
|
0cb0b9 |
|
|
|
0cb0b9 |
#define STREQ(a, b) (strcmp (a, b) == 0)
|
|
|
0cb0b9 |
|
|
|
0cb0b9 |
+size_t get_sector_size (void)
|
|
|
0cb0b9 |
+{
|
|
|
0cb0b9 |
+ char *p = getenv ("PARTED_SECTOR_SIZE");
|
|
|
0cb0b9 |
+ size_t ss = 512;
|
|
|
0cb0b9 |
+ unsigned long val;
|
|
|
0cb0b9 |
+ if (p
|
|
|
0cb0b9 |
+ && xstrtoul (p, NULL, 10, &val, NULL) == LONGINT_OK
|
|
|
0cb0b9 |
+ && val % 512 == 0)
|
|
|
0cb0b9 |
+ ss = val;
|
|
|
0cb0b9 |
+
|
|
|
0cb0b9 |
+ return ss;
|
|
|
0cb0b9 |
+}
|
|
|
0cb0b9 |
+
|
|
|
0cb0b9 |
PedExceptionOption
|
|
|
0cb0b9 |
_test_exception_handler (PedException* e)
|
|
|
0cb0b9 |
{
|
|
|
0cb0b9 |
diff --git a/libparted/tests/common.h b/libparted/tests/common.h
|
|
|
0cb0b9 |
index 1b1c801..5d7485e 100644
|
|
|
0cb0b9 |
--- a/libparted/tests/common.h
|
|
|
0cb0b9 |
+++ b/libparted/tests/common.h
|
|
|
0cb0b9 |
@@ -1,5 +1,10 @@
|
|
|
0cb0b9 |
#include <parted/parted.h>
|
|
|
0cb0b9 |
|
|
|
0cb0b9 |
+/* Determine sector size from environment
|
|
|
0cb0b9 |
+ *
|
|
|
0cb0b9 |
+ */
|
|
|
0cb0b9 |
+size_t get_sector_size (void);
|
|
|
0cb0b9 |
+
|
|
|
0cb0b9 |
/* Create an empty disk image
|
|
|
0cb0b9 |
*
|
|
|
0cb0b9 |
* filename: file (with full path) where to write the disk image
|
|
|
0cb0b9 |
diff --git a/libparted/tests/disk.c b/libparted/tests/disk.c
|
|
|
0cb0b9 |
index 48561b9..62d20c1 100644
|
|
|
0cb0b9 |
--- a/libparted/tests/disk.c
|
|
|
0cb0b9 |
+++ b/libparted/tests/disk.c
|
|
|
0cb0b9 |
@@ -7,24 +7,9 @@
|
|
|
0cb0b9 |
|
|
|
0cb0b9 |
#include "common.h"
|
|
|
0cb0b9 |
#include "progname.h"
|
|
|
0cb0b9 |
-#include "xstrtol.h"
|
|
|
0cb0b9 |
|
|
|
0cb0b9 |
static char* temporary_disk;
|
|
|
0cb0b9 |
|
|
|
0cb0b9 |
-static
|
|
|
0cb0b9 |
-size_t get_sector_size (void)
|
|
|
0cb0b9 |
-{
|
|
|
0cb0b9 |
- char *p = getenv ("PARTED_SECTOR_SIZE");
|
|
|
0cb0b9 |
- size_t ss = 512;
|
|
|
0cb0b9 |
- unsigned long val;
|
|
|
0cb0b9 |
- if (p
|
|
|
0cb0b9 |
- && xstrtoul (p, NULL, 10, &val, NULL) == LONGINT_OK
|
|
|
0cb0b9 |
- && val % 512 == 0)
|
|
|
0cb0b9 |
- ss = val;
|
|
|
0cb0b9 |
-
|
|
|
0cb0b9 |
- return ss;
|
|
|
0cb0b9 |
-}
|
|
|
0cb0b9 |
-
|
|
|
0cb0b9 |
static void
|
|
|
0cb0b9 |
create_disk (void)
|
|
|
0cb0b9 |
{
|
|
|
0cb0b9 |
--
|
|
|
0cb0b9 |
2.9.3
|
|
|
0cb0b9 |
|