summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-05-12 19:32:32 +0700
committerhathach <[email protected]>2013-05-12 19:32:32 +0700
commitcc496074347543d19bbcc691dd46d05db2817b51 (patch)
tree1b5e3651d3ddb47b9a0c2f73b09427e0216ee996 /tests
parent81780008e977fc2093155bfb7be63e00447ad3be (diff)
test refractor
Diffstat (limited to 'tests')
-rw-r--r--tests/readme.md1
-rw-r--r--tests/test/host/ehci/test_ehci_structure.c31
2 files changed, 4 insertions, 28 deletions
diff --git a/tests/readme.md b/tests/readme.md
index 0f6e370bc..d96b8c64b 100644
--- a/tests/readme.md
+++ b/tests/readme.md
@@ -13,3 +13,4 @@ More detail on TDD can be found at
comming soon
<!-- https://travis-ci.org/hathach/tinyusb -->
+[![Build Status](https://travis-ci.org/hathach/tinyusb.png?branch=master)](https://travis-ci.org/hathach/tinyusb)
diff --git a/tests/test/host/ehci/test_ehci_structure.c b/tests/test/host/ehci/test_ehci_structure.c
index 467bb92a2..8298f102a 100644
--- a/tests/test/host/ehci/test_ehci_structure.c
+++ b/tests/test/host/ehci/test_ehci_structure.c
@@ -55,9 +55,8 @@ usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1];
//--------------------------------------------------------------------+
// Setup/Teardown + helper declare
//--------------------------------------------------------------------+
-int8_t first_pos_of_high_bit(uint32_t value);
-uint8_t number_of_high_bits(uint32_t value);
+// log2_of a value is equivalent to its highest set bit's position
#define BITFIELD_OFFSET_OF_MEMBER(struct_type, member, bitfield_member) \
({\
uint32_t value=0;\
@@ -65,7 +64,7 @@ uint8_t number_of_high_bits(uint32_t value);
memclr_((void*)&str, sizeof(struct_type));\
str.member.bitfield_member = 1;\
memcpy(&value, (void*)&str.member, sizeof(str.member));\
- first_pos_of_high_bit( value );\
+ log2_of( value );\
})
#define BITFIELD_OFFSET_OF_UINT32(struct_type, offset, bitfield_member) \
@@ -73,7 +72,7 @@ uint8_t number_of_high_bits(uint32_t value);
struct_type str;\
memclr_(&str, sizeof(struct_type));\
str.bitfield_member = 1;\
- first_pos_of_high_bit( ((uint32_t*) &str)[offset] );\
+ log2_of( ((uint32_t*) &str)[offset] );\
})
void setUp(void)
@@ -322,27 +321,3 @@ void test_ehci_data(void)
// TODO more tests on ehci_data
}
-
-//--------------------------------------------------------------------+
-// Helper
-//--------------------------------------------------------------------+
-int8_t first_pos_of_high_bit(uint32_t value)
-{
- for (int8_t i=0; i<32; i++)
- {
- if (value & BIT_(i))
- return i;
- }
- return (-1);
-}
-
-uint8_t number_of_high_bits(uint32_t value)
-{
- uint8_t result=0;
- for(uint8_t i=0; i<32; i++)
- {
- if (value & BIT_(i))
- result++;
- }
- return result;
-}