source: rtems/testsuites/fstests/fsfseeko01/init.c @ 0268adb3

4.11
Last change on this file since 0268adb3 was 0268adb3, checked in by Sebastian Huber <sebastian.huber@…>, on Nov 22, 2012 at 1:09:03 PM

fstests/fsfseeko01: Add test cases

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2 * Copyright (c) 2012 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Obere Lagerstr. 30
6 *  82178 Puchheim
7 *  Germany
8 *  <rtems@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.com/license/LICENSE.
13 */
14
15#ifdef HAVE_CONFIG_H
16  #include "config.h"
17#endif
18
19#include "tmacros.h"
20
21#include <sys/types.h>
22#include <stdio.h>
23#include <errno.h>
24#include <inttypes.h>
25#include <limits.h>
26
27static void test(void)
28{
29  FILE *file;
30  int rv;
31  const off_t off = sizeof(off_t) >= sizeof(int64_t)
32    ? INT64_MAX
33    : (sizeof(off_t) == sizeof(int32_t) ? INT32_MAX : 1);
34  off_t actual_off;
35  const long long_off = LONG_MAX;
36  long actual_long_off;
37
38  errno = 0;
39  file = fopen("file", "w+");
40  rtems_test_assert(file != NULL);
41  rtems_test_assert(errno == 0);
42
43  errno = 0;
44  rv = fseek(file, long_off, SEEK_SET);
45  rtems_test_assert(rv == 0);
46  rtems_test_assert(errno == 0);
47
48  errno = 0;
49  actual_long_off = ftell(file);
50  rtems_test_assert(actual_long_off == long_off);
51  rtems_test_assert(errno == 0);
52
53  errno = 0;
54  actual_off = ftello(file);
55  rtems_test_assert(actual_off == long_off);
56  rtems_test_assert(errno == 0);
57
58  errno = 0;
59  rv = fseeko(file, off, SEEK_SET);
60  rtems_test_assert(rv == 0);
61  rtems_test_assert(errno == 0);
62
63  errno = 0;
64  actual_long_off = ftell(file);
65  rtems_test_assert(actual_long_off == -1L);
66  rtems_test_assert(errno == EOVERFLOW);
67
68  errno = 0;
69  actual_off = ftello(file);
70  rtems_test_assert(actual_off == off);
71  rtems_test_assert(errno == 0);
72
73  errno = 0;
74  rv = fclose(file);
75  rtems_test_assert(rv == 0);
76  rtems_test_assert(errno == 0);
77}
78
79static void Init(rtems_task_argument arg)
80{
81  puts("\n\n*** TEST FSFSEEKO 1 ***");
82
83  test();
84
85  puts("*** END OF TEST FSFSEEKO 1 ***");
86
87  rtems_test_exit(0);
88}
89
90#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
91#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
92
93#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
94
95#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
96
97#define CONFIGURE_MAXIMUM_TASKS 1
98
99#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
100
101#define CONFIGURE_INIT
102
103#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.