source: rtems/testsuites/fstests/fsfpathconf/test.c @ bc75887

4.115
Last change on this file since bc75887 was bc75887, checked in by Sebastian Huber <sebastian.huber@…>, on 03/16/14 at 15:15:33

tests/fstests: Use <rtems/test.h>

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2 *  COPYRIGHT (c) 2012 - .
3 *  Krzysztof Miesowicz <krzysztof.miesowicz@gmail.com>
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include <sys/stat.h>
15#include <stdio.h>
16#include <string.h>
17#include <unistd.h>
18#include <stdlib.h>
19#include <errno.h>
20#include <rtems.h>
21#include <fcntl.h>
22#include <inttypes.h>
23#include <rtems/error.h>
24#include <ctype.h>
25#include <rtems/libcsupport.h>
26
27#include "fstest.h"
28#include "fs_config.h"
29#include "tmacros.h"
30
31const char rtems_test_name[] = "FSFPATHCONF " FILESYSTEM;
32
33static void fpathconf_test(void){
34
35  int rv = 0;
36  const char *fname = "testfile.km";
37  int fd  = -1;
38
39/* attempt to invoke fpathconf on non-existing file */
40  rv = fpathconf(fd, _PC_LINK_MAX);
41  printf("\nfpathconf of non-existing file give %d , expected -1",rv);
42
43  if (rv == -1) {
44    printf("\n... creating file \"%s\"\n",fname);
45    fd = open(fname,O_WRONLY | O_CREAT | O_TRUNC,S_IREAD|S_IWRITE);
46
47    if (fd < 0) {
48      printf("*** file create failed, errno = %d(%s)\n",errno,strerror(errno));
49    }else
50      printf("*** file created succesfully\n");
51
52/* invoking fpathconf with request for every possible informations */
53    rv = fpathconf(fd, _PC_LINK_MAX);
54    printf("\nrequest with _PC_LINK_MAX return : %d",rv);
55    rv = fpathconf(fd, _PC_MAX_CANON);
56    printf("\nrequest with _PC_MAX_CANON return : %d",rv);
57    rv = fpathconf(fd, _PC_MAX_INPUT);
58    printf("\nrequest with _PC_MAX_INPUT return : %d",rv);
59    rv = fpathconf(fd, _PC_NAME_MAX);
60    printf("\nrequest with _PC_NAME_MAX return : %d",rv);
61    rv = fpathconf(fd, _PC_PATH_MAX);
62    printf("\nrequest with _PC_PATH_MAX return : %d",rv);
63    rv = fpathconf(fd, _PC_PIPE_BUF);
64    printf("\nrequest with _PC_PIPE_BUF return : %d",rv);
65    rv = fpathconf(fd, _PC_CHOWN_RESTRICTED);
66    printf("\nrequest with _PC_CHOWN_RESTRICTED return : %d",rv);
67    rv = fpathconf(fd, _PC_NO_TRUNC);
68    printf("\nrequest with _PC_NO_TRUNC return : %d",rv);
69    rv = fpathconf(fd, _PC_VDISABLE);
70    printf("\nrequest with _PC_VDISABLE return : %d",rv);
71    rv = fpathconf(fd, _PC_ASYNC_IO);
72    printf("\nrequest with _PC_ASYNC_IO return : %d",rv);
73    rv = fpathconf(fd, _PC_PRIO_IO);
74    printf("\nrequest with _PC_PRIO_IO return : %d",rv);
75    rv = fpathconf(fd, _PC_SYNC_IO);
76    printf("\nrequest with _PC_SYNC_IO return : %d",rv);
77/* invoking fpathconf with bad information requested - 255 */
78    rv = fpathconf(fd, 255);
79    printf("\nrequest with bad argument return : %d",rv);
80
81    close(fd);
82    fd = open("testfile.test", O_WRONLY);
83
84    rv = fpathconf(fd, _PC_LINK_MAX);
85  }
86}
87
88void test(void){
89
90  puts("\n\n*** FPATHCONF TEST ***" );
91  fpathconf_test();
92  puts( "\n*** END OF FPATHCONF TEST ***" );
93}
94
95/* end of file */
Note: See TracBrowser for help on using the repository browser.