#include #include #include #include "utils.h" #include "xce/errnox.h" static void test_error_setget(void) { int myerrno = 1; ectx_t* e; SET_ERROR(myerrno); e = get_ectx(); TEST_ASSERT_TRUE(e != NULL); TEST_ASSERT_TRUE(errno == myerrno); TEST_ASSERT_TRUE(e->file != NULL); TEST_ASSERT_TRUE(e->func != NULL); TEST_ASSERT_TRUE(strcmp(e->file, __FILE__) == 0); TEST_ASSERT_TRUE(strcmp(e->func, __func__) == 0); } #if 0 static void test_strerror_r(void) { char errmsg1[256]; char errmsg2[256]; int errors[] ={ENOENT, EINVAL, E_XCE_BAD_JOB, E_XCE_BAD_WORKER, 0}; int i; for(i = 0; errors[i] != 0; i ++) { strerror_r(errors[i], errmsg1, sizeof(errmsg1)); xce_strerror_r(errors[i], errmsg2, sizeof(errmsg2)); TEST_ASSERT_TRUE(strcmp(errmsg1, errmsg2) == 0); } } #endif void test_error(void) { printf("\n>> error test\n\n"); RUN_TEST(test_error_setget); #if 0 RUN_TEST(test_strerror_r); #endif }