File indexing completed on 2025-05-11 08:24:30
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 #ifdef HAVE_CONFIG_H
0029 #include "config.h"
0030 #endif
0031
0032 #include "tmacros.h"
0033
0034 #include <sys/types.h>
0035 #include <stdio.h>
0036 #include <errno.h>
0037 #include <inttypes.h>
0038 #include <limits.h>
0039
0040 const char rtems_test_name[] = "FSFSEEKO 1";
0041
0042 static void test(void)
0043 {
0044 FILE *file;
0045 int rv;
0046 const off_t off = sizeof(off_t) >= sizeof(int64_t)
0047 ? INT64_MAX
0048 : (sizeof(off_t) == sizeof(int32_t) ? INT32_MAX : 1);
0049 off_t actual_off;
0050 const long long_off = LONG_MAX;
0051 long actual_long_off;
0052
0053 errno = 0;
0054 file = fopen("file", "w+");
0055 rtems_test_assert(file != NULL);
0056 rtems_test_assert(errno == 0);
0057
0058 errno = 0;
0059 rv = fseek(file, long_off, SEEK_SET);
0060 rtems_test_assert(rv == 0);
0061 rtems_test_assert(errno == 0);
0062
0063 errno = 0;
0064 actual_long_off = ftell(file);
0065 rtems_test_assert(actual_long_off == long_off);
0066 rtems_test_assert(errno == 0);
0067
0068 errno = 0;
0069 actual_off = ftello(file);
0070 rtems_test_assert(actual_off == long_off);
0071 rtems_test_assert(errno == 0);
0072
0073 errno = 0;
0074 rv = fseeko(file, off, SEEK_SET);
0075 rtems_test_assert(rv == 0);
0076 rtems_test_assert(errno == 0);
0077
0078 if (sizeof(off_t) == sizeof(long)) {
0079 errno = 0;
0080 actual_long_off = ftell(file);
0081 rtems_test_assert(actual_long_off == off);
0082 rtems_test_assert(errno == 0);
0083 } else {
0084 errno = 0;
0085 actual_long_off = ftell(file);
0086 rtems_test_assert(actual_long_off == -1L);
0087 rtems_test_assert(errno == EOVERFLOW);
0088 }
0089
0090 errno = 0;
0091 actual_off = ftello(file);
0092 rtems_test_assert(actual_off == off);
0093 rtems_test_assert(errno == 0);
0094
0095 errno = 0;
0096 rv = fclose(file);
0097 rtems_test_assert(rv == 0);
0098 rtems_test_assert(errno == 0);
0099 }
0100
0101 static void Init(rtems_task_argument arg)
0102 {
0103 TEST_BEGIN();
0104
0105 test();
0106
0107 TEST_END();
0108 rtems_test_exit(0);
0109 }
0110
0111 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
0112 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
0113
0114 #define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 4
0115
0116 #define CONFIGURE_MAXIMUM_TASKS 1
0117
0118 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
0119
0120 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
0121
0122 #define CONFIGURE_INIT
0123
0124 #include <rtems/confdefs.h>