unit-test: modify the test case to support systems with PAGE_SIZE of 64K
PATCH 1/1 unit-test: modify the test case to support systems with PAGE_SIZE of 64K
Hi
Now we want to compile lvm2 on a machine whose PAGE_SIZE is 64K and enable unit test at the same time. However, we found that some test cases cannot be executed normally, so we made some modifications.
Quoted 1 line
From
00acbafcdf006d9da748e404c0eed58d6675791bMon Sep 17 00:00:00 2001
From: root <[email protected]>
Date: Mon, 22 Feb 2021 15:38:49 +0800
Subject: [PATCH] Modify the test case to support systems with PAGE_SIZE of 64K
--- test/unit/bcache_t.c | 6 +++--- test/unit/bcache_utils_t.c | 2 +- test/unit/io_engine_t.c | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-)
test/unit/bcache_t.c +3 -3
@@ -389,12 +389,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 (128 ,16 ); }static void test_nr_cache_blocks_must_be_positive (void *fixture) { -bad_create (8 ,0 ); +bad_create (128 ,0 ); }static void test_block_size_must_be_positive (void *fixture)
@@ -412,7 +412,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 *128 ,16 ); }static void test_get_triggers_read (void *context)
test/unit/bcache_utils_t.c +1 -1
@@ -26,7 +26,7 @@//---------------------------------------------------------------- -#define T_BLOCK_SIZE 4096 +#define T_BLOCK_SIZE 65536#define NR_BLOCKS 64#define INIT_PATTERN 123
test/unit/io_engine_t.c +5 -5
@@ -26,7 +26,7 @@//---------------------------------------------------------------- #define SECTOR_SIZE 512 -#define BLOCK_SIZE_SECTORS 8 +#define BLOCK_SIZE_SECTORS 128#define NR_BLOCKS 64struct fixture {
@@ -83,7 +83,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,65536 ,SECTOR_SIZE *BLOCK_SIZE_SECTORS ))test_fail ("posix_memalign failed" );snprintf (f->fname,sizeof (f->fname),"unit-test-XXXXXX" );
@@ -138,7 +138,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 (128 ,BLOCK_SIZE_SECTORS , f->e);T_ASSERT (cache); f->di =bcache_set_fd (f->fd);
@@ -156,7 +156,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 (128 ,BLOCK_SIZE_SECTORS , f->e);T_ASSERT (cache); f->di =bcache_set_fd (f->fd);
@@ -175,7 +175,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 (128 ,BLOCK_SIZE_SECTORS , f->e);T_ASSERT (cache); f->di =bcache_set_fd (f->fd);
Signature · 7 lines
2.27.0 Regards Wu Guanghao
PATCH 1/1 unit-test: modify the test case to support systems with PAGE_SIZE of 64K
Dne 22. 02. 21 v 9:01 Wu Guanghao napsal(a):
Quoted 11 lines
Hi
Now we want to compile lvm2 on a machine whose
PAGE_SIZEis 64K and enable unit test at the same time. However, we found that some test cases cannot be executed normally, so we made some modifications.Quoted 1 line
-#define
T_BLOCK_SIZE4096+#define
T_BLOCK_SIZE65536
#defineNR_BLOCKS64
#defineINIT_PATTERN123
Hi
Whole patch likely needs to be based on some 'configure' discovered define (likely sysconf(_SC_PAGESIZE))
So the patch itself cannot turn everything into 64K - but should adapt dynamically to system condition (so the existing coverage is not lost/changed).
Regards
Zdenek