コード例 #1
0
ファイル: prof_accum.c プロジェクト: CowLeo/ssdb
static int
prof_dump_open_intercept(bool propagate_err, const char *filename)
{
    int fd;

    fd = open("/dev/null", O_WRONLY);
    assert_d_ne(fd, -1, "Unexpected open() failure");

    return (fd);
}
コード例 #2
0
ファイル: posix_memalign.c プロジェクト: wangxuemin/coding
TEST_END

TEST_BEGIN(test_oom_errors)
{
	size_t alignment, size;
	void *p;

#if LG_SIZEOF_PTR == 3
	alignment = UINT64_C(0x8000000000000000);
	size      = UINT64_C(0x8000000000000000);
#else
	alignment = 0x80000000LU;
	size      = 0x80000000LU;
#endif
	assert_d_ne(posix_memalign(&p, alignment, size), 0,
	    "Expected error for posix_memalign(&p, %zu, %zu)",
	    alignment, size);

#if LG_SIZEOF_PTR == 3
	alignment = UINT64_C(0x4000000000000000);
	size      = UINT64_C(0xc000000000000001);
#else
	alignment = 0x40000000LU;
	size      = 0xc0000001LU;
#endif
	assert_d_ne(posix_memalign(&p, alignment, size), 0,
	    "Expected error for posix_memalign(&p, %zu, %zu)",
	    alignment, size);

	alignment = 0x10LU;
#if LG_SIZEOF_PTR == 3
	size = UINT64_C(0xfffffffffffffff0);
#else
	size = 0xfffffff0LU;
#endif
	assert_d_ne(posix_memalign(&p, alignment, size), 0,
	    "Expected error for posix_memalign(&p, %zu, %zu)",
	    alignment, size);
}