Changeset View
Changeset View
Standalone View
Standalone View
tests/sys/posixshm/posixshm_test.c
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||
#define TEST_PATH_LEN 256 | #define TEST_PATH_LEN 256 | ||||
static char test_path[TEST_PATH_LEN]; | static char test_path[TEST_PATH_LEN]; | ||||
static char test_path2[TEST_PATH_LEN]; | static char test_path2[TEST_PATH_LEN]; | ||||
static unsigned int test_path_idx = 0; | static unsigned int test_path_idx = 0; | ||||
static void | static void | ||||
gen_a_test_path(char *path) | gen_a_test_path(char *path) | ||||
{ | { | ||||
snprintf(path, TEST_PATH_LEN, "%s/tmp.XXXXXX%d", | snprintf(path, TEST_PATH_LEN, "/%s/tmp.XXXXXX%d", | ||||
getenv("TMPDIR") == NULL ? "/tmp" : getenv("TMPDIR"), | getenv("TMPDIR") == NULL ? "/tmp" : getenv("TMPDIR"), | ||||
test_path_idx); | test_path_idx); | ||||
test_path_idx++; | test_path_idx++; | ||||
ATF_REQUIRE_MSG(mkstemp(path) != -1, | ATF_REQUIRE_MSG(mkstemp(path) != -1, | ||||
"mkstemp failed; errno=%d", errno); | "mkstemp failed; errno=%d", errno); | ||||
ATF_REQUIRE_MSG(unlink(path) == 0, | ATF_REQUIRE_MSG(unlink(path) == 0, | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
ATF_TC_WITHOUT_HEAD(rename_from_nonexisting); | ATF_TC_WITHOUT_HEAD(rename_from_nonexisting); | ||||
ATF_TC_BODY(rename_from_nonexisting, tc) | ATF_TC_BODY(rename_from_nonexisting, tc) | ||||
{ | { | ||||
int rc; | int rc; | ||||
gen_test_path(); | gen_test_path(); | ||||
gen_test_path2(); | |||||
rc = shm_rename(test_path, test_path2, 0); | rc = shm_rename(test_path, test_path2, 0); | ||||
if (rc != -1) | if (rc != -1) | ||||
atf_tc_fail("shm_rename of nonexisting shm succeeded unexpectedly"); | atf_tc_fail("shm_rename of nonexisting shm succeeded unexpectedly"); | ||||
if (errno != ENOENT) | if (errno != ENOENT) | ||||
atf_tc_fail("Expected ENOENT to rename of nonexistent shm"); | atf_tc_fail("Expected ENOENT to rename of nonexistent shm; got %d", | ||||
errno); | |||||
} | } | ||||
ATF_TC_WITHOUT_HEAD(rename_to_anon); | ATF_TC_WITHOUT_HEAD(rename_to_anon); | ||||
ATF_TC_BODY(rename_to_anon, tc) | ATF_TC_BODY(rename_to_anon, tc) | ||||
{ | { | ||||
int rc; | int rc; | ||||
gen_test_path(); | gen_test_path(); | ||||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |