forked from Imagelibrary/rtems
fstests/fsfseeko01: Add test cases
This commit is contained in:
@@ -32,26 +32,48 @@ static void test(void)
|
|||||||
? INT64_MAX
|
? INT64_MAX
|
||||||
: (sizeof(off_t) == sizeof(int32_t) ? INT32_MAX : 1);
|
: (sizeof(off_t) == sizeof(int32_t) ? INT32_MAX : 1);
|
||||||
off_t actual_off;
|
off_t actual_off;
|
||||||
|
const long long_off = LONG_MAX;
|
||||||
|
long actual_long_off;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
file = fopen("file", "w+");
|
file = fopen("file", "w+");
|
||||||
perror("fopen");
|
|
||||||
rtems_test_assert(file != NULL);
|
rtems_test_assert(file != NULL);
|
||||||
|
rtems_test_assert(errno == 0);
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
rv = fseeko(file, off, SEEK_SET);
|
rv = fseek(file, long_off, SEEK_SET);
|
||||||
perror("fseeko");
|
|
||||||
rtems_test_assert(rv == 0);
|
rtems_test_assert(rv == 0);
|
||||||
|
rtems_test_assert(errno == 0);
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
actual_long_off = ftell(file);
|
||||||
|
rtems_test_assert(actual_long_off == long_off);
|
||||||
|
rtems_test_assert(errno == 0);
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
actual_off = ftello(file);
|
||||||
|
rtems_test_assert(actual_off == long_off);
|
||||||
|
rtems_test_assert(errno == 0);
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
rv = fseeko(file, off, SEEK_SET);
|
||||||
|
rtems_test_assert(rv == 0);
|
||||||
|
rtems_test_assert(errno == 0);
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
actual_long_off = ftell(file);
|
||||||
|
rtems_test_assert(actual_long_off == -1L);
|
||||||
|
rtems_test_assert(errno == EOVERFLOW);
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
actual_off = ftello(file);
|
actual_off = ftello(file);
|
||||||
perror("ftello");
|
|
||||||
rtems_test_assert(actual_off == off);
|
rtems_test_assert(actual_off == off);
|
||||||
|
rtems_test_assert(errno == 0);
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
rv = fclose(file);
|
rv = fclose(file);
|
||||||
perror("fclose");
|
|
||||||
rtems_test_assert(rv == 0);
|
rtems_test_assert(rv == 0);
|
||||||
|
rtems_test_assert(errno == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Init(rtems_task_argument arg)
|
static void Init(rtems_task_argument arg)
|
||||||
|
|||||||
Reference in New Issue
Block a user