%check modified to make run-unit-test

This commit is contained in:
wguanghao 2021-07-28 14:16:09 +08:00
parent 1e240c89d6
commit 688870712e
2 changed files with 125 additions and 2 deletions

View File

@ -0,0 +1,119 @@
From 262008f1ceb050a9eed64f2fa50b1bc9366b9e75 Mon Sep 17 00:00:00 2001
From: Wu Guanghao <wuguanghao3@huawei.com>
Date: Tue, 23 Feb 2021 17:39:29 +0800
Subject: [PATCH] unit-test: modify for systems with PGSIZE of 64K
This modification supports dynamically obtaining the value of PAGE_SIZE,
which is compatible with systems with PAGE_SIZE of (4K/64K)
Signed-off-by: wuguanghao <wuguanghao3@huawei.com>
---
test/unit/bcache_t.c | 7 ++++---
test/unit/bcache_utils_t.c | 2 +-
test/unit/io_engine_t.c | 11 +++++++----
3 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/test/unit/bcache_t.c b/test/unit/bcache_t.c
index 9c4d102..399468a 100644
--- a/test/unit/bcache_t.c
+++ b/test/unit/bcache_t.c
@@ -360,6 +360,7 @@ static void _large_fixture_exit(void *context)
*--------------------------------------------------------------*/
#define MEG 2048
#define SECTOR_SHIFT 9
+#define PAGE_SIZE_SECTORS (sysconf(_SC_PAGE_SIZE) >> SECTOR_SHIFT)
static void good_create(sector_t block_size, unsigned nr_cache_blocks)
{
@@ -389,12 +390,12 @@ static void bad_create(sector_t block_size, unsigned nr_cache_blocks)
static void test_create(void *fixture)
{
- good_create(8, 16);
+ good_create(PAGE_SIZE_SECTORS, 16);
}
static void test_nr_cache_blocks_must_be_positive(void *fixture)
{
- bad_create(8, 0);
+ bad_create(PAGE_SIZE_SECTORS, 0);
}
static void test_block_size_must_be_positive(void *fixture)
@@ -412,7 +413,7 @@ static void test_block_size_must_be_multiple_of_page_size(void *fixture)
bad_create(_bad_examples[i], 16);
for (i = 1; i < 100; i++)
- good_create(i * 8, 16);
+ good_create(i * PAGE_SIZE_SECTORS, 16);
}
static void test_get_triggers_read(void *context)
diff --git a/test/unit/bcache_utils_t.c b/test/unit/bcache_utils_t.c
index 69c5101..ecc3ebb 100644
--- a/test/unit/bcache_utils_t.c
+++ b/test/unit/bcache_utils_t.c
@@ -26,7 +26,7 @@
//----------------------------------------------------------------
-#define T_BLOCK_SIZE 4096
+#define T_BLOCK_SIZE sysconf(_SC_PAGESIZE)
#define NR_BLOCKS 64
#define INIT_PATTERN 123
diff --git a/test/unit/io_engine_t.c b/test/unit/io_engine_t.c
index 349df25..431cca6 100644
--- a/test/unit/io_engine_t.c
+++ b/test/unit/io_engine_t.c
@@ -25,8 +25,11 @@
//----------------------------------------------------------------
+#define SECTOR_SHIFT 9
#define SECTOR_SIZE 512
#define BLOCK_SIZE_SECTORS 8
+#define PAGE_SIZE sysconf(_SC_PAGESIZE)
+#define PAGE_SIZE_SECTORS (PAGE_SIZE >> SECTOR_SHIFT)
#define NR_BLOCKS 64
struct fixture {
@@ -83,7 +86,7 @@ static void *_fix_init(void)
T_ASSERT(f);
f->e = create_async_io_engine();
T_ASSERT(f->e);
- if (posix_memalign((void **) &f->data, 4096, SECTOR_SIZE * BLOCK_SIZE_SECTORS))
+ if (posix_memalign((void **) &f->data, PAGE_SIZE, SECTOR_SIZE * BLOCK_SIZE_SECTORS))
test_fail("posix_memalign failed");
snprintf(f->fname, sizeof(f->fname), "unit-test-XXXXXX");
@@ -138,7 +141,7 @@ static void _test_read(void *fixture)
{
struct fixture *f = fixture;
struct io io;
- struct bcache *cache = bcache_create(8, BLOCK_SIZE_SECTORS, f->e);
+ struct bcache *cache = bcache_create(PAGE_SIZE_SECTORS, BLOCK_SIZE_SECTORS, f->e);
T_ASSERT(cache);
f->di = bcache_set_fd(f->fd);
@@ -156,7 +159,7 @@ static void _test_write(void *fixture)
{
struct fixture *f = fixture;
struct io io;
- struct bcache *cache = bcache_create(8, BLOCK_SIZE_SECTORS, f->e);
+ struct bcache *cache = bcache_create(PAGE_SIZE_SECTORS, BLOCK_SIZE_SECTORS, f->e);
T_ASSERT(cache);
f->di = bcache_set_fd(f->fd);
@@ -175,7 +178,7 @@ static void _test_write_bytes(void *fixture)
unsigned offset = 345;
char buf_out[32];
char buf_in[32];
- struct bcache *cache = bcache_create(8, BLOCK_SIZE_SECTORS, f->e);
+ struct bcache *cache = bcache_create(PAGE_SIZE_SECTORS, BLOCK_SIZE_SECTORS, f->e);
T_ASSERT(cache);
f->di = bcache_set_fd(f->fd);
--
1.8.3.1

View File

@ -43,7 +43,7 @@
Name: lvm2
Version: 2.03.11
Release: 4
Release: 5
Epoch: 8
Summary: Tools for logical volume management
License: GPLv2+ and LGPLv2.1 and BSD
@ -62,6 +62,7 @@ Patch10: 0010-enhancement-syslog-more-when-use-libdevmapper-so.patch
Patch11: 0011-enhancement-log-it-when-disk-slow.patch
Patch12: 0012-bugfix-lvm2-fix-the-reuse-of-va_list.patch
Patch13: 0013-lvreduce-support-yes.patch
Patch14: 0014-unit-test-modify-for-systems-with-PGSIZE-of-64K.patch
BuildRequires: gcc
BuildRequires: gcc-c++
@ -246,7 +247,7 @@ can register and carryout actions triggered when particular events occur.
make %{?_smp_mflags}
%check
make test
make run-unit-test
%install
make install DESTDIR=%{buildroot}
@ -486,6 +487,9 @@ fi
%changelog
* Wed Jul 28 2021 wuguanghao<wuguanghao3@huawei.com> - 8.2.03.11-5
- %check modified to make run-unit-test
* Wed Jul 28 2021 wuguanghao<wuguanghao3@huawei.com> - 8.2.03.11-4
- lvreduce support --yes option