source: rtems/testsuites/fstests/fsfpathconf/test.c @ 37b18d21

4.115
Last change on this file since 37b18d21 was 37b18d21, checked in by Krzysztof Miesowicz <krzysztof.miesowicz@…>, on Sep 1, 2012 at 8:50:54 AM

new fstest hitting fpathconf function

  • Property mode set to 100644
File size: 2.7 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 "tmacros.h"
29
30static void fpathconf_test(void){
31
32  int rv = 0;
33  const char *fname = "testfile.km";
34  int fd  = -1;
35
36/* attempt to invoke fpathconf on non-existing file */
37  rv = fpathconf(fd, _PC_LINK_MAX);
38  printf("\nfpathconf of non-existing file give %d , expected -1",rv);
39
40  if (rv == -1) {
41    printf("\n... creating file \"%s\"\n",fname);
42    fd = open(fname,O_WRONLY | O_CREAT | O_TRUNC,S_IREAD|S_IWRITE);
43
44    if (fd < 0) {
45      printf("*** file create failed, errno = %d(%s)\n",errno,strerror(errno));
46    }else
47      printf("*** file created succesfully\n");
48
49/* invoking fpathconf with request for every possible informations */
50    rv = fpathconf(fd, _PC_LINK_MAX);
51    printf("\nrequest with _PC_LINK_MAX return : %d",rv);
52    rv = fpathconf(fd, _PC_MAX_CANON);
53    printf("\nrequest with _PC_MAX_CANON return : %d",rv);
54    rv = fpathconf(fd, _PC_MAX_INPUT);
55    printf("\nrequest with _PC_MAX_INPUT return : %d",rv);
56    rv = fpathconf(fd, _PC_NAME_MAX);
57    printf("\nrequest with _PC_NAME_MAX return : %d",rv);
58    rv = fpathconf(fd, _PC_PATH_MAX);
59    printf("\nrequest with _PC_PATH_MAX return : %d",rv);
60    rv = fpathconf(fd, _PC_PIPE_BUF);
61    printf("\nrequest with _PC_PIPE_BUF return : %d",rv);
62    rv = fpathconf(fd, _PC_CHOWN_RESTRICTED);
63    printf("\nrequest with _PC_CHOWN_RESTRICTED return : %d",rv);
64    rv = fpathconf(fd, _PC_NO_TRUNC);
65    printf("\nrequest with _PC_NO_TRUNC return : %d",rv);
66    rv = fpathconf(fd, _PC_VDISABLE);
67    printf("\nrequest with _PC_VDISABLE return : %d",rv);
68    rv = fpathconf(fd, _PC_ASYNC_IO);
69    printf("\nrequest with _PC_ASYNC_IO return : %d",rv);
70    rv = fpathconf(fd, _PC_PRIO_IO);
71    printf("\nrequest with _PC_PRIO_IO return : %d",rv);
72    rv = fpathconf(fd, _PC_SYNC_IO);
73    printf("\nrequest with _PC_SYNC_IO return : %d",rv);
74/* invoking fpathconf with bad information requested - 255 */
75    rv = fpathconf(fd, 255);
76    printf("\nrequest with bad argument return : %d",rv);
77
78    close(fd);
79    fd = open("testfile.test", O_WRONLY);
80   
81    rv = fpathconf(fd, _PC_LINK_MAX);
82  }
83}
84
85void test(void){
86
87  puts("\n\n*** FPATHCONF TEST ***" );
88  fpathconf_test();
89  puts( "\n*** END OF FPATHCONF TEST ***" );
90
91}
92
93/* end of file */
Note: See TracBrowser for help on using the repository browser.