Changeset View
Changeset View
Standalone View
Standalone View
tests/sys/sys/bitstring_test.c
Show First 20 Lines • Show All 346 Lines • ▼ Show 20 Lines | |||||
ATF_TC_BODY(bit_ffs_area, tc) | ATF_TC_BODY(bit_ffs_area, tc) | ||||
{ | { | ||||
const int nbits = 72; | const int nbits = 72; | ||||
bitstr_t bit_decl(bitstr, nbits); | bitstr_t bit_decl(bitstr, nbits); | ||||
int location; | int location; | ||||
memset(bitstr, 0, bitstr_size(nbits)); | memset(bitstr, 0, bitstr_size(nbits)); | ||||
bit_set(bitstr, 5); | bit_nset(bitstr, 5, 6); | ||||
bit_set(bitstr, 6); | |||||
location = 0; | location = 0; | ||||
bit_ffs_area(bitstr, nbits, 3, &location); | bit_ffs_area(bitstr, nbits, 3, &location); | ||||
ATF_REQUIRE_EQ_MSG(-1, location, | ATF_REQUIRE_EQ_MSG(-1, location, | ||||
"bit_ffs_area: found location of size 3 when only 2 bits are set"); | "bit_ffs_area: found location of size 3 when only 2 bits are set"); | ||||
ATF_REQUIRE_EQ_MSG(0, bit_ntest(bitstr, 5, 7, 1), | |||||
"bit_ntest: found location of size 3 when only 2 bits are set"); | |||||
bit_set(bitstr, 7); | bit_set(bitstr, 7); | ||||
location = 0; | location = 0; | ||||
bit_ffs_area(bitstr, nbits, 3, &location); | bit_ffs_area(bitstr, nbits, 3, &location); | ||||
ATF_REQUIRE_EQ_MSG(5, location, | ATF_REQUIRE_EQ_MSG(5, location, | ||||
"bit_ffs_area: failed to find location of size 3"); | "bit_ffs_area: failed to find location of size 3 %d", location); | ||||
ATF_REQUIRE_EQ_MSG(1, bit_ntest(bitstr, 5, 7, 1), | |||||
"bit_ntest: failed to find all 3 bits set"); | |||||
bit_set(bitstr, 8); | bit_set(bitstr, 8); | ||||
location = 0; | location = 0; | ||||
bit_ffs_area(bitstr, nbits, 3, &location); | bit_ffs_area(bitstr, nbits, 3, &location); | ||||
ATF_REQUIRE_EQ_MSG(5, location, | ATF_REQUIRE_EQ_MSG(5, location, | ||||
"bit_ffs_area: failed to find location of size 3"); | "bit_ffs_area: failed to find location of size 3"); | ||||
location = 0; | location = 0; | ||||
bit_ffs_area_at(bitstr, 2, nbits, 3, &location); | bit_ffs_area_at(bitstr, 2, nbits, 3, &location); | ||||
ATF_REQUIRE_EQ_MSG(5, location, | ATF_REQUIRE_EQ_MSG(5, location, | ||||
"bit_ffs_area_at: failed to find location of size 3"); | "bit_ffs_area_at: failed to find location of size 3"); | ||||
location = 0; | location = 0; | ||||
bit_ffs_area_at(bitstr, 6, nbits, 3, &location); | bit_ffs_area_at(bitstr, 6, nbits, 3, &location); | ||||
ATF_REQUIRE_EQ_MSG(6, location, | ATF_REQUIRE_EQ_MSG(6, location, | ||||
"bit_ffs_area_at: failed to find location of size 3"); | "bit_ffs_area_at: failed to find location of size 3"); | ||||
location = 0; | location = 0; | ||||
bit_ffs_area_at(bitstr, 8, nbits, 3, &location); | bit_ffs_area_at(bitstr, 8, nbits, 3, &location); | ||||
ATF_REQUIRE_EQ_MSG(-1, location, | ATF_REQUIRE_EQ_MSG(-1, location, | ||||
"bit_ffs_area_at: found invalid location"); | "bit_ffs_area_at: found invalid location"); | ||||
bit_set(bitstr, 69); | bit_nset(bitstr, 69, 71); | ||||
bit_set(bitstr, 70); | |||||
bit_set(bitstr, 71); | |||||
location = 0; | location = 0; | ||||
bit_ffs_area_at(bitstr, 8, nbits, 3, &location); | bit_ffs_area_at(bitstr, 8, nbits, 3, &location); | ||||
ATF_REQUIRE_EQ_MSG(69, location, | ATF_REQUIRE_EQ_MSG(69, location, | ||||
"bit_ffs_area_at: failed to find location of size 3"); | "bit_ffs_area_at: failed to find location of size 3"); | ||||
location = 0; | location = 0; | ||||
bit_ffs_area_at(bitstr, 69, nbits, 3, &location); | bit_ffs_area_at(bitstr, 69, nbits, 3, &location); | ||||
ATF_REQUIRE_EQ_MSG(69, location, | ATF_REQUIRE_EQ_MSG(69, location, | ||||
"bit_ffs_area_at: failed to find location of size 3"); | "bit_ffs_area_at: failed to find location of size 3"); | ||||
location = 0; | location = 0; | ||||
bit_ffs_area_at(bitstr, 70, nbits, 3, &location); | bit_ffs_area_at(bitstr, 70, nbits, 3, &location); | ||||
ATF_REQUIRE_EQ_MSG(-1, location, | ATF_REQUIRE_EQ_MSG(-1, location, | ||||
"bit_ffs_area_at: found invalid location"); | "bit_ffs_area_at: found invalid location"); | ||||
location = 0; | location = 0; | ||||
bit_ffs_area_at(bitstr, 72, nbits, 3, &location); | bit_ffs_area_at(bitstr, 72, nbits, 3, &location); | ||||
ATF_REQUIRE_EQ_MSG(-1, location, | ATF_REQUIRE_EQ_MSG(-1, location, | ||||
"bit_ffs_area_at: found invalid location"); | "bit_ffs_area_at: found invalid location"); | ||||
bit_nset(bitstr, 59, 67); | |||||
location = 0; | |||||
bit_ffs_area(bitstr, nbits, 9, &location); | |||||
ATF_REQUIRE_EQ_MSG(59, location, | |||||
"bit_ffs_area: failed to find location of size 9"); | |||||
location = 0; | |||||
bit_ffs_area(bitstr, nbits, 10, &location); | |||||
ATF_REQUIRE_EQ_MSG(-1, location, | |||||
"bit_ffs_area: found invalid location"); | |||||
} | } | ||||
ATF_TC_WITHOUT_HEAD(bit_ffc_area); | ATF_TC_WITHOUT_HEAD(bit_ffc_area); | ||||
ATF_TC_BODY(bit_ffc_area, tc) | ATF_TC_BODY(bit_ffc_area, tc) | ||||
{ | { | ||||
const int nbits = 80; | const int nbits = 80; | ||||
bitstr_t bit_decl(bitstr, nbits); | bitstr_t bit_decl(bitstr, nbits); | ||||
int location; | int location; | ||||
▲ Show 20 Lines • Show All 409 Lines • Show Last 20 Lines |