test-bitmap: test set 1 bit case for bitmap_set
PATCH 1/1 test-bitmap: test set 1 bit case for bitmap_set
All current bitmap_set test cases set range across word, while the handle of a range within one word is different from that.
Add case to set 1 bit as a represent for set range within one word.
---
Thanks for Paolo's finding.
--- tests/test-bitmap.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
tests/test-bitmap.c +12 -0
@@ -67,6 +67,18 @@ static void bitmap_set_case(bmap_set_func set_func) bmap =bitmap_new (BMAP_SIZE ); +/* Set one bit at offset in second word */ +for (offset =0 ; offset <=BITS_PER_LONG ; offset++) { +bitmap_clear (bmap,0 ,BMAP_SIZE ); +set_func (bmap,BITS_PER_LONG + offset,1 ); +g_assert_cmpint (find_first_bit (bmap,2 *BITS_PER_LONG ), + ==, BITS_PER_LONG + offset); +g_assert_cmpint (find_next_zero_bit (bmap, +3 *BITS_PER_LONG , +BITS_PER_LONG + offset), + ==, BITS_PER_LONG + offset + 1); + } +/* Both Aligned, set bits [BITS_PER_LONG, 3*BITS_PER_LONG] */ set_func (bmap,BITS_PER_LONG ,2 *BITS_PER_LONG ); g_assert_cmpuint(bmap[1], ==, -1ul);
Signature · 1 line
2.17.1
Quoted 28 lines · Wei Yang
All current
bitmap_settest cases set range across word, while the handle of a range within one word is different from that.Add case to set 1 bit as a represent for set range within one word.
Signed-off-by Wei Yang <[email protected]>---
Thanks for Paolo's finding.--- tests/test-bitmap.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)tests/test-bitmap.c +5
-0@@ -67,6 +67,18 @@ static void bitmap_set_case(bmap_set_func set_func) bmap =bitmap_new (BMAP_SIZE ); +/* Set one bit at offset in second word */ +for (offset =0 ; offset <=BITS_PER_LONG ; offset++) { +bitmap_clear (bmap,0 ,BMAP_SIZE ); +set_func (bmap,BITS_PER_LONG + offset,1 ); + g_assert_cmpint(find_first_bit(bmap, 2 * BITS_PER_LONG),
tests/test-bitmap.c static void bitmap_set_case(bmap_set_func set_func) · line 84
Quoted 10 lines
tests/test-bitmap.c +7
-0+ ==, BITS_PER_LONG + offset); +g_assert_cmpint (find_next_zero_bit (bmap, +3 *BITS_PER_LONG , +BITS_PER_LONG + offset), + ==, BITS_PER_LONG + offset + 1); + } +/* Both Aligned, set bits [BITS_PER_LONG, 3*BITS_PER_LONG] */ set_func (bmap,BITS_PER_LONG ,2 *BITS_PER_LONG ); g_assert_cmpuint(bmap[1], ==, -1ul);
Queued, thanks for writing the testcase without no one asking! :)
Paolo
Quoted 33 lines · Paolo Bonzini
Quoted 32 lines · Wei Yang
All current
bitmap_settest cases set range across word, while the handle of a range within one word is different from that.Add case to set 1 bit as a represent for set range within one word.
Signed-off-by Wei Yang <[email protected]>---
Thanks for Paolo's finding.--- tests/test-bitmap.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)tests/test-bitmap.c +10
-0@@ -67,6 +67,18 @@ static void bitmap_set_case(bmap_set_func set_func) bmap =bitmap_new (BMAP_SIZE ); +/* Set one bit at offset in second word */ +for (offset =0 ; offset <=BITS_PER_LONG ; offset++) { +bitmap_clear (bmap,0 ,BMAP_SIZE ); +set_func (bmap,BITS_PER_LONG + offset,1 ); +g_assert_cmpint (find_first_bit (bmap,2 *BITS_PER_LONG ), + ==, BITS_PER_LONG + offset); +g_assert_cmpint (find_next_zero_bit (bmap, +3 *BITS_PER_LONG , +BITS_PER_LONG + offset), + ==, BITS_PER_LONG + offset + 1);
Quoted 9 lines
tests/test-bitmap.c static void bitmap_set_case(bmap_set_func set_func) · line 84
Quoted 6 lines
tests/test-bitmap.c +2
-0+ } +/* Both Aligned, set bits [BITS_PER_LONG, 3*BITS_PER_LONG] */ set_func (bmap,BITS_PER_LONG ,2 *BITS_PER_LONG ); g_assert_cmpuint(bmap[1], ==, -1ul);Queued, thanks for writing the testcase without no one asking! :)
My pleasure to help :)
Quoted 1 line
Paolo
Signature · 2 lines
Wei Yang Help you, Help me