Changeset View
Changeset View
Standalone View
Standalone View
tests/sys/posixshm/posixshm_test.c
Show First 20 Lines • Show All 1,099 Lines • ▼ Show 20 Lines | ATF_TC_BODY(fspacectl, tc) | ||||
/* Aligned fspacectl(fd, SPACECTL_DEALLOC, ...) */ | /* Aligned fspacectl(fd, SPACECTL_DEALLOC, ...) */ | ||||
ATF_REQUIRE(shm_fill(fd, 0, shm_sz) == 0); | ATF_REQUIRE(shm_fill(fd, 0, shm_sz) == 0); | ||||
range.r_offset = offset = PAGE_SIZE; | range.r_offset = offset = PAGE_SIZE; | ||||
range.r_len = length = ((shm_max_pages - 1) << PAGE_SHIFT) - | range.r_len = length = ((shm_max_pages - 1) << PAGE_SHIFT) - | ||||
range.r_offset; | range.r_offset; | ||||
ATF_CHECK_MSG(fspacectl(fd, SPACECTL_DEALLOC, &range, 0, &range) == 0, | ATF_CHECK_MSG(fspacectl(fd, SPACECTL_DEALLOC, &range, 0, &range) == 0, | ||||
"Aligned fspacectl failed; errno=%d", errno); | "Aligned fspacectl failed; errno=%d", errno); | ||||
ATF_CHECK_MSG(check_content_dealloc(fd, offset, length, shm_sz) == 0, | ATF_CHECK_MSG(check_content_dealloc(fd, offset, length, shm_sz) == 0, | ||||
"Aligned fspacectl content checking failed", errno); | "Aligned fspacectl content checking failed"); | ||||
kib: Perhaps idea was to print out errno. | |||||
Done Inline ActionsSo I did that initially, but check_content_dealloc() doesn't always set errno when it fails, so I believe this was likely a copy-paste error. jhb: So I did that initially, but check_content_dealloc() doesn't always set errno when it fails, so… | |||||
/* Unaligned fspacectl(fd, SPACECTL_DEALLOC, ...) */ | /* Unaligned fspacectl(fd, SPACECTL_DEALLOC, ...) */ | ||||
ATF_REQUIRE(shm_fill(fd, 0, shm_sz) == 0); | ATF_REQUIRE(shm_fill(fd, 0, shm_sz) == 0); | ||||
range.r_offset = offset = 1 << (PAGE_SHIFT - 1); | range.r_offset = offset = 1 << (PAGE_SHIFT - 1); | ||||
range.r_len = length = ((shm_max_pages - 1) << PAGE_SHIFT) + | range.r_len = length = ((shm_max_pages - 1) << PAGE_SHIFT) + | ||||
(1 << (PAGE_SHIFT - 1)) - offset; | (1 << (PAGE_SHIFT - 1)) - offset; | ||||
ATF_CHECK_MSG(fspacectl(fd, SPACECTL_DEALLOC, &range, 0, &range) == 0, | ATF_CHECK_MSG(fspacectl(fd, SPACECTL_DEALLOC, &range, 0, &range) == 0, | ||||
"Unaligned fspacectl failed; errno=%d", errno); | "Unaligned fspacectl failed; errno=%d", errno); | ||||
ATF_CHECK_MSG(check_content_dealloc(fd, offset, length, shm_sz) == 0, | ATF_CHECK_MSG(check_content_dealloc(fd, offset, length, shm_sz) == 0, | ||||
"Unaligned fspacectl content checking failed", errno); | "Unaligned fspacectl content checking failed"); | ||||
/* Aligned fspacectl(fd, SPACECTL_DEALLOC, ...) to OFF_MAX */ | /* Aligned fspacectl(fd, SPACECTL_DEALLOC, ...) to OFF_MAX */ | ||||
ATF_REQUIRE(shm_fill(fd, 0, shm_sz) == 0); | ATF_REQUIRE(shm_fill(fd, 0, shm_sz) == 0); | ||||
range.r_offset = offset = PAGE_SHIFT; | range.r_offset = offset = PAGE_SHIFT; | ||||
range.r_len = length = OFF_MAX - offset; | range.r_len = length = OFF_MAX - offset; | ||||
ATF_CHECK_MSG(fspacectl(fd, SPACECTL_DEALLOC, &range, 0, &range) == 0, | ATF_CHECK_MSG(fspacectl(fd, SPACECTL_DEALLOC, &range, 0, &range) == 0, | ||||
"Aligned fspacectl to OFF_MAX failed; errno=%d", errno); | "Aligned fspacectl to OFF_MAX failed; errno=%d", errno); | ||||
ATF_CHECK_MSG(check_content_dealloc(fd, offset, length, shm_sz) == 0, | ATF_CHECK_MSG(check_content_dealloc(fd, offset, length, shm_sz) == 0, | ||||
"Aligned fspacectl to OFF_MAX content checking failed", errno); | "Aligned fspacectl to OFF_MAX content checking failed"); | ||||
/* Unaligned fspacectl(fd, SPACECTL_DEALLOC, ...) to OFF_MAX */ | /* Unaligned fspacectl(fd, SPACECTL_DEALLOC, ...) to OFF_MAX */ | ||||
ATF_REQUIRE(shm_fill(fd, 0, shm_sz) == 0); | ATF_REQUIRE(shm_fill(fd, 0, shm_sz) == 0); | ||||
range.r_offset = offset = 1 << (PAGE_SHIFT - 1); | range.r_offset = offset = 1 << (PAGE_SHIFT - 1); | ||||
range.r_len = length = OFF_MAX - offset; | range.r_len = length = OFF_MAX - offset; | ||||
ATF_CHECK_MSG(fspacectl(fd, SPACECTL_DEALLOC, &range, 0, &range) == 0, | ATF_CHECK_MSG(fspacectl(fd, SPACECTL_DEALLOC, &range, 0, &range) == 0, | ||||
"Unaligned fspacectl to OFF_MAX failed; errno=%d", errno); | "Unaligned fspacectl to OFF_MAX failed; errno=%d", errno); | ||||
ATF_CHECK_MSG(check_content_dealloc(fd, offset, length, shm_sz) == 0, | ATF_CHECK_MSG(check_content_dealloc(fd, offset, length, shm_sz) == 0, | ||||
"Unaligned fspacectl to OFF_MAX content checking failed", errno); | "Unaligned fspacectl to OFF_MAX content checking failed"); | ||||
/* Aligned fspacectl(fd, SPACECTL_DEALLOC, ...) past shm_sz */ | /* Aligned fspacectl(fd, SPACECTL_DEALLOC, ...) past shm_sz */ | ||||
ATF_REQUIRE(shm_fill(fd, 0, shm_sz) == 0); | ATF_REQUIRE(shm_fill(fd, 0, shm_sz) == 0); | ||||
range.r_offset = offset = PAGE_SIZE; | range.r_offset = offset = PAGE_SIZE; | ||||
range.r_len = length = ((shm_max_pages + 1) << PAGE_SHIFT) - offset; | range.r_len = length = ((shm_max_pages + 1) << PAGE_SHIFT) - offset; | ||||
ATF_CHECK_MSG(fspacectl(fd, SPACECTL_DEALLOC, &range, 0, &range) == 0, | ATF_CHECK_MSG(fspacectl(fd, SPACECTL_DEALLOC, &range, 0, &range) == 0, | ||||
"Aligned fspacectl past shm_sz failed; errno=%d", errno); | "Aligned fspacectl past shm_sz failed; errno=%d", errno); | ||||
ATF_CHECK_MSG(check_content_dealloc(fd, offset, length, shm_sz) == 0, | ATF_CHECK_MSG(check_content_dealloc(fd, offset, length, shm_sz) == 0, | ||||
"Aligned fspacectl past shm_sz content checking failed", errno); | "Aligned fspacectl past shm_sz content checking failed"); | ||||
/* Unaligned fspacectl(fd, SPACECTL_DEALLOC, ...) past shm_sz */ | /* Unaligned fspacectl(fd, SPACECTL_DEALLOC, ...) past shm_sz */ | ||||
ATF_REQUIRE(shm_fill(fd, 0, shm_sz) == 0); | ATF_REQUIRE(shm_fill(fd, 0, shm_sz) == 0); | ||||
range.r_offset = offset = 1 << (PAGE_SHIFT - 1); | range.r_offset = offset = 1 << (PAGE_SHIFT - 1); | ||||
range.r_len = length = ((shm_max_pages + 1) << PAGE_SHIFT) - offset; | range.r_len = length = ((shm_max_pages + 1) << PAGE_SHIFT) - offset; | ||||
ATF_CHECK_MSG(fspacectl(fd, SPACECTL_DEALLOC, &range, 0, &range) == 0, | ATF_CHECK_MSG(fspacectl(fd, SPACECTL_DEALLOC, &range, 0, &range) == 0, | ||||
"Unaligned fspacectl past shm_sz failed; errno=%d", errno); | "Unaligned fspacectl past shm_sz failed; errno=%d", errno); | ||||
ATF_CHECK_MSG(check_content_dealloc(fd, offset, length, shm_sz) == 0, | ATF_CHECK_MSG(check_content_dealloc(fd, offset, length, shm_sz) == 0, | ||||
"Unaligned fspacectl past shm_sz content checking failed", errno); | "Unaligned fspacectl past shm_sz content checking failed"); | ||||
ATF_REQUIRE(close(fd) == 0); | ATF_REQUIRE(close(fd) == 0); | ||||
} | } | ||||
static int | static int | ||||
shm_open_large(int psind, int policy, size_t sz) | shm_open_large(int psind, int policy, size_t sz) | ||||
{ | { | ||||
int error, fd; | int error, fd; | ||||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | |||||
extern int __sys_shm_open2(const char *, int, mode_t, int, const char *); | extern int __sys_shm_open2(const char *, int, mode_t, int, const char *); | ||||
ATF_TC_WITHOUT_HEAD(largepage_config); | ATF_TC_WITHOUT_HEAD(largepage_config); | ||||
ATF_TC_BODY(largepage_config, tc) | ATF_TC_BODY(largepage_config, tc) | ||||
{ | { | ||||
struct shm_largepage_conf lpc; | struct shm_largepage_conf lpc; | ||||
char *addr, *buf; | char *addr, *buf; | ||||
size_t ps[MAXPAGESIZES + 1]; /* silence warnings if MAXPAGESIZES == 1 */ | size_t ps[MAXPAGESIZES + 1]; /* silence warnings if MAXPAGESIZES == 1 */ | ||||
int error, fd, pscnt; | int error, fd; | ||||
pscnt = pagesizes(ps); | |||||
fd = shm_open(SHM_ANON, O_CREAT | O_RDWR, 0); | fd = shm_open(SHM_ANON, O_CREAT | O_RDWR, 0); | ||||
ATF_REQUIRE_MSG(fd >= 0, "shm_open failed; error=%d", errno); | ATF_REQUIRE_MSG(fd >= 0, "shm_open failed; error=%d", errno); | ||||
/* | /* | ||||
* Configure a large page policy for an object created without | * Configure a large page policy for an object created without | ||||
* SHM_LARGEPAGE. | * SHM_LARGEPAGE. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 655 Lines • Show Last 20 Lines |
Perhaps idea was to print out errno.